Skip to content

Commit 35f17a1

Browse files
♻️ - refactor: migrate detail process review to BaseListView
1 parent 679154c commit 35f17a1

16 files changed

+354
-877
lines changed

backend/src/openarchiefbeheer/destruction/tests/e2e/features/test_feature_list_process_review.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ async def test_scenario_record_manager_process_review(self):
6060
await self.when.user_clicks_button(page, "Destruction list to process")
6161
await self.then.path_should_be(page, "/destruction-lists/00000000-0000-0000-0000-000000000000")
6262

63-
# TODO
64-
await self.when.user_clicks_checkbox(page, "(de)selecteer rij")
63+
await self.when.user_clicks_button(page, "Muteren")
6564

6665
# Fill selectielijstklasse as it's probably missing.
6766
await self.when.user_clicks_radio(page, "Aanpassen van selectielijstklasse")
@@ -75,7 +74,7 @@ async def test_scenario_record_manager_process_review(self):
7574
await self.when.user_fills_form_field(page, "Reden", "Andere datum")
7675
await self.when.user_clicks_button(page, "muteren")
7776
await self.when.user_clicks_button(page, "Opnieuw indienen")
78-
await self.when.user_fills_form_field(page, "Opmerking", "Datum aangepast")
77+
await self.when.user_fills_form_field(page, "Opmerking", "Datum aangepast", None, 1)
7978
await self.when.user_clicks_button(page, "Opnieuw indienen", 1)
8079
await self.then.path_should_be(page, "/destruction-lists")
8180

backend/src/openarchiefbeheer/utils/tests/gherkin.py

+17-11
Original file line numberDiff line numberDiff line change
@@ -344,25 +344,31 @@ async def _user_clicks(self, role, page, name, index=0):
344344
await element.wait_for()
345345
await element.click()
346346

347-
async def user_fills_form_field(self, page, label, value, role=None):
348-
select = await page.query_selector(f'.mykn-select[title="{label}"]')
349-
if select: # has content so select?
350-
await select.click()
351-
options = await select.query_selector_all(".mykn-option")
347+
async def user_fills_form_field(self, page, label, value, role=None, index=0):
348+
selects = await page.query_selector_all(f'.mykn-select[title="{label}"]')
349+
try:
350+
select = selects[index]
351+
352+
if select: # has content so select?
353+
await select.click()
354+
options = await select.query_selector_all(".mykn-option")
352355

353-
for option in options:
354-
text_content = await option.text_content()
355-
if text_content == value:
356-
return await option.click()
356+
for option in options:
357+
text_content = await option.text_content()
358+
if text_content == value:
359+
return await option.click()
357360

358-
return
361+
return
362+
except IndexError:
363+
pass
359364

360365
if role:
361366
locator = page.get_by_label(label).and_(page.get_by_role("textbox"))
362367
else:
363368
locator = page.get_by_label(label)
364369

365-
await locator.fill(value)
370+
elements = await locator.all()
371+
await elements[index].fill(value)
366372

367373
async def user_filters_zaken(self, page, name, value):
368374
locator = page.get_by_role("textbox", name=name)

frontend/.storybook/playFunctions.ts

-14
Original file line numberDiff line numberDiff line change
@@ -279,20 +279,6 @@ export const fillButtonConfirmationForm: PlayFunction<ReactRenderer> = async (
279279
});
280280
};
281281

