Skip to content

Commit

Permalink
Merge pull request #22154 from storybookjs/tom/21798-set-docs-paramet…
Browse files Browse the repository at this point in the history
…ers-in-index
  • Loading branch information
tmeasday authored Apr 19, 2023
2 parents c10da37 + cded4cd commit abc2350
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
20 changes: 12 additions & 8 deletions code/e2e-tests/addon-backgrounds.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,25 @@ test.describe('addon-backgrounds', () => {
});

test.describe('docs pages', () => {
// eslint-disable-next-line jest/no-disabled-tests
test.skip(
// eslint-disable-next-line jest/valid-title
templateName.includes('ssv6'),
'Only run this test for Sandboxes with StoryStoreV7 enabled'
);

test('button should appear for attached docs pages', async ({ page }) => {
const sbPage = new SbPage(page);

await sbPage.navigateToStory('example/button', 'docs');
await expect(sbPage.page.locator(backgroundToolbarSelector)).toBeVisible();
});

test('button should appear for unattached docs pages', async ({ page }) => {
test('button should appear for unattached .mdx files', async ({ page }) => {
// SSv6 does not support .mdx files. There is a unattached stories.mdx file
// at /docs/addons-docs-stories-mdx-unattached--docs, but these are functionally
// really attached

// eslint-disable-next-line jest/no-disabled-tests
test.skip(
// eslint-disable-next-line jest/valid-title
templateName.includes('ssv6'),
'Only run this test for Sandboxes with StoryStoreV7 enabled'
);

const sbPage = new SbPage(page);

// We start on the introduction page by default.
Expand Down
12 changes: 12 additions & 0 deletions code/lib/preview-api/src/modules/core-client/start.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,10 @@ describe('start', () => {
"id": "introduction",
"importPath": "./Introduction.stories.mdx",
"name": undefined,
"parameters": Object {
"fileName": "./Introduction.stories.mdx",
"renderer": "test",
},
"storiesImports": Array [],
"tags": Array [
"stories-mdx",
Expand Down Expand Up @@ -1244,6 +1248,10 @@ describe('start', () => {
"id": "component-b--docs",
"importPath": "file2",
"name": "Docs",
"parameters": Object {
"fileName": "file2",
"renderer": "test",
},
"storiesImports": Array [],
"tags": Array [
"autodocs",
Expand Down Expand Up @@ -1277,6 +1285,10 @@ describe('start', () => {
"id": "component-c--docs",
"importPath": "exports-map-0",
"name": "Docs",
"parameters": Object {
"fileName": "exports-map-0",
"renderer": "test",
},
"storiesImports": Array [],
"tags": Array [
"component-tag",
Expand Down
10 changes: 9 additions & 1 deletion code/lib/preview-api/src/modules/store/StoryStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ export class StoryStore<TRenderer extends Renderer> {

getSetIndexPayload(): API_PreparedStoryIndex {
if (!this.storyIndex) throw new Error('getSetIndexPayload called before initialization');
if (!this.cachedCSFFiles)
throw new Error('Cannot call getSetIndexPayload() unless you call cacheAllCSFFiles() first');
const { cachedCSFFiles } = this;

const stories = this.extract({ includeDocsOnly: true });

Expand All @@ -404,7 +407,12 @@ export class StoryStore<TRenderer extends Renderer> {
argTypes: stories[id].argTypes,
parameters: stories[id].parameters,
}
: entry,
: {
...entry,
parameters: this.preparedMetaFromCSFFile({
csfFile: cachedCSFFiles[entry.importPath],
}).parameters,
},
])
),
};
Expand Down

0 comments on commit abc2350

Please sign in to comment.