From 151d6aa03f8f4aa0664190367aafbd3decb0c0fb Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 27 May 2026 11:09:21 +0200 Subject: [PATCH] test(importing): clean up committed rows after CanonicalImportIntegrationTest The canonical importer commits through its own transactions, so this test cannot use @Transactional rollback for isolation. Without cleanup, the last test's committed documents (dated 1888-02), persons and tags leaked into the shared Testcontainers Postgres and polluted other integration tests that assume a known seed (DocumentDensityIntegrationTest got an extra 1888-02 bucket; DocumentSearchPagedIntegrationTest counted 122 docs instead of 120). Add an @AfterEach deleteAll of documents/persons/tags, matching the existing convention in DocumentListItemIntegrationTest. Refs #669 --- .../CanonicalImportIntegrationTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/backend/src/test/java/org/raddatz/familienarchiv/importing/CanonicalImportIntegrationTest.java b/backend/src/test/java/org/raddatz/familienarchiv/importing/CanonicalImportIntegrationTest.java index f3cc936a..bd2b8d8f 100644 --- a/backend/src/test/java/org/raddatz/familienarchiv/importing/CanonicalImportIntegrationTest.java +++ b/backend/src/test/java/org/raddatz/familienarchiv/importing/CanonicalImportIntegrationTest.java @@ -3,6 +3,7 @@ package org.raddatz.familienarchiv.importing; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.raddatz.familienarchiv.PostgresContainerConfig; @@ -59,6 +60,22 @@ class CanonicalImportIntegrationTest { ReflectionTestUtils.setField(orchestrator, "canonicalDir", artifactDir.toString()); } + /** + * The import commits through its own transactions (the orchestrator is not transactional), + * so this test cannot rely on {@code @Transactional} rollback for isolation. Delete the + * committed rows after each test — otherwise the last test's documents (dated 1888-02) and + * persons/tags leak into the shared Testcontainers Postgres and pollute other integration + * tests that assume a known seed (e.g. DocumentDensityIntegrationTest, + * DocumentSearchPagedIntegrationTest). Mirrors the @AfterEach deleteAll convention used by + * DocumentListItemIntegrationTest. + */ + @AfterEach + void cleanup() { + documentRepository.deleteAll(); + personRepository.deleteAll(); + tagRepository.deleteAll(); + } + @Test void reimport_isIdempotent_noDuplicatePersonsTagsOrDocuments() { orchestrator.runImport();