Skip to content

Commit 377fd49

Browse files
✅ [#305] test: add tests for zaaktype
1 parent 4c089b7 commit 377fd49

File tree

5 files changed

+5060
-44
lines changed

5 files changed

+5060
-44
lines changed

backend/src/openbeheer/utils/gherkin_e2e.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,17 @@ def user_navigates_to_zaaktype_list_page(self, page: Page) -> None:
212212
button.click()
213213
page.wait_for_load_state("networkidle")
214214

215+
def user_navigates_to_zaaktype_detail_page(
216+
self, page: Page, zaaktype: ZaakTypeWithUUID
217+
) -> None:
218+
"""
219+
Navigates to the zaaktype list page (by navigation)
220+
"""
221+
222+
self.runner.when.user_navigates_to_zaaktype_list_page(page)
223+
page.wait_for_load_state("networkidle")
224+
self.runner.when.user_clicks_on_link(page, str(zaaktype.identificatie))
225+
215226
def user_navigates_to_informatieobjecttype_list_page(
216227
self, page: Page, catalogus: Catalogus
217228
) -> None:
@@ -262,7 +273,10 @@ def user_selects_tab(self, page: Page, name: str = "") -> None:
262273

263274
# Actions
264275

265-
def user_clicks_on_button(self, page: Page, **kwargs) -> None:
276+
def user_clicks_on_button(self, page: Page, name=None, **kwargs) -> None:
277+
if name:
278+
kwargs["name"] = name
279+
266280
button = page.get_by_role("button", **kwargs)
267281
button.wait_for()
268282
button.click()
@@ -290,7 +304,7 @@ def user_fills_form_field(
290304
"""
291305
Fills the form field with the given value.
292306
If multiple form fields are found, the field at the given index is filled.
293-
If no index is provided: the the last field is used to accommodate modal forms.
307+
If no index is provided: the last field is used to accommodate modal forms.
294308
"""
295309

296310
# Certain form fields may be shown in a modal that needs some time to load
@@ -299,15 +313,19 @@ def user_fills_form_field(
299313

300314
# Try a (custom) select
301315
selects = page.get_by_role("combobox", name=label)
316+
_index = index if index > -1 else selects.count() - 1
302317
if selects.count():
303-
select = selects.nth(index)
318+
select = selects.nth(_index)
304319
select.click()
305320
option = select.get_by_text(value)
306321
option.click()
307322
return
308323

309324
# Fill (native) input
310-
page.get_by_label(label).nth(index).fill(value)
325+
inputs = page.get_by_label(label)
326+
_index = index if index > -1 else inputs.count() - 1
327+
input = inputs.nth(_index)
328+
input.fill(value)
311329

312330
class Then(GherkinScenario):
313331
"""
@@ -330,16 +348,15 @@ def path_should_be(self, page: Page, path: str) -> None:
330348
# Content
331349

332350
def page_should_contain_text(
333-
self, page: Page, text: str, timeout: int | None = None
351+
self, page: Page, text: str, timeout: int | None = None, index: int = 0
334352
) -> Locator:
353+
page.wait_for_load_state("networkidle")
335354
if timeout is None:
336355
timeout = 500
337356

338-
# Wait for the text to appear in the DOM
339-
page.wait_for_selector(f"text={text}", timeout=timeout)
340-
341357
# Confirm the element with the text is visible
342-
element = page.locator(f"text={text}").nth(0)
358+
element = page.locator(f"text={text}").nth(index)
359+
element.wait_for()
343360
expect(element).to_be_visible(timeout=timeout)
344361
return element
345362

0 commit comments

Comments
 (0)