11import pytest
22from playwright .sync_api import Page , expect
3+
4+ from pages .reports_page import ReportsPage
35from utils .click_helper import click
46from pages import reports_page
57from pages .base_page import BasePage
68from utils .user_tools import UserTools
9+ from utils .date_time_utils import DateTimeUtils
710
811
912@pytest .fixture (scope = "function" , autouse = True )
@@ -29,27 +32,27 @@ def test_reports_page_navigation(page: Page) -> None:
2932 expect (page .get_by_text ("Bureau Reports" )).to_be_visible ()
3033
3134 # Failsafe reports page opens as expected
32- reports_page .go_to_failsafe_reports_page (page )
35+ ReportsPage ( page ) .go_to_failsafe_reports_page ()
3336 expect (page .locator ("#ntshPageTitle" )).to_contain_text ("Failsafe Reports" )
3437 click (page , page .get_by_role ("link" , name = "Back" ))
3538
3639 # Operational reports page opens as expected
37- reports_page .go_to_operational_reports_page (page )
40+ ReportsPage ( page ) .go_to_operational_reports_page ()
3841 expect (page .locator ("#ntshPageTitle" )).to_contain_text ("Operational Reports" )
3942 click (page , page .get_by_role ("link" , name = "Back" ))
4043
4144 # Strategic reports page opens as expected
42- reports_page .go_to_strategic_reports_page (page )
45+ ReportsPage ( page ) .go_to_strategic_reports_page ()
4346 expect (page .locator ("#ntshPageTitle" )).to_contain_text ("Strategic Reports" )
4447 click (page , page .get_by_role ("link" , name = "Back" ))
4548
4649 # "Cancer waiting times reports" page opens as expected
47- reports_page .go_to_cancer_waiting_times_reports_page (page )
50+ ReportsPage ( page ) .go_to_cancer_waiting_times_reports_page ()
4851 expect (page .locator ("#ntshPageTitle" )).to_contain_text ("Cancer Waiting Times Reports" )
4952 click (page , page .get_by_role ("link" , name = "Back" ))
5053
5154 # Dashboard opens as expected TODO - this step may be failing legitimately
52- # reports_page .go_to_dashboard(page)
55+ # ReportsPage(page) .go_to_dashboard(page)
5356 # expect(page.locator("#ntshPageTitle")).to_contain_text("Dashboard")
5457 # click(page, page.get_by_role("link", name="Back")
5558
@@ -68,10 +71,10 @@ def test_failsafe_reports_date_report_last_requested(page: Page) -> None:
6871 and the timestamp updates to current date and time when refreshed
6972 """
7073 # Go to failsafe reports page
71- reports_page .go_to_failsafe_reports_page (page )
74+ ReportsPage ( page ) .go_to_failsafe_reports_page ()
7275
7376 # Click 'date report last requested' link
74- reports_page .go_to_date_report_last_requested_page (page )
77+ ReportsPage ( page ) .go_to_date_report_last_requested_page ()
7578
7679 # Verify 'Date Report Last Requested' is the page title
7780 expect (page .locator ("#ntshPageTitle" )).to_contain_text ("Date Report Last Requested" )
@@ -80,14 +83,14 @@ def test_failsafe_reports_date_report_last_requested(page: Page) -> None:
8083 click (page , page .get_by_role ("button" , name = "Generate Report" ))
8184
8285 # Verify timestamp has updated (equals current date and time)
83- report_timestamp = reports_page .report_timestamp_date_format ()
86+ report_timestamp = DateTimeUtils .report_timestamp_date_format ()
8487 expect (page .locator ("b" )).to_contain_text (report_timestamp )
8588
8689 # Click 'refresh' button
8790 click (page , page .get_by_role ("button" , name = "Refresh" ))
8891
8992 # Verify timestamp has updated (equals current date and time)
90- report_timestamp = reports_page .report_timestamp_date_format ()
93+ report_timestamp = DateTimeUtils .report_timestamp_date_format ()
9194 expect (page .locator ("b" )).to_contain_text (report_timestamp )
9295
9396
@@ -99,10 +102,10 @@ def test_failsafe_reports_screening_subjects_with_inactive_open_episode(page: Pa
99102 nhs_number_link = page .get_by_role ("cell" , name = "7652" )
100103
101104 # Go to failsafe reports page
102- reports_page .go_to_failsafe_reports_page (page )
105+ ReportsPage ( page ) .go_to_failsafe_reports_page ()
103106
104107 # Click screening subjects with inactive open episode link
105- reports_page .go_to_screening_subjects_with_inactive_open_episode_link_page (page )
108+ ReportsPage ( page ) .go_to_screening_subjects_with_inactive_open_episode_link_page ()
106109
107110 # Verify "Screening Subjects With Inactive Open Episode" is the page title
108111 expect (page .locator ("#page-title" )).to_contain_text ("Screening Subjects With Inactive Open Episode" )
@@ -129,10 +132,10 @@ def test_failsafe_reports_subjects_ceased_due_to_date_of_birth_changes(page: Pag
129132 timestamp = page .locator ("#displayGenerateDate > tbody > tr > td > b" )
130133
131134 # Go to failsafe reports page
132- reports_page .go_to_failsafe_reports_page (page )
135+ ReportsPage ( page ) .go_to_failsafe_reports_page ()
133136
134137 # Click on "Subjects Ceased Due to Date Of Birth Changes" link
135- reports_page .go_to_subjects_ceased_due_to_date_of_birth_changes_page (page )
138+ ReportsPage ( page ) .go_to_subjects_ceased_due_to_date_of_birth_changes_page ()
136139
137140 # Select a "report start date" from the calendar
138141 click (page , page .get_by_role ("button" , name = "Calendar" ))
@@ -143,7 +146,7 @@ def test_failsafe_reports_subjects_ceased_due_to_date_of_birth_changes(page: Pag
143146 click (page , page .get_by_role ("button" , name = "Generate Report" ))
144147
145148 # Verify timestamp has updated to current date and time
146- report_timestamp = reports_page .report_timestamp_date_format ()
149+ report_timestamp = DateTimeUtils .report_timestamp_date_format ()
147150 expect (timestamp ).to_contain_text (report_timestamp )
148151
149152 # Open a screening subject record from the search results
@@ -166,10 +169,10 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundarie
166169 coventry_and_warwickshire_bcs_centre = "23643"
167170
168171 # Go to failsafe reports page
169- reports_page .go_to_failsafe_reports_page (page )
172+ ReportsPage ( page ) .go_to_failsafe_reports_page ()
170173
171174 # Click on the "Allocate SC for Patient Movements within Hub Boundaries" link
172- reports_page .go_to_allocate_sc_for_patient_movements_within_hub_boundaries_page (page )
175+ ReportsPage ( page ) .go_to_allocate_sc_for_patient_movements_within_hub_boundaries_page ()
173176
174177 # Verify page title is "Allocate SC for Patient Movements within Hub Boundaries"
175178 expect (page .locator ("#ntshPageTitle" )).to_contain_text ("Allocate SC for Patient Movements within Hub Boundaries" )
@@ -178,7 +181,7 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_within_hub_boundarie
178181 click (page , page .get_by_role ("button" , name = "Generate Report" ))
179182
180183 # Verify timestamp has updated to current date and time
181- report_timestamp = reports_page .report_timestamp_date_format ()
184+ report_timestamp = DateTimeUtils .report_timestamp_date_format ()
182185 expect (page .locator ("b" )).to_contain_text (report_timestamp )
183186
184187 # Open a screening subject record from the first row/first cell of the table
@@ -204,10 +207,10 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_into_your_hub(page:
204207 the timestamp updates to current date and time when refreshed
205208 """
206209 # Go to failsafe reports page
207- reports_page .go_to_failsafe_reports_page (page )
210+ ReportsPage ( page ) .go_to_failsafe_reports_page ()
208211
209212 # Click on "allocate sc for patient movements into your hub" link
210- reports_page .go_to_allocate_sc_for_patient_movements_into_your_hub_page (page )
213+ ReportsPage ( page ) .go_to_allocate_sc_for_patient_movements_into_your_hub_page ()
211214
212215 # Verify page title is "Date Report Last Requested"
213216 expect (page .locator ("#ntshPageTitle" )).to_contain_text ("Allocate SC for Patient Movements into your Hub" )
@@ -216,14 +219,14 @@ def test_failsafe_reports_allocate_sc_for_patient_movements_into_your_hub(page:
216219 click (page , page .get_by_role ("button" , name = "Generate Report" ))
217220
218221 # Verify timestamp has updated to current date and time
219- report_timestamp = reports_page .report_timestamp_date_format ()
222+ report_timestamp = DateTimeUtils .report_timestamp_date_format ()
220223 expect (page .locator ("b" )).to_contain_text (report_timestamp )
221224
222225 # Click "Refresh" button
223226 click (page , page .get_by_role ("button" , name = "Refresh" ))
224227
225228 # Verify timestamp has updated to current date and time
226- report_timestamp = reports_page .report_timestamp_date_format ()
229+ report_timestamp = DateTimeUtils .report_timestamp_date_format ()
227230 expect (page .locator ("b" )).to_contain_text (report_timestamp )
228231
229232
@@ -239,10 +242,10 @@ def test_failsafe_reports_identify_and_link_new_gp(page: Page) -> None:
239242 nhs_number_link = page .locator ("//*[@id='listReportDataTable']/tbody/tr[3]/td[2]" )
240243
241244 # Go to failsafe reports page
242- reports_page .go_to_failsafe_reports_page (page )
245+ ReportsPage ( page ) .go_to_failsafe_reports_page ()
243246
244247 # Click on "Identify and link new GP" link
245- reports_page .go_to_identify_and_link_new_gp_page (page )
248+ ReportsPage ( page ) .go_to_identify_and_link_new_gp_page ()
246249
247250 # Verify page title is "Identify and link new GP practices"
248251 expect (page .locator ("#ntshPageTitle" )).to_contain_text ("Identify and link new GP practices" )
@@ -251,14 +254,14 @@ def test_failsafe_reports_identify_and_link_new_gp(page: Page) -> None:
251254 click (page , page .get_by_role ("button" , name = "Generate Report" ))
252255
253256 # Verify timestamp has updated to current date and time
254- report_timestamp = reports_page .report_timestamp_date_format ()
257+ report_timestamp = DateTimeUtils .report_timestamp_date_format ()
255258 expect (page .locator ("b" )).to_contain_text (report_timestamp )
256259
257260 # Click "Refresh" button
258261 click (page , page .get_by_role ("button" , name = "Refresh" ))
259262
260263 # Verify timestamp has updated to current date and time
261- report_timestamp = reports_page .report_timestamp_date_format ()
264+ report_timestamp = DateTimeUtils .report_timestamp_date_format ()
262265 expect (page .locator ("b" )).to_contain_text (report_timestamp )
263266
264267 # Open a screening subject record from the first row/second cell of the table
@@ -282,10 +285,10 @@ def test_operational_reports_appointment_attendance_not_updated(page: Page) -> N
282285 nhs_number_link = page .locator ("#listReportDataTable > tbody > tr:nth-child(3) > td:nth-child(1) > a" )
283286
284287 # Go to operational reports page
285- reports_page .go_to_operational_reports_page (page )
288+ ReportsPage ( page ) .go_to_operational_reports_page ()
286289
287290 # Go to "appointment attendance not updated" report page
288- reports_page .go_to_appointment_attendance_not_updated_page (page )
291+ ReportsPage ( page ) .go_to_appointment_attendance_not_updated_page ()
289292
290293 # Verify page title is "Appointment Attendance Not Updated"
291294 expect (page .locator ("#ntshPageTitle" )).to_contain_text ("Appointment Attendance Not Updated" )
@@ -297,7 +300,7 @@ def test_operational_reports_appointment_attendance_not_updated(page: Page) -> N
297300 click (page , page .get_by_role ("button" , name = "Generate Report" ))
298301
299302 # Verify timestamp has updated to current date and time
300- report_timestamp = reports_page .report_timestamp_date_format ()
303+ report_timestamp = DateTimeUtils .report_timestamp_date_format ()
301304 expect (page .locator ("b" )).to_contain_text (report_timestamp )
302305
303306 # Open an appointment record from the report
@@ -314,10 +317,10 @@ def test_operational_reports_fobt_kits_logged_but_not_read(page: Page) -> None:
314317 the timestamp updates to current date and time when refreshed
315318 """
316319 # Go to operational reports page
317- reports_page .go_to_operational_reports_page (page )
320+ ReportsPage ( page ) .go_to_operational_reports_page ()
318321
319322 # Go to "FOBT Kits Logged but Not Read" page
320- reports_page .go_to_fobt_kits_logged_but_not_read_page (page )
323+ ReportsPage ( page ) .go_to_fobt_kits_logged_but_not_read_page ()
321324
322325 # Verify page title is "FOBT Kits Logged but Not Read - Summary View"
323326 expect (page .locator ("#page-title" )).to_contain_text ("FOBT Kits Logged but Not Read - Summary View" )
@@ -326,7 +329,7 @@ def test_operational_reports_fobt_kits_logged_but_not_read(page: Page) -> None:
326329 click (page , page .get_by_role ("button" , name = "Refresh" ))
327330
328331 # Verify timestamp has updated to current date and time
329- report_timestamp = reports_page .fobt_kits_logged_but_not_read_report_timestamp_date_format ()
332+ report_timestamp = DateTimeUtils .fobt_kits_logged_but_not_read_report_timestamp_date_format ()
330333 expect (page .locator ("#report-generated" )).to_contain_text (f"Report generated on { report_timestamp } ." )
331334
332335
@@ -337,10 +340,10 @@ def test_operational_reports_demographic_update_inconsistent_with_manual_update(
337340 the timestamp updates to current date and time when refreshed
338341 """
339342 # Go to operational reports page
340- reports_page .go_to_operational_reports_page (page )
343+ ReportsPage ( page ) .go_to_operational_reports_page ()
341344
342345 # Go to "Demographic Update Inconsistent With Manual Update" page
343- reports_page .go_to_demographic_update_inconsistent_with_manual_update_page (page )
346+ ReportsPage ( page ) .go_to_demographic_update_inconsistent_with_manual_update_page ()
344347
345348 # Verify page title is "Demographic Update Inconsistent With Manual Update"
346349 expect (page .locator ("#page-title" )).to_contain_text ("Demographic Update Inconsistent With Manual Update" )
@@ -357,10 +360,10 @@ def test_operational_reports_screening_practitioner_6_weeks_availability_not_set
357360 coventry_and_warwickshire_bcs_centre = "23643"
358361
359362 # Go to operational reports page
360- reports_page .go_to_operational_reports_page (page )
363+ ReportsPage ( page ) .go_to_operational_reports_page ()
361364
362365 # Go to "Screening Practitioner 6 Weeks Availability Not Set Up" page
363- reports_page .go_to_screening_practitioner_6_weeks_availability_not_set_up_report_page (page )
366+ ReportsPage ( page ) .go_to_screening_practitioner_6_weeks_availability_not_set_up_report_page ()
364367
365368 # Verify page title is "Screening Practitioner 6 Weeks Availability Not Set Up"
366369 expect (page .locator ("#ntshPageTitle" )).to_contain_text ("Screening Practitioner 6 Weeks Availability Not Set Up" )
@@ -372,14 +375,14 @@ def test_operational_reports_screening_practitioner_6_weeks_availability_not_set
372375 click (page , page .get_by_role ("button" , name = "Generate Report" ))
373376
374377 # Verify timestamp has updated to current date and time
375- report_timestamp = reports_page .report_timestamp_date_format ()
378+ report_timestamp = DateTimeUtils .report_timestamp_date_format ()
376379 expect (page .locator ("#displayGenerateDate" )).to_contain_text (report_timestamp )
377380
378381 # Click "Refresh" button
379382 click (page , page .get_by_role ("button" , name = "Refresh" ))
380383
381384 # Verify timestamp has updated to current date and time
382- report_timestamp = reports_page .report_timestamp_date_format ()
385+ report_timestamp = DateTimeUtils .report_timestamp_date_format ()
383386 expect (page .locator ("#displayGenerateDate" )).to_contain_text (report_timestamp )
384387
385388
@@ -395,10 +398,10 @@ def test_operational_reports_screening_practitioner_appointments(page: Page) ->
395398 screening_practitioner_named_another_stubble = "1982"
396399
397400 # Go to operational reports page
398- reports_page .go_to_operational_reports_page (page )
401+ ReportsPage ( page ) .go_to_operational_reports_page ()
399402
400403 # Go to "Screening Practitioner Appointments" page
401- reports_page .go_to_screening_practitioner_appointments_page (page )
404+ ReportsPage ( page ) .go_to_screening_practitioner_appointments_page ()
402405
403406 # Verify page title is "Screening Practitioner Appointments"
404407 expect (page .locator ("#ntshPageTitle" )).to_contain_text ("Screening Practitioner Appointments" )
@@ -413,5 +416,5 @@ def test_operational_reports_screening_practitioner_appointments(page: Page) ->
413416 click (page , page .locator ("#submitThisForm" ))
414417
415418 # Verify timestamp has updated to current date and time
416- report_timestamp = reports_page .screening_practitioner_appointments_report_timestamp_date_format ()
419+ report_timestamp = DateTimeUtils .screening_practitioner_appointments_report_timestamp_date_format ()
417420 expect (page .locator ("b" )).to_contain_text (report_timestamp )
0 commit comments