11from pathlib import Path
22
3- from playwright .sync_api import Page , expect
3+ from playwright .sync_api import Page
44
5- from mavis .test .annotations import step
65from mavis .test .data import create_child_list_from_file
7- from mavis .test .data_models import Child
86from mavis .test .pages .header_component import HeaderComponent
9- from mavis .test .utils import reload_until_element_is_visible
7+ from mavis .test .pages . search_components import PatientStatusSearchComponent
108
119
1210class ChildrenSearchPage :
1311 def __init__ (self , page : Page ) -> None :
1412 self .page = page
13+ self .search = PatientStatusSearchComponent (page )
1514 self .header = HeaderComponent (page )
1615
17- self .children_heading = self .page .get_by_role (
18- "heading" ,
19- name = "Children" ,
20- exact = True ,
21- )
22- self .children_table_headers = [
23- self .page .get_by_role ("columnheader" , name = header )
24- for header in [
25- "Name and NHS number" ,
26- "Postcode" ,
27- "School" ,
28- "Date of birth" ,
29- ]
30- ]
31-
32- self .search_textbox = self .page .get_by_role ("searchbox" , name = "Search" )
33- self .search_button = self .page .get_by_role ("button" , name = "Search" )
34- self .advanced_filters_link = self .page .get_by_text ("Advanced filters" )
35- self .archived_records_checkbox = self .page .get_by_role (
36- "checkbox" ,
37- name = "Archived records" ,
38- )
39- self .children_aged_out_of_programmes_checkbox = self .page .get_by_role (
40- "checkbox" ,
41- name = "Children aged out of programmes" ,
42- )
43- self .children_missing_an_nhs_number_checkbox = self .page .get_by_role (
44- "checkbox" ,
45- name = "Children missing an NHS number" ,
46- )
47- self .child_record_link = self .page .get_by_role ("link" , name = "Child record" )
48-
49- def verify_headers (self ) -> None :
50- expect (self .children_heading ).to_be_visible ()
51- for header in self .children_table_headers :
52- expect (header ).to_be_visible ()
53-
5416 def verify_list_has_been_uploaded (
5517 self ,
5618 file_path : Path ,
@@ -62,57 +24,4 @@ def verify_list_has_been_uploaded(
6224 is_vaccinations = is_vaccinations ,
6325 )
6426 for child_name in child_names :
65- self .search_with_all_filters_for_child_name (child_name )
66-
67- @step ("Search for child {1}" )
68- def search_for_a_child_name (self , child_name : str ) -> None :
69- self .search_textbox .fill (child_name )
70-
71- with self .page .expect_navigation ():
72- self .search_button .click ()
73-
74- reload_until_element_is_visible (
75- self .page ,
76- self .page .get_by_role ("link" , name = child_name ),
77- )
78-
79- def assert_n_children_found (self , n : int ) -> None :
80- expect (
81- self .page .get_by_role ("heading" , name = f"{ n } child{ 'ren' if n > 1 else '' } " ),
82- ).to_be_visible ()
83-
84- @step ("Click on record for child {1}" )
85- def click_record_for_child (self , child : Child ) -> None :
86- with self .page .expect_navigation ():
87- self .page .get_by_role ("link" , name = str (child )).click ()
88-
89- def search_with_all_filters_for_child_name (self , child_name : str ) -> None :
90- filter_locators = [
91- self .archived_records_checkbox ,
92- self .children_aged_out_of_programmes_checkbox ,
93- self .children_missing_an_nhs_number_checkbox ,
94- ]
95- child_locator = self .page .get_by_role ("link" , name = child_name )
96-
97- self .search_textbox .fill (child_name )
98- self .search_button .click ()
99- self .page .wait_for_load_state ()
100-
101- if not child_locator .is_visible ():
102- for filter_locator in filter_locators :
103- if not filter_locator .is_visible ():
104- self .click_advanced_filters ()
105- filter_locator .check ()
106- self .search_button .click ()
107- self .page .wait_for_load_state ()
108- if child_locator .is_visible ():
109- break
110- filter_locator .uncheck ()
111-
112- @step ("Click on Advanced filters" )
113- def click_advanced_filters (self ) -> None :
114- self .advanced_filters_link .click ()
115-
116- @step ("Check Children aged out of programmes" )
117- def check_children_aged_out_of_programmes (self ) -> None :
118- self .children_aged_out_of_programmes_checkbox .check ()
27+ self .search .search_for_child_name_with_all_filters (child_name )
0 commit comments