Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions backend/src/openbeheer/utils/gherkin_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,17 @@ def user_navigates_to_zaaktype_list_page(self, page: Page) -> None:
button.click()
page.wait_for_load_state("networkidle")

def user_navigates_to_zaaktype_detail_page(
self, page: Page, zaaktype: ZaakTypeWithUUID
) -> None:
"""
Navigates to the zaaktype list page (by navigation)
"""

self.runner.when.user_navigates_to_zaaktype_list_page(page)
page.wait_for_load_state("networkidle")
self.runner.when.user_clicks_on_link(page, str(zaaktype.identificatie))

def user_navigates_to_informatieobjecttype_list_page(
self, page: Page, catalogus: Catalogus
) -> None:
Expand Down Expand Up @@ -266,7 +277,6 @@ def user_selects_tab(self, page: Page, name: str = "") -> None:
self.runner.then.url_should_match(page, f"tab={index}")

# Actions

def user_clicks_on_button(self, page: Page, name: str, index: int = 0) -> None:
button = page.get_by_role("button", name=name, exact=True).nth(index)
button.wait_for()
Expand Down Expand Up @@ -295,7 +305,7 @@ def user_fills_form_field(
"""
Fills the form field with the given value.
If multiple form fields are found, the field at the given index is filled.
If no index is provided: the the last field is used to accommodate modal forms.
If no index is provided: the last field is used to accommodate modal forms.
"""

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

# Try a (custom) select
selects = page.get_by_role("combobox", name=label)
_index = index if index > -1 else selects.count() - 1
if selects.count():
select = selects.nth(index)
select = selects.nth(_index)
select.click()
option = select.get_by_text(value)
option.click()
return

# Fill (native) input
page.get_by_label(label).nth(index).fill(value)
inputs = page.get_by_label(label)
_index = index if index > -1 else inputs.count() - 1
input = inputs.nth(_index)
input.fill(value)

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

def page_should_contain_text(
self, page: Page, text: str, timeout: int | None = None
self, page: Page, text: str, timeout: int | None = None, index: int = 0
) -> Locator:
page.wait_for_load_state("networkidle")
if timeout is None:
timeout = 500

# Wait for the text to appear in the DOM
page.wait_for_selector(f"text={text}", timeout=timeout)

# Confirm the element with the text is visible
element = page.locator(f"text={text}").nth(0)
element = page.locator(f"text={text}").nth(index)
element.wait_for()
expect(element).to_be_visible(timeout=timeout)
return element

Expand Down
Loading
Loading