Skip to content

Commit bbb6fcf

Browse files
authored
Fix: [AEA-0000] - Fix tests being wonky when run too fast (#282)
## Summary - Routine Change ### Details One of the tests ran fine when being run outside of headless, but fails in headless mode. This fixes that. Also adds a `SLOWMO` environment variable that allows us to insert a delay between actions.
1 parent 21ab7ca commit bbb6fcf

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ Make sure that your behave run configuration includes the `--product=` & `--env=
7373
Run the tests by calling the Make command `make run-tests`. This requires the parameters `product=` and `env=` to be passed in.
7474
Optionally, you can pass in tags to be run, for example `tags=cpt-ui` will run all CPT-UI-tagged tests.
7575
Further, if you want to actually see the tests being executed, you can pass a `HEADLESS=true` to the makefile.
76+
If you want to throttle the speed that the tests are done, you can insert a delay between each action by passing the `SLOWMO=<delay, ms>` environment variable. This lets a human keep track of what steps are being done.
7677

7778
For example:
7879
```
79-
product=cpts-ui env=internal-dev PULL_REQUEST_ID=pr-300 tags=cpt-ui HEADLESS=true make run-tests
80+
product=cpts-ui env=internal-dev PULL_REQUEST_ID=pr-300 tags=login HEADLESS=false SLOWMO=2000 make run-tests
8081
```
8182

8283
Note that CPT-UI supports localhost testing. To do this, use the `env=localhost` variable - but ensure you have *not* set the `PULL_REQUEST_ID` variable, as it is not needed and will break the tests. Make sure your localhost server is running!

features/cpts_ui/prescription_list.feature

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ Feature: Prescription List Page in the Clinical Prescription Tracker Service
1111
And I can see the heading "Prescriptions list"
1212
And I can see the results count message
1313

14-
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4778
14+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4778
15+
@testme
1516
Scenario: Back link navigates to appropriate search tab when accessed from prescription ID search
1617
Given I am logged in as a user with a single access role
18+
And I am on the search for a prescription page
1719
And I have accessed the prescription list page using a prescription ID search
1820
When I click on the "Go back" link
1921
Then I am redirected to the prescription ID search tab

features/environment.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
JWT_PRIVATE_KEY = os.getenv("JWT_PRIVATE_KEY")
122122
JWT_KID = os.getenv("JWT_KID")
123123
HEADLESS = os.getenv("HEADLESS", "True").lower() in ("true", "1", "yes")
124+
SLOWMO = float(os.getenv("SLOWMO", "0.0"))
124125

125126
CPTS_UI_PREFIX = "cpt-ui"
126127
CPTS_FHIR_SUFFIX = "clinical-prescription-tracker"
@@ -239,7 +240,7 @@ def before_all(context):
239240
global _playwright
240241
_playwright = sync_playwright().start()
241242
context.browser = _playwright.chromium.launch(
242-
headless=HEADLESS, channel="chrome"
243+
headless=HEADLESS, channel="chrome", slow_mo=SLOWMO
243244
)
244245

245246
eps_api_methods.calculate_eps_fhir_base_url(context)

features/steps/cpts_ui/login_steps.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ def logged_in_urls(url):
131131
valid_urls = [
132132
f"{context.cpts_ui_base_url}site/select-role",
133133
f"{context.cpts_ui_base_url}site/select-role/",
134+
f"{context.cpts_ui_base_url}site/search",
135+
f"{context.cpts_ui_base_url}site/search/",
134136
]
135137
return url in valid_urls
136138

0 commit comments

Comments
 (0)