- Add session-aware login, logout and protected navigation. - Send cookie credentials for API and run-event requests with localized UI stories.
29 lines
947 B
TypeScript
29 lines
947 B
TypeScript
import '../../src/i18n';
|
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
import { expect, fn, userEvent, within } from 'storybook/test';
|
|
import { AuthStatusPage } from '../../src/pages/auth/AuthStatusPage';
|
|
|
|
const meta: Meta<typeof AuthStatusPage> = {
|
|
title: 'Authentication/Session status',
|
|
component: AuthStatusPage,
|
|
parameters: { layout: 'fullscreen' },
|
|
tags: ['autodocs'],
|
|
args: { onRetry: fn() },
|
|
};
|
|
export default meta;
|
|
type Story = StoryObj<typeof AuthStatusPage>;
|
|
|
|
export const Checking: Story = {};
|
|
|
|
export const SessionCheckFailure: Story = {
|
|
args: { failed: true },
|
|
play: async ({ canvasElement, args }) => {
|
|
const canvas = within(canvasElement);
|
|
await expect(canvas.getByRole('alert')).toHaveTextContent(
|
|
"Couldn't check your session. Try again.",
|
|
);
|
|
await userEvent.click(canvas.getByRole('button', { name: 'Retry' }));
|
|
await expect(args.onRetry).toHaveBeenCalledTimes(1);
|
|
},
|
|
};
|