From 3a1a90a98ed9d441ae45b32b86c1b7133a494c77 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Wed, 26 Oct 2022 16:41:48 +1100 Subject: [PATCH] Add `story` | `docs` tags to all entries --- code/lib/client-api/src/StoryStoreFacade.ts | 5 +++-- code/lib/store/src/csf/prepareStory.ts | 2 +- code/lib/store/template/stories/tags.stories.ts | 11 ++++------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/code/lib/client-api/src/StoryStoreFacade.ts b/code/lib/client-api/src/StoryStoreFacade.ts index 82c3ea67702..07b14e2d0a8 100644 --- a/code/lib/client-api/src/StoryStoreFacade.ts +++ b/code/lib/client-api/src/StoryStoreFacade.ts @@ -205,7 +205,7 @@ export class StoryStoreFacade { title, importPath: fileName, componentId, - tags: [...(storyExport.tags || []), ...(defaultExport.tags || [])], + tags: [...(storyExport.tags || []), ...(defaultExport.tags || []), 'story'], }; } }); @@ -224,8 +224,9 @@ export class StoryStoreFacade { title, name, importPath: fileName, - storiesImports: [], componentId, + tags: [...(defaultExport.tags || []), 'docs'], + storiesImports: [], }; } } diff --git a/code/lib/store/src/csf/prepareStory.ts b/code/lib/store/src/csf/prepareStory.ts index 781a8dc0fa8..cc8151e0aaa 100644 --- a/code/lib/store/src/csf/prepareStory.ts +++ b/code/lib/store/src/csf/prepareStory.ts @@ -54,7 +54,7 @@ export function prepareStory( const { moduleExport, id, name } = storyAnnotations; const { title } = componentAnnotations; - const tags = [...(storyAnnotations.tags || []), ...(componentAnnotations.tags || [])]; + const tags = [...(storyAnnotations.tags || []), ...(componentAnnotations.tags || []), 'story']; const parameters: Parameters = combineParameters( projectAnnotations.parameters, diff --git a/code/lib/store/template/stories/tags.stories.ts b/code/lib/store/template/stories/tags.stories.ts index 174f53fcc0b..d119935f3bc 100644 --- a/code/lib/store/template/stories/tags.stories.ts +++ b/code/lib/store/template/stories/tags.stories.ts @@ -9,7 +9,7 @@ export default { decorators: [ (storyFn: PartialStoryFn, context: StoryContext) => { return storyFn({ - args: { object: context.tags }, + args: { object: { tags: context.tags } }, }); }, ], @@ -19,11 +19,8 @@ export const Inheritance = { tags: ['story-one', 'story-two'], play: async ({ canvasElement }: PlayFunctionContext) => { const canvas = within(canvasElement); - await expect(JSON.parse(canvas.getByTestId('pre').innerText)).toEqual([ - 'story-one', - 'story-two', - 'component-one', - 'component-two', - ]); + await expect(JSON.parse(canvas.getByTestId('pre').innerText)).toEqual({ + tags: ['story-one', 'story-two', 'component-one', 'component-two', 'story'], + }); }, };