| 1 | import { within, userEvent, expect } from '@storybook/test'; |
| 2 | import { Page } from './Page'; |
| 3 | |
| 4 | export default { |
| 5 | title: 'Example/Page', |
| 6 | component: Page, |
| 7 | parameters: { |
| 8 | // More on how to position stories at: https://storybook.js.org/docs/configure/story-layout |
| 9 | layout: 'fullscreen', |
| 10 | }, |
| 11 | }; |
| 12 | |
| 13 | export const LoggedOut = {}; |
| 14 | |
| 15 | // More on interaction testing: https://storybook.js.org/docs/writing-tests/interaction-testing |
| 16 | export const LoggedIn = { |
| 17 | play: async ({ canvasElement }) => { |
| 18 | const canvas = within(canvasElement); |
| 19 | const loginButton = canvas.getByRole('button', { name: /Log in/i }); |
| 20 | await expect(loginButton).toBeInTheDocument(); |
| 21 | await userEvent.click(loginButton); |
| 22 | await expect(loginButton).not.toBeInTheDocument(); |
| 23 | |
| 24 | const logoutButton = canvas.getByRole('button', { name: /Log out/i }); |
| 25 | await expect(logoutButton).toBeInTheDocument(); |
| 26 | }, |
| 27 | }; |