Skip to content

Commit

Permalink
✅ FIX broken test.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefrado committed Mar 4, 2025
1 parent 96be0d3 commit f3763d0
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/open_inwoner/search/tests/test_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,24 +308,23 @@ def test_search_with_filters(self):
def _click_checkbox_for_name(page, name):
# Find the details element containing the label with the specific name
details_with_label = page.locator("details.filter").filter(
has=page.get_by_text(name, exact=True)
has=page.get_by_text(name)
)

# If exact match fails, try partial match
if details_with_label.count() == 0:
details_with_label = page.locator("details.filter").filter(
has=page.get_by_text(name)
# Ensure the details element is open
details_with_label.click()

# Find the input element and click it directly
checkbox_input = (
details_with_label.locator(
f"input[type='checkbox'] + label:has-text('{name}')"
)
.locator("..")
.locator("input[type='checkbox']")
)

# Ensure the details element is open
summary = details_with_label.locator("summary")
if not summary.is_visible():
details_with_label.click()

# Find and click the checkbox label
checkbox_label = details_with_label.locator(f"label:has-text('{name}')")
checkbox_label.wait_for(state="visible")
checkbox_label.click()
# Force click the input
checkbox_input.click(force=True)

def _test_search(checkbox_name, expected_text):
page.goto(self.live_reverse("search:search", params={"query": "summary"}))
Expand Down

0 comments on commit f3763d0

Please sign in to comment.