a template starter repo for sveltekit projects
1<script module>
2 import { defineMeta } from '@storybook/addon-svelte-csf';
3 import { expect, userEvent, waitFor, within } from 'storybook/test';
4 import Page from './Page.svelte';
5 // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
6 const { Story } = defineMeta({
7 title: 'Example/Page',
8 component: Page,
9 parameters: {
10 // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
11 layout: 'fullscreen'
12 }
13 });
14</script>
15
16<Story
17 name="Logged In"
18 play={async ({ canvasElement }) => {
19 const canvas = within(canvasElement);
20 const loginButton = canvas.getByRole('button', { name: /Log in/i });
21 await expect(loginButton).toBeInTheDocument();
22 await userEvent.click(loginButton);
23 await waitFor(() => expect(loginButton).not.toBeInTheDocument());
24
25 const logoutButton = canvas.getByRole('button', { name: /Log out/i });
26 await expect(logoutButton).toBeInTheDocument();
27 }}
28/>
29
30<Story name="Logged Out" />