Page.stories.js 890 B

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