Skip to content

Commit

Permalink
Complete e2e tests for import
Browse files Browse the repository at this point in the history
RISDEV-5888

RISDEV-5887
  • Loading branch information
HPrinz committed Jan 3, 2025
1 parent eb4dde6 commit d3bb0e3
Showing 1 changed file with 82 additions and 10 deletions.
92 changes: 82 additions & 10 deletions frontend/test/e2e/caselaw/category-import.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { expect, Page } from "@playwright/test"
import { clickCategoryButton, navigateToCategories, save } from "./e2e-utils"
import {
clickCategoryButton,
fillActiveCitationInputs,
fillNormInputs,
navigateToCategories,
save,
} from "./e2e-utils"
import { caselawTest as test } from "./fixtures"
import SingleNorm from "@/domain/singleNorm"

test.describe("category import", () => {
test(
Expand Down Expand Up @@ -190,7 +197,13 @@ test.describe("category import", () => {
const normContainer = page.getByTestId("norms")

await test.step("import into prefilled category", async () => {
// TODO add norm manually
// add entry manually
await fillNormInputs(page, {
normAbbreviation: "PBefG",
})
await normContainer.getByLabel("Norm speichern").click()
await expect(normContainer.getByText("PBefG")).toBeVisible()

await searchForDocumentUnitToImport(
page,
prefilledDocumentUnit.documentNumber,
Expand All @@ -199,8 +212,12 @@ test.describe("category import", () => {
await expect(page.getByLabel("Normen übernehmen")).toBeVisible()
await page.getByLabel("Normen übernehmen").click()

await expect(page.getByText("BGB")).toBeVisible()
await expect(normContainer.getByLabel("Listen Eintrag")).toHaveCount(2)
await expect(normContainer.getByLabel("Listen Eintrag")).toHaveCount(3) // the last entry is the input field

const correctOrder = ["PBefG", "BGB"]
await expect(
normContainer.getByTestId("editable-list-container"),
).toHaveText(correctOrder.join("") + "RIS-Abkürzung *")
})

await test.step("show success badge", async () => {
Expand All @@ -214,9 +231,19 @@ test.describe("category import", () => {
})

await test.step("do not import duplicates and keep first field of law", async () => {
// TODO add norm manually
// add entry manually
await fillNormInputs(page, {
normAbbreviation: "KBErrG",
singleNorms: [{ singleNorm: "§ 8" } as SingleNorm],
})
await normContainer.getByLabel("Norm speichern").click()

await page.getByLabel("Normen übernehmen").click()
await expect(normContainer.getByLabel("Listen Eintrag")).toHaveCount(2)
await expect(normContainer.getByLabel("Listen Eintrag")).toHaveCount(4) // the last entry is the input field
const correctOrder = ["PBefG", "BGB", "KBErrG, § 8"]
await expect(
normContainer.getByTestId("editable-list-container"),
).toHaveText(correctOrder.join("") + "RIS-Abkürzung *")
})
},
)
Expand All @@ -229,7 +256,17 @@ test.describe("category import", () => {
const activeCitationsContainer = page.getByTestId("activeCitations")

await test.step("import into prefilled category", async () => {
// TODO add active citation manually
// Add active citation to YYTestDoc0014 manually
await fillActiveCitationInputs(page, {
court: "AG Aachen",
decisionDate: "01.01.1989",
citationType: "Abweichung",
})
await activeCitationsContainer
.getByLabel("Nach Entscheidung suchen")
.click()
await page.getByLabel("Treffer übernehmen").click()

await searchForDocumentUnitToImport(
page,
prefilledDocumentUnit.documentNumber,
Expand All @@ -246,7 +283,18 @@ test.describe("category import", () => {

await expect(
activeCitationsContainer.getByLabel("Listen Eintrag"),
).toHaveCount(2)
).toHaveCount(3) // the last entry is the creation form

await expect(
activeCitationsContainer.getByLabel("Listen Eintrag").nth(0),
).toHaveText(
"Abweichung, AG Aachen, 01.01.1989, Beschluss |YYTestDoc0014",
)
await expect(
activeCitationsContainer.getByLabel("Listen Eintrag").nth(1),
).toHaveText(
`Abgrenzung, AG Aachen, 01.02.2022, 123, Anerkenntnisurteil |YYTestDoc0013`,
)
})

await test.step("show success badge", async () => {
Expand All @@ -260,11 +308,35 @@ test.describe("category import", () => {
})

await test.step("do not import duplicates and keep first field of law", async () => {
// TODO add active citation manually
// Add active citation to YYTestDoc0014 manually
await fillActiveCitationInputs(page, {
court: "BGH",
decisionDate: "10.10.1964",
citationType: "Verbunden",
})
await activeCitationsContainer
.getByLabel("Nach Entscheidung suchen")
.click()
await page.getByLabel("Treffer übernehmen").click()

await page.getByLabel("Aktivzitierung übernehmen").click()
await expect(
activeCitationsContainer.getByLabel("Listen Eintrag"),
).toHaveCount(2)
).toHaveCount(4) // the last entry is the creation form

await expect(
activeCitationsContainer.getByLabel("Listen Eintrag").nth(0),
).toHaveText(
"Abweichung, AG Aachen, 01.01.1989, Beschluss |YYTestDoc0014",
)
await expect(
activeCitationsContainer.getByLabel("Listen Eintrag").nth(1),
).toHaveText(
`Abgrenzung, AG Aachen, 01.02.2022, 123, Anerkenntnisurteil |YYTestDoc0013`,
)
await expect(
activeCitationsContainer.getByLabel("Listen Eintrag").nth(2),
).toHaveText(`Verbunden, BGH, 10.10.1964 |YYTestDoc0003`)
})
},
)
Expand Down

0 comments on commit d3bb0e3

Please sign in to comment.