Skip to content

Commit fca0a62

Browse files
🐛 #290 - fix: fix a bug that could cause the application to show incorrect data on the destruction list detail page if editing mode was closed with filters being active
1 parent a9331fd commit fca0a62

File tree

4 files changed

+72
-6
lines changed

4 files changed

+72
-6
lines changed

backend/src/openarchiefbeheer/destruction/tests/e2e/issues/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# fmt: off
2+
from django.test import tag
3+
4+
from openarchiefbeheer.utils.tests.e2e import browser_page
5+
from openarchiefbeheer.utils.tests.gherkin import GherkinLikeTestCase
6+
7+
from ....constants import ListStatus
8+
9+
10+
@tag("e2e")
11+
class Issue290CancelFilteredEditMode(GherkinLikeTestCase):
12+
async def test_scenario_user_cancels_filtered_edit_mode(self):
13+
async with browser_page() as page:
14+
await self.given.list_exists(
15+
name="Destruction list to edit",
16+
status=ListStatus.new,
17+
uuid="00000000-0000-0000-0000-000000000000",
18+
)
19+
20+
await self.when.record_manager_logs_in(page)
21+
await self.then.path_should_be(page, "/destruction-lists")
22+
23+
await self.when.user_clicks_button(page, "Destruction list to edit")
24+
await self.then.path_should_be(page, "/destruction-lists/00000000-0000-0000-0000-000000000000")
25+
await self.then.page_should_contain_text(page, "Zaak-")
26+
27+
await self.when.user_clicks_button(page, "Bewerken")
28+
await self.then.path_should_be(page, "/destruction-lists/00000000-0000-0000-0000-000000000000?page=1&is_editing=true")
29+
await self.when.user_fills_form_field(page, "Identificatie", "non-matching-identifier", "textbox")
30+
31+
await self.then.url_should_contain_text(page, ".*non-matching-identifier.*")
32+
await self.then.not_.page_should_contain_text(page, "Zaak-")
33+
34+
await self.when.user_clicks_button(page, "Annuleren")
35+
await self.then.path_should_be(page, "/destruction-lists/00000000-0000-0000-0000-000000000000")
36+
await self.then.page_should_contain_text(page, "Zaak-")

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

+34-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import re
2+
13
from asgiref.sync import sync_to_async
24
from playwright.async_api import expect
35

@@ -318,7 +320,7 @@ async def _user_clicks(self, role, page, name, index=0):
318320
await element.wait_for()
319321
await element.click()
320322

321-
async def user_fills_form_field(self, page, label, value):
323+
async def user_fills_form_field(self, page, label, value, role=None):
322324
select = await page.query_selector(f'.mykn-select[title="{label}"]')
323325
if select: # has content so select?
324326
await select.click()
@@ -331,7 +333,11 @@ async def user_fills_form_field(self, page, label, value):
331333

332334
return
333335

334-
locator = page.get_by_label(label)
336+
if role:
337+
locator = page.get_by_label(label).and_(page.get_by_role("textbox"))
338+
else:
339+
locator = page.get_by_label(label)
340+
335341
await locator.fill(value)
336342

337343
class Then:
@@ -348,6 +354,29 @@ class Then:
348354
def __init__(self, testcase):
349355
self.testcase = testcase
350356

357+
@property
358+
def not_(self):
359+
class InvertedThen:
360+
def __init__(self, then):
361+
self.then = then
362+
363+
def __getattr__(self, item):
364+
method = getattr(self.then, item)
365+
366+
async def inverted_method(*args, **kwargs):
367+
try:
368+
await method(*args, **kwargs)
369+
except AssertionError:
370+
return
371+
372+
raise AssertionError(
373+
f'Expected {method.__name__} to raise an AssertionError due to "not_".'
374+
)
375+
376+
return inverted_method
377+
378+
return InvertedThen(self)
379+
351380
async def list_should_have_assignee(self, page, destruction_list, assignee):
352381
@sync_to_async()
353382
def refresh_list():
@@ -379,3 +408,6 @@ async def path_should_be(self, page, path):
379408

380409
async def url_should_be(self, page, url):
381410
await expect(page).to_have_url(url)
411+
412+
async def url_should_contain_text(self, page, text):
413+
await expect(page).to_have_url(re.compile(text))

frontend/src/pages/destructionlist/detail/components/DestructionListEdit/DestructionListEdit.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,8 @@ export function DestructionListEdit() {
6464
*/
6565
const handleEditSetEditing = (value: boolean) => {
6666
urlSearchParams.set("page", "1");
67-
value
68-
? urlSearchParams.set("is_editing", "true")
69-
: urlSearchParams.delete("is_editing");
70-
setUrlSearchParams(urlSearchParams);
67+
urlSearchParams.set("is_editing", "true");
68+
setUrlSearchParams(value ? urlSearchParams : {});
7169
};
7270

7371
/**

0 commit comments

Comments
 (0)