From 11a35f2952ed5475a38c2c242ca512e40683a313 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 12 Apr 2026 14:55:34 +0200 Subject: [PATCH] fix(tests): resolve all 4 pre-existing test failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CommentThread: add missing empty-state paragraph using comment_empty_hint i18n key (key existed but was never rendered in the template) - TranscriptionBlock: add selectedQuote hint using transcription_block_quote_hint i18n key (key existed but was never rendered); fix test to use native DOM el.focus()/setSelectionRange()/dispatchEvent instead of locator.selectText() which is not available in this vitest-browser version - TranscriptionEditView: fix test to use native el.dispatchEvent(FocusEvent) instead of locator.blur() which is not available - Conversations: fix test expected text from stale "Korrespondenz durchsuchen" to match current conv_empty_heading() = "Wessen Briefe möchten Sie lesen?" All 687 tests now pass. Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/lib/components/CommentThread.svelte | 4 +++- .../src/lib/components/TranscriptionBlock.svelte | 4 ++++ .../lib/components/TranscriptionBlock.svelte.spec.ts | 12 ++++++------ .../components/TranscriptionEditView.svelte.spec.ts | 5 +++-- .../src/routes/conversations/page.svelte.spec.ts | 2 +- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/frontend/src/lib/components/CommentThread.svelte b/frontend/src/lib/components/CommentThread.svelte index 73858028..740825b3 100644 --- a/frontend/src/lib/components/CommentThread.svelte +++ b/frontend/src/lib/components/CommentThread.svelte @@ -199,7 +199,9 @@ onMount(() => { }); -{#if flatMessages.length > 0} +{#if flatMessages.length === 0} +

{m.comment_empty_hint()}

+{:else}
+ {#if selectedQuote} +

{m.transcription_block_quote_hint()}

+ {/if} +
diff --git a/frontend/src/lib/components/TranscriptionBlock.svelte.spec.ts b/frontend/src/lib/components/TranscriptionBlock.svelte.spec.ts index 1fee54b5..c05a8c88 100644 --- a/frontend/src/lib/components/TranscriptionBlock.svelte.spec.ts +++ b/frontend/src/lib/components/TranscriptionBlock.svelte.spec.ts @@ -228,12 +228,12 @@ describe('TranscriptionBlock — delete confirmation', () => { describe('TranscriptionBlock — quote selection', () => { it('shows quote hint after text is selected in textarea', async () => { renderBlock({ text: 'Breslau, den 12. August' }); - const textarea = page.getByRole('textbox'); - // Select all text via keyboard shortcut to trigger mouseup with selection - await textarea.click(); - await textarea.selectText(); - // Fire mouseup to trigger the selection handler - await textarea.dispatchEvent('mouseup'); + await page.getByRole('textbox').click(); + // Select text and fire mouseup via native DOM — locator.selectText/dispatchEvent not available + const el = document.querySelector('textarea') as HTMLTextAreaElement; + el.focus(); + el.setSelectionRange(0, el.value.length); + el.dispatchEvent(new MouseEvent('mouseup', { bubbles: true })); await expect.element(page.getByText(/Zitat/)).toBeInTheDocument(); }); }); diff --git a/frontend/src/lib/components/TranscriptionEditView.svelte.spec.ts b/frontend/src/lib/components/TranscriptionEditView.svelte.spec.ts index d537de83..c7fd211e 100644 --- a/frontend/src/lib/components/TranscriptionEditView.svelte.spec.ts +++ b/frontend/src/lib/components/TranscriptionEditView.svelte.spec.ts @@ -193,8 +193,9 @@ describe('TranscriptionEditView — flush on blur', () => { const textarea = page.getByRole('textbox').first(); await textarea.fill('Blur text'); - // Blur before 1500ms debounce fires - await textarea.blur(); + // Blur before 1500ms debounce fires — locator.blur() not available, use native DOM + const el = document.querySelector('textarea') as HTMLTextAreaElement; + el.dispatchEvent(new FocusEvent('blur', { bubbles: true })); await vi.runAllTimersAsync(); expect(onSaveBlock).toHaveBeenCalledWith('b1', 'Blur text'); diff --git a/frontend/src/routes/conversations/page.svelte.spec.ts b/frontend/src/routes/conversations/page.svelte.spec.ts index ebc7c4b3..2433c958 100644 --- a/frontend/src/routes/conversations/page.svelte.spec.ts +++ b/frontend/src/routes/conversations/page.svelte.spec.ts @@ -50,7 +50,7 @@ const withDocs = { describe('Conversations page – empty state', () => { it('shows the empty-state heading when no persons are selected', async () => { render(Page, { data: baseData }); - await expect.element(page.getByText(/Korrespondenz durchsuchen/i)).toBeInTheDocument(); + await expect.element(page.getByText(/Wessen Briefe möchten Sie lesen/i)).toBeInTheDocument(); }); it('hides the swap button when no persons are selected', async () => {