From abd94041a62443dfcd8d5b829ea7d68853455f10 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Wed, 6 Jul 2022 12:07:10 +1000 Subject: [PATCH 1/2] Don't append title prefix to Meta of= docs entries --- .../src/utils/StoryIndexGenerator.test.ts | 27 +++++++++++++++++++ .../src/utils/StoryIndexGenerator.ts | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/core-server/src/utils/StoryIndexGenerator.test.ts b/lib/core-server/src/utils/StoryIndexGenerator.test.ts index 24804894589b..edc0379b5502 100644 --- a/lib/core-server/src/utils/StoryIndexGenerator.test.ts +++ b/lib/core-server/src/utils/StoryIndexGenerator.test.ts @@ -525,6 +525,33 @@ describe('StoryIndexGenerator', () => { `); }); + it('does not append title prefix if meta references a CSF file', async () => { + const generator = new StoryIndexGenerator( + [ + storiesSpecifier, + normalizeStoriesEntry( + { directory: './src/docs2', files: '**/*.mdx', titlePrefix: 'titlePrefix' }, + options + ), + ], + options + ); + await generator.initialize(); + + // NOTE: `toMatchInlineSnapshot` on objects sorts the keys, but in actuality, they are + // not sorted by default. + expect(Object.values((await generator.getIndex()).entries).map((e) => e.title)) + .toMatchInlineSnapshot(` + Array [ + "A", + "A", + "titlePrefix/NoTitle", + "A", + "titlePrefix/docs2/Yabbadabbadooo", + ] + `); + }); + it('generates no docs entries when docs are disabled', async () => { const generator = new StoryIndexGenerator([storiesSpecifier, docsSpecifier], { ...options, diff --git a/lib/core-server/src/utils/StoryIndexGenerator.ts b/lib/core-server/src/utils/StoryIndexGenerator.ts index d4d231bf71af..3a96167388b5 100644 --- a/lib/core-server/src/utils/StoryIndexGenerator.ts +++ b/lib/core-server/src/utils/StoryIndexGenerator.ts @@ -307,7 +307,7 @@ export class StoryIndexGenerator { dep.dependents.push(absolutePath); }); - const title = userOrAutoTitleFromSpecifier(importPath, specifier, result.title || ofTitle); + const title = ofTitle || userOrAutoTitleFromSpecifier(importPath, specifier, result.title); const name = result.name || this.options.docs.defaultName; const id = toId(title, name); From 392603beee5dae652b7ec45fb82495f822e1519e Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Thu, 7 Jul 2022 12:43:03 +1000 Subject: [PATCH 2/2] Properly disable `e2e-tests-sb-docs` --- .circleci/config.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7c070d7c9bde..0a9765c0094a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -423,9 +423,6 @@ workflows: - e2e-tests-core: requires: - publish - - e2e-tests-sb-docs: - requires: - - publish - e2e-tests-pnp: requires: - publish