Skip to content

Commit 6053ff8

Browse files
authored
Merge pull request #414 from ixartz/storybook9
Storybook9
2 parents cefe390 + 4fa354c commit 6053ff8

File tree

13 files changed

+12865
-24042
lines changed

13 files changed

+12865
-24042
lines changed

.github/workflows/CI.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
fail-on-cache-miss: true
100100

101101
- name: Run unit tests
102-
uses: docker://mcr.microsoft.com/playwright:v1.53.0
102+
uses: docker://mcr.microsoft.com/playwright:v1.53.1
103103
with:
104104
args: npm run test -- --coverage
105105

@@ -134,9 +134,9 @@ jobs:
134134
fail-on-cache-miss: true
135135

136136
- name: Run storybook tests
137-
uses: docker://mcr.microsoft.com/playwright:v1.53.0
137+
uses: docker://mcr.microsoft.com/playwright:v1.53.1
138138
with:
139-
args: npm run test-storybook:ci
139+
args: npm run storybook:test
140140

141141
e2e:
142142
strategy:
@@ -166,7 +166,7 @@ jobs:
166166
fail-on-cache-miss: true
167167

168168
- name: Run E2E tests
169-
uses: docker://mcr.microsoft.com/playwright:v1.53.0
169+
uses: docker://mcr.microsoft.com/playwright:v1.53.1
170170
with:
171171
args: sh -c "HOME=/root npm run test:e2e" # Set HOME to /root to avoid Playwright error with Firebox
172172
env:

.storybook/main.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
import type { StorybookConfig } from '@storybook/nextjs';
1+
import type { StorybookConfig } from '@storybook/nextjs-vite';
22

33
const config: StorybookConfig = {
4-
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
4+
stories: [
5+
'../src/**/*.mdx',
6+
'../src/**/*.stories.@(js|jsx|mjs|ts|tsx)',
7+
],
58
addons: [
6-
'@storybook/addon-onboarding',
7-
'@storybook/addon-links',
8-
'@storybook/addon-essentials',
9-
'@storybook/addon-interactions',
9+
'@storybook/addon-docs',
10+
'@storybook/addon-a11y',
1011
],
1112
framework: {
12-
name: '@storybook/nextjs',
13+
name: '@storybook/nextjs-vite',
1314
options: {},
1415
},
15-
staticDirs: ['../public'],
16+
staticDirs: [
17+
'../public',
18+
],
19+
features: {
20+
experimentalRSC: true,
21+
},
1622
core: {
1723
disableTelemetry: true,
1824
},
1925
};
20-
2126
export default config;

.storybook/preview.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Preview } from '@storybook/react';
1+
import type { Preview } from '@storybook/nextjs-vite';
22
import '../src/styles/global.css';
33

44
const preview: Preview = {
@@ -10,9 +10,16 @@ const preview: Preview = {
1010
},
1111
},
1212
nextjs: {
13-
appDirectory: true,
13+
appDirectory: true, // Enable App Router support
14+
},
15+
docs: {
16+
toc: true, // Enable table of contents
17+
},
18+
a11y: {
19+
test: 'todo', // Make a11y tests optional
1420
},
1521
},
22+
tags: ['autodocs'],
1623
};
1724

1825
export default preview;

.storybook/vitest.config.mts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
2+
import { defineConfig } from 'vitest/config';
3+
4+
export default defineConfig({
5+
plugins: [
6+
// The plugin will run tests for the stories defined in your Storybook config
7+
// See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
8+
storybookTest(),
9+
],
10+
test: {
11+
projects: [
12+
{
13+
extends: true,
14+
test: {
15+
name: 'storybook',
16+
browser: {
17+
enabled: true,
18+
headless: true,
19+
provider: 'playwright',
20+
instances: [{ browser: 'chromium' }],
21+
},
22+
setupFiles: ['.storybook/vitest.setup.ts'],
23+
},
24+
},
25+
],
26+
},
27+
});

.storybook/vitest.setup.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as a11yAddonAnnotations from '@storybook/addon-a11y/preview';
2+
import { setProjectAnnotations } from '@storybook/nextjs-vite';
3+
import * as projectAnnotations from './preview';
4+
5+
// This is an important step to apply the right configuration when testing your stories.
6+
// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
7+
setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]);

eslint.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import nextPlugin from '@next/eslint-plugin-next';
33
import jestDom from 'eslint-plugin-jest-dom';
44
import jsxA11y from 'eslint-plugin-jsx-a11y';
55
import playwright from 'eslint-plugin-playwright';
6+
import storybook from 'eslint-plugin-storybook';
67

78
export default antfu(
89
{
@@ -55,6 +56,8 @@ export default antfu(
5556
],
5657
...playwright.configs['flat/recommended'],
5758
},
59+
// --- Storybook Rules ---
60+
...storybook.configs['flat/recommended'],
5861
// --- Custom Rule Overrides ---
5962
{
6063
rules: {

0 commit comments

Comments
 (0)