Build ErsatzTV Image / Docs update reminder (pull_request) Successful in 12s
Build ErsatzTV Image / decisions.md append-only (pull_request) Successful in 12s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 13s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 14s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 8m26s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 10m23s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Refs #247 Co-Authored-By: OpenAI Codex <codex@openai.com>
69 lines
2.2 KiB
TypeScript
69 lines
2.2 KiB
TypeScript
import { cleanup, fireEvent, render, screen } from '@testing-library/react';
|
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
import {
|
|
Button,
|
|
Checkbox,
|
|
Input,
|
|
ProgressBar,
|
|
Switch,
|
|
Tabs,
|
|
Toast,
|
|
Tooltip
|
|
} from '.';
|
|
|
|
describe('component primitives', () => {
|
|
afterEach(cleanup);
|
|
|
|
it('exports typed primitives with expected interactions', () => {
|
|
const onSwitch = vi.fn();
|
|
const onCheckbox = vi.fn();
|
|
const onTab = vi.fn();
|
|
|
|
render(
|
|
<>
|
|
<Button variant="primary" loading>
|
|
Saving
|
|
</Button>
|
|
<Switch checked={false} onChange={onSwitch} label="Show disabled" />
|
|
<Checkbox indeterminate onChange={onCheckbox} label="Select all" />
|
|
<Input label="Channel number" value="5.1" error="Already in use" onChange={() => {}} />
|
|
<ProgressBar value={62} showLabel />
|
|
<Tabs
|
|
value="streaming"
|
|
onChange={onTab}
|
|
tabs={[{ value: 'streaming', label: 'Streaming' }]}
|
|
/>
|
|
<Tooltip label="Reset playout">
|
|
<button type="button">Reset</button>
|
|
</Tooltip>
|
|
</>
|
|
);
|
|
|
|
expect(screen.getByRole('button', { name: 'Saving' })).toBeDisabled();
|
|
fireEvent.click(screen.getByRole('switch', { name: 'Show disabled' }));
|
|
expect(onSwitch).toHaveBeenCalledWith(true);
|
|
expect(screen.getByRole('checkbox', { name: 'Select all' })).toHaveAttribute(
|
|
'aria-checked',
|
|
'mixed'
|
|
);
|
|
expect(screen.getByText('Already in use')).toBeInTheDocument();
|
|
expect(screen.getByText('62%')).toBeInTheDocument();
|
|
fireEvent.click(screen.getByRole('tab', { name: 'Streaming' }));
|
|
expect(onTab).toHaveBeenCalledWith('streaming');
|
|
fireEvent.mouseEnter(screen.getByText('Reset'));
|
|
expect(screen.getByRole('tooltip')).toHaveTextContent('Reset playout');
|
|
});
|
|
|
|
it('uses distinct semantic icons for warning and error toasts', () => {
|
|
const { container } = render(
|
|
<>
|
|
<Toast tone="warn" title="Check settings" />
|
|
<Toast tone="error" title="Save failed" />
|
|
</>
|
|
);
|
|
|
|
expect(container.querySelector('.lucide-triangle-alert')).toBeInTheDocument();
|
|
expect(container.querySelector('.lucide-circle-x')).toBeInTheDocument();
|
|
});
|
|
});
|