Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

1.5 KB
Raw Blame
import type { Meta, StoryObj } from '@storybook/react-vite';
import { userEvent, within } from 'storybook/test';

import { storyMocks } from '@/storybook/controls/defineStoryMocks';
import type { PageStoryArgs } from '@/storybook/runtime/resolveStory';

import LicensePage from '../index';
import { licenseMocks } from './License.stories.mocks';

type LicenseArgs = PageStoryArgs<typeof licenseMocks>;

const pageStory = storyMocks(licenseMocks, { layout: 'app' });

/**
 * Licence keys applied to the workspace, and the form that applies another.
 *
 * Route: `/licenses`.
 */
const meta = {
	title: 'Pages/System/License',
	tags: ['play'],
	component: LicensePage,
	...pageStory,
	parameters: { ...pageStory.parameters },
} satisfies Meta<LicenseArgs>;

export default meta;

type Story = StoryObj<LicenseArgs>;

const applyKey = async (canvasElement: HTMLElement): Promise<void> => {
	const canvas = within(canvasElement);

	await userEvent.type(
		await canvas.findByRole('textbox'),
		'96a1c6a4-3f1e-4b7d-9f2a-8c0d5e6f7a8b',
	);
	await userEvent.click(canvas.getByRole('button', { name: /apply/i }));
};

/** Where a self-hosted deployment puts the key it was sold. */
export const Default: Story = {};

/** A key the backend will not take, which the form reports where it stands. */
export const KeyRejected: Story = {
	args: { apply: 'rejected' },
	// The deliberate 400 is the state under test.
	parameters: { allowConsoleErrors: true },
	play: async ({ canvasElement }): Promise<void> => {
		await applyKey(canvasElement);
	},
};