Skip to content

Core: Update StoryStore.extract to handle tests#32388

Merged
yannbf merged 3 commits into
yann/test-fn-prototypefrom
update-storystore-extract
Sep 3, 2025
Merged

Core: Update StoryStore.extract to handle tests#32388
yannbf merged 3 commits into
yann/test-fn-prototypefrom
update-storystore-extract

Conversation

@ghengeveld

@ghengeveld ghengeveld commented Sep 3, 2025

Copy link
Copy Markdown
Member

Closes #

What I did

Make it possible to distinguish tests from stories in StoryStore.extract, and track the parent story name for a test.

  • Updated story property to always be the story name rather than the test name
  • Added storyId property to point to the parent story from a test

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

Greptile Summary

Updated On: 2025-09-03 14:47:43 UTC

This PR enhances Storybook's StoryStore.extract method to properly distinguish between tests and stories, which is part of a test function prototype feature. The changes introduce a new parentName property to the story indexing system that tracks the parent story name for test entries.

The implementation spans across four key files:

  1. Type definitions (indexer.ts): Adds optional parentName property to both StoryIndexEntry and StoryIndexInput interfaces
  2. Story index generation (StoryIndexGenerator.ts): Conditionally includes parent metadata (both parent ID and parentName) when processing test entries
  3. CSF file parsing (CsfFile.ts): Adds parentName to test index entries during CSF parsing
  4. Story store extraction (StoryStore.ts): Modifies the extract method so that test entries use their parent story name in the story property and includes a new storyId property for tracking parent-child relationships

The core behavioral change is that when extracting test entries, the story property now contains the parent story name rather than the test name itself, and a new storyId property points to the parent story ID. This allows consumers to understand that tests are conceptually part of their parent story while maintaining clear hierarchical relationships.

The changes maintain backward compatibility since the parentName property is optional and only applies to test entries. This fits into Storybook's architecture by extending the existing story indexing system to support test-story relationships without breaking existing functionality.

Confidence score: 4/5

  • This PR appears safe to merge with proper testing and review
  • Score reflects well-structured changes with clear intent and consistent implementation patterns
  • Pay close attention to the StoryStore.ts extract method logic and type definitions to ensure test-story relationships work correctly

…act, and track the parent story name for a test.

- Updated 'story' property to always be the story name rather than the test name
- Added 'storyId' property to point to the parent story from a test
@ghengeveld ghengeveld requested a review from yannbf September 3, 2025 14:45
@ghengeveld ghengeveld self-assigned this Sep 3, 2025
@ghengeveld ghengeveld added feature request ci:normal Run our default set of CI jobs (choose this for most PRs). labels Sep 3, 2025
@ghengeveld ghengeveld changed the title Update StoryStore.extract to handle tests Core: Update StoryStore.extract to handle tests Sep 3, 2025

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@nx-cloud

nx-cloud Bot commented Sep 3, 2025

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit d61fba2

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 1m 8s View ↗

☁️ Nx Cloud last updated this comment at 2025-09-03 16:07:26 UTC

@yannbf yannbf merged commit 319ace2 into yann/test-fn-prototype Sep 3, 2025
3 of 4 checks passed
@yannbf yannbf deleted the update-storystore-extract branch September 3, 2025 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:normal Run our default set of CI jobs (choose this for most PRs). feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants