test: cover ScriptTypeSelect, SinglePersonHintBar, UserGroupsSection
ScriptTypeSelect: option list, placeholder disabled, value initialisation, disabled prop propagation. SinglePersonHintBar: hasDateFilter false vs true branches, sortDir DESC vs ASC label switch, year-range with only fromDate fallback. UserGroupsSection: per-group checkbox rendering, label visibility, selectedGroupIds preselection, empty groups list, default empty selection. 15 tests across three small primitives. Refs #496. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
43
frontend/src/lib/document/ScriptTypeSelect.svelte.test.ts
Normal file
43
frontend/src/lib/document/ScriptTypeSelect.svelte.test.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { describe, it, expect, afterEach } from 'vitest';
|
||||
import { cleanup, render } from 'vitest-browser-svelte';
|
||||
import { page } from 'vitest/browser';
|
||||
import ScriptTypeSelect from './ScriptTypeSelect.svelte';
|
||||
|
||||
afterEach(cleanup);
|
||||
|
||||
describe('ScriptTypeSelect', () => {
|
||||
it('renders the label and select', async () => {
|
||||
render(ScriptTypeSelect, { props: { value: '' } });
|
||||
|
||||
await expect.element(page.getByLabelText(/schrifttyp/i)).toBeVisible();
|
||||
});
|
||||
|
||||
it('renders all four option values', async () => {
|
||||
render(ScriptTypeSelect, { props: { value: '' } });
|
||||
|
||||
const options = document.querySelectorAll('option');
|
||||
const values = Array.from(options).map((o) => (o as HTMLOptionElement).value);
|
||||
expect(values).toEqual(['', 'TYPEWRITER', 'HANDWRITING_LATIN', 'HANDWRITING_KURRENT']);
|
||||
});
|
||||
|
||||
it('marks the placeholder option as disabled', async () => {
|
||||
render(ScriptTypeSelect, { props: { value: '' } });
|
||||
|
||||
const placeholder = document.querySelector('option[value=""]') as HTMLOptionElement;
|
||||
expect(placeholder.disabled).toBe(true);
|
||||
});
|
||||
|
||||
it('initialises the select with the supplied value', async () => {
|
||||
render(ScriptTypeSelect, { props: { value: 'TYPEWRITER' } });
|
||||
|
||||
const select = (await page.getByRole('combobox').element()) as HTMLSelectElement;
|
||||
expect(select.value).toBe('TYPEWRITER');
|
||||
});
|
||||
|
||||
it('disables the select when the disabled prop is true', async () => {
|
||||
render(ScriptTypeSelect, { props: { value: '', disabled: true } });
|
||||
|
||||
const select = (await page.getByRole('combobox').element()) as HTMLSelectElement;
|
||||
expect(select.disabled).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user