Skip to content

Commit

Permalink
Conditional button display, based on status
Browse files Browse the repository at this point in the history
RISDEV-5139
  • Loading branch information
leonie-koch committed Oct 18, 2024
1 parent c6dda33 commit adfd16a
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 12 deletions.
22 changes: 21 additions & 1 deletion frontend/src/components/DocumentUnitList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import TableView from "@/components/TableView.vue"
import { useStatusBadge } from "@/composables/useStatusBadge"
import { ResponseError } from "@/services/httpClient"
import IconAttachedFile from "~icons/ic/baseline-attach-file"
import IconCheck from "~icons/ic/baseline-check"
import IconDelete from "~icons/ic/baseline-close"
import IconError from "~icons/ic/baseline-error"
import IconSubject from "~icons/ic/baseline-subject"
Expand Down Expand Up @@ -214,7 +215,26 @@ function onDelete() {
</CellItem>
<CellItem class="flex">
<div class="float-end flex">
<Tooltip v-if="listEntry.isEditable" text="Bearbeiten">
<Tooltip
v-if="
listEntry.status?.publicationStatus ==
'EXTERNAL_HANDOVER_PENDING'
"
text="Übernehmen"
>
<router-link
aria-label="Dokumentationseinheit übernehmen"
class="flex cursor-pointer border-2 border-r-0 border-solid border-blue-800 p-4 text-blue-800 hover:bg-blue-200 focus-visible:outline focus-visible:outline-4 focus-visible:outline-offset-4 focus-visible:outline-blue-800 active:border-blue-200 active:bg-blue-200"
target="_blank"
:to="{
name: 'caselaw-documentUnit-documentNumber-categories',
params: { documentNumber: listEntry.documentNumber },
}"
>
<IconCheck />
</router-link>
</Tooltip>
<Tooltip v-else-if="listEntry.isEditable" text="Bearbeiten">
<router-link
aria-label="Dokumentationseinheit bearbeiten"
class="flex cursor-pointer border-2 border-r-0 border-solid border-blue-800 p-4 text-blue-800 hover:bg-blue-200 focus-visible:outline focus-visible:outline-4 focus-visible:outline-offset-4 focus-visible:outline-blue-800 active:border-blue-200 active:bg-blue-200"
Expand Down
31 changes: 31 additions & 0 deletions frontend/test/components/documentUnit/documentUnitList.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,35 @@ describe("documentUnit list", () => {
screen.queryByRole("button", { name: "Dokumentationseinheit löschen" }),
).not.toBeInTheDocument()
})

test("shows 'Übernehmen' icon instead if edit icon, if status equals EXTERNAL_HANDOVER_PENDING", async () => {
renderComponent({
documentUnitListEntries: [
{
id: "id",
uuid: "1",
documentNumber: "123",
decisionDate: "2022-02-10",
fileNumber: "",
documentType: { label: "Test", jurisShortcut: "T" },
court: { type: "typeA", location: "locB", label: "typeA locB" },
status: {
publicationStatus: PublicationState.EXTERNAL_HANDOVER_PENDING,
withError: false,
},
},
],
activeUser: {
name: "fooUser",
documentationOffice: { abbreviation: "fooDocumentationOffice" },
},
})

expect(
screen.queryByRole("link", { name: "Dokumentationseinheit bearbeiten" }),
).not.toBeInTheDocument()
expect(
screen.getByRole("link", { name: "Dokumentationseinheit übernehmen" }),
).toBeInTheDocument()
})
})
40 changes: 29 additions & 11 deletions frontend/test/e2e/caselaw/docunit-creation-from-evaluation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,16 +379,6 @@ test.describe(
).toBeVisible()
})

await test.step("Created documentation unit is not editable for foreign docoffice", async () => {
const url = `/caselaw/documentunit/${documentNumber}/categories`
await getRequest(url, pageWithBghUser)
await expect(
pageWithBghUser.getByText(
"Diese Dokumentationseinheit existiert nicht oder Sie haben keine Berechtigung.",
),
).toBeVisible()
})

await test.step("The new documentation unit is added to the list of references", async () => {
await expect(page.getByLabel("Listen Eintrag")).toHaveCount(2)

Expand All @@ -406,7 +396,7 @@ test.describe(
).toBeVisible()
})

await test.step("The new documentation unit is not visible to creating doc office in search with Fremdanlage status", async () => {
await test.step("Created documentation unit is not visible to creating doc office in search with Fremdanlage status", async () => {
await navigateToSearch(page)

await page.getByLabel("Dokumentnummer Suche").fill(documentNumber)
Expand All @@ -417,6 +407,34 @@ test.describe(
const listEntry = page.getByTestId("listEntry")
await expect(listEntry).toHaveCount(0)
})

await test.step("Created documentation unit is visible with 'Übernehmen' button to foreign doc office in search with Fremdanlage status", async () => {
await navigateToSearch(pageWithBghUser)

await pageWithBghUser
.getByLabel("Dokumentnummer Suche")
.fill(documentNumber)

const select = pageWithBghUser.locator(`select[id="status"]`)
await select.selectOption("Fremdanlage")
await pageWithBghUser
.getByLabel("Nach Dokumentationseinheiten suchen")
.click()
const listEntry = pageWithBghUser.getByTestId("listEntry")
await expect(listEntry).toHaveCount(1)
await expect(
pageWithBghUser.getByLabel("Dokumentationseinheit übernehmen"),
).toBeVisible()
})
await test.step("Created documentation unit is not editable for foreign docoffice, as long as it has not been taken over", async () => {
const url = `/caselaw/documentunit/${documentNumber}/categories`
await getRequest(url, pageWithBghUser)
await expect(
pageWithBghUser.getByText(
"Diese Dokumentationseinheit existiert nicht oder Sie haben keine Berechtigung.",
),
).toBeVisible()
})
} finally {
await deleteDocumentUnit(page, documentNumber)
}
Expand Down

0 comments on commit adfd16a

Please sign in to comment.