@@ -4,8 +4,12 @@ import { BrowserContext, Locator, Page, expect } from '@playwright/test'
44interface StorybookIndexJSON {
55 v : number
66 entries : Record < string , StorybookIndexStory >
7+ stories : Record < string , StorybookStoriesStory >
78}
89
10+ /**
11+ * Storybook v7
12+ */
913export interface StorybookIndexStory {
1014 id : string // composite-typography--variants
1115 title : string // Composite/Typography
@@ -15,7 +19,24 @@ export interface StorybookIndexStory {
1519 type : 'story' | 'docs'
1620}
1721
18- type StoriesFilterFn = ( story : StorybookIndexStory ) => boolean
22+ /**
23+ * Storybook v6
24+ */
25+ export interface StorybookStoriesStory {
26+ id : string // composite-typography--variants
27+ title : string // Composite/Typography
28+ name : string // Variants
29+ importPath : string // ./components/Typography/Typography.stories.tsx
30+ kind : string
31+ story : string
32+ parameters : {
33+ __id : string
34+ docsOnly : boolean
35+ fileName : string
36+ }
37+ }
38+
39+ type StoriesFilterFn = < V7 = true > ( story : V7 extends true ? StorybookIndexStory : StorybookStoriesStory ) => boolean
1940
2041export const storybookPlaywright = {
2142 getStories : ( pathToStorybookIndexJson : string , storyFilterFn : StoriesFilterFn ) => {
@@ -25,7 +46,9 @@ export const storybookPlaywright = {
2546 }
2647 const storybookIndexJson : StorybookIndexJSON = fse . readJsonSync ( pathToStorybookIndexJson )
2748
28- const stories = Object . values ( storybookIndexJson . entries ) . filter ( storyFilterFn )
49+ const storyObject = storybookIndexJson . entries || storybookIndexJson . stories
50+
51+ const stories = Object . values ( storyObject ) . filter ( storyFilterFn )
2952
3053 return stories
3154 } ,
0 commit comments