From a65a55448ef03324079a4c9b2ceee9316f9e849e Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 10 Jun 2026 08:37:31 +0200 Subject: [PATCH] test: align unit stubs and fixtures with the review-round changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI caught three spots the targeted local runs missed: the relevance-path unit tests still stubbed findAllById (the path now calls findByIdIn — the batchMetadata stubs legitimately keep findAllById), the second GeschichtenCard test file still expected the removed email fallback, and the AND/OR-toggle describe lacked the wait-for-slide-transition guard its sibling describe documents — the flake that failed run 2208. Co-Authored-By: Claude Fable 5 --- .../raddatz/familienarchiv/document/DocumentService.java | 2 +- .../familienarchiv/document/DocumentServiceSortTest.java | 8 ++++---- .../familienarchiv/document/DocumentServiceTest.java | 4 ++-- .../src/lib/geschichte/GeschichtenCard.svelte.test.ts | 7 +++---- frontend/src/routes/SearchFilterBar.svelte.spec.ts | 4 ++++ 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/backend/src/main/java/org/raddatz/familienarchiv/document/DocumentService.java b/backend/src/main/java/org/raddatz/familienarchiv/document/DocumentService.java index 3c9814ec..011ab3b1 100644 --- a/backend/src/main/java/org/raddatz/familienarchiv/document/DocumentService.java +++ b/backend/src/main/java/org/raddatz/familienarchiv/document/DocumentService.java @@ -851,7 +851,7 @@ public class DocumentService { FtsPage ftsPage = toFtsPage(documentRepository.findFtsPageRaw(text, offset, limit)); if (ftsPage.hits().isEmpty()) return DocumentSearchResult.of(List.of()); - // Preserve ts_rank order from SQL across the JPA findAllById call. + // Preserve ts_rank order from SQL across the JPA findByIdIn call. Map rankMap = new HashMap<>(); List pageIds = new ArrayList<>(); for (int i = 0; i < ftsPage.hits().size(); i++) { diff --git a/backend/src/test/java/org/raddatz/familienarchiv/document/DocumentServiceSortTest.java b/backend/src/test/java/org/raddatz/familienarchiv/document/DocumentServiceSortTest.java index bbc058ac..e432c71b 100644 --- a/backend/src/test/java/org/raddatz/familienarchiv/document/DocumentServiceSortTest.java +++ b/backend/src/test/java/org/raddatz/familienarchiv/document/DocumentServiceSortTest.java @@ -81,7 +81,7 @@ class DocumentServiceSortTest { UUID id1 = UUID.randomUUID(); List ftsRows = ftsRows(id1, 0.5d, 1L); when(documentRepository.findFtsPageRaw(anyString(), anyInt(), anyInt())).thenReturn(ftsRows); - when(documentRepository.findAllById(any())) + when(documentRepository.findByIdIn(any())) .thenReturn(List.of(doc(id1))); documentService.searchDocuments( @@ -101,7 +101,7 @@ class DocumentServiceSortTest { ftsRows.add(new Object[]{id1, 0.8d, 2L}); ftsRows.add(new Object[]{id2, 0.3d, 2L}); when(documentRepository.findFtsPageRaw(anyString(), anyInt(), anyInt())).thenReturn(ftsRows); - when(documentRepository.findAllById(any())).thenReturn(List.of(doc(id2), doc(id1))); // unordered from JPA + when(documentRepository.findByIdIn(any())).thenReturn(List.of(doc(id2), doc(id1))); // unordered from JPA DocumentSearchResult result = documentService.searchDocuments( new SearchFilters("Brief", null, null, null, null, null, null, null, null, false), @@ -119,7 +119,7 @@ class DocumentServiceSortTest { ftsRows.add(new Object[]{id1, 0.8d, 2L}); ftsRows.add(new Object[]{id2, 0.3d, 2L}); when(documentRepository.findFtsPageRaw(anyString(), anyInt(), anyInt())).thenReturn(ftsRows); - when(documentRepository.findAllById(any())).thenReturn(List.of(doc(id2), doc(id1))); + when(documentRepository.findByIdIn(any())).thenReturn(List.of(doc(id2), doc(id1))); DocumentSearchResult result = documentService.searchDocuments( new SearchFilters("Brief", null, null, null, null, null, null, null, null, false), @@ -153,7 +153,7 @@ class DocumentServiceSortTest { List ftsRows = new ArrayList<>(); ftsRows.add(new Object[]{stringId, 0.5d, 1L}); when(documentRepository.findFtsPageRaw(anyString(), anyInt(), anyInt())).thenReturn(ftsRows); - when(documentRepository.findAllById(any())).thenReturn(List.of(doc(uuidId))); + when(documentRepository.findByIdIn(any())).thenReturn(List.of(doc(uuidId))); DocumentSearchResult result = documentService.searchDocuments( new SearchFilters("Brief", null, null, null, null, null, null, null, null, false), diff --git a/backend/src/test/java/org/raddatz/familienarchiv/document/DocumentServiceTest.java b/backend/src/test/java/org/raddatz/familienarchiv/document/DocumentServiceTest.java index 023b2003..65fbb21f 100644 --- a/backend/src/test/java/org/raddatz/familienarchiv/document/DocumentServiceTest.java +++ b/backend/src/test/java/org/raddatz/familienarchiv/document/DocumentServiceTest.java @@ -2166,7 +2166,7 @@ class DocumentServiceTest { List ftsRows = new java.util.ArrayList<>(); ftsRows.add(new Object[]{docId, 0.5d, 1L}); when(documentRepository.findFtsPageRaw(anyString(), anyInt(), anyInt())).thenReturn(ftsRows); - when(documentRepository.findAllById(any())).thenReturn(List.of(doc)); + when(documentRepository.findByIdIn(any())).thenReturn(List.of(doc)); when(documentRepository.findEnrichmentData(any(), eq("Brief"))).thenReturn(rows); DocumentSearchResult result = documentService.searchDocuments( @@ -2202,7 +2202,7 @@ class DocumentServiceTest { List snippetFtsRows = new java.util.ArrayList<>(); snippetFtsRows.add(new Object[]{docId, 0.5d, 1L}); when(documentRepository.findFtsPageRaw(anyString(), anyInt(), anyInt())).thenReturn(snippetFtsRows); - when(documentRepository.findAllById(any())).thenReturn(List.of(doc)); + when(documentRepository.findByIdIn(any())).thenReturn(List.of(doc)); when(documentRepository.findEnrichmentData(any(), eq("Brief"))).thenReturn(rows); DocumentSearchResult result = documentService.searchDocuments( diff --git a/frontend/src/lib/geschichte/GeschichtenCard.svelte.test.ts b/frontend/src/lib/geschichte/GeschichtenCard.svelte.test.ts index 9b46a7d8..34611cd3 100644 --- a/frontend/src/lib/geschichte/GeschichtenCard.svelte.test.ts +++ b/frontend/src/lib/geschichte/GeschichtenCard.svelte.test.ts @@ -17,7 +17,6 @@ const makeGeschichte = (overrides: Record = {}): GeschichteSumm type: 'STORY' as const, publishedAt: '2026-04-15T10:00:00Z', author: { - email: 'a@b', firstName: 'Anna', lastName: 'Schmidt' }, @@ -103,17 +102,17 @@ describe('GeschichtenCard', () => { await expect.element(page.getByText(/Anna Schmidt/)).toBeVisible(); }); - it('falls back to author email when no name', async () => { + it('falls back to [Unbekannt] when no name', async () => { render(GeschichtenCard, { props: baseProps({ geschichten: [ makeGeschichte({ - author: { firstName: undefined, lastName: undefined, email: 'fallback@x' } + author: { firstName: undefined, lastName: undefined } }) ] }) }); - await expect.element(page.getByText(/fallback@x/)).toBeVisible(); + await expect.element(page.getByText('[Unbekannt]')).toBeVisible(); }); }); diff --git a/frontend/src/routes/SearchFilterBar.svelte.spec.ts b/frontend/src/routes/SearchFilterBar.svelte.spec.ts index 723e5858..db0e1a8e 100644 --- a/frontend/src/routes/SearchFilterBar.svelte.spec.ts +++ b/frontend/src/routes/SearchFilterBar.svelte.spec.ts @@ -47,6 +47,10 @@ describe('SearchFilterBar – AND/OR tag operator toggle', () => { async function openAdvanced() { const filterBtn = page.getByRole('button', { name: 'Filter', exact: true }); await filterBtn.click(); + // Wait for slide transition to finish before interacting with contents — + // clicking during the transition triggers track_reactivity_loss in Svelte 5 async.js + // (same guard as the undated-only describe below; this block flaked in CI run 2208). + await expect.element(page.getByTestId('undated-only-toggle')).toBeVisible(); } it('hides AND/OR toggle when fewer than 2 tags are selected', async () => {