Skip to content

Commit f032a1e

Browse files
committed
Moved attendence methods into new AppointmentAttendance class and updated tests accordingly
1 parent 360e0fd commit f032a1e

File tree

3 files changed

+77
-76
lines changed

3 files changed

+77
-76
lines changed

tests/regression/regression_tests/fobt_regression_tests/test_scenario_5.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from pages.screening_subject_search.record_diagnosis_date_page import (
2222
RecordDiagnosisDatePage,
2323
)
24-
from utils.appointments import mark_appointment_as_dna
24+
from utils.appointments import AppointmentAttendance
2525

2626

2727
@pytest.mark.usefixtures("setup_org_and_appointments")
@@ -61,6 +61,7 @@ def test_scenario_5(page: Page) -> None:
6161
"""
6262

6363
summary_page = SubjectScreeningSummaryPage(page)
64+
attendance = AppointmentAttendance(page)
6465
logging.info(
6566
"[TEST START] Regression - Scenario: 5: DNA colonoscopy assessment twice"
6667
)
@@ -227,7 +228,7 @@ def test_scenario_5(page: Page) -> None:
227228
# And I view the event history for the subject's latest episode
228229
# And I view the latest practitioner appointment in the subject's episode
229230
# And The subject DNAs the practitioner appointment
230-
mark_appointment_as_dna(page, "Patient did not attend")
231+
attendance.mark_as_dna("Patient did not attend")
231232

232233
# And there is a "J11" letter batch for my subject with the exact title "Practitioner Clinic 1st Appointment Non Attendance (Patient)"
233234
# When I process the open "J11" letter batch for my subject
@@ -278,7 +279,7 @@ def test_scenario_5(page: Page) -> None:
278279
# And I view the event history for the subject's latest episode
279280
# And I view the latest practitioner appointment in the subject's episode
280281
# And The subject DNAs the practitioner appointment
281-
mark_appointment_as_dna(page, "Patient did not attend")
282+
attendance.mark_as_dna("Patient did not attend")
282283

283284
# Then my subject has been updated as follows:
284285
subject_assertion(

tests/regression/regression_tests/fobt_regression_tests/test_scenario_6.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from pages.screening_subject_search.record_diagnosis_date_page import (
2222
RecordDiagnosisDatePage,
2323
)
24-
from utils.appointments import mark_appointment_as_dna, mark_appointment_as_attended
24+
from utils.appointments import AppointmentAttendance
2525

2626

2727
@pytest.mark.wip
@@ -69,6 +69,7 @@ def test_scenario_6(page: Page) -> None:
6969
"""
7070

7171
summary_page = SubjectScreeningSummaryPage(page)
72+
attendance = AppointmentAttendance(page)
7273
logging.info(
7374
"[TEST START] Regression - Scenario: 6: Non-agreement to diagnostic tests"
7475
)
@@ -235,7 +236,7 @@ def test_scenario_6(page: Page) -> None:
235236
# And I view the event history for the subject's latest episode
236237
# And I view the latest practitioner appointment in the subject's episode
237238
# And The Screening Centre DNAs the practitioner appointment
238-
mark_appointment_as_dna(page, "Screening Centre did not attend") # TODO: Line 1188
239+
attendance.mark_as_dna("Screening Centre did not attend")
239240

240241
# Then my subject has been updated as follows:
241242
subject_assertion(
@@ -269,7 +270,7 @@ def test_scenario_6(page: Page) -> None:
269270
)
270271

