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 d269bfa555..46893e175a 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 @@ -520,10 +520,13 @@ public static DocumentUnit transformToDomain(DocumentationUnitDTO documentationU List pendingDecisionDTOs = documentationUnitDTO.getPendingDecisions(); if (pendingDecisionDTOs != null || ensuingDecisionDTOs != null) { - EnsuingDecision[] ensuingDecisions = new EnsuingDecision[ensuingDecisionDTOs.size()]; - for (EnsuingDecisionDTO currentDTO : ensuingDecisionDTOs) { - ensuingDecisions[currentDTO.getRank() - 1] = - EnsuingDecisionTransformer.transformToDomain(currentDTO); + EnsuingDecision[] ensuingDecisions = + new EnsuingDecision[ensuingDecisionDTOs.size() + pendingDecisionDTOs.size()]; + if (ensuingDecisionDTOs != null) { + for (EnsuingDecisionDTO currentDTO : ensuingDecisionDTOs) { + ensuingDecisions[currentDTO.getRank() - 1] = + EnsuingDecisionTransformer.transformToDomain(currentDTO); + } } if (pendingDecisionDTOs != null) { diff --git a/backend/src/main/java/de/bund/digitalservice/ris/caselaw/adapter/transformer/EnsuingDecisionTransformer.java b/backend/src/main/java/de/bund/digitalservice/ris/caselaw/adapter/transformer/EnsuingDecisionTransformer.java index dc37caac7a..7aa34cdf71 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/caselaw/adapter/transformer/EnsuingDecisionTransformer.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/caselaw/adapter/transformer/EnsuingDecisionTransformer.java @@ -13,7 +13,7 @@ public static EnsuingDecision transformToDomain(EnsuingDecisionDTO ensuingDecisi .documentType(getDocumentTypeFromDTO(ensuingDecisionDTO.getDocumentType())) .decisionDate(ensuingDecisionDTO.getDate()) .note(ensuingDecisionDTO.getNote()) - .isPending(false) + .pending(false) .build(); } diff --git a/backend/src/main/java/de/bund/digitalservice/ris/caselaw/adapter/transformer/PendingDecisionTransformer.java b/backend/src/main/java/de/bund/digitalservice/ris/caselaw/adapter/transformer/PendingDecisionTransformer.java index eb9c05e299..d68854d7a5 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/caselaw/adapter/transformer/PendingDecisionTransformer.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/caselaw/adapter/transformer/PendingDecisionTransformer.java @@ -13,7 +13,7 @@ public static EnsuingDecision transformToDomain(PendingDecisionDTO pendingDecisi .documentType(getDocumentTypeFromDTO(pendingDecisionDTO.getDocumentType())) .decisionDate(pendingDecisionDTO.getDate()) .note(pendingDecisionDTO.getNote()) - .isPending(true) + .pending(true) .build(); } diff --git a/backend/src/main/java/de/bund/digitalservice/ris/caselaw/domain/EnsuingDecision.java b/backend/src/main/java/de/bund/digitalservice/ris/caselaw/domain/EnsuingDecision.java index 72446d85cd..49a573568e 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/caselaw/domain/EnsuingDecision.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/caselaw/domain/EnsuingDecision.java @@ -14,7 +14,7 @@ @DateKnownConstraint @Data public class EnsuingDecision extends RelatedDocumentationUnit { - private boolean isPending; + private boolean pending; private String note; public boolean hasNoValues() { diff --git a/frontend/src/components/EnsuingDecisionInputGroup.vue b/frontend/src/components/EnsuingDecisionInputGroup.vue index 00bd887b40..a309f7c4a2 100644 --- a/frontend/src/components/EnsuingDecisionInputGroup.vue +++ b/frontend/src/components/EnsuingDecisionInputGroup.vue @@ -35,10 +35,10 @@ const searchResultsCurrentPage = ref>() const searchResults = ref>() const isPending = computed({ - get: () => ensuingDecision.value.isPending, + get: () => ensuingDecision.value.pending, set: (value) => { if (value) ensuingDecision.value.decisionDate = undefined - ensuingDecision.value.isPending = value + ensuingDecision.value.pending = value }, }) @@ -146,7 +146,7 @@ onMounted(() => { { { { diff --git a/frontend/src/components/EnsuingDecisions.vue b/frontend/src/components/EnsuingDecisions.vue index d7d0dbddff..e1a0745b7c 100644 --- a/frontend/src/components/EnsuingDecisions.vue +++ b/frontend/src/components/EnsuingDecisions.vue @@ -19,7 +19,7 @@ const ensuingDecisions = computed({ return props.modelValue }, set: (value) => { - if (value) emit("update:modelValue", value) + emit("update:modelValue", value) }, }) const defaultValue = new EnsuingDecision() @@ -29,7 +29,7 @@ function decisionSummarizer(dataEntry: EnsuingDecision) { !dataEntry.hasMissingRequiredFields || (dataEntry.missingRequiredFields.length === 1 && dataEntry.missingRequiredFields[0] === "decisionDate" && - dataEntry.isPending) + dataEntry.pending) ) { return h("div", { class: ["link-02-reg"] }, dataEntry.renderDecision) } else { diff --git a/frontend/src/domain/ensuingDecision.ts b/frontend/src/domain/ensuingDecision.ts index 7653864640..150cb5f8b5 100644 --- a/frontend/src/domain/ensuingDecision.ts +++ b/frontend/src/domain/ensuingDecision.ts @@ -6,12 +6,12 @@ export default class EnsuingDecision extends RelatedDocumentation implements EditableListItem { - public isPending = false + public pending: boolean | undefined public note: string | undefined static requiredFields = ["fileNumber", "court", "decisionDate"] as const static fields = [ - "isPending", + "pending", "fileNumber", "court", "decisionDate", @@ -26,12 +26,12 @@ export default class EnsuingDecision get renderDecision(): string { return [ - ...(this.isPending === true ? ["anhängig"] : ["nachgehend"]), + ...(this.pending === true ? ["anhängig"] : ["nachgehend"]), ...(this.court ? [`${this.court.label}`] : []), ...(this.decisionDate ? [dayjs(this.decisionDate).format("DD.MM.YYYY")] : []), - ...(this.isPending ? ["Datum unbekannt"] : []), + ...(this.pending ? ["Datum unbekannt"] : []), ...(this.fileNumber ? [this.fileNumber] : []), ...(this.documentType ? [this.documentType?.jurisShortcut] : []), ...(this.note ? [this.note] : []), @@ -70,7 +70,7 @@ export default class EnsuingDecision fieldName: keyof EnsuingDecision, value: EnsuingDecision[(typeof EnsuingDecision.fields)[number]], ) { - if (fieldName === "isPending" && value === true) { + if (fieldName === "pending" && value === true) { return false } if (value === undefined || !value || value === null) { diff --git a/frontend/test/e2e/caselaw/categories/ensuing-decisions.spec.ts b/frontend/test/e2e/caselaw/categories/ensuing-decisions.spec.ts new file mode 100644 index 0000000000..3ad05627c2 --- /dev/null +++ b/frontend/test/e2e/caselaw/categories/ensuing-decisions.spec.ts @@ -0,0 +1,443 @@ +import { expect } from "@playwright/test" +import { generateString } from "../../../test-helper/dataGenerators" +import { + fillEnsuingDecisionInputs, + navigateToCategories, + navigateToPublication, + waitForSaving, +} from "~/e2e/caselaw/e2e-utils" +import { caselawTest as test } from "~/e2e/caselaw/fixtures" + +test.describe("ensuing decisions", () => { + test("renders empty ensuing decision in edit mode, when none in list", async ({ + page, + documentNumber, + }) => { + await navigateToCategories(page, documentNumber) + await expect( + page.getByRole("heading", { name: "Nachgehende Entscheidung " }), + ).toBeVisible() + await expect( + page.getByLabel("Gericht Nachgehende Entscheidung"), + ).toBeVisible() + await expect( + page.getByLabel("Entscheidungsdatum Nachgehende Entscheidung"), + ).toBeVisible() + await expect( + page.getByLabel("Aktenzeichen Nachgehende Entscheidung"), + ).toBeVisible() + await expect( + page.getByLabel("Dokumenttyp Nachgehende Entscheidung"), + ).toBeVisible() + await expect(page.getByLabel("Datum unbekannt")).toBeVisible() + }) + + test("create and renders new ensuing decision in list", async ({ + page, + documentNumber, + prefilledDocumentUnit, + }) => { + await navigateToCategories(page, documentNumber) + await expect(page.getByText(documentNumber)).toBeVisible() + + await fillEnsuingDecisionInputs(page, { + pending: false, + court: prefilledDocumentUnit.coreData.court?.label, + fileNumber: prefilledDocumentUnit.coreData.fileNumbers?.[0], + documentType: prefilledDocumentUnit.coreData.documentType?.jurisShortcut, + decisionDate: "01.01.2020", + note: "abc", + }) + + await page.getByLabel("Nachgehende Entscheidung speichern").click() + await expect( + page.getByText( + `nachgehend, AG Aachen, 01.01.2020, ${prefilledDocumentUnit.coreData.fileNumbers?.[0]}, AnU`, + { + exact: true, + }, + ), + ).toBeVisible() + + const ensuingDecisionContainer = page.getByLabel("Nachgehende Entscheidung") + + await expect( + ensuingDecisionContainer.getByLabel("Listen Eintrag"), + ).toHaveCount(1) + + await page.getByLabel("Weitere Angabe").click() + await fillEnsuingDecisionInputs(page, { + court: prefilledDocumentUnit.coreData.court?.label, + fileNumber: prefilledDocumentUnit.coreData.fileNumbers?.[0], + documentType: prefilledDocumentUnit.coreData.documentType?.jurisShortcut, + decisionDate: "01.01.2020", + }) + + await page.getByLabel("Nachgehende Entscheidung speichern").click() + + await expect( + ensuingDecisionContainer.getByLabel("Listen Eintrag"), + ).toHaveCount(2) + }) + + test("change to 'anhaengig' removes date with value and vice versa", async ({ + page, + documentNumber, + prefilledDocumentUnit, + }) => { + await navigateToCategories(page, documentNumber) + await expect(page.getByText(documentNumber)).toBeVisible() + + await fillEnsuingDecisionInputs(page, { + court: prefilledDocumentUnit.coreData.court?.label, + fileNumber: prefilledDocumentUnit.coreData.fileNumbers?.[0], + documentType: prefilledDocumentUnit.coreData.documentType?.jurisShortcut, + decisionDate: "01.01.2020", + }) + + await page.getByLabel("Nachgehende Entscheidung speichern").click() + await expect( + page.getByText( + `nachgehend, AG Aachen, 01.01.2020, ${prefilledDocumentUnit.coreData.fileNumbers?.[0]}, AnU`, + { + exact: true, + }, + ), + ).toBeVisible() + + const ensuingDecisionContainer = page.getByLabel("Nachgehende Entscheidung") + + await expect( + ensuingDecisionContainer.getByLabel("Listen Eintrag"), + ).toHaveCount(1) + + await page.getByLabel("Weitere Angabe").click() + await fillEnsuingDecisionInputs(page, { + court: prefilledDocumentUnit.coreData.court?.label, + fileNumber: prefilledDocumentUnit.coreData.fileNumbers?.[0], + documentType: prefilledDocumentUnit.coreData.documentType?.jurisShortcut, + decisionDate: "01.01.2020", + }) + + const pendingCheckbox = page.getByLabel("Anhängige Entscheidung") + + await pendingCheckbox.click() + await expect(pendingCheckbox).toBeChecked() + + await expect( + page.getByLabel("Entscheidungsdatum Nachgehende Entscheidung"), + ).toBeHidden() + + await page.getByLabel("Nachgehende Entscheidung speichern").click() + await expect( + page.getByText( + `anhängig, AG Aachen, Datum unbekannt, ${prefilledDocumentUnit.coreData.fileNumbers?.[0]}, AnU`, + { + exact: true, + }, + ), + ).toBeVisible() + + await expect( + ensuingDecisionContainer.getByLabel("Listen Eintrag"), + ).toHaveCount(2) + }) + + test("saving behaviour of ensuing decision", async ({ + page, + documentNumber, + prefilledDocumentUnit, + }) => { + await navigateToCategories(page, documentNumber) + await expect(page.getByText(documentNumber)).toBeVisible() + + await waitForSaving( + async () => { + await fillEnsuingDecisionInputs(page, { + court: prefilledDocumentUnit.coreData.court?.label, + fileNumber: prefilledDocumentUnit.coreData.fileNumbers?.[0], + documentType: + prefilledDocumentUnit.coreData.documentType?.jurisShortcut, + decisionDate: "01.01.2020", + }) + + await page.getByLabel("Nachgehende Entscheidung speichern").click() + await expect( + page.getByText( + `nachgehend, AG Aachen, 01.01.2020, ${prefilledDocumentUnit.coreData.fileNumbers?.[0]}, AnU`, + { + exact: true, + }, + ), + ).toBeVisible() + }, + page, + { clickSaveButton: true }, + ) + + const ensuingDecisionContainer = page.getByLabel("Nachgehende Entscheidung") + + await expect( + ensuingDecisionContainer.getByLabel("Listen Eintrag"), + ).toHaveCount(1) + + await page.reload() + + await expect( + ensuingDecisionContainer.getByLabel("Listen Eintrag"), + ).toHaveCount(1, { timeout: 10000 }) // reloading can be slow if too many parallel tests + + await page.getByLabel("Weitere Angabe").click() + await page.getByLabel("Aktenzeichen Nachgehende Entscheidung").fill("two") + await page.getByLabel("Nachgehende Entscheidung speichern").click() + await expect( + page.getByText(`nachgehend, two`, { + exact: true, + }), + ).toBeVisible() + // "Nachgehende Entscheidung speichern" only saves state in frontend, no communication to backend yet + await page.reload() + await expect( + ensuingDecisionContainer.getByLabel("Listen Eintrag"), + ).toHaveCount(1, { timeout: 10000 }) // reloading can be slow if too many parallel tests + + await page.getByLabel("Weitere Angabe").click() + await waitForSaving( + async () => { + await page + .getByLabel("Aktenzeichen Nachgehende Entscheidung") + .fill("two") + await page.getByLabel("Nachgehende Entscheidung speichern").click() + }, + page, + { clickSaveButton: true }, + ) + + await page.reload() + await expect( + ensuingDecisionContainer.getByLabel("Listen Eintrag"), + ).toHaveCount(2, { timeout: 20000 }) + }) + + test("manually added ensuing decision can be edited", async ({ + page, + documentNumber, + }) => { + const fileNumber1 = generateString() + const fileNumber2 = generateString() + await navigateToCategories(page, documentNumber) + + await waitForSaving( + async () => { + await page + .getByLabel("Aktenzeichen Nachgehende Entscheidung") + .fill(fileNumber1) + }, + page, + { clickSaveButton: true }, + ) + await page.getByLabel("Nachgehende Entscheidung speichern").click() + await expect(page.getByText(fileNumber1)).toBeVisible() + + await page.getByLabel("Eintrag bearbeiten").click() + await waitForSaving( + async () => { + await page + .getByLabel("Aktenzeichen Nachgehende Entscheidung") + .fill(fileNumber2) + }, + page, + { clickSaveButton: true }, + ) + await page.getByLabel("Nachgehende Entscheidung speichern").click() + await expect(page.getByText(fileNumber1)).toBeHidden() + await expect(page.getByText(fileNumber2)).toBeVisible() + }) + + test("manually added ensuing decision can be deleted", async ({ + page, + documentNumber, + }) => { + await navigateToCategories(page, documentNumber) + + await waitForSaving( + async () => { + await page + .getByLabel("Aktenzeichen Nachgehende Entscheidung") + .fill("one") + }, + page, + { clickSaveButton: true }, + ) + + await page.getByLabel("Nachgehende Entscheidung speichern").click() + await page.getByLabel("Weitere Angabe").click() + await waitForSaving( + async () => { + await page + .getByLabel("Aktenzeichen Nachgehende Entscheidung") + .fill("two") + }, + page, + { clickSaveButton: true }, + ) + const ensuingDecisionContainer = page.getByLabel("Nachgehende Entscheidung") + await page.getByLabel("Nachgehende Entscheidung speichern").click() + await expect( + ensuingDecisionContainer.getByLabel("Listen Eintrag"), + ).toHaveCount(2) + await page.getByLabel("Eintrag löschen").first().click() + await expect( + ensuingDecisionContainer.getByLabel("Listen Eintrag"), + ).toHaveCount(1) + }) + + //Todo enable again when linking possible + // eslint-disable-next-line playwright/no-skipped-test + test.skip("search for documentunits and link as ensuing decision", async ({ + page, + documentNumber, + prefilledDocumentUnit, + }) => { + await navigateToPublication( + page, + prefilledDocumentUnit.documentNumber || "", + ) + + await page + .locator("[aria-label='Dokumentationseinheit veröffentlichen']") + .click() + await expect(page.locator("text=Email wurde versendet")).toBeVisible() + + await expect(page.locator("text=Xml Email Abgabe -")).toBeVisible() + await expect(page.locator("text=in Veröffentlichung")).toBeVisible() + + await navigateToCategories(page, documentNumber) + await expect(page.getByText(documentNumber)).toBeVisible() + + await fillEnsuingDecisionInputs(page, { + court: prefilledDocumentUnit.coreData.court?.label, + fileNumber: prefilledDocumentUnit.coreData.fileNumbers?.[0], + documentType: prefilledDocumentUnit.coreData.documentType?.jurisShortcut, + decisionDate: "01.01.2020", + }) + const ensuingDecisionContainer = page.getByLabel("Nachgehende Entscheidung") + await ensuingDecisionContainer + .getByLabel("Nach Entscheidung suchen") + .click() + + await expect(page.getByText("1 Ergebnis gefunden.")).toBeVisible() + + const result = page.getByText( + `AG Aachen, 01.01.2020, ${prefilledDocumentUnit.coreData.fileNumbers?.[0]}, AnU, ${prefilledDocumentUnit.documentNumber}`, + ) + + await expect(result).toBeVisible() + await page.getByLabel("Treffer übernehmen").click() + + //make sure to have citation style in list + const listItem = page.getByText( + `AG Aachen, 01.01.2020, ${prefilledDocumentUnit.coreData.fileNumbers?.[0]}, AnU, ${prefilledDocumentUnit.documentNumber}`, + ) + await expect(listItem).toBeVisible() + await expect(page.getByLabel("Eintrag löschen")).toBeVisible() + + //can not be edited + await expect(page.getByLabel("Eintrag bearbeiten")).toBeHidden() + + // search for same parameters gives same result, indication that decision is already added + await page.getByLabel("Weitere Angabe").click() + await fillEnsuingDecisionInputs(page, { + court: prefilledDocumentUnit.coreData.court?.label, + fileNumber: prefilledDocumentUnit.coreData.fileNumbers?.[0], + documentType: prefilledDocumentUnit.coreData.documentType?.jurisShortcut, + decisionDate: "01.01.2020", + }) + + await ensuingDecisionContainer + .getByLabel("Nach Entscheidung suchen") + .click() + + await expect(page.getByText("1 Ergebnis gefunden.")).toBeVisible() + await expect(page.getByText("Bereits hinzugefügt")).toBeVisible() + + //can be deleted + await page.getByLabel("Eintrag löschen").first().click() + await expect( + ensuingDecisionContainer.getByLabel("Listen Eintrag"), + ).toHaveCount(1) + await expect(listItem).toBeHidden() + }) + + test("validates against required fields", async ({ + page, + documentNumber, + prefilledDocumentUnit, + }) => { + await navigateToCategories(page, documentNumber) + await expect(page.getByText(documentNumber)).toBeVisible() + + await fillEnsuingDecisionInputs(page, { + fileNumber: "abc", + }) + await page.getByLabel("Nachgehende Entscheidung speichern").click() + + await expect(page.getByLabel("Fehlerhafte Eingabe")).toBeVisible() + await page.getByLabel("Eintrag bearbeiten").click() + await expect( + page + .getByLabel("Nachgehende Entscheidung") + .getByText("Pflichtfeld nicht befüllt"), + ).toHaveCount(2) + + await fillEnsuingDecisionInputs(page, { + court: prefilledDocumentUnit.coreData.court?.label, + fileNumber: prefilledDocumentUnit.coreData.fileNumbers?.[0], + documentType: prefilledDocumentUnit.coreData.documentType?.jurisShortcut, + decisionDate: "01.01.2020", + }) + await page.getByLabel("Nachgehende Entscheidung speichern").click() + + await expect(page.getByLabel("Fehlerhafte Eingabe")).toBeHidden() + }) + + test("adding empty ensuing decision not possible", async ({ + page, + documentNumber, + }) => { + await navigateToCategories(page, documentNumber) + await expect(page.getByText(documentNumber)).toBeVisible() + + await page.getByLabel("Nachgehende Entscheidung speichern").isDisabled() + }) + + test("incomplete date input shows error message and does not persist", async ({ + page, + documentNumber, + }) => { + await navigateToCategories(page, documentNumber) + await expect(page.getByText(documentNumber)).toBeVisible() + + await page + .locator("[aria-label='Entscheidungsdatum Nachgehende Entscheidung']") + .fill("03") + + await page.keyboard.press("Tab") + + await expect( + page.locator( + "[aria-label='Entscheidungsdatum Nachgehende Entscheidung']", + ), + ).toHaveValue("03") + + await expect(page.locator("text=Unvollständiges Datum")).toBeVisible() + + await page.reload() + + await expect( + page.locator( + "[aria-label='Entscheidungsdatum Nachgehende Entscheidung']", + ), + ).toHaveValue("") + }) +}) diff --git a/frontend/test/e2e/caselaw/categories/previous-decisions.spec.ts b/frontend/test/e2e/caselaw/categories/previous-decisions.spec.ts index 8ab2ab14e3..4c0985d1d6 100644 --- a/frontend/test/e2e/caselaw/categories/previous-decisions.spec.ts +++ b/frontend/test/e2e/caselaw/categories/previous-decisions.spec.ts @@ -78,7 +78,7 @@ test.describe("previous decisions", () => { ).toHaveCount(2) }) - test("saving behaviour of proceeding decision", async ({ + test("saving behaviour of previous decision", async ({ page, documentNumber, prefilledDocumentUnit, @@ -154,7 +154,7 @@ test.describe("previous decisions", () => { ).toHaveCount(2, { timeout: 20000 }) }) - test("manually added proceeding decision can be edited", async ({ + test("manually added previous decision can be edited", async ({ page, documentNumber, }) => { @@ -189,7 +189,7 @@ test.describe("previous decisions", () => { await expect(page.getByText(fileNumber2)).toBeVisible() }) - test("manually added proceeding decision can be deleted", async ({ + test("manually added previous decision can be deleted", async ({ page, documentNumber, }) => { @@ -216,22 +216,20 @@ test.describe("previous decisions", () => { page, { clickSaveButton: true }, ) - const proceedingDecisionContainer = page.getByLabel( - "Vorgehende Entscheidung", - ) + const previousDecisionContainer = page.getByLabel("Vorgehende Entscheidung") await page.getByLabel("Vorgehende Entscheidung speichern").click() await expect( - proceedingDecisionContainer.getByLabel("Listen Eintrag"), + previousDecisionContainer.getByLabel("Listen Eintrag"), ).toHaveCount(2) await page.getByLabel("Eintrag löschen").first().click() await expect( - proceedingDecisionContainer.getByLabel("Listen Eintrag"), + previousDecisionContainer.getByLabel("Listen Eintrag"), ).toHaveCount(1) }) //Todo enable again when linking possible // eslint-disable-next-line playwright/no-skipped-test - test.skip("search for documentunits and link as proceeding decision", async ({ + test.skip("search for documentunits and link as previous decision", async ({ page, documentNumber, prefilledDocumentUnit, @@ -258,10 +256,8 @@ test.describe("previous decisions", () => { documentType: prefilledDocumentUnit.coreData.documentType?.jurisShortcut, decisionDate: "01.01.2020", }) - const proceedingDecisionContainer = page.getByLabel( - "Vorgehende Entscheidung", - ) - await proceedingDecisionContainer + const previousDecisionContainer = page.getByLabel("Vorgehende Entscheidung") + await previousDecisionContainer .getByLabel("Nach Entscheidung suchen") .click() @@ -293,7 +289,7 @@ test.describe("previous decisions", () => { decisionDate: "01.01.2020", }) - await proceedingDecisionContainer + await previousDecisionContainer .getByLabel("Nach Entscheidung suchen") .click() @@ -303,7 +299,7 @@ test.describe("previous decisions", () => { //can be deleted await page.getByLabel("Eintrag löschen").first().click() await expect( - proceedingDecisionContainer.getByLabel("Listen Eintrag"), + previousDecisionContainer.getByLabel("Listen Eintrag"), ).toHaveCount(1) await expect(listItem).toBeHidden() }) @@ -340,7 +336,7 @@ test.describe("previous decisions", () => { await expect(page.getByLabel("Fehlerhafte Eingabe")).toBeHidden() }) - test("adding empty proceeding decision not possible", async ({ + test("adding empty previous decision not possible", async ({ page, documentNumber, }) => { diff --git a/frontend/test/e2e/caselaw/e2e-utils.ts b/frontend/test/e2e/caselaw/e2e-utils.ts index cc530924c8..c37dfc3c01 100644 --- a/frontend/test/e2e/caselaw/e2e-utils.ts +++ b/frontend/test/e2e/caselaw/e2e-utils.ts @@ -154,9 +154,61 @@ export async function fillPreviousDecisionInputs( if (!(await dateUnknownCheckbox.isChecked())) { await dateUnknownCheckbox.click() await expect(dateUnknownCheckbox).toBeChecked() + } + } +} + +export async function fillEnsuingDecisionInputs( + page: Page, + values?: { + pending?: boolean + court?: string + decisionDate?: string + fileNumber?: string + documentType?: string + note?: string + }, + decisionIndex = 0, +): Promise { + const fillInput = async (ariaLabel: string, value = generateString()) => { + const input = page.locator(`[aria-label='${ariaLabel}']`).nth(decisionIndex) + await input.fill(value ?? ariaLabel) + await waitForInputValue(page, `[aria-label='${ariaLabel}']`, value) + } + + if (values?.court) { + await fillInput("Gericht Nachgehende Entscheidung", values?.court) + await page.getByText(values.court, { exact: true }).click() + await waitForInputValue( + page, + "[aria-label='Gericht Nachgehende Entscheidung']", + values.court, + ) + } + if (values?.decisionDate) { + await fillInput( + "Entscheidungsdatum Nachgehende Entscheidung", + values?.decisionDate, + ) + } + if (values?.fileNumber) { + await fillInput("Aktenzeichen Nachgehende Entscheidung", values?.fileNumber) + } + if (values?.documentType) { + await fillInput( + "Dokumenttyp Nachgehende Entscheidung", + values?.documentType, + ) + await page.locator("[aria-label='dropdown-option']").first().click() + } + if (values?.pending) { + const pendingCheckbox = page.getByLabel("Anhängige Entscheidung") + if (!(await pendingCheckbox.isChecked())) { + await pendingCheckbox.click() + await expect(pendingCheckbox).toBeChecked() await waitForInputValue( page, - "[aria-label='Entscheidungsdatum Vorgehende Entscheidung']", + "[aria-label='Entscheidungsdatum Nachgehende Entscheidung']", "", ) }