- update client and server dependencies within their ranges, keeping all playwright packages aligned at 1.63 - fix code flagged by react-hooks 7.1: refs written during render and synchronous setState in effects - add stories for the ui components that had none, with interaction tests, and cover all DescriptionList layouts - drop the unused mdx stories pattern - run the storybook tests as part of the pre-commit checks - bump version to 1.20.1
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import React, { useState } from 'react';
|
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
import { expect, userEvent, within } from 'storybook/test';
|
|
import { Search } from '../../src/ui/Search/Search';
|
|
|
|
function ControlledSearch({ placeholder }: { placeholder?: string }) {
|
|
const [value, setValue] = useState('');
|
|
return (
|
|
<div>
|
|
<Search value={value} onChange={setValue} placeholder={placeholder} />
|
|
<p data-testid="query">{value}</p>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const meta: Meta<typeof ControlledSearch> = {
|
|
title: 'UI/Search',
|
|
component: ControlledSearch,
|
|
parameters: { layout: 'centered' },
|
|
tags: ['autodocs'],
|
|
};
|
|
export default meta;
|
|
type Story = StoryObj<typeof ControlledSearch>;
|
|
|
|
export const Default: Story = {};
|
|
|
|
export const Typing: Story = {
|
|
args: { placeholder: 'Filter logs…' },
|
|
play: async ({ canvasElement }) => {
|
|
const canvas = within(canvasElement);
|
|
await userEvent.type(canvas.getByPlaceholderText('Filter logs…'), 'timeout');
|
|
await expect(canvas.getByTestId('query')).toHaveTextContent('timeout');
|
|
},
|
|
};
|