From b518c0c8f039188eea1fe5d72477c85acfcdc0eb Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Mon, 21 Nov 2022 16:18:27 +1100 Subject: [PATCH 1/4] Allow overriding port in serve/e2e-test task --- scripts/tasks/serve.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/tasks/serve.ts b/scripts/tasks/serve.ts index f7aa5db7bdc5..41d7f1ac6db6 100644 --- a/scripts/tasks/serve.ts +++ b/scripts/tasks/serve.ts @@ -4,7 +4,9 @@ import detectFreePort from 'detect-port'; import type { Task } from '../task'; import { exec } from '../utils/exec'; -export const PORT = 8001; +export const PORT = process.env.STORYBOOK_SERVE_PORT + ? parseInt(process.env.STORYBOOK_SERVE_PORT, 10) + : 8001; export const serve: Task = { description: 'Serve the build storybook for a sandbox', service: true, @@ -22,7 +24,7 @@ export const serve: Task = { // If aborted, we want to make sure the rejection is handled. if (!err.killed) throw err; }); - await exec('yarn wait-on http://localhost:8001', { cwd: codeDir }, { dryRun, debug }); + await exec(`yarn wait-on http://localhost:${PORT}`, { cwd: codeDir }, { dryRun, debug }); return controller; }, From 6762e7a60c5d35b3df3c222a53fcf5bd53e52823 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Mon, 21 Nov 2022 16:18:44 +1100 Subject: [PATCH 2/4] Add failing test for docs order For https://github.com/storybookjs/storybook/issues/19163 --- code/e2e-tests/addon-docs.spec.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/code/e2e-tests/addon-docs.spec.ts b/code/e2e-tests/addon-docs.spec.ts index 3363d4476f9e..abe9afe392db 100644 --- a/code/e2e-tests/addon-docs.spec.ts +++ b/code/e2e-tests/addon-docs.spec.ts @@ -52,4 +52,17 @@ test.describe('addon-docs', () => { const noAutoplayPre = root.locator('#story--addons-docs-docspage-autoplay--no-autoplay pre'); await expect(noAutoplayPre).toHaveText('Play has not run'); }); + + test('should order entries correctly', async ({ page }) => { + const sbPage = new SbPage(page); + await sbPage.navigateToStory('addons/docs/docspage/basic', 'docs'); + + // The `` block should render the "basic" story, and the `` block should + // render the "Another story" + const root = sbPage.previewRoot(); + const stories = root.locator('.sbdocs-h3'); + + await expect(await stories.count()).toBe(1); + await expect(stories.first()).toHaveText('Another'); + }); }); From 7890b3976c68e970d8059c364e2a6562fca826bf Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Mon, 21 Nov 2022 16:32:43 +1100 Subject: [PATCH 3/4] Fix ordering of docs entries for component --- code/lib/preview-web/src/docs-context/DocsContext.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/code/lib/preview-web/src/docs-context/DocsContext.ts b/code/lib/preview-web/src/docs-context/DocsContext.ts index 953041cf6680..063d7e890a1f 100644 --- a/code/lib/preview-web/src/docs-context/DocsContext.ts +++ b/code/lib/preview-web/src/docs-context/DocsContext.ts @@ -49,14 +49,15 @@ export class DocsContext implements DocsContextProps Object.values(csfFile.stories).forEach((annotation) => { this.storyIdToCSFFile.set(annotation.id, csfFile); this.exportToStoryId.set(annotation.moduleExport, annotation.id); + }); - if (addToComponentStories) { - this.nameToStoryId.set(annotation.name, annotation.id); - const story = this.storyById(annotation.id); + if (addToComponentStories) { + this.store.componentStoriesFromCSFFile({ csfFile }).forEach((story) => { + this.nameToStoryId.set(story.name, story.id); this.componentStoriesValue.push(story); if (!this.primaryStory) this.primaryStory = story; - } - }); + }); + } } setMeta(metaExports: Store_ModuleExports) { From f4394de826515bb1f37214c5aea1af6c4c3c9745 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Mon, 21 Nov 2022 16:32:57 +1100 Subject: [PATCH 4/4] Small comment fix --- code/e2e-tests/addon-docs.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/e2e-tests/addon-docs.spec.ts b/code/e2e-tests/addon-docs.spec.ts index abe9afe392db..402ba144ece0 100644 --- a/code/e2e-tests/addon-docs.spec.ts +++ b/code/e2e-tests/addon-docs.spec.ts @@ -57,8 +57,8 @@ test.describe('addon-docs', () => { const sbPage = new SbPage(page); await sbPage.navigateToStory('addons/docs/docspage/basic', 'docs'); - // The `` block should render the "basic" story, and the `` block should - // render the "Another story" + // The `` block should render the "Basic" story, and the `` block should + // render the "Another" story const root = sbPage.previewRoot(); const stories = root.locator('.sbdocs-h3');