@@ -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
0 commit comments