@@ -9,10 +9,10 @@ import {
99 STORY_INDEX_INVALIDATED ,
1010 UPDATE_GLOBALS ,
1111} from 'storybook/internal/core-events' ;
12- import type {
13- API_IndexHash ,
14- API_PreparedIndexEntry ,
15- API_StoryEntry ,
12+ import {
13+ type API_IndexHash ,
14+ type API_PreparedIndexEntry ,
15+ type API_StoryEntry ,
1616} from 'storybook/internal/types' ;
1717
1818import { type API , addons , internal_universalTestProviderStore } from 'storybook/manager-api' ;
@@ -27,6 +27,7 @@ import {
2727 ADDON_ID as ADDON_TEST_ID ,
2828 STORYBOOK_ADDON_TEST_CHANNEL ,
2929} from '../../../../addons/vitest/src/constants' ;
30+ import { SUPPORTED_FRAMEWORKS } from '../../cli/AddonVitestService.constants' ;
3031import { ADDON_ID as ADDON_DOCS_ID } from '../../docs-tools/shared' ;
3132import { TourGuide } from '../../manager/components/TourGuide/TourGuide' ;
3233import type { initialState } from './checklistData.state' ;
@@ -119,12 +120,21 @@ export interface ChecklistData {
119120 } [ ] ;
120121}
121122
123+ const isExample = ( id : string ) =>
124+ id . startsWith ( 'example-' ) || id . startsWith ( 'configure-your-project--' ) ;
125+
122126const subscribeToIndex : (
123127 condition : ( entries : Record < string , API_PreparedIndexEntry > ) => boolean
124128) => ChecklistData [ 'sections' ] [ number ] [ 'items' ] [ number ] [ 'subscribe' ] =
125129 ( condition ) =>
126130 ( { api, done } ) => {
127- const check = ( ) => condition ( api . getIndex ( ) ?. entries || { } ) ;
131+ const check = ( ) =>
132+ condition (
133+ Object . entries ( api . getIndex ( ) ?. entries || { } ) . reduce (
134+ ( acc , [ id , entry ] ) => ( isExample ( entry . id ) ? acc : Object . assign ( acc , { [ id ] : entry } ) ) ,
135+ { } as Record < string , API_PreparedIndexEntry >
136+ )
137+ ) ;
128138 if ( check ( ) ) {
129139 done ( ) ;
130140 } else {
@@ -187,7 +197,10 @@ export const checklistData = {
187197 label : 'Render a component' ,
188198 criteria : 'A story finished rendering successfully' ,
189199 subscribe : ( { api, done } ) =>
190- api . on ( STORY_FINISHED , ( { status } ) => status === 'success' && done ( ) ) ,
200+ api . on (
201+ STORY_FINISHED ,
202+ ( { storyId, status } ) => status === 'success' && ! isExample ( storyId ) && done ( )
203+ ) ,
191204 content : ( { api } ) => (
192205 < >
193206 < p >
@@ -301,8 +314,7 @@ export const Primary: Story = {
301314 criteria : 'At least 5 components exist in the index' ,
302315 subscribe : subscribeToIndex ( ( entries ) => {
303316 const stories = Object . values ( entries ) . filter (
304- ( entry ) : entry is API_StoryEntry =>
305- entry . type === 'story' && ! entry . id . startsWith ( 'example-' )
317+ ( entry ) : entry is API_StoryEntry => entry . type === 'story'
306318 ) ;
307319 const components = new Set ( stories . map ( ( { title } ) => title ) ) ;
308320 return components . size >= 5 ;
@@ -342,8 +354,7 @@ export const Primary: Story = {
342354 criteria : 'At least 20 stories exist in the index' ,
343355 subscribe : subscribeToIndex ( ( entries ) => {
344356 const stories = Object . values ( entries ) . filter (
345- ( entry ) : entry is API_StoryEntry =>
346- entry . type === 'story' && ! entry . id . startsWith ( 'example-' )
357+ ( entry ) : entry is API_StoryEntry => entry . type === 'story'
347358 ) ;
348359 return stories . length >= 20 ;
349360 } ) ,
@@ -522,7 +533,9 @@ export default {
522533 id : 'installVitest' ,
523534 label : 'Install Vitest addon' ,
524535 afterCompletion : 'unavailable' ,
525- available : ( ) => true , // TODO check for compatibility with the project
536+ available : ( ) =>
537+ ! ! globalThis . STORYBOOK_FRAMEWORK &&
538+ SUPPORTED_FRAMEWORKS . includes ( globalThis . STORYBOOK_FRAMEWORK ) ,
526539 criteria : '@storybook/addon-vitest registered in .storybook/main.js|ts' ,
527540 subscribe : ( { done } ) => {
528541 if ( addons . experimental_getRegisteredAddons ( ) . includes ( ADDON_TEST_ID ) ) {
@@ -665,9 +678,7 @@ export default {
665678 criteria : 'At least one story with a play or test function' ,
666679 subscribe : subscribeToIndex ( ( entries ) =>
667680 Object . values ( entries ) . some (
668- ( { id, tags } ) =>
669- ! id . startsWith ( 'example-' ) &&
670- ( tags ?. includes ( 'play-fn' ) || tags ?. includes ( 'test-fn' ) )
681+ ( entry ) => entry . tags ?. includes ( 'play-fn' ) || entry . tags ?. includes ( 'test-fn' )
671682 )
672683 ) ,
673684 content : ( { api } ) => (
@@ -1079,9 +1090,7 @@ export const Disabled: Story = {
10791090 label : 'Automatically document your components' ,
10801091 criteria : 'At least one component with the autodocs tag applied' ,
10811092 subscribe : subscribeToIndex ( ( entries ) =>
1082- Object . values ( entries ) . some (
1083- ( { id, tags } ) => ! id . startsWith ( 'example-' ) && tags ?. includes ( 'autodocs' )
1084- )
1093+ Object . values ( entries ) . some ( ( entry ) => entry . tags ?. includes ( 'autodocs' ) )
10851094 ) ,
10861095 content : ( { api } ) => (
10871096 < >
@@ -1091,12 +1100,14 @@ export const Disabled: Story = {
10911100 and a description.
10921101 </ p >
10931102 < CodeSnippet language = "typescript" >
1094- { `// Button.stories.ts
1103+ { `// Button.stories.js
10951104
1096- export default {
1105+ const meta = {
10971106 component: Button,
10981107 tags: ['autodocs'], // 👈 Add this tag
1099- }` }
1108+ }
1109+
1110+ export default meta;` }
11001111 </ CodeSnippet >
11011112 < p >
11021113 That tag can also be applied in < code > .storybook/preview.ts</ code > , to generate
@@ -1138,9 +1149,7 @@ export default {
11381149 label : 'Custom content with MDX' ,
11391150 criteria : 'At least one MDX page' ,
11401151 subscribe : subscribeToIndex ( ( entries ) =>
1141- Object . values ( entries ) . some (
1142- ( { id, type } ) => type === 'docs' && ! id . startsWith ( 'example-' )
1143- )
1152+ Object . values ( entries ) . some ( ( entry ) => entry . type === 'docs' )
11441153 ) ,
11451154 content : ( { api } ) => (
11461155 < >
0 commit comments