Core: Respect !dev tag on MDX docs in sidebar#35031
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThis PR changes the static sidebar filter to distinguish CSF autodocs from explicit MDX docs: autodocs are shown unless explicitly filtered, while MDX docs with ChangesStatic filter logic for sidebar doc visibility
🎯 3 (Moderate) | ⏱️ ~20 minutes ✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
code/core/src/manager-api/tests/tags.test.js (1)
1-60: ⚡ Quick winConsider migrating to TypeScript for type safety.
The test file uses JavaScript (
.test.js) while testing a TypeScript module (tags.ts). Using TypeScript for the test file would provide type safety for the test data structures and catch potential type mismatches at write time.♻️ Rename to TypeScript
Rename
tags.test.js→tags.test.tsand add type annotations for the test data:+import type { API_PreparedIndexEntry } from 'storybook/internal/types'; + - it('shows stories with dev tag and hides stories without dev', () => { - expect(filter({ id: 's1', type: 'story', tags: ['dev'] })).toBe(true); - expect(filter({ id: 's2', type: 'story', tags: ['test'] })).toBe(false); + it('shows stories with dev tag and hides stories without dev', () => { + expect(filter({ id: 's1', type: 'story', tags: ['dev'] } as API_PreparedIndexEntry)).toBe(true); + expect(filter({ id: 's2', type: 'story', tags: ['test'] } as API_PreparedIndexEntry)).toBe(false);Apply similar type assertions to other test cases.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@code/core/src/manager-api/tests/tags.test.js` around lines 1 - 60, Rename the test file from tags.test.js to tags.test.ts and convert the test code to TypeScript: import types for story/docs entries and annotate test fixtures passed into computeStaticFilterFn (e.g., the objects with id, type, tags) so the compiler validates shapes; ensure the test imports remain from '../modules/tags' (computeStaticFilterFn, parseTagsParam, serializeTagsParam) and adjust any default exports or import paths if needed, and update project test/tsconfig or Vitest config to include .ts tests if not already enabled.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@code/core/src/manager-api/tests/tags.test.js`:
- Around line 1-60: Rename the test file from tags.test.js to tags.test.ts and
convert the test code to TypeScript: import types for story/docs entries and
annotate test fixtures passed into computeStaticFilterFn (e.g., the objects with
id, type, tags) so the compiler validates shapes; ensure the test imports remain
from '../modules/tags' (computeStaticFilterFn, parseTagsParam,
serializeTagsParam) and adjust any default exports or import paths if needed,
and update project test/tsconfig or Vitest config to include .ts tests if not
already enabled.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d728b948-a144-4eae-ba5d-d54e9f068fd0
📒 Files selected for processing (5)
code/addons/docs/template/stories/docs2/no-dev-attached.mdxcode/addons/docs/template/stories/docs2/no-dev-unattached.mdxcode/core/src/manager-api/modules/tags.tscode/core/src/manager-api/tests/tags.test.jscode/e2e-tests/tags.spec.ts
c5151d6 to
6f41347
Compare
Core: Respect !dev tag on MDX docs in sidebar (cherry picked from commit c91f986)
Closes #35029
What I did
The static sidebar filter treated every
type === 'docs'entry as visible, which bypassed!devon unattached and attached MDX. That behavior was introduced in 15d7ef9 to keep CSF autodocs pages visible when meta uses!dev.Narrowed the exception to CSF autodocs entries only (docs without
attached-mdxorunattached-mdxsystem tags). MDX docs now require thedevtag to appear in the sidebar, same as stories.Added
no-dev-unattached.mdxandno-dev-attached.mdxfixtures underaddons/docsdocs2, unit tests forcomputeStaticFilterFn, and e2e assertions intags.spec.ts.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
Caution
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
cd code && yarn storybook:ui(or a React sandbox with docs:yarn task sandbox --template react-vite/default-ts --start-from auto)!devDocumentation
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.tsDeclare whether manual QA will be needed for this PR during the next release, through
qa:neededorqa:skipMake 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 publish.yml --field pr=<PR_NUMBER>Made with Cursor
Summary by CodeRabbit
Bug Fixes
!devtag, including autodocs and attached/unattached MDX docs.Documentation
!devbehavior for attached and unattached examples.Tests
!devhandling, and sidebar exclusion behavior.