Skip to content

Commit 6f98ab1

Browse files
Add empty states to references page
RISDEV-4639
1 parent 290659f commit 6f98ab1

File tree

6 files changed

+81
-4
lines changed

6 files changed

+81
-4
lines changed

frontend/e2e/amending-law-references.spec.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { test, expect } from "@playwright/test"
22

3-
test("navigate to amending law overview", async ({ page }) => {
3+
test("navigate to amending law references page without selected mods", async ({
4+
page,
5+
}) => {
46
await page.goto("/amending-laws")
57
await page.getByRole("link", { name: "BGBl. I 1002 Nr. 10" }).click()
68
await page.getByRole("link", { name: "Betroffene Normenkomplexe" }).click()
@@ -9,6 +11,34 @@ test("navigate to amending law overview", async ({ page }) => {
911
await expect(page).toHaveURL(
1012
"/amending-laws/eli/bund/bgbl-1/1002/10/1002-01-10/1/deu/regelungstext-1/affected-documents/eli/bund/bgbl-1/1002/1/1002-01-10/1/deu/regelungstext-1/references",
1113
)
14+
15+
await expect(
16+
page.getByText(
17+
"Wählen Sie links einen Änderungsbefehl zur Dokumentation von textbasierten Metadaten aus.",
18+
),
19+
).toBeVisible()
20+
})
21+
22+
test("selects a mod but not references present so it shows the empty state for the ref table", async ({
23+
page,
24+
}) => {
25+
await page.goto(
26+
"/amending-laws/eli/bund/bgbl-1/1002/10/1002-01-10/1/deu/regelungstext-1/affected-documents/eli/bund/bgbl-1/1002/1/1002-01-10/1/deu/regelungstext-1/references",
27+
)
28+
29+
await page
30+
.getByRole("button", { name: /Absatz 2 bis Absatz 3 wird ersetzt durch/ })
31+
.click()
32+
33+
await expect(page).toHaveURL(
34+
"/amending-laws/eli/bund/bgbl-1/1002/10/1002-01-10/1/deu/regelungstext-1/affected-documents/eli/bund/bgbl-1/1002/1/1002-01-10/1/deu/regelungstext-1/references/hauptteil-1_art-1_abs-1_untergl-1_listenelem-6_untergl-1_listenelem-a_inhalt-1_text-1_ändbefehl-1",
35+
)
36+
37+
await expect(
38+
page.getByText(
39+
"Für die ausgewählte Textpassage sind noch keine Verweise dokumentiert. Markieren Sie links Text, um neue Verweise hinzuzufügen.",
40+
),
41+
).toBeVisible()
1242
})
1343

1444
test("handles API call still in progress and disables mod selection", async ({

frontend/src/components/references/RisModRefsEditor.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,29 @@ describe("RisModRefsEditor", () => {
2727
renderError.value = undefined
2828
})
2929

30+
it("Should not render component if no mod was selected", async () => {
31+
const { default: RisModRefsEditor } = await import(
32+
"@/components/references/RisModRefsEditor.vue"
33+
)
34+
35+
render(RisModRefsEditor, {
36+
props: {
37+
normXml: "",
38+
selectedModEId: "",
39+
isSaving: false,
40+
hasSaved: false,
41+
saveError: null,
42+
},
43+
})
44+
45+
await nextTick()
46+
47+
const emptyState = screen.getByText(
48+
"Wählen Sie links einen Änderungsbefehl zur Dokumentation von textbasierten Metadaten aus.",
49+
)
50+
expect(emptyState).toBeInTheDocument()
51+
})
52+
3053
it("Should render the html of the second quotedText of the selected mod", async () => {
3154
vi.doMock("vue-router", () => ({
3255
useRoute: vi.fn().mockReturnValue({

frontend/src/components/references/RisModRefsEditor.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,14 @@ function handleSave() {
117117
/>
118118
<RisEmptyState
119119
v-else
120-
text-content="Wählen sie einen Änderungsbefehl zur Bearbeitung aus."
120+
text-content="Wählen Sie links einen Änderungsbefehl zur Dokumentation von textbasierten Metadaten aus."
121121
/>
122122
</section>
123-
<section aria-labelledby="referencesHeading" class="flex flex-col">
123+
<section
124+
v-if="selectedModQuotedContentXmlString"
125+
aria-labelledby="referencesHeading"
126+
class="flex flex-col"
127+
>
124128
<h3 id="referencesHeading" class="ds-label-02-bold mb-12 block">
125129
Verweise
126130
</h3>

frontend/src/components/references/RisRefEditorTable.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@ import { describe, expect, it } from "vitest"
66
import { nextTick } from "vue"
77

88
describe("RisRefEditorTable", () => {
9+
it("Should not render the ref editor because no akn:ref present in the xml snippet", async () => {
10+
render(RisRefEditorTable, {
11+
props: {
12+
xmlSnippet:
13+
"<akn:quotedText xmlns:akn=\"http://Inhaltsdaten.LegalDocML.de/1.6/\" eId='quot-1'>Render of a ref and a second ref and <akn:p eId='quot-1_p-1'>place for a third ref</akn:p></akn:quotedText>",
14+
},
15+
})
16+
await nextTick()
17+
const emptyState = screen.getByText(
18+
"Für die ausgewählte Textpassage sind noch keine Verweise dokumentiert. Markieren Sie links Text, um neue Verweise hinzuzufügen.",
19+
)
20+
expect(emptyState).toBeInTheDocument()
21+
})
22+
923
it("Should render a ref editor for every akn:ref of the xml snippet", async () => {
1024
render(RisRefEditorTable, {
1125
props: {

frontend/src/components/references/RisRefEditorTable.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
} from "@/services/xmlService"
1111
import { useDebounceFn } from "@vueuse/core"
1212
import { deleteRef } from "@/lib/ref"
13+
import RisEmptyState from "@/components/RisEmptyState.vue"
1314
1415
/**
1516
* The eId of the currently selected akn:ref element.
@@ -78,6 +79,7 @@ function selectNextRef(relativeTo: number) {
7879
<template>
7980
<div>
8081
<div
82+
v-if="refs.length > 0"
8183
class="grid max-h-full grid-cols-[3fr,8fr,max-content] items-center overflow-auto"
8284
>
8385
<div>Typ</div>
@@ -104,5 +106,9 @@ function selectNextRef(relativeTo: number) {
104106
></RefEditor>
105107
</section>
106108
</div>
109+
<RisEmptyState
110+
v-else
111+
text-content="Für die ausgewählte Textpassage sind noch keine Verweise dokumentiert. Markieren Sie links Text, um neue Verweise hinzuzufügen."
112+
/>
107113
</div>
108114
</template>

frontend/src/views/References.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ const breadcrumbs = ref<HeaderBreadcrumb[]>([
174174
</section>
175175

176176
<RisModRefsEditor
177-
v-if="selectedModEId && amendingNormXml"
177+
v-if="amendingNormXml"
178178
:norm-xml="amendingNormXml"
179179
:selected-mod-e-id="selectedModEId"
180180
:eli="amendingNormEli"

0 commit comments

Comments
 (0)