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>
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import { describe, it, expect, vi, afterEach } from 'vitest';
|
|
import { cleanup, render } from 'vitest-browser-svelte';
|
|
import { page, userEvent } from 'vitest/browser';
|
|
import BulkDropZone from './BulkDropZone.svelte';
|
|
|
|
afterEach(cleanup);
|
|
|
|
describe('BulkDropZone', () => {
|
|
it('file input has multiple attribute', async () => {
|
|
const { container } = render(BulkDropZone, { onFilesAdded: vi.fn() });
|
|
const input = container.querySelector('input[type="file"]');
|
|
expect(input).not.toBeNull();
|
|
expect(input?.hasAttribute('multiple')).toBe(true);
|
|
});
|
|
|
|
it('fires onFilesAdded with selected files when 3 files are picked via input', async () => {
|
|
const onFilesAdded = vi.fn();
|
|
render(BulkDropZone, { onFilesAdded });
|
|
|
|
const files = [
|
|
new File(['a'], 'a.pdf', { type: 'application/pdf' }),
|
|
new File(['b'], 'b.pdf', { type: 'application/pdf' }),
|
|
new File(['c'], 'c.pdf', { type: 'application/pdf' })
|
|
];
|
|
|
|
const input = page.getByRole('button', { name: /Dateien auswählen/i });
|
|
await userEvent.upload(input, files);
|
|
|
|
expect(onFilesAdded).toHaveBeenCalledOnce();
|
|
const received: File[] = onFilesAdded.mock.calls[0][0];
|
|
expect(received).toHaveLength(3);
|
|
expect(received.map((f) => f.name)).toEqual(['a.pdf', 'b.pdf', 'c.pdf']);
|
|
});
|
|
|
|
it('shows drop hint text', async () => {
|
|
render(BulkDropZone, { onFilesAdded: vi.fn() });
|
|
await expect.element(page.getByText(/Dateien ablegen/i)).toBeInTheDocument();
|
|
});
|
|
});
|