Skip to content

Commit a7a1c8f

Browse files
committed
Removeb check schools appear in dropdown
1 parent a3f3904 commit a7a1c8f

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

mavis/test/pages/team/team_schools_page.py

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,33 +65,26 @@ def check_only_expected_schools_visible(
6565
def click_add_new_school_site(self) -> None:
6666
self.add_new_school_site_link.click()
6767

68-
@step("Check only schools associated with the team are visible in the dropdown")
69-
def check_only_expected_schools_visible_in_dropdown(
70-
self, schools: dict[str, list[School]]
71-
) -> None:
72-
expected_school_names = {
73-
school.name for school_list in schools.values() for school in school_list
74-
}
75-
76-
self.page.wait_for_load_state()
77-
hidden_select = self.page.locator("#draft-school-site-urn-field-select")
78-
options = hidden_select.locator("option[value]").all()
79-
80-
actual_school_names = {
81-
option.inner_text().strip().rsplit(" (URN:", 1)[0]
82-
for option in options
83-
if option.get_attribute("value")
84-
}
85-
86-
assert actual_school_names == expected_school_names
87-
8868
@step("Select a school")
8969
def select_school(self, school: School) -> None:
9070
self.page.wait_for_load_state()
9171
self.page.reload() # to allow combobox to be interactable
9272

9373
self.select_a_school_combobox.fill(str(school))
94-
self.page.get_by_role("option", name=str(school)).click()
74+
options = self.page.locator('[class*="app-autocomplete__option"]')
75+
count = options.count()
76+
77+
for i in range(count):
78+
option = options.nth(i)
79+
text = option.inner_text().strip()
80+
first_line = text.split("\n", 1)[0].strip()
81+
location_name = first_line.split(" (URN:", 1)[0]
82+
if location_name == str(school):
83+
option.click()
84+
break
85+
else:
86+
msg = f"No autocomplete option found for location: {school!s}"
87+
raise AssertionError(msg)
9588

9689
self.click_continue()
9790

tests/test_team.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ def test_team_page_add_school_sites(page, log_in_as_nurse, schools):
7777
DashboardPage(page).click_your_team()
7878
TeamContactDetailsPage(page).links.click_schools()
7979
TeamSchoolsPage(page).click_add_new_school_site()
80-
TeamSchoolsPage(page).check_only_expected_schools_visible_in_dropdown(schools)
8180
TeamSchoolsPage(page).select_school(school)
8281
TeamSchoolsPage(page).check_site_details_form(school)
8382
TeamSchoolsPage(page).fill_site_name(new_site_name_1)
@@ -99,7 +98,6 @@ def test_team_page_add_school_sites(page, log_in_as_nurse, schools):
9998
new_site_name_2 = f"{school} (Site C)"
10099
new_site_urn_2 = f"{school.urn}C"
101100

102-
TeamSchoolsPage(page).check_only_expected_schools_visible_in_dropdown(schools)
103101
TeamSchoolsPage(page).select_school(school)
104102
TeamSchoolsPage(page).check_site_details_form(school)
105103
TeamSchoolsPage(page).fill_site_name(new_site_name_2)

0 commit comments

Comments
 (0)