Skip to content

Commit f7cbfdf

Browse files
✅ [#305] test: add tests for zaaktype
1 parent 795b412 commit f7cbfdf

File tree

5 files changed

+5056
-44
lines changed

5 files changed

+5056
-44
lines changed

backend/src/openbeheer/utils/gherkin_e2e.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,17 @@ def user_navigates_to_zaaktype_list_page(self, page: Page) -> None:
217217
button.click()
218218
page.wait_for_load_state("networkidle")
219219

220+
def user_navigates_to_zaaktype_detail_page(
221+
self, page: Page, zaaktype: ZaakTypeWithUUID
222+
) -> None:
223+
"""
224+
Navigates to the zaaktype list page (by navigation)
225+
"""
226+
227+
self.runner.when.user_navigates_to_zaaktype_list_page(page)
228+
page.wait_for_load_state("networkidle")
229+
self.runner.when.user_clicks_on_link(page, str(zaaktype.identificatie))
230+
220231
def user_navigates_to_informatieobjecttype_list_page(
221232
self, page: Page, catalogus: Catalogus
222233
) -> None:
@@ -266,7 +277,6 @@ def user_selects_tab(self, page: Page, name: str = "") -> None:
266277
self.runner.then.url_should_match(page, f"tab={index}")
267278

268279
# Actions
269-
270280
def user_clicks_on_button(self, page: Page, name: str, index: int = 0) -> None:
271281
button = page.get_by_role("button", name=name, exact=True).nth(index)
272282
button.wait_for()
@@ -295,7 +305,7 @@ def user_fills_form_field(
295305
"""
296306
Fills the form field with the given value.
297307
If multiple form fields are found, the field at the given index is filled.
298-
If no index is provided: the the last field is used to accommodate modal forms.
308+
If no index is provided: the last field is used to accommodate modal forms.
299309
"""
300310

301311
# Certain form fields may be shown in a modal that needs some time to load
@@ -304,15 +314,19 @@ def user_fills_form_field(
304314

305315
# Try a (custom) select
306316
selects = page.get_by_role("combobox", name=label)
317+
_index = index if index > -1 else selects.count() - 1
307318
if selects.count():
308-
select = selects.nth(index)
319+
select = selects.nth(_index)
309320
select.click()
310321
option = select.get_by_text(value)
311322
option.click()
312323
return
313324

314325
# Fill (native) input
315-
page.get_by_label(label).nth(index).fill(value)
326+
inputs = page.get_by_label(label)
327+
_index = index if index > -1 else inputs.count() - 1
328+
input = inputs.nth(_index)
329+
input.fill(value)
316330

317331
class Then(GherkinScenario):
318332
"""
@@ -335,16 +349,15 @@ def path_should_be(self, page: Page, path: str) -> None:
335349
# Content
336350

337351
def page_should_contain_text(
338-
self, page: Page, text: str, timeout: int | None = None
352+
self, page: Page, text: str, timeout: int | None = None, index: int = 0
339353
) -> Locator:
354+
page.wait_for_load_state("networkidle")
340355
if timeout is None:
341356
timeout = 500
342357

343-
# Wait for the text to appear in the DOM
344-
page.wait_for_selector(f"text={text}", timeout=timeout)
345-
346358
# Confirm the element with the text is visible
347-
element = page.locator(f"text={text}").nth(0)
359+
element = page.locator(f"text={text}").nth(index)
360+
element.wait_for()
348361
expect(element).to_be_visible(timeout=timeout)
349362
return element
350363

0 commit comments

Comments
 (0)