Skip to content

Commit 6acb6b3

Browse files
committed
Started refactoring work previously done on this ticket
1 parent 330f44c commit 6acb6b3

File tree

4 files changed

+242
-128
lines changed

4 files changed

+242
-128
lines changed
Lines changed: 57 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,70 @@
1-
from playwright.sync_api import Page, expect
1+
from playwright.sync_api import Page
22
from pages.base_page import BasePage
3+
import logging
34

4-
class SubjectPage(BasePage):
55

6-
def __init__(
7-
self,
8-
page: Page,
9-
hub_manager_role: str,
10-
lynch_diagnosis_type: str,
11-
subject_age: int,
12-
diagnosis_date: str,
13-
last_colonoscopy_date: str,
14-
default_pause_seconds: int,
15-
screening_status_lynch_self_referral: str,
16-
expected_self_referral_updates: dict,
17-
expected_seeking_further_data_updates: dict,
18-
expected_reset_seeking_further_data_updates: dict,
19-
):
6+
class SubjectPage(BasePage):
7+
"""Page object for interacting with subject-related actions."""
208

9+
def __init__(self, page: Page):
2110
super().__init__(page)
2211
self.page = page
23-
self.hub_manager_role = hub_manager_role
24-
self.lynch_diagnosis_type = lynch_diagnosis_type
25-
self.subject_age = subject_age
26-
self.diagnosis_date = diagnosis_date
27-
self.last_colonoscopy_date = last_colonoscopy_date
28-
self.default_pause_seconds = default_pause_seconds
29-
self.screening_status_lynch_self_referral = screening_status_lynch_self_referral
30-
self.expected_self_referral_updates = expected_self_referral_updates
31-
self.expected_seeking_further_data_updates = expected_seeking_further_data_updates
32-
self.expected_reset_seeking_further_data_updates = expected_reset_seeking_further_data_updates
33-
34-
# Class attributes for test data and expected results
35-
36-
hub_manager_role = "Hub Manager"
37-
lynch_diagnosis_type = "EPCAM"
38-
subject_age = 75
39-
diagnosis_date = "3 years ago"
40-
last_colonoscopy_date = "2 years ago"
41-
default_pause_seconds = 5
42-
screening_status_lynch_self_referral = "Lynch Self-referral"
43-
44-
expected_self_referral_updates = {
45-
# ... (your expected values here)
46-
}
47-
expected_seeking_further_data_updates = {
48-
# ... (your expected values here)
49-
}
50-
expected_reset_seeking_further_data_updates = {
51-
# ... (your expected values here)
52-
}
53-
54-
def receive_lynch_diagnosis(self, diagnosis_type, age, diagnosis_date, last_colonoscopy_date):
55-
"""
56-
Implement UI steps to receive Lynch diagnosis for a subject.
57-
"""
58-
# Example: Fill diagnosis form fields and submit
59-
pass
6012

61-
def pause_for_processing(self, seconds):
62-
"""
63-
Pause for the specified number of seconds to allow processing.
64-
"""
65-
self.page.wait_for_timeout(seconds * 1000)
13+
class TestData:
14+
hub_manager_role = "Hub Manager"
15+
lynch_diagnosis_type = "EPCAM"
16+
subject_age = 75
17+
diagnosis_date = "3 years ago"
18+
last_colonoscopy_date = "2 years ago"
19+
screening_status_lynch_self_referral = "Lynch Self-referral"
6620

67-
def self_refer_subject(self):
68-
"""
69-
Implement UI steps to self-refer the subject.
70-
"""
71-
# Example: Click self-referral button
72-
pass
21+
def self_refer_subject(self) -> None:
22+
"""Implement UI steps to self-refer the subject."""
23+
logging.warning("[TODO] self_refer_subject not yet implemented.")
24+
# TODO: Implement UI steps to self-refer the subject
7325

74-
def confirm_prompt(self):
75-
"""
76-
Implement UI steps to confirm the prompt (e.g., confirmation dialog).
77-
"""
78-
# Example: Accept confirmation dialog
79-
pass
26+
def confirm_prompt(self) -> None:
27+
"""Implement UI steps to confirm the prompt (e.g., confirmation dialog)."""
28+
logging.warning("[TODO] confirm_prompt not yet implemented.")
29+
# TODO: Implement UI steps to confirm the prompt
8030

81-
def assert_subject_updates(self, expected_updates: dict):
82-
"""
83-
Assert that subject details match the expected updates.
84-
"""
85-
for key, expected_value in expected_updates.items():
86-
locator = self.page.get_by_text(key)
87-
expect(locator).to_be_visible()
88-
# Optionally, check the value displayed next to the key
89-
# value_locator = locator.locator("xpath=following-sibling::*[1]")
90-
# expect(value_locator).to_have_text(expected_value)
91-
92-
def set_seeking_further_data(self):
93-
"""
94-
Implement UI steps to set the subject to Seeking Further Data.
95-
"""
96-
# Example: Select status from dropdown and save
97-
pass
31+
def set_seeking_further_data(self) -> None:
32+
"""Set the subject to Seeking Further Data."""
33+
34+
logging.info(
35+
"[UI ACTION] Setting screening status to 'Seeking Further Data' with reason 'Uncertified Death'"
36+
)
37+
38+
# Select 'Seeking Further Data' from the screening status dropdown
39+
self.page.get_by_label("Change Screening Status").select_option("4007") # Seeking Further Data
40+
41+
# Select 'Uncertified Death' as the reason
42+
self.page.get_by_label("Reason", exact=True).select_option("11314") # Uncertified Death
9843

99-
def set_screening_status(self, status):
44+
# Click the update button
45+
self.page.get_by_role("button", name="Update Subject Data").click()
46+
47+
def set_screening_status(self, status) -> None:
48+
"""Set the screening status."""
49+
logging.warning("[TODO] set_screening_status not yet implemented.")
50+
# TODO: Implement UI steps to set the screening status
51+
52+
def receive_lynch_diagnosis(
53+
self, diagnosis_type, age, diagnosis_date, last_colonoscopy_date=None
54+
) -> None:
10055
"""
101-
Implement UI steps to set the screening status.
56+
Simulates receiving a Lynch diagnosis for a subject via the UI.
10257
"""
103-
# Example: Select status from dropdown and save
104-
pass
58+
logging.info(
59+
f"[UI ACTION] Receiving Lynch diagnosis: {diagnosis_type}, age={age}, diagnosis_date={diagnosis_date}, colonoscopy={last_colonoscopy_date}"
60+
)
61+
62+
# Example UI interactions
63+
self.page.get_by_label("Diagnosis Type").select_option(diagnosis_type)
64+
self.page.get_by_label("Age").fill(str(age))
65+
self.page.get_by_label("Diagnosis Date").fill(diagnosis_date)
66+
67+
if last_colonoscopy_date:
68+
self.page.get_by_label("Last Colonoscopy Date").fill(last_colonoscopy_date)
69+
70+
self.page.get_by_role("button", name="Submit").click()

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ markers =
5555
spine_retrieval_search_tests: tests that are part of subject spine retrieval demographics
5656
hub_user_tests: tests that are part of the hub user test suite
5757
fobt_regression_tests: tests that are part of the fobt regression test suite
58+
lynch_self_referral_tests: tests that are part of the lynch self referral test suite

0 commit comments

Comments
 (0)