Skip to content

Commit 21ab7ca

Browse files
authored
New: [AEA-4787] - Prescription not found page (#278)
## Summary - Routine Change ### Details Tests the behaviour of the prescription not found page
1 parent ac6c790 commit 21ab7ca

File tree

5 files changed

+70
-3
lines changed

5 files changed

+70
-3
lines changed

features/cpts_ui/search_for_a_prescription.feature

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,35 @@ Feature: I can visit the Clinical Prescription Tracker Service Website
3333
And I click the confirm and continue button on the your selected role page
3434
Then I can see the RBAC banner
3535

36+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4787
37+
Scenario: User is redirected correctly when they search for non-existent prescriptions
38+
Given I am logged in as a user with a single access role
39+
When I am on the search for a prescription page
40+
And I click on tab Prescription ID search
41+
# Search for a prescription ID that DOES NOT return anything
42+
And I search for a prescription using a valid prescription ID "209E3D-A83008-327F9F"
43+
Then I am on the prescription not found page with redirect to PrescriptionIdSearch
44+
45+
# TODO: Update this test when the NHS number search is implemented
46+
# @allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4787
47+
# Scenario: User is redirected correctly when they search for non-existent patient
48+
# Given I am logged in as a user with a single access role
49+
# When I am on the search for a prescription page
50+
# And I click on tab NHS Number search
51+
# # Search for a prescription ID that DOES NOT return anything
52+
# And I search for a patient using a valid NHS number "1234567890"
53+
# Then I am on the prescription not found page with redirect to NhsNumSearch
54+
55+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4787
56+
Scenario: User is redirected correctly when they hit the "Go Back" button after searching for non-existent prescription ID
57+
Given I am logged in as a user with a single access role
58+
When I am on the search for a prescription page
59+
And I click on tab Prescription ID search
60+
# Search for a prescription ID that DOES NOT return anything
61+
And I search for a prescription using a valid prescription ID "209E3D-A83008-327F9F"
62+
And I click the Go Back link on the prescription not found page
63+
Then I am on tab Prescription ID search
64+
3665
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4783
3766
@find_prescription
3867
Scenario: User enters a valid prescription ID and is redirected to results page
@@ -43,7 +72,7 @@ Feature: I can visit the Clinical Prescription Tracker Service Website
4372
And I click the Find a prescription button
4473
Then I am redirected to the prescription results page for "C0C757-A83008-C2D93O"
4574

46-
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4783
75+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4783
4776
@find_prescription
4877
Scenario Outline: User sees validation error for incorrect prescription ID
4978
Given I am logged in as a user with a single access role

features/steps/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
from cpts_ui.your_selected_role_steps import * # noqa: F403,F401
1010
from cpts_ui.page_not_found_steps import * # noqa: F403,F401
1111
from cpts_ui.prescription_list_steps import * # noqa: F403,F401
12+
from cpts_ui.prescription_not_found_page_steps import * # noqa: F403,F401

features/steps/cpts_ui/prescription_list_steps.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ def search_using_prescription_id(context, prescription_id):
1111
search_input = context.page.get_by_test_id("prescription-id-input")
1212
search_input.fill(prescription_id)
1313

14-
# Use data-testid to find the button instead of text content
15-
context.page.locator('[data-testid="find-prescription-button"]').click()
14+
context.page.get_by_test_id("find-prescription-button").click()
1615

1716

1817
@given("I have accessed the prescription list page using a prescription ID search")
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# pylint: disable=no-name-in-module
2+
from behave import when, then # pyright: ignore [reportAttributeAccessIssue]
3+
from playwright.sync_api import expect
4+
5+
from pages.prescription_not_found import PrescriptionNotFound
6+
7+
8+
@then("I am on the prescription not found page with redirect to {}")
9+
def i_am_on_prescription_not_found_page(context, tab_name):
10+
page = PrescriptionNotFound(context.page)
11+
12+
expect(page.header).to_be_visible()
13+
expect(page.body1).to_be_visible()
14+
expect(page.back_link).to_be_visible()
15+
16+
url_target = "/site/search"
17+
if tab_name:
18+
url_target += f"#{tab_name}"
19+
20+
expect(page.back_link).to_have_attribute("href", url_target)
21+
22+
23+
@when("I click the Go Back link on the prescription not found page")
24+
def i_click_go_back_presc_not_found(context):
25+
page = PrescriptionNotFound(context.page)
26+
27+
page.back_link.click()

pages/prescription_not_found.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from playwright.sync_api import Page
2+
3+
4+
class PrescriptionNotFound:
5+
def __init__(self, page: Page):
6+
page.wait_for_load_state()
7+
self.page = page
8+
9+
self.header = page.get_by_test_id("presc-not-found-header")
10+
self.body1 = page.get_by_test_id("presc-not-found-body1")
11+
self.back_link = page.get_by_test_id("presc-not-found-backlink")

0 commit comments

Comments
 (0)