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
Showing only changes of commit 1b9cefff86 - Show all commits

View File

@@ -172,8 +172,7 @@ describe('TranscriptionEditView', () => {
expect(chip).toBeDefined();
chip?.click();
await new Promise((r) => setTimeout(r, 30));
expect(onToggleTrainingLabel).toHaveBeenCalled();
await vi.waitFor(() => expect(onToggleTrainingLabel).toHaveBeenCalled());
});
it('renders blocks sorted by sortOrder', async () => {
@@ -195,7 +194,7 @@ describe('TranscriptionEditView', () => {
expect(idxSecond).toBeLessThan(idxThird);
});
it('reactivates the active block when activeAnnotationId changes to one with a matching annotation', async () => {
it('renders both blocks with their text after rerender with a new activeAnnotationId', async () => {
const { rerender } = render(TranscriptionEditView, {
props: baseProps({
blocks: [
@@ -206,7 +205,8 @@ describe('TranscriptionEditView', () => {
})
});
// re-render with activeAnnotationId set to ann-2 — block b2 should become active
// re-render with activeAnnotationId set to ann-2 — the activeBlockId $effect re-runs
// and both blocks must still be present in the rendered list.
await rerender({
...baseProps({
blocks: [
@@ -217,9 +217,10 @@ describe('TranscriptionEditView', () => {
})
});
await new Promise((r) => setTimeout(r, 30));
// No throw is the assertion — the $effect that syncs activeBlockId fires
expect(true).toBe(true);
await vi.waitFor(() => {
expect(document.body.textContent).toContain('First');
expect(document.body.textContent).toContain('Second');
});
});
it('handleMarkAllReviewed calls onMarkAllReviewed when clicked', async () => {
@@ -235,8 +236,7 @@ describe('TranscriptionEditView', () => {
.getByRole('button', { name: /alle als fertig/i })
.element()) as HTMLButtonElement;
btn.click();
await new Promise((r) => setTimeout(r, 30));
expect(onMarkAllReviewed).toHaveBeenCalledOnce();
await vi.waitFor(() => expect(onMarkAllReviewed).toHaveBeenCalledOnce());
});
it('renders all blocks with their text', async () => {