282-
/**
283-
* Clicks element at position `elementIndex`, within <tbody> if `inTbody` is truthy.
284-
* Then fills in dialog form, submits if `submitForm` is truthy.
285-
* @param context
286-
*/
287-
export const fillCheckboxConfirmationForm: PlayFunction<ReactRenderer> = async (
288-
context,
289-
) => {
290-
await fillConfirmationForm({
291-
...context,
292-
parameters: { ...context.parameters, checked: true, role: "checkbox" },
293-
});
294-
};
295-
296282
/**
297283
* Clicks element at position `elementIndex`, within <tbody> if `inTbody` is truthy.
298284
* Then fills in dialog form, submits if `submitForm` is truthy.

frontend/src/pages/destructionlist/abstract/BaseListView.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export type BaseListViewProps = React.PropsWithChildren<{
3535
paginatedZaken: PaginatedZaken;
3636
secondaryNavigationItems?: ListTemplateProps["secondaryNavigationItems"];
3737

38-
selectable?: boolean;
38+
// Visible means that no checkboxes appear, but the zaken are marked if selected (via another route).
39+
selectable?: boolean | "visible";
3940
allowSelectAllPages?: boolean;
4041
selectionActions?: ButtonProps[];
4142
initiallySelectedZakenOnPage?: Zaak[];
@@ -164,7 +165,7 @@ export function BaseListView({
164165
fieldsSelectable: true,
165166
pageSize: 100,
166167
showPaginator: true,
167-
selectable: selectable,
168+
selectable: selectable === true,
168169
filterable: true,
169170
tableLayout: "fixed",
170171

frontend/src/pages/destructionlist/detail/DestructionListDetail.stories.tsx

+15-10
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import { ReactRouterDecorator } from "../../../../.storybook/decorators";
66
import {
77
assertColumnSelection,
88
clickButton,
9-
clickElement,
109
fillButtonConfirmationForm,
11-
fillCheckboxConfirmationForm,
1210
fillForm,
1311
} from "../../../../.storybook/playFunctions";
1412
import { auditLogFactory } from "../../../fixtures/auditLog";
@@ -25,7 +23,7 @@ import {
2523
FIXTURE_SELECTIELIJSTKLASSE_CHOICES_MAP,
2624
selectieLijstKlasseFactory,
2725
} from "../../../fixtures/selectieLijstKlasseChoices";
28-
import { usersFactory } from "../../../fixtures/user";
26+
import { userFactory, usersFactory } from "../../../fixtures/user";
2927
import {
3028
clearZaakSelection,
3129
getZaakSelection,
@@ -83,6 +81,12 @@ const meta: Meta<typeof DestructionListDetailPage> = {
8381
status: 200,
8482
response: FIXTURE_SELECTIELIJSTKLASSE_CHOICES,
8583
},
84+
{
85+
url: "http://localhost:8000/api/v1/whoami/?",
86+
method: "GET",
87+
status: 200,
88+
response: userFactory(),
89+
},
8690
],
8791
},
8892
};
@@ -240,10 +244,11 @@ export const ProcessReview: Story = {
240244
},
241245
},
242246
play: async (context) => {
243-
await fillCheckboxConfirmationForm({
247+
await fillButtonConfirmationForm({
244248
...context,
245249
parameters: {
246250
elementIndex: 0,
251+
name: "Muteren",
247252
formValues: {
248253
"Aanpassen van selectielijstklasse": true,
249254
Selectielijstklasse: selectieLijstKlasseFactory()[0].label,
@@ -252,10 +257,11 @@ export const ProcessReview: Story = {
252257
},
253258
});
254259

255-
await fillCheckboxConfirmationForm({
260+
await fillButtonConfirmationForm({
256261
...context,
257262
parameters: {
258263
elementIndex: 1,
264+
name: "Muteren",
259265
formValues: {
260266
"Aanpassen van selectielijstklasse": true,
261267
Selectielijstklasse: selectieLijstKlasseFactory()[1].label,
@@ -264,10 +270,11 @@ export const ProcessReview: Story = {
264270
},
265271
});
266272

267-
await fillCheckboxConfirmationForm({
273+
await fillButtonConfirmationForm({
268274
...context,
269275
parameters: {
270276
elementIndex: 2,
277+
name: "Muteren",
271278
formValues: {
272279
"Aanpassen van selectielijstklasse": true,
273280
Selectielijstklasse: selectieLijstKlasseFactory()[2].label,
@@ -328,12 +335,10 @@ export const CheckSelectielijstklasseSelection: Story = {
328335
},
329336
},
330337
play: async (context) => {
331-
await clickElement({
338+
await clickButton({
332339
...context,
333340
parameters: {
334-
elementIndex: 0,
335-
role: "checkbox",
336-
checked: true,
341+
name: "Muteren",
337342
},
338343
});
339344

Original file line numberDiff line numberDiff line change
@@ -1,31 +1,21 @@
1-
import { CardBaseTemplate } from "@maykin-ui/admin-ui";
21
import React from "react";
32
import { useLoaderData } from "react-router-dom";
43

54
import { DestructionListDetailContext } from "./DestructionListDetail.loader";
65
import { DestructionListEdit } from "./components/DestructionListEdit/DestructionListEdit";
76
import { DestructionListProcessReview } from "./components/DestructionListProcessReview/DestructionListProcessReview";
8-
import { DestructionListToolbar } from "./components/DestructionListToolbar/DestructionListToolbar";
9-
import { useSecondaryNavigation } from "./hooks/useSecondaryNavigation";
107

118
/**
129
* Destruction list detail page
1310
*/
1411
export function DestructionListDetailPage() {
1512
const { destructionList } = useLoaderData() as DestructionListDetailContext;
1613
const isInReview = destructionList.status === "changes_requested";
17-
const secondaryNavigationItems = useSecondaryNavigation();
1814

19-
// TODO: SEPARATE ROUTE?
15+
// TODO: SEPARATE ROUTES?
2016
if (!isInReview) {
2117
return <DestructionListEdit />;
18+
} else {
19+
return <DestructionListProcessReview />;
2220
}
23-
24-
// FIXME: MIGRATE TO NEW APPROACH (NEW URL?)
25-
return (
26-
<CardBaseTemplate secondaryNavigationItems={secondaryNavigationItems}>
27-
<DestructionListToolbar />
28-
<DestructionListProcessReview />
29-
</CardBaseTemplate>
30-
);
3121
}

0 commit comments

Comments
 (0)