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

CSF: Automatically extract componentPath #24396

Merged
merged 12 commits into from
Jun 9, 2024
107 changes: 103 additions & 4 deletions code/lib/core-server/src/utils/StoryIndexGenerator.deprecated.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,36 @@ describe('StoryIndexGenerator with deprecated indexer API', () => {
expect(await generator.getIndex()).toMatchInlineSnapshot(`
Object {
"entries": Object {
"componentpath-extension--story-one": Object {
"id": "componentpath-extension--story-one",
"importPath": "./src/componentPath/extension.stories.js",
"name": "Story One",
"tags": Array [
"story",
],
"title": "componentPath/extension",
"type": "story",
},
"componentpath-noextension--story-one": Object {
"id": "componentpath-noextension--story-one",
"importPath": "./src/componentPath/noExtension.stories.js",
"name": "Story One",
"tags": Array [
"story",
],
"title": "componentPath/noExtension",
"type": "story",
},
"componentpath-package--story-one": Object {
"id": "componentpath-package--story-one",
"importPath": "./src/componentPath/package.stories.js",
"name": "Story One",
"tags": Array [
"story",
],
"title": "componentPath/package",
"type": "story",
},
"nested-button--story-one": Object {
"id": "nested-button--story-one",
"importPath": "./src/nested/Button.stories.ts",
Expand Down Expand Up @@ -182,6 +212,36 @@ describe('StoryIndexGenerator with deprecated indexer API', () => {
"title": "B",
"type": "story",
},
"componentpath-extension--story-one": Object {
"id": "componentpath-extension--story-one",
"importPath": "./src/componentPath/extension.stories.js",
"name": "Story One",
"tags": Array [
"story",
],
"title": "componentPath/extension",
"type": "story",
},
"componentpath-noextension--story-one": Object {
"id": "componentpath-noextension--story-one",
"importPath": "./src/componentPath/noExtension.stories.js",
"name": "Story One",
"tags": Array [
"story",
],
"title": "componentPath/noExtension",
"type": "story",
},
"componentpath-package--story-one": Object {
"id": "componentpath-package--story-one",
"importPath": "./src/componentPath/package.stories.js",
"name": "Story One",
"tags": Array [
"story",
],
"title": "componentPath/package",
"type": "story",
},
"d--story-one": Object {
"id": "d--story-one",
"importPath": "./src/D.stories.jsx",
Expand Down Expand Up @@ -339,6 +399,36 @@ describe('StoryIndexGenerator with deprecated indexer API', () => {
"title": "B",
"type": "story",
},
"componentpath-extension--story-one": Object {
"id": "componentpath-extension--story-one",
"importPath": "./src/componentPath/extension.stories.js",
"name": "Story One",
"tags": Array [
"story",
],
"title": "componentPath/extension",
"type": "story",
},
"componentpath-noextension--story-one": Object {
"id": "componentpath-noextension--story-one",
"importPath": "./src/componentPath/noExtension.stories.js",
"name": "Story One",
"tags": Array [
"story",
],
"title": "componentPath/noExtension",
"type": "story",
},
"componentpath-package--story-one": Object {
"id": "componentpath-package--story-one",
"importPath": "./src/componentPath/package.stories.js",
"name": "Story One",
"tags": Array [
"story",
],
"title": "componentPath/package",
"type": "story",
},
"d--docs": Object {
"id": "d--docs",
"importPath": "./src/D.stories.jsx",
Expand Down Expand Up @@ -448,6 +538,12 @@ describe('StoryIndexGenerator with deprecated indexer API', () => {
"d--story-one",
"h--docs",
"h--story-one",
"componentpath-extension--docs",
"componentpath-extension--story-one",
"componentpath-noextension--docs",
"componentpath-noextension--story-one",
"componentpath-package--docs",
"componentpath-package--story-one",
"first-nested-deeply-f--docs",
"first-nested-deeply-f--story-one",
"nested-button--docs",
Expand Down Expand Up @@ -1228,6 +1324,9 @@ describe('StoryIndexGenerator with deprecated indexer API', () => {
"componentreference--docs",
"notitle--docs",
"h--story-one",
"componentpath-extension--story-one",
"componentpath-noextension--story-one",
"componentpath-package--story-one",
"first-nested-deeply-f--story-one",
]
`);
Expand All @@ -1246,7 +1345,7 @@ describe('StoryIndexGenerator with deprecated indexer API', () => {
const generator = new StoryIndexGenerator([specifier], options);
await generator.initialize();
await generator.getIndex();
expect(loadCsfMock).toHaveBeenCalledTimes(7);
expect(loadCsfMock).toHaveBeenCalledTimes(10);

loadCsfMock.mockClear();
await generator.getIndex();
Expand Down Expand Up @@ -1303,7 +1402,7 @@ describe('StoryIndexGenerator with deprecated indexer API', () => {
const generator = new StoryIndexGenerator([specifier], options);
await generator.initialize();
await generator.getIndex();
expect(loadCsfMock).toHaveBeenCalledTimes(7);
expect(loadCsfMock).toHaveBeenCalledTimes(10);

generator.invalidate(specifier, './src/B.stories.ts', false);

Expand Down Expand Up @@ -1388,7 +1487,7 @@ describe('StoryIndexGenerator with deprecated indexer API', () => {
const generator = new StoryIndexGenerator([specifier], options);
await generator.initialize();
await generator.getIndex();
expect(loadCsfMock).toHaveBeenCalledTimes(7);
expect(loadCsfMock).toHaveBeenCalledTimes(10);

generator.invalidate(specifier, './src/B.stories.ts', true);

Expand Down Expand Up @@ -1427,7 +1526,7 @@ describe('StoryIndexGenerator with deprecated indexer API', () => {
const generator = new StoryIndexGenerator([specifier], options);
await generator.initialize();
await generator.getIndex();
expect(loadCsfMock).toHaveBeenCalledTimes(7);
expect(loadCsfMock).toHaveBeenCalledTimes(10);

generator.invalidate(specifier, './src/B.stories.ts', true);

Expand Down
Loading
Loading