Skip to content

Commit 8ff05c5

Browse files
Feature/bcss 21311 fobt regression scenario 8 (#142)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> This covers the migration of the fobt regression tests, Scenario 8, from selenium to playwright including any POMs and Utils as required. ## Context <!-- Why is this change required? What problem does it solve? --> This is part of the selenium to playwright migration work. ## Type of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [x] Refactoring (non-breaking change) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would change existing functionality) - [ ] Bug fix (non-breaking change which fixes an issue) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I am familiar with the [contributing guidelines](https://github.com/nhs-england-tools/playwright-python-blueprint/blob/main/CONTRIBUTING.md) - [x] I have followed the code style of the project - [x] I have added tests to cover my changes (where appropriate) - [x] I have updated the documentation accordingly - [x] This PR is a result of pair or mob programming --- ## Sensitive Information Declaration To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including [PII (Personal Identifiable Information) / PID (Personal Identifiable Data)](https://digital.nhs.uk/data-and-information/keeping-data-safe-and-benefitting-the-public) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter. - [x] I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes. --------- Co-authored-by: Adriano Aru <[email protected]>
1 parent 3d9ebfa commit 8ff05c5

File tree

12 files changed

+1462
-65
lines changed

12 files changed

+1462
-65
lines changed

classes/episode/latest_episode_latest_investigation_dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ def from_description(cls, description: str) -> str:
5252
ValueError: If the description is not recognized.
5353
"""
5454
key = description.strip().lower()
55-
if key not in cls._valid_values:
55+
if key not in (value.lower() for value in cls._valid_values):
5656
raise ValueError(f"Unknown investigation dataset filter: '{description}'")
5757
return key

pages/base_page.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,22 @@ def _accept_dialog(self, dialog: Dialog) -> None:
237237

238238
def safe_accept_dialog(self, locator: Locator) -> None:
239239
"""
240-
Safely accepts a dialog triggered by a click, avoiding the error:
241-
playwright._impl._errors.Error: Dialog.accept: Cannot accept dialog which is already handled!
240+
Safely accepts a dialog triggered by a click, logging its contents.
241+
Avoids the error: Dialog.accept: Cannot accept dialog which is already handled!
242242
If no dialog appears, continues without error.
243243
Args:
244244
locator (Locator): The locator that triggers the dialog when clicked.
245-
example: If clicking a save button opens a dialog, pass that save button's locator.
246245
"""
247-
self.page.once("dialog", self._accept_dialog)
246+
247+
def handle_dialog(dialog: Dialog):
248+
try:
249+
logging.info(f"[DIALOG APPEARED WITH MESSAGE]: {dialog.message}")
250+
dialog.accept()
251+
except Exception:
252+
logging.warning("Dialog already accepted or handled")
253+
254+
self.page.once("dialog", handle_dialog)
255+
248256
try:
249257
self.click(locator)
250258
except Exception as e:
@@ -271,8 +279,8 @@ def handle_dialog(dialog: Dialog, accept: bool = False):
271279
actual_text = dialog.message
272280
try:
273281
assert (
274-
actual_text == expected_text
275-
), f"Expected '{expected_text}', but got '{actual_text}'"
282+
expected_text in actual_text
283+
), f"Expected dialog to contain '{expected_text}', but got '{actual_text}'"
276284
except AssertionError as e:
277285
self._dialog_assertion_error = e
278286
if accept:

pages/datasets/cancer_audit_datasets_page.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def select_first_definitive_teatment_information_option(self, option: str) -> No
175175
NOT_REPORTED_CODE = "202140~~202188"
176176

177177

178-
class ASAGradeOptions(StrEnum):
178+
class CancerASAGradeOptions(StrEnum):
179179
"""Enum for ASA Grade options."""
180180

181181
FIT = "17009"
@@ -186,22 +186,38 @@ class ASAGradeOptions(StrEnum):
186186
NOT_KNOWN = "17015"
187187

188188

189-
class YesNoOptions(StrEnum):
189+
class CancerYesNoOptions(StrEnum):
190190
"""Enum for YesNo options."""
191191

192192
YES = "17058"
193193
NO = "17059"
194194

195195

196-
class MetastasesPresentOptions(StrEnum):
196+
class CancerRadiologyYesNoOptions(StrEnum):
197+
"""Enum for Yes/No options specific to Radiology fields"""
198+
199+
YES = "17058~~204365"
200+
NO = "17059~~204366"
201+
NOT_REPORTED = "202140"
202+
203+
204+
class CancerTaggingAgentDrugAdministeredOptions(StrEnum):
205+
"""Enum for Tagging Agent Given Drugs Administered"""
206+
207+
YES = "17058~~204368"
208+
NO = "17059"
209+
NOT_REPORTED = "202140"
210+
211+
212+
class CancerMetastasesPresentOptions(StrEnum):
197213
"""Enum for Metastases Present options."""
198214

199215
CERTAIN = "17131~~202199"
200216
NONE = "17130"
201217
NOT_REPORTED = NOT_REPORTED_CODE
202218

203219

204-
class FinalPreTreatmentTCategoryOptions(StrEnum):
220+
class CancerFinalPreTreatmentTCategoryOptions(StrEnum):
205221
"""Enum for Final Pre-Treatment T Category options."""
206222

207223
CTX = "17356"
@@ -213,7 +229,7 @@ class FinalPreTreatmentTCategoryOptions(StrEnum):
213229
NOT_REPORTED = NOT_REPORTED_CODE
214230

215231

216-
class FinalPreTreatmentNCategoryOptions(StrEnum):
232+
class CancerFinalPreTreatmentNCategoryOptions(StrEnum):
217233
"""Enum for Final Pre-Treatment N Category options."""
218234

219235
CNX = "202201"
@@ -223,7 +239,7 @@ class FinalPreTreatmentNCategoryOptions(StrEnum):
223239
NOT_REPORTED = NOT_REPORTED_CODE
224240

225241

226-
class ReasonNoTreatmentRecievedOptions(StrEnum):
242+
class CancerReasonNoTreatmentReceivedOptions(StrEnum):
227243
"""Enum for Reason No Treatment Received options."""
228244

229245
ADVANCED_DISEASE = "99016"
@@ -234,7 +250,7 @@ class ReasonNoTreatmentRecievedOptions(StrEnum):
234250
UNKNOWN = "99018"
235251

236252

237-
class PreviouslyExcisedTumorOptions(StrEnum):
253+
class CancerPreviouslyExcisedTumorOptions(StrEnum):
238254
"""Enum for Previously Excised Tumor options."""
239255

240256
YES = "17058~~305403"
@@ -243,14 +259,14 @@ class PreviouslyExcisedTumorOptions(StrEnum):
243259
NOT_REPORTED = "202140"
244260

245261

246-
class TreatmentTypeOptions(StrEnum):
262+
class CancerTreatmentTypeOptions(StrEnum):
247263
"""Enum for Treatment Type options."""
248264

249265
SURGICAL = "202143"
250266
NON_SURGICAL = "202144"
251267

252268

253-
class TreatmentGivenOptions(StrEnum):
269+
class CancerTreatmentGivenOptions(StrEnum):
254270
"""Enum for Treatment Given options."""
255271

256272
CHEMOTHERAPY = "202160~~202184,202217,202218,202219,202220,202221,202222,202223,202224,202225,202226,202227,202228,202287,305395,305397"
@@ -269,14 +285,14 @@ class CancerTreatmentIntentOptions(StrEnum):
269285
NOT_KNOWN = "17373"
270286

271287

272-
class NHSOrPrivateOptions(StrEnum):
288+
class CancerNHSOrPrivateOptions(StrEnum):
273289
"""Enum for NHS or Private options."""
274290

275291
NHS = "202153~~202177,202178"
276292
PRIVATE = "202154~~202179"
277293

278294

279-
class TreatmentProviderLookupOptions(StrEnum):
295+
class CancerTreatmentProviderLookupOptions(StrEnum):
280296
"""Enum for Treatment Provider lookup options."""
281297

282298
ADVANCE_NURSE_PRACTITIONER_1 = "51905"
@@ -305,7 +321,7 @@ class TreatmentProviderLookupOptions(StrEnum):
305321
BUSHBURY_HEALTH_CENTRE = "51801"
306322

307323

308-
class ConsultantLookupOptions(StrEnum):
324+
class CancerConsultantLookupOptions(StrEnum):
309325
"""Enum for Consultant lookup options."""
310326

311327
B_FRAME = "201"

0 commit comments

Comments
 (0)