Skip to content

Commit 2d97858

Browse files
committed
Merge branch 'main' into feature/BCSS-20605-regression-tests-subject-notes
# Conflicts: # pages/screening_subject_search/subject_screening_summary_page.py # pytest.ini
2 parents 8d1de67 + 6dcdfef commit 2d97858

File tree

8 files changed

+585
-5
lines changed

8 files changed

+585
-5
lines changed

pages/base_page.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,17 @@ def assert_dialog_text(self, expected_text: str) -> None:
256256
Args:
257257
expected_text (str): The text that should be present in the dialog.
258258
"""
259+
self._dialog_assertion_error = None
259260

260-
def handle_dialog(dialog):
261+
def handle_dialog(dialog: Dialog):
262+
logging.info(f"Dialog appeared with message: {dialog.message}")
261263
actual_text = dialog.message
262-
assert (
263-
actual_text == expected_text
264-
), f"Expected '{expected_text}', but got '{actual_text}'"
264+
try:
265+
assert (
266+
actual_text == expected_text
267+
), f"Expected '{expected_text}', but got '{actual_text}'"
268+
except AssertionError as e:
269+
self._dialog_assertion_error = e
265270
dialog.dismiss() # Dismiss dialog
266271

267272
self.page.once("dialog", handle_dialog)

pages/screening_subject_search/subject_demographic_page.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,41 @@ def __init__(self, page: Page):
1818
self.update_subject_data_button = self.page.get_by_role(
1919
"button", name="Update Subject Data"
2020
)
21+
self.temporary_address_show_link = (
22+
self.page.locator("font")
23+
.filter(has_text="Temporary Address show")
24+
.get_by_role("link")
25+
)
26+
self.temporary_address_valid_from_calendar_button = self.page.locator(
27+
"#UI_SUBJECT_ALT_FROM_0_LinkOrButton"
28+
)
29+
self.temporary_address_valid_to_calendar_button = self.page.locator(
30+
"#UI_SUBJECT_ALT_TO_0_LinkOrButton"
31+
)
32+
self.temporary_address_valid_from_text_box = self.page.get_by_role(
33+
"textbox", name="Valid from"
34+
)
35+
self.temporary_address_valid_to_text_box = self.page.get_by_role(
36+
"textbox", name="Valid to"
37+
)
38+
self.temporary_address_address_line_1 = self.page.locator(
39+
"#UI_SUBJECT_ALT_ADDR1_0"
40+
)
41+
self.temporary_address_address_line_2 = self.page.locator(
42+
"#UI_SUBJECT_ALT_ADDR2_0"
43+
)
44+
self.temporary_address_address_line_3 = self.page.locator(
45+
"#UI_SUBJECT_ALT_ADDR3_0"
46+
)
47+
self.temporary_address_address_line_4 = self.page.locator(
48+
"#UI_SUBJECT_ALT_ADDR4_0"
49+
)
50+
self.temporary_address_address_line_5 = self.page.locator(
51+
"#UI_SUBJECT_ALT_ADDR5_0"
52+
)
53+
self.temporary_address_postcode = self.page.locator(
54+
"#UI_SUBJECT_ALT_POSTCODE_0"
55+
)
2156

2257
def is_forename_filled(self) -> bool:
2358
"""
@@ -99,3 +134,53 @@ def get_dob_field_value(self) -> str:
99134
str: The subject's date of birth as a string
100135
"""
101136
return self.dob_field.input_value()
137+
138+
def update_temporary_address(self, dict: dict) -> None:
139+
"""
140+
Updates the temporary address fields with the provided dictionary values.
141+
Args:
142+
dict (dict): A dictionary containing the temporary address details.
143+
Expected keys: 'valid_from', 'valid_to', 'address_line_1',
144+
'address_line_2', 'address_line_3', 'address_line_4', 'address_line_5'.
145+
"""
146+
# Click the link to show the temporary address fields
147+
if self.temporary_address_show_link.is_visible():
148+
# If the link is visible, click it to show the temporary address fields
149+
self.click(self.temporary_address_show_link)
150+
151+
# Update the valid from date
152+
if "valid_from" in dict:
153+
if dict["valid_from"] is None:
154+
self.temporary_address_valid_from_text_box.fill("")
155+
else:
156+
CalendarPicker(self.page).calendar_picker_ddmmyyyy(
157+
dict["valid_from"], self.temporary_address_valid_from_text_box
158+
)
159+
160+
# Update the valid to date
161+
if "valid_to" in dict:
162+
if dict["valid_to"] is None:
163+
self.temporary_address_valid_to_text_box.fill("")
164+
else:
165+
CalendarPicker(self.page).calendar_picker_ddmmyyyy(
166+
dict["valid_to"], self.temporary_address_valid_to_text_box
167+
)
168+
169+
# Fill in the address lines
170+
if "address_line_1" in dict:
171+
self.temporary_address_address_line_1.fill(dict["address_line_1"])
172+
if "address_line_2" in dict:
173+
self.temporary_address_address_line_2.fill(dict["address_line_2"])
174+
if "address_line_3" in dict:
175+
self.temporary_address_address_line_3.fill(dict["address_line_3"])
176+
if "address_line_4" in dict:
177+
self.temporary_address_address_line_4.fill(dict["address_line_4"])
178+
if "address_line_5" in dict:
179+
self.temporary_address_address_line_5.fill(dict["address_line_5"])
180+
181+
# Fill in the postcode
182+
if "postcode" in dict:
183+
self.temporary_address_postcode.fill(dict["postcode"])
184+
185+
# Click the update subject data button to save changes
186+
self.update_subject_data_button.click()

pages/screening_subject_search/subject_screening_summary_page.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ def __init__(self, page: Page):
5555
"button", name="Advance FOBT Screening Episode"
5656
)
5757
self.additional_care_note_link = self.page.get_by_role("link", name="(AN)")
58+
self.temporary_address_icon = self.page.get_by_role(
59+
"link", name="The person has a current"
60+
)
61+
self.temporary_address_popup = self.page.locator("#idTempAddress")
62+
self.close_button = self.page.get_by_role("img", name="close")
5863

5964
def wait_for_page_title(self) -> None:
6065
"""Waits for the page to be the Subject Screening Summary"""
@@ -232,6 +237,37 @@ def verify_note_link_not_present(self, note_type_name: str) -> None:
232237
not note_link_locator.is_visible()
233238
), f"'{note_type_name}' link is visible, but it should not be."
234239
logging.info(f"Verified: '{note_type_name}' link is not visible.")
240+
def verify_temporary_address_popup_visible(self) -> None:
241+
"""Verify that the temporary address popup is visible."""
242+
try:
243+
expect(self.temporary_address_popup).to_be_visible()
244+
logging.info("Temporary address popup is visible")
245+
except Exception as e:
246+
pytest.fail(f"Temporary address popup is not visible: {e}")
247+
248+
def click_temporary_address_icon(self) -> None:
249+
"""Click on the temporary address icon."""
250+
self.click(self.temporary_address_icon)
251+
252+
def verify_temporary_address_icon_visible(self) -> None:
253+
"""Verify that the temporary address icon is visible."""
254+
try:
255+
expect(self.temporary_address_icon).to_be_visible()
256+
logging.info("Temporary address icon is visible")
257+
except Exception as e:
258+
pytest.fail(f"Temporary address icon is not visible when it should be: {e}")
259+
260+
def verify_temporary_address_icon_not_visible(self) -> None:
261+
"""Verify that the temporary address icon is not visible."""
262+
try:
263+
expect(self.temporary_address_icon).not_to_be_visible()
264+
logging.info("Temporary address icon is not visible as expected")
265+
except Exception as e:
266+
pytest.fail(f"Temporary address icon is visible when it should not be: {e}")
267+
268+
def click_close_button(self) -> None:
269+
"""Click on the close button in the temporary address popup."""
270+
self.click(self.close_button)
235271

236272

237273
class ChangeScreeningStatusOptions(Enum):

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,5 @@ markers =
4040
regression: tests that are part of the regression test suite
4141
call_and_recall: tests that are part of the call and recall test suite
4242
notes_tests: tests that are part of the notes test suite
43+
subject_tests: tests that are part of the subject tests suite
44+
subject_search: tests that are part of the subject search test suite

0 commit comments

Comments
 (0)