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 @@

Basic Usage

Product Inventory

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Product IDProduct NameCategoryPriceIn StockLast Ordered
P1001Wireless MouseElectronics29.99452023-05-15
P1002Ergonomic KeyboardElectronics89.99232023-05-18
P2001Desk LampFurniture45.50122023-05-10
P2002Office ChairFurniture249.9952023-05-05
P3001Notebook SetStationery12.99872023-05-20
Gear / Revs5101520
Low10152025
Medium17222732
High27253035
@@ -124,7 +100,7 @@

Monthly Sales Data

Revenue Expenses Profit - Growth % + Dominant item @@ -133,35 +109,35 @@

Monthly Sales Data

12500 9800 2700 - 5.2 + Corded Mouse February 11800 9200 2600 - -3.7 + Wireless Mouse March 14200 10100 4100 - 20.3 + Corded Mouse April 13800 9900 3900 - -2.8 + Corded Mouse May 15600 10500 5100 - 13.0 + Desk Lamp @@ -182,7 +158,7 @@

Browser Console

- +