Skip to content

Conversation

@yannbf
Copy link
Member

@yannbf yannbf commented Sep 29, 2025

Closes #

What I did

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>

Summary by CodeRabbit

  • Refactor

    • Updated Storybook stories to use a mock manager store instead of direct context, standardizing label rendering and provider nesting.
    • Streamlined render flow for stories without changing visible behavior.
  • Tests

    • Switched mocked API methods to test helpers for more reliable story interactions.
    • Enhanced mock data to better simulate real story states.
  • Chores

    • Removed outdated story references and tidied related setups.
    • No changes to public APIs or user-facing features.

@yannbf yannbf self-assigned this Sep 29, 2025
@yannbf yannbf added build Internal-facing build tooling & test updates ci:normal labels Sep 29, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 29, 2025

Walkthrough

  • Layout.stories.tsx now provides ManagerContext via a mockManagerStore instead of a direct managerContext, including root/component/story nodes with renderLabel using startCase from es-toolkit/string.
  • The mock API’s getCurrentStoryData returns the store’s mock story data.
  • MobileNavigation.stories.tsx updates mockManagerStore.api.getCurrentStoryData to use storybook/test’s fn wrapper; the same change is applied in a LongStoryName decorator’s inner mock.
  • References to the old MobileNavigation.stories-based setup are removed in Layout.
  • Decorators continue wrapping with LocationProvider and LayoutProvider, with ManagerContext.Provider now sourcing from the mock store.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Tester
  participant Storybook as Storybook Runtime
  participant Decorators as Decorators (LocationProvider, LayoutProvider)
  participant Manager as ManagerContext.Provider (mockManagerStore)
  participant Component as Layout / MobileNavigation
  participant API as mockManagerStore.api
  participant Store as mock state (root/component/story nodes)

  Tester->>Storybook: Run story
  Storybook->>Decorators: Apply providers
  Decorators->>Manager: Provide mockManagerStore
  Decorators->>Component: Render story
  Component->>API: getCurrentStoryData()
  API->>Store: Read mock story data
  Store-->>API: Mock story payload
  API-->>Component: Current story data
  Component-->>Tester: Rendered UI with labels (startCase)
Loading
sequenceDiagram
  autonumber
  participant Component as MobileNavigation story
  participant API as mockManagerStore.api.getCurrentStoryData
  note over API: Updated to use storybook/test fn(...)
  Component->>API: Invoke getCurrentStoryData
  API-->>Component: Return mock story data
Loading

Suggested reviewers

  • ndelangen

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The current title “Build: Fix layout stories” only references layout story fixes and uses a “Build” prefix that does not match the content, while the pull request also refactors mocks in mobile navigation stories and focuses on storybook context rather than build tooling. As a result, it doesn’t clearly or fully convey the primary scope of changes. Rename the title to succinctly reflect the main changes, for example: “chore: refactor mockManagerStore in Layout and MobileNavigation stories” to accurately describe both the layout and mobile navigation story updates.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch yann/fix-layout-stories

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Sep 29, 2025

View your CI Pipeline Execution ↗ for commit 4f01283

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

☁️ Nx Cloud last updated this comment at 2025-09-29 08:53:10 UTC

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
code/core/src/manager/components/layout/Layout.stories.tsx (2)

62-62: Small nit: type the renderLabel’s parameter

You can tighten the param type to the expected index entry shape if available (e.g., { name: string } is fine, but prefer the concrete Node type if exported).


64-89: Avoid any: type the mock store to ManagerContext for safer stories

Use the Context’s value type to keep the mock aligned with real shape and catch drift.

Apply this diff:

-const mockManagerStore: any = {
+const mockManagerStore = {
   state: {
     index: {
       someRootId: {
         type: 'root',
         id: 'someRootId',
         name: 'root',
         renderLabel,
       },
       someComponentId: {
         type: 'component',
         id: 'someComponentId',
         name: 'component',
         parent: 'someRootId',
         renderLabel,
       },
       someStoryId: {
         type: 'story',
         subtype: 'story',
         id: 'someStoryId',
         name: 'story',
         parent: 'someComponentId',
         renderLabel,
       },
     },
   },
-};
+} satisfies React.ContextType<typeof ManagerContext>;
code/core/src/manager/components/mobile/navigation/MobileNavigation.stories.tsx (2)

30-61: Mirror typing improvement: avoid any on mockManagerStore

Align with ManagerContext type for safer mocks.

-const mockManagerStore: any = {
+const mockManagerStore = {
   state: {
     index: {
       someRootId: {
         type: 'root',
         id: 'someRootId',
         name: 'root',
         renderLabel,
       },
       someComponentId: {
         type: 'component',
         id: 'someComponentId',
         name: 'component',
         parent: 'someRootId',
         renderLabel,
       },
       someStoryId: {
         type: 'story',
         subtype: 'story',
         id: 'someStoryId',
         name: 'story',
         parent: 'someComponentId',
         renderLabel,
       },
     },
   },
   api: {
     getCurrentStoryData: fn(() => {
       return mockManagerStore.state.index.someStoryId;
     }),
   },
-};
+} satisfies React.ContextType<typeof ManagerContext>;