271272
# And there is a "J30" letter batch for my subject with the exact title "Practitioner Clinic 1st Appointment Non Attendance (Screening Centre)"
272-
# When I process the open "J30" letter batch for my subject TODO: Line 1203
273+
# When I process the open "J30" letter batch for my subject
273274
# Then my subject has been updated as follows:
274275
batch_processing(
275276
page,
@@ -298,7 +299,7 @@ def test_scenario_6(page: Page) -> None:
298299
# And I save Diagnosis Date Information
299300
RecordDiagnosisDatePage(page).click_save_button()
300301

301-
# Then my subject has been updated as follows: TODO: line 1215
302+
# Then my subject has been updated as follows: TODO: Selenium Feature File line 1215
302303
subject_assertion(
303304
nhs_no,
304305
{
@@ -320,7 +321,7 @@ def test_scenario_6(page: Page) -> None:
320321
# And I view the event history for the subject's latest episode
321322
# And I view the latest practitioner appointment in the subject's episode
322323
# And I attend the subject's practitioner appointment "today"
323-
mark_appointment_as_attended(page)
324+
attendance.mark_as_attended()
324325

325326
# Then my subject has been updated as follows:
326327
subject_assertion(

utils/appointments.py

Lines changed: 67 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from pages.screening_practitioner_appointments.book_appointment_page import (
1515
BookAppointmentPage,
1616
)
17-
from pages.screening_subject_search import subject_screening_summary_page
1817
from utils.calendar_picker import CalendarPicker
1918
from utils.user_tools import UserTools
2019
from datetime import datetime
@@ -133,81 +132,81 @@ def book_appointments(page: Page, screening_centre: str, site: str) -> None:
133132
)
134133

135134

136-
def mark_appointment_as_dna(page: Page, non_attendance_reason: str) -> None:
137-
"""
138-
Marks an appointment as DNA (Did Not Attend)
139-
This process starts from the subject screening summary page.
140-
141-
This method navigates through the subject's episode and appointment pages,
142-
selects the 'Attendance' radio option, and sets the given DNA reason.
143-
144-
Args:
145-
page (Page): Playwright page object.
146-
non_attendance_reason (str): Reason for non-attendance. Must match one of the following:
147-
- "Patient did not attend"
148-
- "Screening Centre did not attend"
149-
- "Patient and Screening Centre did not attend"
150-
151-
Raises:
152-
AssertionError: If expected elements are not found or interaction fails.
153-
"""
154-
appointment_detail_page = AppointmentDetailPage(page)
155-
subject_screening_summary_page = SubjectScreeningSummaryPage(page)
156-
episode_events_and_notes_page = EpisodeEventsAndNotesPage(page)
157-
158-
logging.info(
159-
f"[APPOINTMENT DNA] Starting DNA flow with reason: {non_attendance_reason}"
160-
)
161-
subject_screening_summary_page.click_list_episodes()
162-
subject_screening_summary_page.click_view_events_link()
163-
episode_events_and_notes_page.click_most_recent_view_appointment_link()
164-
appointment_detail_page.check_attendance_radio()
165-
page.locator("#UI_NON_ATTENDANCE_REASON").select_option(label=non_attendance_reason)
166-
appointment_detail_page.click_save_button(accept_dialog=True)
167-
168-
logging.info("[APPOINTMENT DNA] DNA flow completed successfully")
135+
class AppointmentAttendance:
136+
def __init__(self, page: Page):
137+
self.page = page
138+
self.appointment_detail_page = AppointmentDetailPage(page)
139+
self.subject_screening_summary_page = SubjectScreeningSummaryPage(page)
140+
self.episode_events_and_notes_page = EpisodeEventsAndNotesPage(page)
141+
142+
def mark_as_dna(self, non_attendance_reason: str) -> None:
143+
"""
144+
Marks an appointment as DNA (Did Not Attend)
145+
This process starts from the subject screening summary page.
146+
147+
This method navigates through the subject's episode and appointment pages,
148+
selects the 'Attendance' radio option, and sets the given DNA reason.
149+
150+
Args:
151+
page (Page): Playwright page object.
152+
non_attendance_reason (str): Reason for non-attendance. Must match one of the following:
153+
- "Patient did not attend"
154+
- "Screening Centre did not attend"
155+
- "Patient and Screening Centre did not attend"
156+
157+
Raises:
158+
AssertionError: If expected elements are not found or interaction fails.
159+
"""
160+
logging.info(
161+
f"[APPOINTMENT DNA] Starting DNA flow with reason: {non_attendance_reason}"
162+
)
163+
self.subject_screening_summary_page.click_list_episodes()
164+
self.subject_screening_summary_page.click_view_events_link()
165+
self.episode_events_and_notes_page.click_most_recent_view_appointment_link()
166+
self.appointment_detail_page.check_attendance_radio()
167+
self.page.locator("#UI_NON_ATTENDANCE_REASON").select_option(
168+
label=non_attendance_reason
169+
)
170+
self.appointment_detail_page.click_save_button(accept_dialog=True)
169171

172+
logging.info("[APPOINTMENT DNA] DNA flow completed successfully")
170173

171-
def mark_appointment_as_attended(page: Page) -> None:
172-
"""
173-
Marks an appointment as attended and logs the auto-filled attendance details.
174-
This process starts from the subject screening summary page.
174+
def mark_as_attended(self) -> None:
175+
"""
176+
Marks an appointment as attended and logs the auto-filled attendance details.
177+
This process starts from the subject screening summary page.
175178
176-
This method navigates through the subject's episode and appointment pages,
177-
selects the 'Attendance' radio option, checks the 'Attended' checkbox,
178-
and logs the resulting date and time values.
179+
This method navigates through the subject's episode and appointment pages,
180+
selects the 'Attendance' radio option, checks the 'Attended' checkbox,
181+
and logs the resulting date and time values.
179182
180-
Args:
181-
page (Page): Playwright page object.
183+
Args:
184+
page (Page): Playwright page object.
182185
183-
Raises:
184-
AssertionError: If expected elements are not found or interaction fails.
185-
"""
186-
appointment_detail_page = AppointmentDetailPage(page)
187-
subject_screening_summary_page = SubjectScreeningSummaryPage(page)
188-
episode_events_and_notes_page = EpisodeEventsAndNotesPage(page)
189-
190-
logging.info("[APPOINTMENT ATTENDED] Starting attended flow")
186+
Raises:
187+
AssertionError: If expected elements are not found or interaction fails.
188+
"""
189+
logging.info("[APPOINTMENT ATTENDED] Starting attended flow")
191190

192-
subject_screening_summary_page.click_list_episodes()
193-
subject_screening_summary_page.click_view_events_link()
194-
episode_events_and_notes_page.click_most_recent_view_appointment_link()
195-
appointment_detail_page.check_attendance_radio()
191+
self.subject_screening_summary_page.click_list_episodes()
192+
self.subject_screening_summary_page.click_view_events_link()
193+
self.episode_events_and_notes_page.click_most_recent_view_appointment_link()
194+
self.appointment_detail_page.check_attendance_radio()
196195

197-
# Check the 'Attended' checkbox
198-
attended_checkbox = page.locator("#UI_ATTENDED")
199-
attended_checkbox.check()
196+
# Check the 'Attended' checkbox
197+
attended_checkbox = self.page.locator("#UI_ATTENDED")
198+
attended_checkbox.check()
200199

201-
# Log the auto-filled attendance details
202-
attended_date = page.locator("#UI_ATTENDED_DATE").input_value()
203-
time_from = page.locator("#UI_ATTENDED_TIME_FROM").input_value()
204-
time_to = page.locator("#UI_ATTENDED_TIME_TO").input_value()
205-
meeting_mode = page.locator("#UI_NEW_MEETING_MODE").input_value()
200+
# Log the auto-filled attendance details
201+
attended_date = self.page.locator("#UI_ATTENDED_DATE").input_value()
202+
time_from = self.page.locator("#UI_ATTENDED_TIME_FROM").input_value()
203+
time_to = self.page.locator("#UI_ATTENDED_TIME_TO").input_value()
204+
meeting_mode = self.page.locator("#UI_NEW_MEETING_MODE").input_value()
206205

207-
logging.info(
208-
f"[APPOINTMENT ATTENDED] How Attended: {meeting_mode}, Date: {attended_date}, Time From: {time_from}, Time To: {time_to}"
209-
)
206+
logging.info(
207+
f"[APPOINTMENT ATTENDED] How Attended: {meeting_mode}, Date: {attended_date}, Time From: {time_from}, Time To: {time_to}"
208+
)
210209

211-
appointment_detail_page.click_save_button(accept_dialog=True)
210+
self.appointment_detail_page.click_save_button(accept_dialog=True)
212211

213-
logging.info("[APPOINTMENT ATTENDED] Attended flow completed successfully")
212+
logging.info("[APPOINTMENT ATTENDED] Attended flow completed successfully")

0 commit comments

Comments
 (0)