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(); expect(chip).toBeDefined();
chip?.click(); chip?.click();
await new Promise((r) => setTimeout(r, 30)); await vi.waitFor(() => expect(onToggleTrainingLabel).toHaveBeenCalled());
expect(onToggleTrainingLabel).toHaveBeenCalled();
}); });
it('renders blocks sorted by sortOrder', async () => { it('renders blocks sorted by sortOrder', async () => {
@@ -195,7 +194,7 @@ describe('TranscriptionEditView', () => {
expect(idxSecond).toBeLessThan(idxThird); 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, { const { rerender } = render(TranscriptionEditView, {
props: baseProps({ props: baseProps({
blocks: [ 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({ await rerender({
...baseProps({ ...baseProps({
blocks: [ blocks: [
@@ -217,9 +217,10 @@ describe('TranscriptionEditView', () => {
}) })
}); });
await new Promise((r) => setTimeout(r, 30)); await vi.waitFor(() => {
// No throw is the assertion — the $effect that syncs activeBlockId fires expect(document.body.textContent).toContain('First');
expect(true).toBe(true); expect(document.body.textContent).toContain('Second');
});
}); });
it('handleMarkAllReviewed calls onMarkAllReviewed when clicked', async () => { it('handleMarkAllReviewed calls onMarkAllReviewed when clicked', async () => {
@@ -235,8 +236,7 @@ describe('TranscriptionEditView', () => {
.getByRole('button', { name: /alle als fertig/i }) .getByRole('button', { name: /alle als fertig/i })
.element()) as HTMLButtonElement; .element()) as HTMLButtonElement;
btn.click(); btn.click();
await new Promise((r) => setTimeout(r, 30)); await vi.waitFor(() => expect(onMarkAllReviewed).toHaveBeenCalledOnce());
expect(onMarkAllReviewed).toHaveBeenCalledOnce();
}); });
it('renders all blocks with their text', async () => { it('renders all blocks with their text', async () => {