Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

chore(web): Setup storybook interaction tests (#14279)

Ben Bachemad854598f53e
diff --git a/.agents/skills/storybook/SKILL.md b/.agents/skills/storybook/SKILL.md
index 891826063a..ae85f587fb 100644
--- a/.agents/skills/storybook/SKILL.md
+++ b/.agents/skills/storybook/SKILL.md
@@ -33,6 +33,7 @@ Keep the existing component, but update it to use the newly created component fo
- Avoid custom render functions by default.
- Use `satisfies` and typed Storybook metadata so invalid args, decorators, and play functions are type-checked.
- Use play functions to test user-relevant interactions after render, not to compensate for complex setup or hidden dependencies.
+- Prefix stories whose primary purpose is interaction test coverage with `(Test)` in the Storybook display name, for example `name: "(Test) Opens Menu"`.
- Name stories after the state they represent, not the implementation. Also do not include the component name in the story name.
- Prefer: `Default`, `Empty`, `WithLongName`, `Error`, `Disabled`, `Loading`
- Avoid: `Test1`, `CustomRenderExample`, `ButtonWithLongNameAndIcon`
diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml
index 87f3a4c7a6..df861ad498 100644
--- a/.github/workflows/pipeline.yml
+++ b/.github/workflows/pipeline.yml
@@ -237,6 +237,45 @@ jobs:
- name: run eslint-plugin tests
run: pnpm --filter @repo/eslint-plugin run test
+ tests-storybook:
+ runs-on: blacksmith-4vcpu-ubuntu-2404
+ needs:
+ - pre-job
+ # pre-job only runs on push events; everywhere else it resolves as skipped
+ # at run creation, so this job starts immediately (!cancelled() lets the
+ # condition evaluate despite the skipped dependency).
+ if: ${{ !cancelled() && (github.event_name != 'push' || needs.pre-job.outputs.should_skip != 'true') }}
+ steps:
+ - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
+ with:
+ persist-credentials: false
+ - uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
+ with:
+ version: 11.4.0
+ - name: Use Node.js ${{ env.NODE_VERSION }} without cache
+ if: env.CI_CACHE_ALLOWED != 'true'
+ uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
+ with:
+ node-version: ${{ env.NODE_VERSION }}
+ package-manager-cache: false
+ - name: Use Node.js ${{ env.NODE_VERSION }} with pnpm cache
+ if: env.CI_CACHE_ALLOWED == 'true'
+ uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # zizmor: ignore[cache-poisoning] Storybook test dependency cache only; no released artifacts are built or published from this cached state
+ with:
+ node-version: ${{ env.NODE_VERSION }}
+ cache: "pnpm"
+ cache-dependency-path: "pnpm-lock.yaml"
+ - name: install dependencies
+ run: |
+ pnpm install
+ - name: Load default env
+ run: |
+ cp .env.dev.example .env
+ - name: Install playwright
+ run: pnpm --filter=web exec playwright install --with-deps --only-shell chromium
+ - name: run Storybook tests
+ run: pnpm --filter web run test-storybook
+
tests-shared:
timeout-minutes: 15
runs-on: blacksmith-4vcpu-ubuntu-2404
@@ -901,6 +940,7 @@ jobs:
lint,
prettier-check,
tests-eslint-plugin,
+ tests-storybook,
tests-shared,
tests-web,
tests-worker,
diff --git a/package.json b/package.json
index 8f2bf4810a..45051dffbb 100644
--- a/package.json
+++ b/package.json
@@ -37,6 +37,7 @@
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\" --experimental-cli",
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,css}\" --experimental-cli",
"playwright:install": "pnpm --filter web exec playwright install chromium",
+ "storybook": "pnpm --filter web run storybook",
"test": "turbo run test",
"release": "dotenv -e ../.env -- release-it",
"release:cloud": "bash ./scripts/release-cloud.sh",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 4816158872..2ac7f945d3 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -157,7 +157,7 @@ importers:
version: 5.9.2
vitest:
specifier: ^4.1.4
packages/shared:
dependencies:
@@ -356,7 +356,7 @@ importers:
version: 5.9.2
vitest:
specifier: ^4.1.4
web:
dependencies:
@@ -815,13 +815,16 @@ importers:
specifier: workspace:*
version: link:../packages/config-typescript
'@storybook/addon-a11y':
- specifier: ^10.3.6
+ specifier: 10.3.6
'@storybook/addon-docs':
- specifier: ^10.3.6
+ specifier: 10.3.6
+ '@storybook/addon-vitest':
+ specifier: 10.3.6
'@storybook/nextjs-vite':
- specifier: ^10.3.6
+ specifier: 10.3.6
'@tailwindcss/forms':
specifier: ^0.5.11
@@ -871,6 +874,9 @@ importers:
'@vitejs/plugin-react':
specifier: ^4.7.0
+ '@vitest/browser-playwright':
+ specifier: 4.1.4
dotenv:
specifier: ^16.6.1
version: 16.6.1
@@ -887,7 +893,7 @@ importers:
specifier: 16.2.6
eslint-plugin-storybook:
- specifier: ^10.3.6
+ specifier: 10.3.6
jsdom:
specifier: ^26.1.0
@@ -902,7 +908,7 @@ importers:
specifier: ^0.7.2
version: 0.7.2([email protected])
storybook:
- specifier: ^10.3.6
+ specifier: 10.3.6
tailwindcss:
specifier: ^4.2.2
@@ -918,7 +924,7 @@ importers:
vitest:
specifier: ^4.1.4
wait-for-expect:
specifier: ^3.0.2
version: 3.0.2
@@ -1069,7 +1075,7 @@ importers:
version: 7.0.0-dev.20260122.3
'@vitest/coverage-v8':
specifier: ^4.1.4
- version: 4.1.4([email protected])
+ version: 4.1.4(@vitest/[email protected])([email protected])
eslint:
specifier: ^9.39.2
version: 9.39.4([email protected])
@@ -1096,7 +1102,7 @@ importers:
version: 5.9.2
vitest:
specifier: ^4.1.4
wait-for-expect:
specifier: ^3.0.2
version: 3.0.2
@@ -1644,6 +1650,9 @@ packages:
resolution: {integrity: sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==}
engines: {node: '>=18'}
+ '@blazediff/[email protected]':
+ resolution: {integrity: sha512-ehg3jIkYKulZh+8om/O25vkvSsXXwC+skXmyA87FFx6A/45eqOkZsBltMw/TVteb0mloiGT8oGRTcjRAz66zaA==}
+
'@braintree/[email protected]':
resolution: {integrity: sha512-jigsZK+sMF/cuiB7sERuo9V7N9jx+dhmHHnQyDSVdpZwVutaBu7WvNYqMDLSgFgfB30n452TP3vjDAvFC973mA==}
@@ -3551,6 +3560,9 @@ packages:
engines: {node: '>=18'}
hasBin: true
+ '@polka/[email protected]':
+ resolution: {integrity: sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww==}
+
'@posthog/[email protected]':
resolution: {integrity: sha512-7FFWWYWvRFxQqDXYzv8klCjk0Pox1IpuPr61eeOCBsKkmt6xvvHwH0jc3ObvwDXZj2NSAWg+V9N2E2F1ul2CRQ==}
@@ -5037,6 +5049,24 @@ packages:
peerDependencies:
storybook: ^10.3.6
+ '@storybook/[email protected]':
+ resolution: {integrity: sha512-HXj7RrPJY+xzoNjL+xZu2oLw1fI5BA87Noh1NAXMPuECHR5R5fuRM/tTsJuIGXHFMO06FjSi/rekDIfCj1fL4w==}
+ peerDependencies:
+ '@vitest/browser': ^3.0.0 || ^4.0.0
+ '@vitest/browser-playwright': ^4.0.0
+ '@vitest/runner': ^3.0.0 || ^4.0.0
+ storybook: ^10.3.6
+ vitest: ^3.0.0 || ^4.0.0
+ peerDependenciesMeta:
+ '@vitest/browser':
+ optional: true
+ '@vitest/browser-playwright':
+ optional: true
+ '@vitest/runner':
+ optional: true
+ vitest:
+ optional: true
+
'@storybook/[email protected]':
resolution: {integrity: sha512-gpvR/sE4BcrFtmQZ+Ker7zD23oQzoVeqD9nF6cK6yzY+Q0svJXyX2EPmFG4y+EwygD5/vNzDpP84gGMut8VRwg==}
peerDependencies:
@@ -5987,6 +6017,17 @@ packages:
peerDependencies:
vite: ^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0
+ '@vitest/[email protected]':
+ resolution: {integrity: sha512-q3PchVhZINX23Pv+RERgAtDlp6wzVkID/smOPnZ5YGWpeWUe3jMNYppeVh15j4il3G7JIJty1d1Kicpm0HSMig==}
+ peerDependencies:
+ playwright: '*'
+ vitest: 4.1.4
+
+ '@vitest/[email protected]':
+ resolution: {integrity: sha512-TrNaY/yVOwxtrxNsDUC/wQ56xSwplpytTeRAqF/197xV/ZddxxulBsxR6TrhVMyniJmp9in8d5u0AcDaNRY30w==}
+ peerDependencies:
+ vitest: 4.1.4
+
'@vitest/[email protected]':
resolution: {integrity: sha512-x7FptB5oDruxNPDNY2+S8tCh0pcq7ymCe1gTHcsp733jYjrJl8V1gMUlVysuCD9Kz46Xz9t1akkv08dPcYDs1w==}
peerDependencies:
@@ -9086,6 +9127,10 @@ packages:
resolution: {integrity: sha512-EGWKgxALGMgzvxYF1UyGTy0HXX/2vHLkw6+NvDKW2jypWbHpjQuj4UMcqQWXHERJhVGKikolT06G3bcKe4fi7w==}
+ resolution: {integrity: sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==}
+ engines: {node: '>=10'}
+
resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==}
@@ -9639,6 +9684,10 @@ packages:
engines: {node: '>=18'}
hasBin: true
+ resolution: {integrity: sha512-LKWqWJRhstyYo9pGvgor/ivk2w94eSjE3RGVuzLGlr3NmD8bf7RcYGze1mNdEHRP6TRP6rMuDHk5t44hnTRyow==}
+ engines: {node: '>=14.19.0'}
+
resolution: {integrity: sha512-0mYKnYYe9ZcqMCWhUjItv/oHjvgEsfKvnUTg8sAtnHr3GVy7rGkXCb6d5cSyqrWqL4k81b9CPg3urd+T7aop3A==}
@@ -10362,6 +10411,10 @@ packages:
resolution: {integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==}
+ resolution: {integrity: sha512-2wcC/oGxHis/BoHkkPwldgiPSYcpZK3JU28WoMVv55yHJgcZ8rlXvuG9iZggz+sU1d4bRgIGASwyWqjxu3FM0g==}
+ engines: {node: '>=18'}
+
resolution: {integrity: sha512-kUMbT1oBJCpgrnKoSr0o6wPtvRWT9W9UKvGLwfJYO2WuahZRHOpEyL1ckyMGgMWh0UdpmaoFqKKD29WTomNEGA==}
engines: {node: '>=8'}
@@ -10765,6 +10818,10 @@ packages:
resolution: {integrity: sha512-NLdXTEZkKiO0gZuLtMoZKjCXTREXeZZt8nnnNeyoXtNZAfG/GKGSbQtLU5STspc0rMSwcA+UJfWZkbNU01iKmQ==}
+ resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==}
+ engines: {node: '>=6'}
+
resolution: {integrity: sha512-Loo5UUvLD9ScZ6jh8beX1T6sO1w2/MpCRpEP7V280GKMVUQ0Jzar2U3UJPsrdbziLEMMhu3Ujnq//rhiFuIeag==}
engines: {node: '>=6'}
@@ -12671,6 +12728,8 @@ snapshots:
'@bcoe/[email protected]': {}
+ '@blazediff/[email protected]': {}
+
'@braintree/[email protected]': {}
'@bufbuild/[email protected]': {}
@@ -14742,6 +14801,8 @@ snapshots:
dependencies:
playwright: 1.57.0
+ '@polka/[email protected]': {}
+
'@posthog/[email protected]':
dependencies:
'@posthog/types': 1.372.5
@@ -16272,6 +16333,20 @@ snapshots:
- vite
- webpack
+ dependencies:
+ '@storybook/global': 5.0.0
+ optionalDependencies:
+ '@vitest/runner': 4.1.4
+ transitivePeerDependencies:
+ - react
+ - react-dom
+
dependencies:
@@ -17259,7 +17334,37 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ dependencies:
+ playwright: 1.57.0
+ tinyrainbow: 3.1.0
+ transitivePeerDependencies:
+ - bufferutil
+ - msw
+ - utf-8-validate
+ - vite
+
+ dependencies:
+ '@blazediff/core': 1.9.1
+ '@vitest/utils': 4.1.4
+ magic-string: 0.30.21
+ pngjs: 7.0.0
+ sirv: 3.0.2
+ tinyrainbow: 3.1.0
+ ws: 8.21.0
+ transitivePeerDependencies:
+ - bufferutil
+ - msw
+ - utf-8-validate
+ - vite
+
dependencies:
'@bcoe/v8-coverage': 1.0.2
'@vitest/utils': 4.1.4
@@ -17271,7 +17376,9 @@ snapshots:
obug: 2.1.1
std-env: 4.0.0
tinyrainbow: 3.1.0
+ optionalDependencies:
'@vitest/[email protected]':
dependencies:
@@ -20972,6 +21079,8 @@ snapshots:
+
@@ -21631,6 +21740,8 @@ snapshots:
optionalDependencies:
fsevents: 2.3.2
+
@@ -22516,6 +22627,12 @@ snapshots:
dependencies:
is-arrayish: 0.3.2
+ dependencies:
+ '@polka/url': 1.0.0-next.29
+ mrmime: 2.0.1
+ totalist: 3.0.1
+
dependencies:
unicode-emoji-modifier-base: 1.0.0
@@ -22919,6 +23036,8 @@ snapshots:
+
dependencies:
psl: 1.9.0
@@ -23379,7 +23498,7 @@ snapshots:
tsx: 4.20.5
yaml: 2.8.4
dependencies:
'@vitest/expect': 4.1.4
@@ -23404,7 +23523,8 @@ snapshots:
optionalDependencies:
'@opentelemetry/api': 1.9.1
'@types/node': 24.3.0
- '@vitest/coverage-v8': 4.1.4([email protected])
+ '@vitest/coverage-v8': 4.1.4(@vitest/[email protected])([email protected])
jsdom: 26.1.0
transitivePeerDependencies:
- msw
diff --git a/web/.storybook/main.ts b/web/.storybook/main.ts
index ade3a2f514..d00f6440cb 100644
--- a/web/.storybook/main.ts
+++ b/web/.storybook/main.ts
@@ -17,6 +17,7 @@ const config: StorybookConfig = {
addons: [
getAbsolutePath("@storybook/addon-a11y"),
getAbsolutePath("@storybook/addon-docs"),
+ getAbsolutePath("@storybook/addon-vitest"),
],
framework: getAbsolutePath("@storybook/nextjs-vite"),
staticDirs: ["../public"],
diff --git a/web/.storybook/preview.ts b/web/.storybook/preview.tsx
similarity index 56%
rename from web/.storybook/preview.ts
rename to web/.storybook/preview.tsx
index fc79f9a7e2..7b8fc1c047 100644
--- a/web/.storybook/preview.ts
+++ b/web/.storybook/preview.tsx
@@ -1,10 +1,29 @@
import { definePreview } from "@storybook/nextjs-vite";
import addonA11y from "@storybook/addon-a11y";
-import { createElement } from "react";
+import { useEffect, type ReactNode } from "react";
import { TooltipProvider } from "../src/components/ui/tooltip";
-import { ThemeProvider } from "../src/features/theming/ThemeProvider";
import "../src/styles/globals.css";
+function StorybookThemeProvider({
+ children,
+ theme,
+}: {
+ children?: ReactNode;
+ theme: "light" | "dark";
+}) {
+ useEffect(() => {
+ document.documentElement.classList.toggle("dark", theme === "dark");
+
+ return () => {
+ document.documentElement.classList.remove("dark");
+ };
+ }, [theme]);
+
+ return (
+ <div className="bg-background text-foreground min-h-screen">{children}</div>
+ );
+}
+
export default definePreview({
addons: [addonA11y()],
globalTypes: {
@@ -28,23 +47,12 @@ export default definePreview({
(Story, context) => {
const theme = context.globals.theme === "dark" ? "dark" : "light";
- return createElement(
- ThemeProvider,
- {
- attribute: "class",
- disableTransitionOnChange: true,
- enableSystem: false,
- forcedTheme: theme,
- },
- createElement(
- TooltipProvider,
- null,
- createElement(
- "div",
- { className: "min-h-screen bg-background text-foreground" },
- createElement(Story),
- ),
- ),
+ return (
+ <StorybookThemeProvider theme={theme}>
+ <TooltipProvider>
+ <Story />
+ </TooltipProvider>
+ </StorybookThemeProvider>
);
},
],
diff --git a/web/package.json b/web/package.json
index 0f5e95f0ae..861796f99c 100644
--- a/web/package.json
+++ b/web/package.json
@@ -21,6 +21,7 @@
"test:in-source": "vitest run --project in-source",
"test-client": "vitest run --project client",
"test:watch": "vitest --project client --project server --project server-isolated --project server-unit --project in-source",
+ "test-storybook": "vitest run --project storybook",
"test:e2e": "dotenv -e ../.env.test -e ../.env -- playwright test --reporter=line",
"test:e2e:server": "vitest run --project e2e-server",
"build-trace": "dotenv -e ../.env -- next internal trace .next/trace-turbopack",
@@ -181,9 +182,10 @@
"@playwright/test": "^1.57.0",
"@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
- "@storybook/addon-a11y": "^10.3.6",
- "@storybook/addon-docs": "^10.3.6",
- "@storybook/nextjs-vite": "^10.3.6",
+ "@storybook/addon-a11y": "10.3.6",
+ "@storybook/addon-docs": "10.3.6",
+ "@storybook/addon-vitest": "10.3.6",
+ "@storybook/nextjs-vite": "10.3.6",
"@tailwindcss/forms": "^0.5.11",
"@tailwindcss/postcss": "^4.2.2",
"@tailwindcss/typography": "^0.5.19",
@@ -200,17 +202,18 @@
"@types/react-grid-layout": "^1.3.6",
"@typescript/native-preview": "7.0.0-dev.20260122.3",
"@vitejs/plugin-react": "^4.7.0",
+ "@vitest/browser-playwright": "4.1.4",
"dotenv": "^16.6.1",
"dotenv-cli": "^7.4.2",
"dotenv-expand": "^10.0.0",
"eslint": "^9.39.2",
"eslint-config-next": "16.2.6",
- "eslint-plugin-storybook": "^10.3.6",
+ "eslint-plugin-storybook": "10.3.6",
"jsdom": "^26.1.0",
"node-mocks-http": "^1.17.2",
"prettier": "^3.8.3",
"prettier-plugin-tailwindcss": "^0.7.2",
- "storybook": "^10.3.6",
+ "storybook": "10.3.6",
"tailwindcss": "^4.2.2",
"typescript": "^5.7.2",
"vite": "^7.3.5",
diff --git a/web/src/ee/features/in-app-agent/components/InAppAgentMessage.stories.tsx b/web/src/ee/features/in-app-agent/components/InAppAgentMessage.stories.tsx
index 3bbef37725..fed1e99ca9 100644
--- a/web/src/ee/features/in-app-agent/components/InAppAgentMessage.stories.tsx
+++ b/web/src/ee/features/in-app-agent/components/InAppAgentMessage.stories.tsx
@@ -313,7 +313,7 @@ export const FeedbackPopoverInteraction = meta.story({
const commentInput = await body.findByPlaceholderText(
"Optional feedback comment",
);
- await expect(commentInput).toBeVisible();
+ await waitFor(() => expect(commentInput).toBeVisible());
const saveButton = await body.findByRole("button", {
name: "Save comment",
diff --git a/web/vitest.config.mts b/web/vitest.config.mts
index c3b6f692fb..ca78c711eb 100644
--- a/web/vitest.config.mts
+++ b/web/vitest.config.mts
@@ -1,5 +1,7 @@
import { globSync, readFileSync } from "node:fs";
import { join } from "node:path";
+import { storybookTest } from "@storybook/addon-vitest/vitest-plugin";
+import { playwright } from "@vitest/browser-playwright";
import { config } from "dotenv";
import { expand } from "dotenv-expand";
import { defineConfig } from "vitest/config";
@@ -124,6 +126,24 @@ export default defineConfig({
setupFiles: ["./src/__tests__/after-teardown.ts"],
},
},
+ {
+ extends: true,
+ plugins: [
+ storybookTest({
+ configDir: join(import.meta.dirname, ".storybook"),
+ storybookScript: "pnpm run storybook -- --ci --no-open",
+ }),
+ ],
+ test: {
+ name: "storybook",
+ browser: {
+ enabled: true,
+ provider: playwright(),
+ headless: true,
+ instances: [{ browser: "chromium" }],
+ },
+ },
+ },
{
extends: true,
test: {