From 908dd89ea5fbe8821e5c3d411d9cf9b3d98d5228 Mon Sep 17 00:00:00 2001 From: Leonie Koch Date: Wed, 11 Dec 2024 11:55:26 +0100 Subject: [PATCH] Seperate reference list in docunit view RISDEV-5670 --- .../DocumentationUnitTransformer.java | 18 +- .../ris/caselaw/domain/DocumentationUnit.java | 1 + .../DocumentationUnitTransformerTest.java | 3 +- ...LegalPeriodicalEditionIntegrationTest.java | 119 ++++++----- .../tests/ReferenceIntegrationTest.java | 8 +- .../DocumentUnitLiteratureReferenceInput.vue | 195 ++++++++++++++++++ .../components/DocumentUnitReferenceInput.vue | 96 +-------- .../src/components/DocumentUnitReferences.vue | 22 +- .../preview/DocumentUnitPreview.vue | 4 + .../preview/PreviewLiteratureReferences.vue | 25 +++ .../components/preview/PreviewReferences.vue | 26 +-- frontend/src/domain/documentUnit.ts | 6 + .../e2e/caselaw/categories/references.spec.ts | 99 +++------ frontend/test/e2e/caselaw/e2e-utils.ts | 2 +- 14 files changed, 378 insertions(+), 246 deletions(-) create mode 100644 frontend/src/components/DocumentUnitLiteratureReferenceInput.vue create mode 100644 frontend/src/components/preview/PreviewLiteratureReferences.vue diff --git a/backend/src/main/java/de/bund/digitalservice/ris/caselaw/adapter/transformer/DocumentationUnitTransformer.java b/backend/src/main/java/de/bund/digitalservice/ris/caselaw/adapter/transformer/DocumentationUnitTransformer.java index eaeb0d81dd..04a4d8573d 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/caselaw/adapter/transformer/DocumentationUnitTransformer.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/caselaw/adapter/transformer/DocumentationUnitTransformer.java @@ -29,7 +29,6 @@ import de.bund.digitalservice.ris.caselaw.domain.ManagementData; import de.bund.digitalservice.ris.caselaw.domain.NormReference; import de.bund.digitalservice.ris.caselaw.domain.PreviousDecision; -import de.bund.digitalservice.ris.caselaw.domain.ReferenceType; import de.bund.digitalservice.ris.caselaw.domain.ShortTexts; import de.bund.digitalservice.ris.caselaw.domain.SingleNorm; import de.bund.digitalservice.ris.caselaw.domain.StringUtils; @@ -167,7 +166,6 @@ private static void addReferences( updatedDomainObject.references() == null ? Collections.emptyList() : updatedDomainObject.references().stream() - .filter(reference -> reference.referenceType() == ReferenceType.CASELAW) .map(ReferenceTransformer::transformToDTO) .map( referenceDTO -> { @@ -183,10 +181,9 @@ private static void addDependentLiteratureCitations( DocumentationUnit updatedDomainObject, DocumentationUnitDTOBuilder builder) { AtomicInteger i = new AtomicInteger(1); builder.dependentLiteratureCitations( - updatedDomainObject.references() == null + updatedDomainObject.literatureReferences() == null ? Collections.emptyList() - : updatedDomainObject.references().stream() - .filter(reference -> reference.referenceType() == ReferenceType.LITERATURE) + : updatedDomainObject.literatureReferences().stream() .map(DependentLiteratureTransformer::transformToDTO) .map( referenceDTO -> { @@ -761,6 +758,7 @@ public static DocumentationUnit transformToDomain(DocumentationUnitDTO documenta addStatusToDomain(documentationUnitDTO, builder); addReferencesToDomain(documentationUnitDTO, builder); + addLiteratureReferencesToDomain(documentationUnitDTO, builder); return builder.build(); } @@ -780,10 +778,18 @@ private static void addReferencesToDomain( .map(ReferenceTransformer::transformToDomain) .toList()); } + } + + private static void addLiteratureReferencesToDomain( + DocumentationUnitDTO documentationUnitDTO, + DocumentationUnit.DocumentationUnitBuilder builder) { + + builder.literatureReferences(new ArrayList<>()); + if (documentationUnitDTO.getDependentLiteratureCitations() != null) { builder .build() - .references() + .literatureReferences() .addAll( documentationUnitDTO.getDependentLiteratureCitations().stream() .map(DependentLiteratureTransformer::transformToDomain) diff --git a/backend/src/main/java/de/bund/digitalservice/ris/caselaw/domain/DocumentationUnit.java b/backend/src/main/java/de/bund/digitalservice/ris/caselaw/domain/DocumentationUnit.java index 3cdc365d9b..ae2f87f1b2 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/caselaw/domain/DocumentationUnit.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/caselaw/domain/DocumentationUnit.java @@ -43,5 +43,6 @@ public record DocumentationUnit( String note, ContentRelatedIndexing contentRelatedIndexing, List references, + List literatureReferences, boolean isEditable, boolean isDeletable) {} diff --git a/backend/src/test/java/de/bund/digitalservice/ris/caselaw/adapter/transformer/DocumentationUnitTransformerTest.java b/backend/src/test/java/de/bund/digitalservice/ris/caselaw/adapter/transformer/DocumentationUnitTransformerTest.java index d150e132fb..e3d545bfd5 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/caselaw/adapter/transformer/DocumentationUnitTransformerTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/caselaw/adapter/transformer/DocumentationUnitTransformerTest.java @@ -1349,7 +1349,8 @@ private DocumentationUnit.DocumentationUnitBuilder generateSimpleDocumentationUn .collectiveAgreements(Collections.emptyList()) .hasLegislativeMandate(false) .build()) - .references(Collections.emptyList()); + .references(Collections.emptyList()) + .literatureReferences(Collections.emptyList()); } private CoreDataBuilder generateSimpleCoreDataBuilder() { diff --git a/backend/src/test/java/de/bund/digitalservice/ris/caselaw/integration/tests/LegalPeriodicalEditionIntegrationTest.java b/backend/src/test/java/de/bund/digitalservice/ris/caselaw/integration/tests/LegalPeriodicalEditionIntegrationTest.java index 9b7b994634..34e74f1003 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/caselaw/integration/tests/LegalPeriodicalEditionIntegrationTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/caselaw/integration/tests/LegalPeriodicalEditionIntegrationTest.java @@ -276,7 +276,7 @@ void testGetEdition_withMixedReferencesAndLiteratureCitationsFromDocUnitAndEditi DependentLiteratureCitationDTO.builder() .id(UUID.randomUUID()) .rank(1) - .citation("1") + .citation("Literature Reference Citation from Docunit") .legalPeriodicalRawValue("A") .author("author 1") .type(DependentLiteratureCitationType.PASSIVE) @@ -293,9 +293,9 @@ void testGetEdition_withMixedReferencesAndLiteratureCitationsFromDocUnitAndEditi .build(), DependentLiteratureCitationDTO.builder() .id(existingLiteratureCitationId) - .rank(3) - .citation("3 - original literature citation") - .author("author 3") + .rank(2) + .citation("Original Literature Reference Citation from Docunit") + .author("author 2") .type(DependentLiteratureCitationType.PASSIVE) .documentType( DocumentTypeDTO.builder() @@ -313,8 +313,8 @@ void testGetEdition_withMixedReferencesAndLiteratureCitationsFromDocUnitAndEditi List.of( ReferenceDTO.builder() .id(UUID.randomUUID()) - .rank(2) - .citation("2") + .rank(1) + .citation("Caselaw Reference Citation from Docunit") .legalPeriodicalRawValue("A") .documentationUnit( DocumentationUnitDTO.builder() @@ -324,9 +324,9 @@ void testGetEdition_withMixedReferencesAndLiteratureCitationsFromDocUnitAndEditi .build(), ReferenceDTO.builder() .id(existingReferenceId) - .citation("Original Citation") + .citation("Original Caselaw Reference Citation from Docunit") .legalPeriodicalRawValue("B") - .rank(4) + .rank(2) .documentationUnit( DocumentationUnitDTO.builder() .id(docUnit.getId()) @@ -336,6 +336,7 @@ void testGetEdition_withMixedReferencesAndLiteratureCitationsFromDocUnitAndEditi .build()); UUID newReferenceId = UUID.randomUUID(); + UUID newLiteratureReferenceId = UUID.randomUUID(); UUID editionId = UUID.randomUUID(); RelatedDocumentationUnit relatedDocUnit = @@ -356,14 +357,14 @@ void testGetEdition_withMixedReferencesAndLiteratureCitationsFromDocUnitAndEditi Reference.builder() .id(existingReferenceId) .referenceType(ReferenceType.CASELAW) - .citation("1 - Updated Citation") + .citation("Updated Caselaw Reference Citation from Edition") .legalPeriodicalRawValue("B") .documentationUnit(relatedDocUnit) .build(), Reference.builder() .id(existingLiteratureCitationId) .referenceType(ReferenceType.LITERATURE) - .citation("2 - Updated Literature Citation") + .citation("Updated Literature Reference Citation from Edition") .author("author 2") .documentType(EBS) .legalPeriodicalRawValue("B") @@ -372,15 +373,15 @@ void testGetEdition_withMixedReferencesAndLiteratureCitationsFromDocUnitAndEditi Reference.builder() .id(newReferenceId) .referenceType(ReferenceType.CASELAW) - .citation("3 - New Reference") + .citation("New Caselaw Reference Citation from Edition") .legalPeriodicalRawValue("D") .documentationUnit(relatedDocUnit) .build(), Reference.builder() - .id(UUID.randomUUID()) + .id(newLiteratureReferenceId) .referenceType(ReferenceType.LITERATURE) - .citation("4 - New Literature Citation") - .author("author 4") + .citation("New Literature Reference Citation from Edition") + .author("author 3") .documentType(EAN) .legalPeriodicalRawValue("C") .documentationUnit(relatedDocUnit) @@ -402,26 +403,47 @@ void testGetEdition_withMixedReferencesAndLiteratureCitationsFromDocUnitAndEditi Assertions.assertEquals("2024 Sonderheft 1", edition.name()); List references = editionResponse.references(); Assertions.assertEquals(4, references.size()); - Assertions.assertEquals("1 - Updated Citation", references.get(0).citation()); - Assertions.assertEquals("2 - Updated Literature Citation", references.get(1).citation()); - Assertions.assertEquals("3 - New Reference", references.get(2).citation()); - Assertions.assertEquals("4 - New Literature Citation", references.get(3).citation()); + Assertions.assertEquals( + "Updated Caselaw Reference Citation from Edition", references.get(0).citation()); + Assertions.assertEquals( + "Updated Literature Reference Citation from Edition", references.get(1).citation()); + Assertions.assertEquals( + "New Caselaw Reference Citation from Edition", references.get(2).citation()); + Assertions.assertEquals( + "New Literature Reference Citation from Edition", references.get(3).citation()); + // first, caselaw references assertThat(documentationUnitService.getByDocumentNumber("DOC_NUMBER").references()) - .hasSize(6) + .hasSize(3) .satisfies( list -> { - // first, caselaw references - assertThat(list.get(0).citation()).isEqualTo("2"); + assertThat(list.get(0).citation()) + .isEqualTo("Caselaw Reference Citation from Docunit"); assertThat(list.get(1).id()).isEqualTo(existingReferenceId); - assertThat(list.get(1).citation()).isEqualTo("1 - Updated Citation"); + assertThat(list.get(1).citation()) + .isEqualTo("Updated Caselaw Reference Citation from Edition"); + assertThat(list.get(1).rank()).isEqualTo(2); assertThat(list.get(2).id()).isEqualTo(newReferenceId); - assertThat(list.get(2).citation()).isEqualTo("3 - New Reference"); - // then, literature references - assertThat(list.get(3).citation()).isEqualTo("1"); - assertThat(list.get(4).id()).isEqualTo(existingLiteratureCitationId); - assertThat(list.get(4).citation()).isEqualTo("2 - Updated Literature Citation"); - assertThat(list.get(5).citation()).isEqualTo("4 - New Literature Citation"); + assertThat(list.get(2).citation()) + .isEqualTo("New Caselaw Reference Citation from Edition"); + assertThat(list.get(2).rank()).isEqualTo(3); + }); + + // then, literature references + assertThat(documentationUnitService.getByDocumentNumber("DOC_NUMBER").literatureReferences()) + .hasSize(3) + .satisfies( + list -> { + assertThat(list.get(0).citation()) + .isEqualTo("Literature Reference Citation from Docunit"); + assertThat(list.get(1).id()).isEqualTo(existingLiteratureCitationId); + assertThat(list.get(1).citation()) + .isEqualTo("Updated Literature Reference Citation from Edition"); + assertThat(list.get(1).rank()).isEqualTo(2); + assertThat(list.get(2).id()).isEqualTo(newLiteratureReferenceId); + assertThat(list.get(2).citation()) + .isEqualTo("New Literature Reference Citation from Edition"); + assertThat(list.get(2).rank()).isEqualTo(3); }); // clean up @@ -446,7 +468,7 @@ void testDeleteReferencesAndLiteratureCitations_fromEdition_shouldSucceed() DependentLiteratureCitationDTO.builder() .id(UUID.randomUUID()) .rank(1) - .citation("1") + .citation("Literature Reference from Docunit") .legalPeriodicalRawValue("A") .author("author 1") .type(DependentLiteratureCitationType.PASSIVE) @@ -466,7 +488,7 @@ void testDeleteReferencesAndLiteratureCitations_fromEdition_shouldSucceed() ReferenceDTO.builder() .id(UUID.randomUUID()) .rank(1) - .citation("2") + .citation("Caselaw Reference from Docunit") .legalPeriodicalRawValue("A") .documentationUnit( DocumentationUnitDTO.builder() @@ -499,14 +521,14 @@ void testDeleteReferencesAndLiteratureCitations_fromEdition_shouldSucceed() Reference.builder() .id(referenceId) .referenceType(ReferenceType.CASELAW) - .citation("1 - New Citation") + .citation("Updated Caselaw Reference Citation from Edition") .legalPeriodicalRawValue("B") .documentationUnit(relatedDocUnit) .build(), Reference.builder() .id(literatureCitationId) .referenceType(ReferenceType.LITERATURE) - .citation("2 - New Literature Citation") + .citation("Updated Literature Reference Citation from Edition") .author("author 2") .documentType(EBS) .legalPeriodicalRawValue("B") @@ -515,14 +537,14 @@ void testDeleteReferencesAndLiteratureCitations_fromEdition_shouldSucceed() Reference.builder() .id(UUID.randomUUID()) .referenceType(ReferenceType.CASELAW) - .citation("3 - New Reference") + .citation("New Caselaw Reference from Edition") .legalPeriodicalRawValue("D") .documentationUnit(relatedDocUnit) .build(), Reference.builder() .id(UUID.randomUUID()) .referenceType(ReferenceType.LITERATURE) - .citation("4 - New Literature Citation") + .citation("New Literature Reference from Edition") .author("author 4") .documentType(EAN) .legalPeriodicalRawValue("C") @@ -530,8 +552,8 @@ void testDeleteReferencesAndLiteratureCitations_fromEdition_shouldSucceed() .build())) .build()); - edition.references().remove(0); // delete 1 - New Citation - edition.references().remove(0); // delete 2 - New Literature Citation + edition.references().remove(0); // delete Updated Caselaw Reference Citation from Edition + edition.references().remove(0); // delete Updated Literature Reference Citation from Edition assertThat(referenceRepository.findById(referenceId)).isPresent(); assertThat(literatureCitationRepository.findById(literatureCitationId)).isPresent(); @@ -552,29 +574,34 @@ void testDeleteReferencesAndLiteratureCitations_fromEdition_shouldSucceed() Assertions.assertEquals("2024 Sonderheft 1", edition.name()); List references = editionResponse.references(); Assertions.assertEquals(2, references.size()); - Assertions.assertEquals("3 - New Reference", references.get(0).citation()); - Assertions.assertEquals("4 - New Literature Citation", references.get(1).citation()); + Assertions.assertEquals("New Caselaw Reference from Edition", references.get(0).citation()); + Assertions.assertEquals("New Literature Reference from Edition", references.get(1).citation()); // assure rank is updated assertThat(references.get(0).rank()).isEqualTo(1); assertThat(references.get(1).rank()).isEqualTo(2); - // documentation unit is updated + // documentation unit references are updated assertThat(documentationUnitService.getByDocumentNumber("DOC_NUMBER").references()) - .hasSize(4) + .hasSize(2) .satisfies( list -> { // first, caselaw references - assertThat(list.get(0).citation()).isEqualTo("2"); + assertThat(list.get(0).citation()).isEqualTo("Caselaw Reference from Docunit"); assertThat(list.get(0).rank()).isEqualTo(1); - assertThat(list.get(1).citation()).isEqualTo("3 - New Reference"); + assertThat(list.get(1).citation()).isEqualTo("New Caselaw Reference from Edition"); assertThat(list.get(1).rank()).isEqualTo(2); + }); + assertThat(documentationUnitService.getByDocumentNumber("DOC_NUMBER").literatureReferences()) + .hasSize(2) + .satisfies( + list -> { // then, literature citations - assertThat(list.get(2).citation()).isEqualTo("1"); - assertThat(list.get(2).rank()).isEqualTo(1); - assertThat(list.get(3).citation()).isEqualTo("4 - New Literature Citation"); - assertThat(list.get(3).rank()).isEqualTo(2); + assertThat(list.get(0).citation()).isEqualTo("Literature Reference from Docunit"); + assertThat(list.get(0).rank()).isEqualTo(1); + assertThat(list.get(1).citation()).isEqualTo("New Literature Reference from Edition"); + assertThat(list.get(1).rank()).isEqualTo(2); }); assertThat(referenceRepository.findById(referenceId)).isEmpty(); diff --git a/backend/src/test/java/de/bund/digitalservice/ris/caselaw/integration/tests/ReferenceIntegrationTest.java b/backend/src/test/java/de/bund/digitalservice/ris/caselaw/integration/tests/ReferenceIntegrationTest.java index 3f5d6c320b..e849e84f2e 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/caselaw/integration/tests/ReferenceIntegrationTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/caselaw/integration/tests/ReferenceIntegrationTest.java @@ -235,7 +235,7 @@ void testLiteratureReferencesCanBeSaved() { .uuid(dto.getId()) .documentNumber(dto.getDocumentNumber()) .coreData(CoreData.builder().documentationOffice(docOffice).build()) - .references( + .literatureReferences( List.of( Reference.builder() .id(referenceId) @@ -266,11 +266,11 @@ void testLiteratureReferencesCanBeSaved() { assertThat(response.getResponseBody()).isNotNull(); assertThat(response.getResponseBody().documentNumber()) .isEqualTo(DEFAULT_DOCUMENT_NUMBER); - assertThat(response.getResponseBody().references()).hasSize(1); - assertThat(response.getResponseBody().references()) + assertThat(response.getResponseBody().literatureReferences()).hasSize(1); + assertThat(response.getResponseBody().literatureReferences()) .extracting("citation", "author", "documentType", "id") .containsExactly(tuple("2024, S.3", "Heinz Otto", eanDocumentType, referenceId)); - assertThat(response.getResponseBody().references()) + assertThat(response.getResponseBody().literatureReferences()) .extracting("legalPeriodical") .usingRecursiveComparison() .isEqualTo(List.of(bverwgeLegalPeriodical)); diff --git a/frontend/src/components/DocumentUnitLiteratureReferenceInput.vue b/frontend/src/components/DocumentUnitLiteratureReferenceInput.vue new file mode 100644 index 0000000000..4e349a94c2 --- /dev/null +++ b/frontend/src/components/DocumentUnitLiteratureReferenceInput.vue @@ -0,0 +1,195 @@ + + + diff --git a/frontend/src/components/DocumentUnitReferenceInput.vue b/frontend/src/components/DocumentUnitReferenceInput.vue index 55611615e2..08931caa55 100644 --- a/frontend/src/components/DocumentUnitReferenceInput.vue +++ b/frontend/src/components/DocumentUnitReferenceInput.vue @@ -1,8 +1,7 @@ @@ -25,12 +33,22 @@ const defaultValue = new Reference() as Reference Fundstellen
+ + Literaturfundstellen +
+ +
diff --git a/frontend/src/components/preview/DocumentUnitPreview.vue b/frontend/src/components/preview/DocumentUnitPreview.vue index 4da0663272..8d72b3eabe 100644 --- a/frontend/src/components/preview/DocumentUnitPreview.vue +++ b/frontend/src/components/preview/DocumentUnitPreview.vue @@ -9,6 +9,7 @@ import { } from "@/components/preview/constants" import PreviewContentRelatedIndexing from "@/components/preview/PreviewContentRelatedIndexing.vue" import PreviewCoreData from "@/components/preview/PreviewCoreData.vue" +import PreviewLiteratureReferences from "@/components/preview/PreviewLiteratureReferences.vue" import PreviewLongTexts from "@/components/preview/PreviewLongTexts.vue" import PreviewNote from "@/components/preview/PreviewNote.vue" import PreviewProceedingDecisions from "@/components/preview/PreviewProceedingDecisions.vue" @@ -46,6 +47,9 @@ provide(previewLayoutInjectionKey, props.layout || "wide") + +import PreviewCategory from "@/components/preview/PreviewCategory.vue" +import PreviewContent from "@/components/preview/PreviewContent.vue" +import PreviewRow from "@/components/preview/PreviewRow.vue" +import Reference from "@/domain/reference" + +defineProps<{ + literatureReferences: Reference[] | undefined +}>() + + + diff --git a/frontend/src/components/preview/PreviewReferences.vue b/frontend/src/components/preview/PreviewReferences.vue index 7dc0e5fdf7..97d0b4637a 100644 --- a/frontend/src/components/preview/PreviewReferences.vue +++ b/frontend/src/components/preview/PreviewReferences.vue @@ -11,22 +11,12 @@ const props = defineProps<{ const primaryReferences = computed(() => props.references?.filter( - (reference) => - reference.referenceType === "caselaw" && - reference.legalPeriodical?.primaryReference, + (reference) => reference.legalPeriodical?.primaryReference, ), ) const secondaryReferences = computed(() => props.references?.filter( - (reference) => - reference.referenceType === "caselaw" && - !reference.legalPeriodical?.primaryReference, - ), -) - -const literatureReferences = computed(() => - props.references?.filter( - (reference) => reference.referenceType === "literature", + (reference) => !reference.legalPeriodical?.primaryReference, ), ) @@ -75,16 +65,4 @@ const literatureReferences = computed(() => - - Literaturfundstellen - - -
- {{ item.renderDecision }} -
-
-
diff --git a/frontend/src/domain/documentUnit.ts b/frontend/src/domain/documentUnit.ts index f7282f14fe..93eabcee20 100644 --- a/frontend/src/domain/documentUnit.ts +++ b/frontend/src/domain/documentUnit.ts @@ -139,6 +139,7 @@ export default class DocumentUnit { public contentRelatedIndexing: ContentRelatedIndexing = {} public note: string = "" public references?: Reference[] + public literatureReferences?: Reference[] public isEditable: boolean = false public managementData: ManagementData = { borderNumbers: [] } @@ -233,6 +234,11 @@ export default class DocumentUnit { (reference) => new Reference({ ...reference }), ) + if (data.literatureReferences) + data.literatureReferences = data.literatureReferences.map( + (literatureReference) => new Reference({ ...literatureReference }), + ) + Object.assign(this, data) } diff --git a/frontend/test/e2e/caselaw/categories/references.spec.ts b/frontend/test/e2e/caselaw/categories/references.spec.ts index bfd93233f3..5b60c488e5 100644 --- a/frontend/test/e2e/caselaw/categories/references.spec.ts +++ b/frontend/test/e2e/caselaw/categories/references.spec.ts @@ -21,7 +21,7 @@ test.describe( }, () => { test( - "Display, adding, editing and deleting multiple references", + "Display, adding, editing and deleting references", { annotation: { type: "story", @@ -192,7 +192,7 @@ test.describe( ) test( - "References input validated against required fields", + "References input is validated against required fields", { annotation: { type: "story", @@ -249,69 +249,32 @@ test.describe( { tag: "@RISDEV-5236 @RISDEV-5454", }, - async ({ page, documentNumber }) => { - await test.step("Caselaw reference type is preselected", async () => { - await navigateToReferences(page, documentNumber) - - await expect( - page.getByLabel("Rechtsprechung Fundstelle"), - ).toBeChecked() - - await expect( - page.getByLabel("Literatur Fundstelle"), - ).not.toBeChecked() - - await expect(page.getByLabel("Klammernzusatz")).toBeVisible() - - await expect( - page.getByLabel("Dokumenttyp Literaturfundstelle"), - ).toBeHidden() - - await expect( - page.getByLabel("Autor Literaturfundstelle"), - ).toBeHidden() - }) - - await test.step("Selecting literature reference type, renders different inputs", async () => { - await page.getByLabel("Literatur Fundstelle").click() - await expect( - page.getByLabel("Rechtsprechung Fundstelle"), - ).not.toBeChecked() - - await expect(page.getByLabel("Literatur Fundstelle")).toBeChecked() - - await expect( - page.getByLabel("Dokumenttyp Literaturfundstelle"), - ).toBeVisible() - - await expect( - page.getByLabel("Autor Literaturfundstelle"), - ).toBeVisible() - await expect(page.getByLabel("Klammernzusatz")).toBeHidden() - }) - + async ({ page, prefilledDocumentUnit }) => { await test.step("Literature references are validated for required inputs", async () => { - await fillInput(page, "Periodikum", "AllMBl") + await navigateToReferences( + page, + prefilledDocumentUnit.documentNumber ?? "", + ) + await fillInput(page, "Periodikum Literaturfundstelle", "AllMBl") await page .getByText("AllMBl | Allgemeines Ministerialblatt", { exact: true, }) .click() - await waitForInputValue(page, "[aria-label='Periodikum']", "AllMBl") - await fillInput(page, "Zitatstelle", "2024, 2") + await waitForInputValue( + page, + "[aria-label='Periodikum Literaturfundstelle']", + "AllMBl", + ) + await fillInput(page, "Zitatstelle Literaturfundstelle", "2024, 2") - await page.locator("[aria-label='Fundstelle speichern']").click() + await page + .locator("[aria-label='Literaturfundstelle speichern']") + .click() // check that both fields display error message await expect( page.locator("text=Pflichtfeld nicht befüllt"), ).toHaveCount(2) - - // Switching between radio buttons resets the validation errors - await page.getByLabel("Rechtsprechung Fundstelle").click() - await page.getByLabel("Literatur Fundstelle").click() - await expect( - page.locator("text=Pflichtfeld nicht befüllt"), - ).toHaveCount(0) }) await test.step("Save literature reference, verify that it is shown in the list", async () => { @@ -323,20 +286,13 @@ test.describe( "[aria-label='Dokumenttyp Literaturfundstelle']", "Anmerkung", ) - await page.locator("[aria-label='Fundstelle speichern']").click() + await page + .locator("[aria-label='Literaturfundstelle speichern']") + .click() await expect( page.getByText("Bilen, Ulviye, AllMBl 2024, 2 (Ean)"), ).toBeVisible() }) - - await test.step("Radio buttons should not be visible after saving", async () => { - await page.getByTestId("list-entry-0").click() - await expect( - page.getByLabel("Rechtsprechung Fundstelle"), - ).toBeHidden() - - await expect(page.getByLabel("Literatur Fundstelle")).toBeHidden() - }) }, ) @@ -424,15 +380,18 @@ test.describe( await test.step("Add literature reference, verify remdering in preview", async () => { await navigateToReferences(page, documentNumber) - await page.getByLabel("Literatur Fundstelle").click() - await fillInput(page, "Periodikum", "AllMBl") + await fillInput(page, "Periodikum Literaturfundstelle", "AllMBl") await page .getByText("AllMBl | Allgemeines Ministerialblatt", { exact: true, }) .click() - await waitForInputValue(page, "[aria-label='Periodikum']", "AllMBl") - await fillInput(page, "Zitatstelle", "2024, 2") + await waitForInputValue( + page, + "[aria-label='Periodikum Literaturfundstelle']", + "AllMBl", + ) + await fillInput(page, "Zitatstelle Literaturfundstelle", "2024, 2") await fillInput(page, "Autor Literaturfundstelle", "Bilen, Ulviye") await fillInput(page, "Dokumenttyp Literaturfundstelle", "Ean") await page.getByText("Ean", { exact: true }).click() @@ -442,7 +401,9 @@ test.describe( "Anmerkung", ) - await page.locator("[aria-label='Fundstelle speichern']").click() + await page + .locator("[aria-label='Literaturfundstelle speichern']") + .click() await expect( page.getByText("Bilen, Ulviye, AllMBl 2024, 2 (Ean)"), ).toBeVisible() diff --git a/frontend/test/e2e/caselaw/e2e-utils.ts b/frontend/test/e2e/caselaw/e2e-utils.ts index 58adeeb831..40f7fc9a57 100644 --- a/frontend/test/e2e/caselaw/e2e-utils.ts +++ b/frontend/test/e2e/caselaw/e2e-utils.ts @@ -79,7 +79,7 @@ export const navigateToReferences = async ( const baseUrl = `/caselaw/documentunit/${documentNumber}/references` await page.goto(baseUrl) - await expect(page.getByText("Periodikum")).toBeVisible() + await expect(page.getByLabel("Periodikum", { exact: true })).toBeVisible() }) }