Some checks failed
CI / Unit & Component Tests (pull_request) Failing after 3m54s
CI / OCR Service Tests (pull_request) Successful in 33s
CI / Backend Unit Tests (pull_request) Failing after 3m13s
CI / Unit & Component Tests (push) Failing after 3m48s
CI / OCR Service Tests (push) Successful in 39s
CI / Backend Unit Tests (push) Failing after 3m24s
Fixes all remaining failing tests in the browser project. Root cause in
every case: Playwright CDP-based clicks/keyboard events do not reliably
trigger Svelte 5 onclick/onkeydown handlers. Pattern applied throughout:
- Buttons / result items: native `.element().click()` or
`dispatchEvent(new MouseEvent('click', { bubbles: true }))`
- Keyboard events: `dispatchEvent(new KeyboardEvent('keydown', { key }))`
on the target DOM element
- TipTap selection: `element.focus()` + Selection API +
`document.dispatchEvent(new Event('selectionchange'))`
- ProseMirror focus for onFocus: `dispatchEvent(new FocusEvent('focus'))`
Also fixes pre-existing content/logic issues found during analysis:
- ChronikErrorCard, BulkDropZone, CorrespondenzHero: stale i18n strings
and wrong ARIA role (combobox not textbox)
- RichtlinienRuleCard: beide beispielInput + beispielOutput required for
arrow to render; querySelectorAll to get last code element
- admin/system/page: vi.unstubAllGlobals() in afterEach; strict-mode
heading selector; per-call mockResolvedValueOnce for dual-card page
- DocumentList: add total prop + result count paragraph (test relied on it)
- PersonTypeahead keyboard navigation: pressKey() helper with native
KeyboardEvent dispatch replaces userEvent.keyboard()
- PersonMultiSelect: native element clicks for result selection and
chip removal; keydown dispatch on result div for Enter key test
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
55 lines
2.1 KiB
TypeScript
55 lines
2.1 KiB
TypeScript
import { describe, it, expect, afterEach } from 'vitest';
|
|
import { cleanup, render } from 'vitest-browser-svelte';
|
|
import { page } from 'vitest/browser';
|
|
import RichtlinienRuleCard from './RichtlinienRuleCard.svelte';
|
|
|
|
afterEach(cleanup);
|
|
|
|
const defaultProps = {
|
|
icon: '✍',
|
|
title: 'Unleserliche Wörter',
|
|
body: 'Schreiben Sie [unleserlich].',
|
|
// beispielInput is required for the → arrow to render (component: {#if beispielInput !== undefined})
|
|
beispielInput: '[Original]',
|
|
beispielOutput: '[unleserlich]'
|
|
};
|
|
|
|
describe('RichtlinienRuleCard', () => {
|
|
it('renders an h3 with the title', async () => {
|
|
render(RichtlinienRuleCard, { props: defaultProps });
|
|
await expect
|
|
.element(page.getByRole('heading', { level: 3 }))
|
|
.toHaveTextContent('Unleserliche Wörter');
|
|
});
|
|
|
|
it('renders the body text', async () => {
|
|
render(RichtlinienRuleCard, { props: defaultProps });
|
|
await expect.element(page.getByText('Schreiben Sie [unleserlich].')).toBeInTheDocument();
|
|
});
|
|
|
|
it('renders icon in a span with aria-hidden="true"', async () => {
|
|
render(RichtlinienRuleCard, { props: defaultProps });
|
|
const iconSpan = document.querySelector('span[aria-hidden="true"]');
|
|
expect(iconSpan).not.toBeNull();
|
|
expect(iconSpan!.textContent).toContain('✍');
|
|
});
|
|
|
|
it('renders beispielOutput in monospace with → arrow', async () => {
|
|
render(RichtlinienRuleCard, { props: defaultProps });
|
|
// With both beispielInput and beispielOutput, the component renders two code elements:
|
|
// [Input] → [Output]. querySelectorAll gets both; last one is the output.
|
|
const codes = document.querySelectorAll('code, [class*="font-mono"]');
|
|
expect(codes.length).toBeGreaterThanOrEqual(1);
|
|
const outputCode = codes[codes.length - 1];
|
|
expect(outputCode.textContent).toContain('[unleserlich]');
|
|
await expect.element(page.getByText(/→/)).toBeInTheDocument();
|
|
});
|
|
|
|
it('does not render beispiel section when beispielOutput is absent', async () => {
|
|
render(RichtlinienRuleCard, {
|
|
props: { icon: '✍', title: 'Test', body: 'Body' }
|
|
});
|
|
expect(document.querySelector('code, [class*="font-mono"]')).toBeNull();
|
|
});
|
|
});
|