From 766de62c1d863de749314e76d16f599a148fb1ea Mon Sep 17 00:00:00 2001 From: eti Date: Thu, 20 Aug 2026 21:02:17 +0200 Subject: [PATCH] web: move story fixtures out of the component tree Signed-off-by: eti --- web/eslint.config.js | 19 ++++++++++++++++++- .../comments.ts} | 2 +- .../mock.ts => fixtures/pipelines.ts} | 6 +++--- .../timeline/mock.ts => fixtures/timeline.ts} | 0 .../components/comment/Comment.stories.svelte | 2 +- .../comment/CommentCard.stories.svelte | 2 +- .../comment/CommentEditor.stories.svelte | 2 +- .../comment/CommentList.stories.svelte | 2 +- .../repo/CommitHeader.stories.svelte | 2 +- .../components/repo/CommitList.stories.svelte | 6 ++++-- .../repo/CommitLogView.stories.svelte | 2 +- .../repo/RepoIndexView.stories.svelte | 2 +- .../pipelines/PipelineCard.stories.svelte | 2 +- .../pipelines/PipelineList.stories.svelte | 2 +- .../PipelineWorkflows.stories.svelte | 2 +- .../pipelines/WorkflowLogs.stories.svelte | 2 +- .../pipelines/WorkflowSidebar.stories.svelte | 2 +- .../pipelines/WorkflowView.stories.svelte | 7 ++++++- .../pulls/PullReviewComment.stories.svelte | 2 +- .../timeline/Timeline.stories.svelte | 2 +- .../timeline/TimelineView.stories.svelte | 2 +- .../timeline/TrendingRepos.stories.svelte | 2 +- web/svelte.config.js | 4 +++- 23 files changed, 51 insertions(+), 25 deletions(-) rename web/src/{lib/components/comment/sampleComments.ts => fixtures/comments.ts} (98%) rename web/src/{lib/components/repo/pipelines/mock.ts => fixtures/pipelines.ts} (97%) rename web/src/{lib/components/timeline/mock.ts => fixtures/timeline.ts} (100%) diff --git a/web/eslint.config.js b/web/eslint.config.js index 905166cd..57b65d08 100644 --- a/web/eslint.config.js +++ b/web/eslint.config.js @@ -56,6 +56,23 @@ export default defineConfig( } }, { - rules: {} + // fixtures feed stories and nothing else. without this the app can import + // them and ship sample data, which is how the notifications page got its + // mock feed + files: ["**/*.svelte", "**/*.svelte.ts", "**/*.svelte.js", "**/*.ts", "**/*.js"], + ignores: ["**/*.stories.svelte"], + rules: { + "no-restricted-imports": [ + "error", + { + patterns: [ + { + group: ["$fixtures", "$fixtures/*", "**/src/fixtures", "**/src/fixtures/*"], + message: "fixtures are storybook input: import them from a *.stories.svelte file." + } + ] + } + ] + } } ); diff --git a/web/src/lib/components/comment/sampleComments.ts b/web/src/fixtures/comments.ts similarity index 98% rename from web/src/lib/components/comment/sampleComments.ts rename to web/src/fixtures/comments.ts index c1a07be3..9241a5d4 100644 --- a/web/src/lib/components/comment/sampleComments.ts +++ b/web/src/fixtures/comments.ts @@ -1,7 +1,7 @@ // real comment data pulled from tangled.org/tangled.org/core/issues/245, used across // the comment stories so the fixtures live in one place. import type { MarkupContext } from "$lib/markup"; -import type { CommentThread, CommentView } from "./comments"; +import type { CommentThread, CommentView } from "$lib/components/comment/comments"; export const sampleMarkup: MarkupContext = { repo: "tangled.org/core", diff --git a/web/src/lib/components/repo/pipelines/mock.ts b/web/src/fixtures/pipelines.ts similarity index 97% rename from web/src/lib/components/repo/pipelines/mock.ts rename to web/src/fixtures/pipelines.ts index a290ecac..4dbd7c03 100644 --- a/web/src/lib/components/repo/pipelines/mock.ts +++ b/web/src/fixtures/pipelines.ts @@ -1,9 +1,9 @@ -// fixture pipelines for the stories and the commit list, the pipelines tab -// reads from a spindle now +// fixture pipelines for the pipeline and commit-list stories. the app reads real +// runs from a spindle, so nothing here ever reaches the bundle import type { PipelineSummary } from "$lib/components/repo/types"; import type { LogControl, LogFrame } from "$lib/api/spindleLogs"; -import { createLogAccumulator, type LogStep } from "./logs"; +import { createLogAccumulator, type LogStep } from "$lib/components/repo/pipelines/logs"; const minutes = (n: number) => n * 60_000; diff --git a/web/src/lib/components/timeline/mock.ts b/web/src/fixtures/timeline.ts similarity index 100% rename from web/src/lib/components/timeline/mock.ts rename to web/src/fixtures/timeline.ts diff --git a/web/src/lib/components/comment/Comment.stories.svelte b/web/src/lib/components/comment/Comment.stories.svelte index 1516af70..898b1157 100644 --- a/web/src/lib/components/comment/Comment.stories.svelte +++ b/web/src/lib/components/comment/Comment.stories.svelte @@ -1,7 +1,7 @@ diff --git a/web/src/lib/components/repo/CommitLogView.stories.svelte b/web/src/lib/components/repo/CommitLogView.stories.svelte index 0a1367d7..aba07d08 100644 --- a/web/src/lib/components/repo/CommitLogView.stories.svelte +++ b/web/src/lib/components/repo/CommitLogView.stories.svelte @@ -2,7 +2,7 @@ import { defineMeta, type StoryContext } from "@storybook/addon-svelte-csf"; import { expect, fn, userEvent } from "storybook/test"; import CommitLogView from "./CommitLogView.svelte"; - import { pipelinesByCommitHash } from "./pipelines/mock"; + import { pipelinesByCommitHash } from "$fixtures/pipelines"; import type { CommitSummary } from "./types"; const commit = (index: number): CommitSummary => ({ diff --git a/web/src/lib/components/repo/RepoIndexView.stories.svelte b/web/src/lib/components/repo/RepoIndexView.stories.svelte index bdc64943..35b79d7c 100644 --- a/web/src/lib/components/repo/RepoIndexView.stories.svelte +++ b/web/src/lib/components/repo/RepoIndexView.stories.svelte @@ -1,7 +1,7 @@