Files
romm/frontend/test/storybook.test.ts
zurdi df8f6178ef chore(frontend): set up vitest + storybook play() tests and align CI
Add Vitest 4 with happy-dom, @vue/test-utils, and a single
test/storybook.test.ts that auto-discovers every story under
src/v2/lib and runs its play() via composeStories — no Playwright,
just composition-based interaction tests. 89 stories now smoke-pass
in CI.

Scripts: lint:fix (auto-fix), lint (now scoped to ./src/v2; v1 is
frozen), lint:all (legacy sweep), test, test:watch, test:ui,
storybook:test.

eslint.config.js gets argsIgnorePattern: "^_" so unused-by-design
parameters can use the underscore convention.

CI: new frontend.yml runs lint, test, build in parallel on
frontend/** changes; typecheck.yml bumped to Node 22 with cached
npm ci. Existing typecheck job preserved for branch protection.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 11:52:44 +00:00

28 lines
807 B
TypeScript

import { composeStories } from "@storybook/vue3-vite";
import { describe, it } from "vitest";
type StoryModule = Record<string, unknown>;
type ComposedStory = { run?: () => Promise<void> };
const storyModules = import.meta.glob<StoryModule>(
"../src/v2/lib/**/*.stories.ts",
{ eager: true },
);
for (const [path, module] of Object.entries(storyModules)) {
const composed = composeStories(module);
describe(path.replace(/^\.\.\//, ""), () => {
for (const [name, story] of Object.entries(composed)) {
const s = story as ComposedStory;
it(name, async () => {
if (typeof s.run !== "function") {
throw new Error(
`Story "${name}" has no run() helper — composeStories incompatible.`,
);
}
await s.run();
});
}
});
}