134-137: Inconsistent mocking: wrap LongStoryName’s getCurrentStoryData with fn as well

Keeps mocks uniform and spy-able across stories.

-        api: {
-          getCurrentStoryData() {
-            return mockManagerStoreWithLongNames.state.index.someStoryId;
-          },
-        },
+        api: {
+          getCurrentStoryData: fn(() => {
+            return mockManagerStoreWithLongNames.state.index.someStoryId;
+          }),
+        },
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between df23220 and 4f01283.

📒 Files selected for processing (2)
  • code/core/src/manager/components/layout/Layout.stories.tsx (3 hunks)
  • code/core/src/manager/components/mobile/navigation/MobileNavigation.stories.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Adhere to ESLint and Prettier rules across all JS/TS source files

Files:

  • code/core/src/manager/components/layout/Layout.stories.tsx
  • code/core/src/manager/components/mobile/navigation/MobileNavigation.stories.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Fix type errors and prefer precise typings instead of using any or suppressions, consistent with strict mode

Files:

  • code/core/src/manager/components/layout/Layout.stories.tsx
  • code/core/src/manager/components/mobile/navigation/MobileNavigation.stories.tsx
🧠 Learnings (3)
📓 Common learnings
Learnt from: ndelangen
PR: storybookjs/storybook#32507
File: code/core/src/manager/globals/globals-module-info.ts:25-33
Timestamp: 2025-09-24T09:39:39.209Z
Learning: In Storybook, storybook/actions/decorator is a preview-only entrypoint and should not be included in manager globals configuration. The duplicatedKeys array in code/core/src/manager/globals/globals-module-info.ts is specifically for manager-side externalization, not preview entrypoints.
Learnt from: CR
PR: storybookjs/storybook#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-25T09:21:27.274Z
Learning: Applies to test-storybooks/** : Maintain test configurations and assets under test-storybooks/ for Storybook testing
📚 Learning: 2025-09-17T08:11:47.197Z
Learnt from: CR
PR: storybookjs/storybook#0
File: .cursor/rules/spy-mocking.mdc:0-0
Timestamp: 2025-09-17T08:11:47.197Z
Learning: Applies to **/*.test.{ts,tsx,js,jsx} : Document complex mock behaviors

Applied to files:

  • code/core/src/manager/components/layout/Layout.stories.tsx
📚 Learning: 2025-09-24T09:39:39.209Z
Learnt from: ndelangen
PR: storybookjs/storybook#32507
File: code/core/src/manager/globals/globals-module-info.ts:25-33
Timestamp: 2025-09-24T09:39:39.209Z
Learning: In Storybook, storybook/actions/decorator is a preview-only entrypoint and should not be included in manager globals configuration. The duplicatedKeys array in code/core/src/manager/globals/globals-module-info.ts is specifically for manager-side externalization, not preview entrypoints.

Applied to files:

  • code/core/src/manager/components/layout/Layout.stories.tsx
🧬 Code graph analysis (1)
code/core/src/manager/components/layout/Layout.stories.tsx (2)
code/core/src/manager-api/root.tsx (1)
  • ManagerContext (78-78)
code/core/src/manager/components/layout/LayoutProvider.tsx (1)
  • LayoutProvider (29-59)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Danger JS
  • GitHub Check: normal
  • GitHub Check: Core Unit Tests, windows-latest
🔇 Additional comments (5)
code/core/src/manager/components/layout/Layout.stories.tsx (3)

91-93: Good move: wrap getCurrentStoryData with storybook/test’s fn

This makes interactions/assertions easier in play functions and Chromatic traces.


113-117: Providers order looks sane

ManagerContext → LocationProvider → LayoutProvider composition is reasonable for these stories.

If LocationProvider has routing-side effects that should be outermost for other stories, confirm this order matches MobileNavigation for consistency.


8-8: es-toolkit is declared in code/core package.json
The import from 'es-toolkit/string' will resolve—es-toolkit@^1.36.0 is listed in devDependencies of code/core/package.json.

code/core/src/manager/components/mobile/navigation/MobileNavigation.stories.tsx (2)

7-7: LGTM: importing fn from storybook/test

Matches current repo pattern and enables spy-able mocks in stories and play functions.


57-59: Nice: getCurrentStoryData wrapped in fn

Consistent with Layout stories and improves traceability in tests.

@ndelangen ndelangen merged commit 93afdba into next Sep 29, 2025
57 of 61 checks passed
@ndelangen ndelangen deleted the yann/fix-layout-stories branch September 29, 2025 09:47
@github-actions github-actions bot mentioned this pull request Sep 30, 2025
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Internal-facing build tooling & test updates ci:normal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants