-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Build: Fix layout stories #32577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build: Fix layout stories #32577
Conversation
Walkthrough
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)
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
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Comment |
|
View your CI Pipeline Execution ↗ for commit 4f01283
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this 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 parameterYou 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 storiesUse 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 mockManagerStoreAlign 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 wellKeeps 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
📒 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.tsxcode/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.tsxcode/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 fnThis makes interactions/assertions easier in play functions and Chromatic traces.
113-117: Providers order looks saneManagerContext → 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 importfrom 'es-toolkit/string'will resolve—es-toolkit@^1.36.0 is listed in devDependencies ofcode/core/package.json.code/core/src/manager/components/mobile/navigation/MobileNavigation.stories.tsx (2)
7-7: LGTM: importing fn from storybook/testMatches current repo pattern and enables spy-able mocks in stories and play functions.
57-59: Nice: getCurrentStoryData wrapped in fnConsistent with Layout stories and improves traceability in tests.
Closes #
What I did
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsMake 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/coreteam 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
Tests
Chores