2022-10-31 11:57:34 +01:00

47 lines
1.2 KiB
TypeScript

import type { Meta, StoryObj } from '@storybook/angular';
import { moduleMetadata } from '@storybook/angular';
import { within, userEvent } from '@storybook/testing-library';
import { CommonModule } from '@angular/common';
import Button from './button.component';
import Header from './header.component';
import Page from './page.component';
const meta: Meta<Page> = {
title: 'Example/Page',
component: Page,
parameters: {
// More on StoryFn layout: https://storybook.js.org/docs/angular/configure/story-layout
layout: 'fullscreen',
},
decorators: [
moduleMetadata({
declarations: [Button, Header],
imports: [CommonModule],
}),
],
};
export default meta;
type Story = StoryObj<Page>;
export const LoggedOut: Story = {
render: (args: Page) => ({
props: args,
}),
};
// More on interaction testing: https://storybook.js.org/docs/angular/writing-tests/interaction-testing
export const LoggedIn: Story = {
render: (args: Page) => ({
props: args,
}),
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const loginButton = await canvas.getByRole('button', {
name: /Log in/i,
});
await userEvent.click(loginButton);
},
};