test(coverage): drive browser tests to 80% on all metrics (#496) #505

Merged
marcel merged 189 commits from feat/issue-496-browser-coverage-tests into main 2026-05-11 21:50:39 +02:00
4 changed files with 114 additions and 0 deletions
Showing only changes of commit acb52c3929 - Show all commits

View File

@@ -0,0 +1,29 @@
import { describe, it, expect, afterEach } from 'vitest';
import { cleanup, render } from 'vitest-browser-svelte';
import TimelineYAxis from './TimelineYAxis.svelte';
afterEach(cleanup);
describe('TimelineYAxis', () => {
it('renders the maxCount and 0 labels', async () => {
render(TimelineYAxis, { props: { maxCount: 42, barAreaHeight: 100 } });
const axis = document.querySelector('[data-testid="timeline-y-axis"]') as HTMLElement;
expect(axis.textContent).toContain('42');
expect(axis.textContent).toContain('0');
});
it('applies the supplied barAreaHeight as inline style', async () => {
render(TimelineYAxis, { props: { maxCount: 10, barAreaHeight: 250 } });
const axis = document.querySelector('[data-testid="timeline-y-axis"]') as HTMLElement;
expect(axis.style.height).toBe('250px');
});
it('renders zero count without crashing', async () => {
render(TimelineYAxis, { props: { maxCount: 0, barAreaHeight: 100 } });
const axis = document.querySelector('[data-testid="timeline-y-axis"]') as HTMLElement;
expect(axis).not.toBeNull();
});
});

View File

@@ -0,0 +1,36 @@
import { describe, it, expect, afterEach } from 'vitest';
import { cleanup, render } from 'vitest-browser-svelte';
import { page } from 'vitest/browser';
import TranscriptionSection from './TranscriptionSection.svelte';
afterEach(cleanup);
describe('TranscriptionSection', () => {
it('renders the section heading and textarea', async () => {
render(TranscriptionSection, { props: {} });
await expect.element(page.getByRole('heading', { name: /transkription/i })).toBeVisible();
const textarea = document.querySelector(
'textarea[name="transcription"]'
) as HTMLTextAreaElement;
expect(textarea).not.toBeNull();
});
it('hydrates the textarea with the initial transcription value', async () => {
render(TranscriptionSection, { props: { initialTranscription: 'Hello World' } });
const textarea = document.querySelector(
'textarea[name="transcription"]'
) as HTMLTextAreaElement;
expect(textarea.value).toBe('Hello World');
});
it('renders an empty textarea by default', async () => {
render(TranscriptionSection, { props: {} });
const textarea = document.querySelector(
'textarea[name="transcription"]'
) as HTMLTextAreaElement;
expect(textarea.value).toBe('');
});
});

View File

@@ -0,0 +1,21 @@
import { describe, it, expect, afterEach } from 'vitest';
import { cleanup, render } from 'vitest-browser-svelte';
import { page } from 'vitest/browser';
import RelationshipPill from './RelationshipPill.svelte';
afterEach(cleanup);
describe('RelationshipPill', () => {
it('renders the supplied label', async () => {
render(RelationshipPill, { props: { label: 'Vater' } });
await expect.element(page.getByText('Vater')).toBeVisible();
});
it('renders an empty string label without crashing', async () => {
render(RelationshipPill, { props: { label: '' } });
const span = document.querySelector('span');
expect(span).not.toBeNull();
});
});

View File

@@ -0,0 +1,28 @@
import { describe, it, expect, afterEach } from 'vitest';
import { cleanup, render } from 'vitest-browser-svelte';
import OverflowPillDisplay from './OverflowPillDisplay.svelte';
afterEach(cleanup);
describe('OverflowPillDisplay', () => {
it('renders the +N count', async () => {
render(OverflowPillDisplay, { props: { extraCount: 3 } });
const span = document.querySelector('span') as HTMLElement;
expect(span.textContent?.trim()).toBe('+3');
});
it('renders +0 when extraCount is 0', async () => {
render(OverflowPillDisplay, { props: { extraCount: 0 } });
const span = document.querySelector('span') as HTMLElement;
expect(span.textContent?.trim()).toBe('+0');
});
it('marks the pill as aria-hidden (decorative)', async () => {
render(OverflowPillDisplay, { props: { extraCount: 5 } });
const span = document.querySelector('span') as HTMLElement;
expect(span.getAttribute('aria-hidden')).toBe('true');
});
});