Skip to content

Commit 2310d71

Browse files
committed
feat: added a11y to storybook
1 parent 93f5f1f commit 2310d71

File tree

7 files changed

+319
-365
lines changed

7 files changed

+319
-365
lines changed

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"@nrwl/storybook": "15.8.7",
3232
"@nrwl/vite": "15.8.7",
3333
"@nrwl/workspace": "15.8.7",
34+
"@storybook/addon-a11y": "7.0.0-rc.10",
3435
"@storybook/addon-essentials": "7.0.0-rc.7",
3536
"@storybook/addon-interactions": "7.0.0-rc.7",
3637
"@storybook/addon-links": "7.0.0-rc.7",
@@ -48,11 +49,13 @@
4849
"@vitest/ui": "^0.28.5",
4950
"all-contributors-cli": "^6.24.0",
5051
"autoprefixer": "^10.4.13",
52+
"axe-core": "4.6.3",
5153
"commitizen": "^4.3.0",
5254
"commitlint": "^17.4.3",
5355
"country-list-json": "1.1.0",
54-
"cypress": "^12.6.0",
55-
"cypress-ct-qwik": "0.0.5",
56+
"cypress": "^12.9.0",
57+
"cypress-axe": "1.4.0",
58+
"cypress-ct-qwik": "0.0.9",
5659
"cz-conventional-changelog": "^3.3.0",
5760
"daisyui": "^2.50.1",
5861
"danger": "11.2.4",
@@ -83,7 +86,7 @@
8386
"ts-node": "10.9.1",
8487
"typescript": "5.0.2",
8588
"undici": "5.21.0",
86-
"vite": "4.1.2",
89+
"vite": "4.2.1",
8790
"vite-plugin-dts": "~1.7.3",
8891
"vite-plugin-eslint": "^1.8.1",
8992
"vite-tsconfig-paths": "4.0.7",

packages/headless/.storybook/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const config: StorybookConfig = {
1313
'@storybook/addon-links',
1414
'@storybook/addon-essentials',
1515
'@storybook/addon-interactions',
16+
'@storybook/addon-a11y',
17+
'@storybook/addon-coverage',
1618
],
1719
// addons: ['@storybook/addon-essentials', ...(rootMain.addons || [])],
1820

packages/headless/cypress/support/component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515

1616
// Import commands.ts using ES2015 syntax:
1717
import './commands';
18+
import 'cypress-axe';

packages/headless/src/components/accordion/accordion.spec.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ describe('Accordion', () => {
2020
</Accordion>
2121
);
2222

23+
// cy.injectAxe();
24+
2325
cy.contains(/Heading 1/i).click();
2426
cy.get('.content').should('exist');
2527
cy.contains(/Heading 2/i).should('exist');
28+
29+
// cy.checkA11y();
2630
});
2731
});

packages/headless/src/components/tooltip/tooltip.stories.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { userEvent, within } from '@storybook/testing-library';
12
import { Meta, StoryObj } from 'storybook-framework-qwik';
23
import { Tooltip, TooltipProps } from './tooltip';
4+
import { expect } from '@storybook/jest';
35

46
const meta: Meta<TooltipProps> = {
57
component: Tooltip,
@@ -13,9 +15,12 @@ export const Primary: Story = {
1315
args: {
1416
content: 'Hi there',
1517
},
16-
render: () => (
17-
<Tooltip content="test">
18-
<button>Hello</button>
19-
</Tooltip>
20-
),
18+
render: (args) => <Tooltip content={args.content}>Please hover me</Tooltip>,
19+
// play: async ({ canvasElement }) => {
20+
// const canvas = within(canvasElement);
21+
22+
// await userEvent.hover(canvas.getByText('Please hover me'));
23+
24+
// await expect(canvas.getByText('Hi there')).toBeInTheDocument();
25+
// }
2126
};

packages/headless/tsconfig.spec.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
44
"outDir": "../../dist/out-tsc",
5-
"types": ["vitest/globals", "cypress", "node"]
5+
"types": ["vitest/globals", "cypress", "cypress-axe", "node"]
66
},
77
"include": [
88
"vite.config.ts",
@@ -17,5 +17,6 @@
1717
"src/**/*.test.jsx",
1818
"src/**/*.spec.jsx",
1919
"src/**/*.d.ts"
20-
]
20+
],
21+
"exclude": ["**/*.stories.ts", "**/*.stories.js"]
2122
}

0 commit comments

Comments
 (0)