Skip to content

Commit 93f5f1f

Browse files
committed
test: added storybook interaction test
1 parent 616e00c commit 93f5f1f

File tree

3 files changed

+587
-171
lines changed

3 files changed

+587
-171
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@storybook/builder-vite": "7.0.0-rc.7",
3939
"@storybook/html": "7.0.0-rc.7",
4040
"@storybook/html-vite": "7.0.0-rc.7",
41+
"@storybook/jest": "0.0.10",
4142
"@storybook/testing-library": "0.0.13",
4243
"@types/eslint": "8.21.3",
4344
"@types/node": "18.15.3",
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Meta, StoryObj } from 'storybook-framework-qwik';
2+
import { Accordion, AccordionItem, AccordionProps } from './accordion';
3+
import { within, userEvent } from '@storybook/testing-library';
4+
import { expect } from '@storybook/jest';
5+
6+
const meta: Meta<AccordionProps> = {
7+
component: Accordion,
8+
};
9+
10+
export default meta;
11+
12+
type Story = StoryObj<AccordionProps>;
13+
14+
export const Primary: Story = {
15+
render: () => (
16+
<Accordion>
17+
<AccordionItem label="Item 1">This is a test</AccordionItem>
18+
</Accordion>
19+
),
20+
play: async ({ canvasElement }) => {
21+
const canvas = within(canvasElement);
22+
23+
await userEvent.click(canvas.getByText('Item 1'));
24+
25+
await expect(canvas.getByText('This is a test')).toBeInTheDocument();
26+
},
27+
};

0 commit comments

Comments
 (0)