Skip to content

Commit

Permalink
Adapt all related docunit tests
Browse files Browse the repository at this point in the history
RISDEV-3168
  • Loading branch information
leonie-koch committed Jan 29, 2024
1 parent fd8a3d5 commit 964793b
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 121 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/ActiveCitationInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ watch(
</div>
<TextButton
v-if="!lastModelValue.isEmpty"
aria-label="Aktivzitierung löschen"
aria-label="Eintrag löschen"
button-type="error"
label="Eintrag löschen"
size="small"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/EnsuingDecisionInputGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ onMounted(() => {
</div>
<TextButton
v-if="!lastModelValue.isEmpty"
aria-label="Nachgehende Entscheidung löschen"
aria-label="Eintrag löschen"
button-type="error"
label="Eintrag löschen"
size="small"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/NormReferenceInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ watch(props, () => {
</div>
<TextButton
v-if="!lastModelValue.isEmpty"
aria-label="Norm löschen"
aria-label="Eintrag löschen"
button-type="error"
label="Eintrag löschen"
size="small"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/PreviousDecisionInputGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ onMounted(() => {
</div>
<TextButton
v-if="!lastModelValue.isEmpty"
aria-label="Vorgehende Entscheidung löschen"
aria-label="Eintrag löschen"
button-type="error"
label="Eintrag löschen"
size="small"
Expand Down
51 changes: 26 additions & 25 deletions frontend/test/components/activeCitations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ describe("Active Citations", () => {
}),
],
})
const button = screen.getByLabelText("Eintrag bearbeiten")
await user.click(button)
const itemHeader = screen.getByLabelText("Listen Eintrag")
await user.click(itemHeader)

expect(screen.getByLabelText("Art der Zitierung")).toBeVisible()
expect(
Expand All @@ -223,7 +223,7 @@ describe("Active Citations", () => {
renderComponent({
modelValue: [generateActiveCitation()],
})
expect(screen.getByLabelText("Eintrag bearbeiten")).toBeInTheDocument()
expect(screen.getByLabelText("Listen Eintrag")).toBeInTheDocument()
})

it("correctly updates value citation style input", async () => {
Expand All @@ -241,8 +241,8 @@ describe("Active Citations", () => {

expect(screen.queryByText(/Änderungen/)).not.toBeInTheDocument()

const editButton = screen.getByLabelText("Eintrag bearbeiten")
await user.click(editButton)
const itemHeader = screen.getByLabelText("Listen Eintrag")
await user.click(itemHeader)

await user.type(
await screen.findByLabelText("Art der Zitierung"),
Expand All @@ -264,8 +264,8 @@ describe("Active Citations", () => {

expect(screen.queryByText(/EuGH-Vorlage/)).not.toBeInTheDocument()

const editButton = screen.getByLabelText("Eintrag bearbeiten")
await user.click(editButton)
const itemHeader = screen.getByLabelText("Listen Eintrag")
await user.click(itemHeader)

await user.type(
await screen.findByLabelText("Dokumenttyp der Aktivzitierung"),
Expand All @@ -287,8 +287,8 @@ describe("Active Citations", () => {

expect(screen.queryByText(/AG Test/)).not.toBeInTheDocument()

const editButton = screen.getByLabelText("Eintrag bearbeiten")
await user.click(editButton)
const itemHeader = screen.getByLabelText("Listen Eintrag")
await user.click(itemHeader)

await user.type(
await screen.findByLabelText("Gericht der Aktivzitierung"),
Expand All @@ -309,8 +309,8 @@ describe("Active Citations", () => {
})

expect(screen.queryByText(/new fileNumber/)).not.toBeInTheDocument()
const editButton = screen.getByLabelText("Eintrag bearbeiten")
await user.click(editButton)
const itemHeader = screen.getByLabelText("Listen Eintrag")
await user.click(itemHeader)

const fileNumberInput = await screen.findByLabelText(
"Aktenzeichen Aktivzitierung",
Expand All @@ -330,8 +330,8 @@ describe("Active Citations", () => {
})

expect(screen.queryByText(/02.02.2022/)).not.toBeInTheDocument()
const editButton = screen.getByLabelText("Eintrag bearbeiten")
await user.click(editButton)
const itemHeader = screen.getByLabelText("Listen Eintrag")
await user.click(itemHeader)

const fileNumberInput = await screen.findByLabelText(
"Entscheidungsdatum der Aktivzitierung",
Expand All @@ -351,8 +351,8 @@ describe("Active Citations", () => {
})
const activeCitations = screen.getAllByLabelText("Listen Eintrag")
expect(activeCitations.length).toBe(2)
const buttonList = screen.getAllByLabelText("Eintrag löschen")
await user.click(buttonList[0])
await user.click(activeCitations[0])
await user.click(screen.getByLabelText("Eintrag löschen"))
expect(screen.getAllByLabelText("Listen Eintrag").length).toBe(1)
})

Expand All @@ -364,8 +364,8 @@ describe("Active Citations", () => {
const { user } = renderComponent({ modelValue })
const activeCitations = screen.getAllByLabelText("Listen Eintrag")
expect(activeCitations.length).toBe(2)
const buttonList = screen.getAllByLabelText("Eintrag löschen")
await user.click(buttonList[0])
await user.click(activeCitations[0])
await user.click(screen.getByLabelText("Eintrag löschen"))
expect(screen.getAllByLabelText("Listen Eintrag").length).toBe(1)
})

Expand All @@ -379,8 +379,8 @@ describe("Active Citations", () => {
"Änderungen, label1, 01.02.2022, test fileNumber, documentType1",
),
).toBeInTheDocument()
const editButton = screen.getByLabelText("Eintrag bearbeiten")
await user.click(editButton)
const itemHeader = screen.getByLabelText("Listen Eintrag")
await user.click(itemHeader)

const fileNumberInput = await screen.findByLabelText(
"Aktenzeichen Aktivzitierung",
Expand Down Expand Up @@ -409,7 +409,8 @@ describe("Active Citations", () => {
],
})

await user.click(screen.getByLabelText("Eintrag bearbeiten"))
const itemHeader = screen.getByLabelText("Listen Eintrag")
await user.click(itemHeader)

expect(screen.getByLabelText("Art der Zitierung")).toBeVisible()
;[
Expand Down Expand Up @@ -453,16 +454,16 @@ describe("Active Citations", () => {
it("displays error in list and edit component when fields missing", async () => {
const modelValue: ActiveCitation[] = [generateActiveCitation()]
const { user } = renderComponent({ modelValue })
const editButton = screen.getByLabelText("Eintrag bearbeiten")
await user.click(editButton)
const itemHeader = screen.getByLabelText("Listen Eintrag")
await user.click(itemHeader)

const fileInput = await screen.findByLabelText(
"Aktenzeichen Aktivzitierung",
)
await user.clear(fileInput)
await user.click(screen.getByLabelText("Aktivzitierung speichern"))
expect(screen.getByLabelText(/Fehlerhafte Eingabe/)).toBeInTheDocument()
await user.click(editButton)
await user.click(itemHeader)
expect(screen.getAllByText(/Pflichtfeld nicht befüllt/).length).toBe(1)
})

Expand Down Expand Up @@ -494,8 +495,8 @@ describe("Active Citations", () => {
}),
],
})
const editButton = screen.getByLabelText("Eintrag bearbeiten")
await user.click(editButton)
const itemHeader = screen.getByLabelText("Listen Eintrag")
await user.click(itemHeader)

expect(screen.getByText("Art der Zitierung *")).toBeVisible()
expect(screen.getAllByText(/Pflichtfeld nicht befüllt/).length).toBe(1)
Expand Down
41 changes: 20 additions & 21 deletions frontend/test/components/ensuingDecisions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ describe("EnsuingDecisions", () => {
expect(screen.getAllByLabelText("Listen Eintrag").length).toBe(1)
})

it("click on edit icon, opens the list entry in edit mode", async () => {
it("click on list item, opens the list entry in edit mode", async () => {
const { user } = renderComponent({
modelValue: [
generateEnsuingDecision({
Expand All @@ -197,8 +197,8 @@ describe("EnsuingDecisions", () => {
screen.queryByLabelText("Nachgehende Entscheidung speichern"),
).not.toBeInTheDocument()

const button = screen.getByLabelText("Eintrag bearbeiten")
await user.click(button)
const entryHeader = screen.getByLabelText("Listen Eintrag")
await user.click(entryHeader)

expect(
screen.getByLabelText("Nachgehende Entscheidung speichern"),
Expand All @@ -210,8 +210,8 @@ describe("EnsuingDecisions", () => {
modelValue: [generateEnsuingDecision()],
})

const editButton = screen.getByLabelText("Eintrag bearbeiten")
await user.click(editButton)
const entryHeader = screen.getByLabelText("Listen Eintrag")
await user.click(entryHeader)

const checkbox = await screen.findByLabelText("Anhängige Entscheidung")

Expand All @@ -228,8 +228,8 @@ describe("EnsuingDecisions", () => {

expect(screen.queryByText(/AG Test/)).not.toBeInTheDocument()

const editButton = screen.getByLabelText("Eintrag bearbeiten")
await user.click(editButton)
const entryHeader = screen.getByLabelText("Listen Eintrag")
await user.click(entryHeader)

await user.type(
await screen.findByLabelText("Gericht Nachgehende Entscheidung"),
Expand All @@ -250,8 +250,8 @@ describe("EnsuingDecisions", () => {
})

expect(screen.queryByText(/new fileNumber/)).not.toBeInTheDocument()
const editButton = screen.getByLabelText("Eintrag bearbeiten")
await user.click(editButton)
const entryHeader = screen.getByLabelText("Listen Eintrag")
await user.click(entryHeader)

const fileNumberInput = await screen.findByLabelText(
"Aktenzeichen Nachgehende Entscheidung",
Expand All @@ -271,8 +271,8 @@ describe("EnsuingDecisions", () => {
})

expect(screen.queryByText(/02.02.2022/)).not.toBeInTheDocument()
const editButton = screen.getByLabelText("Eintrag bearbeiten")
await user.click(editButton)
const entryHeader = screen.getByLabelText("Listen Eintrag")
await user.click(entryHeader)

const fileNumberInput = await screen.findByLabelText(
"Entscheidungsdatum Nachgehende Entscheidung",
Expand All @@ -292,8 +292,9 @@ describe("EnsuingDecisions", () => {
})
const proceedingDecisions = screen.getAllByLabelText("Listen Eintrag")
expect(proceedingDecisions.length).toBe(2)
const buttonList = screen.getAllByLabelText("Eintrag löschen")
await user.click(buttonList[0])

await user.click(proceedingDecisions[0])
await user.click(screen.getByLabelText("Eintrag löschen"))
expect(screen.getAllByLabelText("Listen Eintrag").length).toBe(1)
})

Expand All @@ -306,10 +307,8 @@ describe("EnsuingDecisions", () => {
}),
],
})
expect(screen.getByLabelText("Eintrag bearbeiten")).toBeInTheDocument()

const editButton = screen.getByLabelText("Eintrag bearbeiten")
await user.click(editButton)
const entryHeader = screen.getByLabelText("Listen Eintrag")
await user.click(entryHeader)

expect(
screen.queryByLabelText("Anhängige Entscheidung"),
Expand Down Expand Up @@ -338,7 +337,7 @@ describe("EnsuingDecisions", () => {
await user.click(saveButton)
expect(
screen.getByText(
/nachgehend, label1, 01.02.2022, test fileNumber, documentType1, Vermerk, ABC/,
/nachgehend, label1, 01.02.2022, test fileNumber, documentType1, Vermerk/,
),
).toBeInTheDocument()
})
Expand Down Expand Up @@ -373,8 +372,8 @@ describe("EnsuingDecisions", () => {
it("displays error in list and edit component when fields missing", async () => {
const modelValue: EnsuingDecision[] = [generateEnsuingDecision()]
const { user } = renderComponent({ modelValue })
const editButton = screen.getByLabelText("Eintrag bearbeiten")
await user.click(editButton)
const entryHeader = screen.getByLabelText("Listen Eintrag")
await user.click(entryHeader)

const fileInput = await screen.findByLabelText(
"Aktenzeichen Nachgehende Entscheidung",
Expand All @@ -384,7 +383,7 @@ describe("EnsuingDecisions", () => {
screen.getByLabelText("Nachgehende Entscheidung speichern"),
)
expect(screen.getByLabelText(/Fehlerhafte Eingabe/)).toBeInTheDocument()
await user.click(editButton)
await user.click(entryHeader)
expect(screen.getAllByText(/Pflichtfeld nicht befüllt/).length).toBe(1)
})
})
21 changes: 10 additions & 11 deletions frontend/test/components/normReferences.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ describe("Norm references", () => {
]
renderComponent({ modelValue })

expect(screen.getAllByLabelText("Eintrag bearbeiten").length).toBe(2)
expect(screen.getAllByLabelText("Eintrag löschen").length).toBe(2)
expect(screen.getAllByLabelText("Listen Eintrag").length).toBe(2)
expect(
screen.queryByLabelText("RIS-Abkürzung der Norm"),
Expand All @@ -102,7 +100,7 @@ describe("Norm references", () => {
expect(screen.getByText(/§ 345/)).toBeInTheDocument()
})

it("click on edit icon, opens the list entry in edit mode", async () => {
it("click on list item, opens the list entry in edit mode", async () => {
vi.spyOn(documentUnitService, "validateSingleNorm").mockImplementation(() =>
Promise.resolve({ status: 200, data: "Ok" }),
)
Expand All @@ -113,8 +111,8 @@ describe("Norm references", () => {
}),
],
})
const button = screen.getByLabelText("Eintrag bearbeiten")
await user.click(button)
const itemHeader = screen.getByLabelText("Listen Eintrag")
await user.click(itemHeader)

expect(screen.getByLabelText("RIS-Abkürzung der Norm")).toBeInTheDocument()
expect(screen.getByLabelText("Einzelnorm der Norm")).toBeInTheDocument()
Expand All @@ -127,9 +125,10 @@ describe("Norm references", () => {
modelValue: [generateNormReference(), generateNormReference()],
})

expect(screen.getAllByLabelText("Listen Eintrag").length).toBe(2)
const buttonList = screen.getAllByLabelText("Eintrag löschen")
await user.click(buttonList[0])
const norms = screen.getAllByLabelText("Listen Eintrag")
expect(norms.length).toBe(2)
await user.click(norms[0])
await user.click(screen.getByLabelText("Eintrag löschen"))
expect(screen.getAllByLabelText("Listen Eintrag").length).toBe(1)
})

Expand All @@ -154,8 +153,8 @@ describe("Norm references", () => {
]
const { user } = renderComponent({ modelValue })
await screen.findByText(/CDE, 01.02.2022, 2022/)
const editButton = screen.getByLabelText("Eintrag bearbeiten")
await user.click(editButton)
const itemHeader = screen.getByLabelText("Listen Eintrag")
await user.click(itemHeader)

const abbreviationInput = await screen.findByLabelText(
"RIS-Abkürzung der Norm",
Expand All @@ -166,7 +165,7 @@ describe("Norm references", () => {
await user.click(screen.getByLabelText("Norm speichern"))
await screen.findByText(/01.02.2022, 2022/)
expect(screen.getByLabelText(/Fehlerhafte Eingabe/)).toBeInTheDocument()
await user.click(editButton)
await user.click(itemHeader)
expect(screen.getAllByText(/Pflichtfeld nicht befüllt/).length).toBe(1)
})
})
Loading

0 comments on commit 964793b

Please sign in to comment.