Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/storybook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Storybook Build and Test

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

jobs:
storybook:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
Comment on lines +16 to +19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use setup-node v4 and current LTS

Node 18 reached EOL in April 2025; move to Node 20 (or 22) and the latest action.

-      - uses: actions/setup-node@v3
+      - uses: actions/setup-node@v4
         with:
-          node-version: '18'
+          node-version: '20'
           cache: 'npm'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
🧰 Tools
🪛 actionlint (1.7.7)

16-16: the runner of "actions/setup-node@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🤖 Prompt for AI Agents
.github/workflows/storybook.yml around lines 16 to 19 currently pins
actions/setup-node@v3 and node-version: '18'; update the workflow to use
actions/setup-node@v4 and bump the node-version to a current LTS (e.g., '20' or
'22') in those lines, keeping the cache setting as needed (cache: 'npm'); ensure
any other steps relying on Node 18 are compatible or adjusted accordingly.

- name: Install dependencies
run: npm ci
- name: Install Playwright
run: npx playwright install --with-deps chromium
- name: Build Storybook
run: npm run build-storybook
- name: Storybook smoke tests
run: npm run test-storybook
36 changes: 36 additions & 0 deletions .storybook/test-runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Basic smoke tests for Storybook stories.
*
* This configuration runs in CI via the Storybook test runner. It renders each
* story and performs a minimal interaction to surface runtime errors that unit
* tests might miss.
*
* What it covers:
* - Verifies that stories render without throwing.
* - Clicks the first button (if present) to catch simple interaction bugs.
*
* What it doesn't cover:
* - Visual regressions or accessibility checks.
* - Complex workflows that require multiple interactions.
* - Stories that depend on network requests or auth; those may require mocks
* or can be excluded from CI if flaky.
*
* This smoke test is a lightweight safety net and does not replace dedicated
* unit, integration, or visual testing.
*/
// If a button exists, click the first one to ensure the interaction doesn't trigger
// runtime errors.
export const run = async ({ canvasElement }) => {
// Import testing utilities inside the runner so that Storybook's jsdom
// environment is available. Importing at the module level throws because the
// package expects `location` to exist on the global object.
const { within, userEvent } = await import('@storybook/testing-library');

const canvas = within(canvasElement);
// Use queryAllByRole so the test runner doesn't throw when multiple buttons
// are present.
const [button] = canvas.queryAllByRole('button');
if (button) {
await userEvent.click(button);
}
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"sb": "storybook dev -p 6006",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"test-storybook": "npx @storybook/test-runner --index-json ./storybook-static/index.json",
"build-css": "rollup -c rollup-css.config.js",
"generate-tokens": "tsx ./src/tokenGen/index.js",
"bundle-tokens": "rollup --config rollup-tokens.config.js",
Expand Down
Loading