Skip to content
Merged
3 changes: 2 additions & 1 deletion pages/datasets/investigation_dataset_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,8 @@ def click_edit_dataset_button(self) -> None:
This method is designed to click on the edit dataset button.
It clicks on the edit dataset button.
"""
self.click(self.edit_dataset_button)
if self.edit_dataset_button.is_visible():
self.click(self.edit_dataset_button)

def assert_polyp_algorithm_size(
self, polyp_number: int, expected_value: Optional[str]
Expand Down
21 changes: 18 additions & 3 deletions pages/datasets/subject_datasets_page.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from playwright.sync_api import Page, expect, Locator
from playwright.sync_api import Page, expect, Locator, TimeoutError
from pages.base_page import BasePage


Expand All @@ -22,11 +22,16 @@ def __init__(self, page: Page):
.get_by_role("link")
)
self.add_link = self.page.get_by_role("link", name="Add")
self.view_link = self.page.get_by_role("link", name="View")

def click_add_link(self) -> None:
"""Clicks on the first 'Add' link on the Subject Datasets Page."""
self.click(self.add_link.first)

def click_view_link(self) -> None:
"""Clicks on the first 'View' link on the Subject Datasets Page."""
self.click(self.view_link.first)

def click_colonoscopy_show_datasets(self) -> None:
"""
Clicks on the 'Show Dataset(s)' button for the Colonoscopy Assessment row on the Subject Datasets Page.
Expand Down Expand Up @@ -64,9 +69,19 @@ def click_show_datasets_button(self, header: Locator) -> None:
show_link = container.locator("a:has-text('Show Dataset')")
show_link.wait_for(state="visible", timeout=10000)
self.click(show_link)
# If plural, also click Add
# If plural, also click Add or View depending on visibility
if dataset_count_text and "Datasets" in dataset_count_text:
self.click_add_link()
try:
self.add_link.first.wait_for(state="visible", timeout=2000)
self.click_add_link()
except TimeoutError:
try:
self.view_link.first.wait_for(state="visible", timeout=2000)
self.click_view_link()
except Exception:
raise TimeoutError(
"Neither 'Add' nor 'View' link was found after clicking 'Show Datasets'."
)

def check_investigation_dataset_complete(self) -> None:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class OutcomeOfDiagnosticTest(StrEnum):
REFER_SURVEILLANCE = "20365"
INVESTIGATION_COMPLETE = "20360"
REFER_ANOTHER_DIAGNOSTIC_TEST = "20364"
REFER_MDT = "20367"


class ReasonForSymptomaticReferral(StrEnum):
Expand Down
Loading