Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index: Don't prepend titlePrefix to a docs entry that references a CSF file's title #18634

Merged
merged 2 commits into from
Jul 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,6 @@ workflows:
- e2e-tests-core:
requires:
- publish
- e2e-tests-sb-docs:
requires:
- publish
- e2e-tests-pnp:
requires:
- publish
Expand Down
27 changes: 27 additions & 0 deletions lib/core-server/src/utils/StoryIndexGenerator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/core-server/src/utils/StoryIndexGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down