Skip to content

Commit d2ded66

Browse files
New: [AEA-4802] - Site org information cards (#291)
## Summary - Routine Change ### Details Basic tests. Note that this is only creating the prescription details page so that the cards have somewhere to live - the actual surrounding page is way beyond the scope of this ticket, so ONLY the cards are checked for. Also, since we have no live data yet, I've added a dev link to take us to the prescription details page. This will need to be removed later, and I've left a fixme note to that effect. --------- Co-authored-by: Sean Steberis <[email protected]>
1 parent a2d71c9 commit d2ded66

10 files changed

+123
-10
lines changed

.devcontainer/devcontainer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
"github.vscode-github-actions",
4545
"ms-python.pylint",
4646
"ms-python.black-formatter",
47-
"jimasp.behave-vsc"
47+
"jimasp.behave-vsc",
48+
"Gruntfuggly.todo-tree"
4849
],
4950
"settings": {
5051
"python.defaultInterpreterPath": "/workspaces/electronic-prescription-service-api-regression-tests/venv/bin/python",
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
@cpts_ui @prescription_details @regression @ui
2+
Feature: Prescription Detail Page in the Clinical Prescription Tracker Service
3+
4+
Background:
5+
Given I am logged in as a user with a single access role
6+
And I am on the search for a prescription page
7+
8+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4802
9+
Scenario: User sees all the organisation cards when they should
10+
# FIXME: Remove references to static data
11+
When I go to the prescription details for prescription ID "C0C757-A83008-C2D93O"
12+
Then The prescriber site card is visible
13+
And The dispenser site card is visible
14+
And The nominated dispenser site card is visible
15+
16+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4802
17+
Scenario: User sees only the prescriber organisation card when they should
18+
# FIXME: Remove references to static data
19+
When I go to the prescription details for prescription ID "209E3D-A83008-327F9F"
20+
Then The prescriber site card is visible
21+
And The dispenser site card is not visible
22+
And The nominated dispenser site card is not visible
23+
24+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4802
25+
Scenario: User sees only the prescriber and dispenser organisation cards when they should
26+
# FIXME: Remove references to static data
27+
When I go to the prescription details for prescription ID "7F1A4B-A83008-91DC2E"
28+
Then The prescriber site card is visible
29+
And The dispenser site card is visible
30+
And The nominated dispenser site card is not visible
31+
32+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4802
33+
Scenario: User sees the all the organisation cards when one of them is missing site data
34+
# FIXME: Remove references to static data
35+
When I go to the prescription details for prescription ID "4D6F2C-A83008-A3E7D1"
36+
Then The prescriber site card is visible
37+
And The dispenser site card is visible
38+
And The nominated dispenser site card is visible

features/cpts_ui/prescription_information_banner.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ Feature: The site displays the prescription information banner
2121

2222
# This test uses static mock data. Update once real prescription API integration is in place.
2323
Scenario: The banner shows eRD type with repeat info and days supply
24-
When I go to the prescription details page with prescription ID "EC5ACF-A83008-733FD3"
24+
When I go to the prescription details page with prescription ID "209E3D-A83008-327F9F"
2525
Then The prescription information banner shows
26-
| Prescription ID | EC5ACF-A83008-733FD3 |
26+
| Prescription ID | 209E3D-A83008-327F9F |
2727
| Issue Date | 22-Jan-2025 |
2828
| Status | All items dispensed |
2929
| Type | eRD 2 of 6 |
@@ -37,5 +37,5 @@ Feature: The site displays the prescription information banner
3737

3838
# This test uses static mock data. Update once real prescription API integration is in place.
3939
Scenario: The loading message is displayed when prescription data is being fetched
40-
When I go to the prescription details page with prescription ID "EC5ACF-A83008-733FD3"
40+
When I go to the prescription details page with prescription ID "209E3D-A83008-327F9F"
4141
Then The page shows the loading message "Loading full prescription"

features/cpts_ui/prescription_list.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ Feature: Prescription List Page in the Clinical Prescription Tracker Service
4646
Then I can see the future prescriptions results table
4747

4848
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4792
49-
@testme
5049
Scenario: Display past prescriptions results table when clicking the past tab heading
5150
Given I am logged in as a user with a single access role
5251
# FIXME: This will need to be updated when the search pages are updated to use real data

features/steps/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
from cpts_ui.patient_details_banner import * # noqa: F403,F401
1212
from cpts_ui.prescription_information_banner import * # noqa: F403,F401
1313
from cpts_ui.prescription_list_steps import * # noqa: F403,F401
14+
from cpts_ui.prescription_details_steps import * # noqa: F403,F401
1415
from cpts_ui.prescription_not_found_page_steps import * # noqa: F403,F401
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
from behave import when, then # pyright: ignore [reportAttributeAccessIssue]
2+
from playwright.sync_api import expect
3+
4+
from pages.prescription_details import PrescriptionDetailsPage
5+
6+
# FIXME: Remove references to the dev link when we can navigate properly to the prescription details
7+
from pages.prescription_list_page import PrescriptionListPage
8+
9+
10+
@when('I go to the prescription details for prescription ID "{prescription_id}"')
11+
def i_go_to_prescription_details_for_prescription_id(context, prescription_id):
12+
context.execute_steps(
13+
f"""
14+
When I search for a prescription using a valid prescription ID "{prescription_id}"
15+
And I click through to the prescription details page
16+
"""
17+
)
18+
19+
20+
# FIXME: THIS IS FOR DEVELOPMENT ONLY - DELETE IT WHEN WE HAVE A PROPER USER FLOW!!!
21+
@when("I click through to the prescription details page")
22+
def i_click_to_prescription_details_page(context):
23+
page = PrescriptionListPage(context.page)
24+
page.dev_link.click()
25+
26+
context.page.wait_for_load_state()
27+
28+
29+
@then("The {org} site card is {visibility}")
30+
def site_card_visibility_check(context, org, visibility):
31+
page = PrescriptionDetailsPage(context.page)
32+
33+
expect_prescribed_from_field = False
34+
match org:
35+
case "prescriber":
36+
card = page.prescriber_card
37+
expect_prescribed_from_field = True
38+
case "dispenser":
39+
card = page.dispenser_card
40+
case "nominated dispenser":
41+
card = page.nominated_dispenser_card
42+
case _:
43+
raise ValueError(f"Unrecognised site definition: {org}")
44+
45+
if visibility == "visible":
46+
expect(card).to_be_visible()
47+
if expect_prescribed_from_field:
48+
expect(page.prescribed_from_field)
49+
50+
elif visibility == "not visible":
51+
expect(card).not_to_be_visible()
52+
if expect_prescribed_from_field:
53+
expect(page.prescribed_from_field)
54+
55+
else:
56+
raise ValueError(f"Unrecognised visibility definition: {visibility}")

features/steps/cpts_ui/prescription_information_banner.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,5 @@ def clipboard_has_text(context, expected):
6060

6161
@then('The page shows the loading message "{expected_message}"')
6262
def check_loading_message(context, expected_message):
63-
heading = context.page.locator("#prescription-details-page h2")
64-
actual = heading.first.inner_text()
65-
assert (
66-
actual == expected_message
67-
), f"Expected heading '{expected_message}', but got '{actual}'"
63+
heading = context.page.get_by_test_id("loading-message")
64+
expect(heading).to_have_text(expected_message)

features/steps/cpts_ui/prescription_list_steps.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def search_using_prescription_id(context, prescription_id):
1818
@given("I have accessed the prescription list page using a prescription ID search")
1919
def access_list_page_via_prescription_id(context):
2020
# Navigate directly to the results page with a prescription ID parameter
21+
# FIXME: This should not be hardcoded once we can actually search for real data
2122
context.page.goto(
2223
context.cpts_ui_base_url
2324
+ "site/prescription-list-current?prescriptionId=C0C757-A83008-C2D93O"

pages/prescription_details.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from playwright.sync_api import Page
2+
3+
4+
class PrescriptionDetailsPage:
5+
6+
def __init__(self, page: Page):
7+
page.wait_for_load_state()
8+
self.page = page
9+
self.url = "/prescription-details"
10+
11+
# Site org cards
12+
self.dispenser_card = page.get_by_test_id("site-card-dispenser")
13+
self.nominated_dispenser_card = page.get_by_test_id(
14+
"site-card-nominated-dispenser"
15+
)
16+
self.prescriber_card = page.get_by_test_id("site-card-prescriber")
17+
self.prescribed_from_field = page.get_by_test_id("site-card-prescribed-from")

pages/prescription_list_page.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ def __init__(self, page: Page):
77
self.page = page
88
self.url = "/prescription-list"
99

10+
# FIXME: DELETEME
11+
self.dev_link = page.get_by_test_id("prescription-details-link-container")
12+
1013
# Locators for elements on the page with updated data-testid attributes
1114
self.heading = page.get_by_test_id("prescription-list-heading")
1215
self.results_count = page.get_by_test_id("results-count")

0 commit comments

Comments
 (0)