diff --git a/.github/workflows/storybook-tests.yml b/.github/workflows/storybook-tests.yml index bc79392..f309b9b 100644 --- a/.github/workflows/storybook-tests.yml +++ b/.github/workflows/storybook-tests.yml @@ -35,16 +35,22 @@ jobs: - name: Build Storybook run: yarn build-storybook + - name: Install test dependencies + run: yarn add --dev http-server wait-on + - name: Run Storybook tests run: | # Start Storybook in the background - npx http-server storybook-static --port 6006 --silent & + yarn http-server storybook-static --port 6006 --silent & # Wait for Storybook to be ready - npx wait-on http://localhost:6006 + yarn wait-on http://localhost:6006 + + # Set environment variable for Storybook URL + export STORYBOOK_URL=http://localhost:6006 - # Run the tests using test-runner directly - npx test-storybook --url http://localhost:6006 --browsers chromium + # Run the tests using Vitest + yarn test:storybook - name: Upload test artifacts on failure if: failure() diff --git a/.storybook/main.ts b/.storybook/main.ts index 9e12745..21e318d 100644 --- a/.storybook/main.ts +++ b/.storybook/main.ts @@ -5,6 +5,7 @@ const config: StorybookConfig = { addons: [ '@storybook/addon-essentials', '@storybook/addon-interactions', + '@storybook/addon-vitest' ], framework: { name: '@storybook/html-vite', diff --git a/.storybook/vitest.setup.ts b/.storybook/vitest.setup.ts new file mode 100644 index 0000000..c583eaf --- /dev/null +++ b/.storybook/vitest.setup.ts @@ -0,0 +1,6 @@ +import { setProjectAnnotations } from '@storybook/html-vite'; +import * as projectAnnotations from './preview'; + +// This is an important step to apply the right configuration when testing your stories. +// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations +setProjectAnnotations([projectAnnotations]); \ No newline at end of file diff --git a/.windsurf/rules/storybook.md b/.windsurf/rules/storybook.md index 9f41380..961de9c 100644 --- a/.windsurf/rules/storybook.md +++ b/.windsurf/rules/storybook.md @@ -6,4 +6,6 @@ This is guidance for generation and maintenance of StoryBook stories. Lots of data tables are generated for StoryBook tests. Do not create them as template text in the story. Generate them as suitably named `.html` files in the `stories` sub-folder. -This make it easier to understand and maintain them. \ No newline at end of file +This make it easier to understand and maintain them. + +We will be using Storybook V9 interaction tests, as documented here: https://storybook.js.org/docs/writing-tests/interaction-testing \ No newline at end of file diff --git a/package.json b/package.json index 82a9695..9940757 100644 --- a/package.json +++ b/package.json @@ -7,28 +7,31 @@ "dev": "vite", "build": "tsc && vite build && node scripts/copy-demo.js", "preview": "vite preview", - "preview:demo": "vite preview --port 3000 --open /demo", + "preview:demo": "vite preview --port 3000 --open grid-sight", "storybook": "storybook dev -p 6006", "build-storybook": "storybook build", - "test:storybook": "test-storybook", + "test:storybook": "vitest run --project=storybook", "test": "vitest run", "test:watch": "vitest", "test:coverage": "vitest run --coverage", - "test:e2e": "playwright test tests/e2e/demo.spec.ts", - "test:e2e:ui": "playwright test --ui tests/e2e/demo.spec.ts" + "test:e2e": "vite build && playwright test tests/e2e", + "test:e2e:ui": "vite build && playwright test --ui tests/e2e" }, "devDependencies": { "@playwright/test": "^1.53.0", "@storybook/addon-docs": "^9.0.6", "@storybook/addon-essentials": "^9.0.0-alpha.12", "@storybook/addon-interactions": "^9.0.0-alpha.10", + "@storybook/addon-vitest": "^9.0.9", "@storybook/html-vite": "^9.0.6", "@storybook/test": "^8.6.14", "@types/fs-extra": "^11.0.4", + "@vitest/browser": "3.2.3", "@vitest/coverage-v8": "^3.2.3", "@vitest/ui": "^3.2.3", "fs-extra": "^11.3.0", "jsdom": "^26.1.0", + "playwright": "^1.53.0", "storybook": "^9.0.6", "terser": "^5.42.0", "typescript": "~5.8.3", diff --git a/public/demo/index.html b/public/index.html similarity index 75% rename from public/demo/index.html rename to public/index.html index 5ac46f0..299eb74 100644 --- a/public/demo/index.html +++ b/public/index.html @@ -60,58 +60,34 @@
| Product ID | -Product Name | -Category | -Price | -In Stock | -Last Ordered | -
|---|---|---|---|---|---|
| P1001 | -Wireless Mouse | -Electronics | -29.99 | -45 | -2023-05-15 | -
| P1002 | -Ergonomic Keyboard | -Electronics | -89.99 | -23 | -2023-05-18 | -
| P2001 | -Desk Lamp | -Furniture | -45.50 | -12 | -2023-05-10 | -
| P2002 | -Office Chair | -Furniture | -249.99 | -5 | -2023-05-05 | -
| P3001 | -Notebook Set | -Stationery | -12.99 | -87 | -2023-05-20 | -
| Gear / Revs | +5 | +10 | +15 | +20 | +|
| Low | +10 | +15 | +20 | +25 | +|
| Medium | +17 | +22 | +27 | +32 | +|
| High | +27 | +25 | +30 | +35 | +