Skip to content

Commit 52ff972

Browse files
Chore: [AEA-4518] - and [AEA-4516] search for a prescription tabs and hero banner (#195)
## Summary - Routine Change ### Details - Tests for AEA-4516 and AEA-4518 - Refactoring of classes for page objects - Steps for UI-related steps now in sub folders for better organisation
1 parent faba043 commit 52ff972

File tree

11 files changed

+225
-105
lines changed

11 files changed

+225
-105
lines changed

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ pre-commit: git-secrets-docker-setup
7070
poetry run pre-commit run --all-files
7171

7272
git-secrets-docker-setup:
73-
LOCAL_WORKSPACE_FOLDER=$(pwd)
74-
export LOCAL_WORKSPACE_FOLDER=$(LOCAL_WORKSPACE_FOLDER)
73+
export LOCAL_WORKSPACE_FOLDER=$(pwd)
7574
docker build -f https://raw.githubusercontent.com/NHSDigital/eps-workflow-quality-checks/refs/tags/v4.0.4/dockerfiles/nhsd-git-secrets.dockerfile -t git-secrets .
7675

7776
download-allure-report: guard-GITHUB_RUN_ID
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,11 @@ Feature: I can visit the Clinical Prescription Tracker Service Website
2020
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4513
2121
Scenario: user sees a menu with links when the screen size is small
2222
Given I am on the homepage
23-
When I have a screen size of 900 pixels wide
23+
When I have a screen size of 690 pixels wide
2424
Then I can see the header links in a dropdown menu
25+
26+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4518
27+
Scenario: user can visit the search for a prescription page
28+
Given I am on the homepage
29+
When I click on Find a prescription
30+
Then I am on the search for a prescription page
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@cpts_ui @home @regression @blocker @smoke @ui
2+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4460
3+
Feature: I can visit the Clinical Prescription Tracker Service Website
4+
5+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4516
6+
Scenario: User can view the Search For A Prescription Page
7+
Given I am on the homepage
8+
When I click on Find a prescription
9+
Then I am on the search for a prescription page
10+
And I can see the search for a prescription header
11+
12+
13+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4518
14+
Scenario Outline: user can switch between different tabs
15+
Given I am on the search for a prescription page
16+
When I click on tab <Tab Name>
17+
Then I am on tab <Tab Name>
18+
Examples:
19+
| Tab Name |
20+
| Prescription ID search |
21+
| NHS Number Search |
22+
| Basic Details Search |

features/environment.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ def count_of_scenarios_to_run(context):
9191
return total_scenarios
9292

9393

94+
def before_scenario(context, scenario):
95+
product = context.config.userdata["product"].upper()
96+
if product == "CPTS-UI":
97+
global _page
98+
context.page = context.browser.new_page()
99+
_page = context.page
100+
set_page(context, _page)
101+
102+
94103
def before_all(context):
95104
product = context.config.userdata["product"].upper()
96105
if count_of_scenarios_to_run(context) != 0:
@@ -118,10 +127,7 @@ def before_all(context):
118127
if product == "CPTS-UI":
119128
global _page
120129
playwright = sync_playwright().start()
121-
browser = playwright.chromium.launch(headless=True, channel="chrome")
122-
context.page = browser.new_page()
123-
_page = context.page
124-
set_page(context, _page)
130+
context.browser = playwright.chromium.launch(headless=True, channel="chrome")
125131

126132
eps_api_methods.calculate_eps_fhir_base_url(context)
127133
print("CPTS-UI: ", context.cpts_ui_base_url)

features/steps/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from cpts_ui.search_for_a_prescription_steps import * # noqa: F403,F401
2+
from cpts_ui.home_steps import * # noqa: F403,F401
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# pylint: disable=no-name-in-module
2+
from behave import given, when, then # pyright: ignore [reportAttributeAccessIssue]
3+
from playwright.sync_api import expect
4+
5+
from pages.home import Home
6+
7+
8+
@when("I go to the homepage")
9+
def goto_page(context):
10+
context.page.goto(context.cpts_ui_base_url + "site/")
11+
12+
13+
@given("I am on the homepage")
14+
def i_am_on_the_home_page(context):
15+
goto_page(context)
16+
home_page = Home(context.page)
17+
home_page.page.is_visible(home_page.header)
18+
19+
20+
@then("I am on the homepage")
21+
def verify_on_home_page(context):
22+
home_page = Home(context.page)
23+
home_page.page.is_visible(home_page.header)
24+
25+
26+
@then("I can see the footer")
27+
def i_can_see_the_footer(context):
28+
home_page = Home(context.page)
29+
home_page.page.is_visible(home_page.footer)
30+
31+
32+
@then("I can see the header")
33+
def i_can_see_the_header(context):
34+
home_page = Home(context.page)
35+
home_page.page.is_visible(home_page.header)
36+
37+
38+
@then("I can see the links on the header")
39+
def i_can_see_the_links_on_the_header(context):
40+
home_page = Home(context.page)
41+
expect(home_page.confirm_role_link).to_be_visible()
42+
expect(home_page.find_a_prescription_link).to_be_visible()
43+
44+
45+
@when("I have a screen size of {pixel_width} pixels wide")
46+
def i_have_a_screen_size_of_x_pixels_wide(context, pixel_width):
47+
context.page.set_viewport_size({"width": int(pixel_width), "height": 1200})
48+
49+
50+
@then("I can see the header links in a dropdown menu")
51+
def i_can_see_the_header_links_in_a_dropdown_menu(context):
52+
home_page = Home(context.page)
53+
expect(home_page.menu_button).to_be_visible()
54+
home_page.menu_button.click()
55+
expect(home_page.confirm_role_link).to_be_visible()
56+
expect(home_page.find_a_prescription_link).to_be_visible()
57+
home_page.menu_button.click()
58+
expect(home_page.confirm_role_link).to_be_visible(visible=False)
59+
expect(home_page.find_a_prescription_link).to_be_visible(visible=False)
60+
61+
62+
@when("I click on Find a prescription")
63+
def step_impl(context):
64+
home_page = Home(context.page)
65+
home_page.find_a_prescription_link.click()
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# pylint: disable=no-name-in-module
2+
from behave import given, when, then # pyright: ignore [reportAttributeAccessIssue]
3+
from playwright.sync_api import expect
4+
5+
from pages.home import Home
6+
from pages.search_for_a_prescription import SearchForAPrescription
7+
8+
9+
@when("I go to the search for a prescription page")
10+
def goto_page(context):
11+
context.page.goto(context.cpts_ui_base_url + "site/")
12+
home = Home(context.page)
13+
home.find_a_prescription_link.click()
14+
15+
16+
@given("I am on the search for a prescription page")
17+
def go_to_search_prescription_page(context):
18+
context.execute_steps("when I go to the search for a prescription page")
19+
expect(context.page).to_have_title("Search for a prescription")
20+
21+
22+
@then("I am on the search for a prescription page")
23+
def i_am_on_the_search_prescription_page(context):
24+
expect(context.page).to_have_title("Search for a prescription")
25+
26+
27+
@when("I click on tab {}")
28+
def i_click_on_tab(context, tab_name):
29+
search_for_a_prescription = SearchForAPrescription(context.page)
30+
match tab_name.lower():
31+
case "prescription id search":
32+
search_for_a_prescription.prescription_id_search_tab.click()
33+
case "nhs number search":
34+
search_for_a_prescription.nhs_number_search_tab.click()
35+
case "basic details search":
36+
search_for_a_prescription.basic_details_search_tab.click()
37+
case _:
38+
raise AssertionError("Unknown tab {}".format(tab_name))
39+
40+
41+
@then("I am on tab {}")
42+
def i_am_on_tab(context, tab_name):
43+
search_for_a_prescription = SearchForAPrescription(context.page)
44+
match tab_name.lower():
45+
case "prescription id search":
46+
expect(
47+
search_for_a_prescription.prescription_id_search_header
48+
).to_be_visible()
49+
expect(search_for_a_prescription.nhs_number_search_header).to_be_visible(
50+
visible=False
51+
)
52+
expect(search_for_a_prescription.basic_details_search_header).to_be_visible(
53+
visible=False
54+
)
55+
case "nhs number search":
56+
expect(
57+
search_for_a_prescription.prescription_id_search_header
58+
).to_be_visible(visible=False)
59+
expect(search_for_a_prescription.nhs_number_search_header).to_be_visible()
60+
expect(search_for_a_prescription.basic_details_search_header).to_be_visible(
61+
visible=False
62+
)
63+
case "basic details search":
64+
expect(
65+
search_for_a_prescription.prescription_id_search_header
66+
).to_be_visible(visible=False)
67+
expect(search_for_a_prescription.nhs_number_search_header).to_be_visible(
68+
visible=False
69+
)
70+
expect(
71+
search_for_a_prescription.basic_details_search_header
72+
).to_be_visible()
73+
case _:
74+
raise AssertionError("Unknown tab {}".format(tab_name))
75+
76+
77+
@then("I can see the search for a prescription header")
78+
def i_can_see_the_search_for_a_prescription_header(context):
79+
search_for_a_prescription = SearchForAPrescription(context.page)
80+
expect(search_for_a_prescription.hero_banner).to_be_visible()

features/steps/cpts_ui_home_page_steps.py

Lines changed: 0 additions & 50 deletions
This file was deleted.

pages/home.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from playwright.sync_api import Page
2+
3+
4+
class Home:
5+
6+
def __init__(self, page: Page):
7+
self.page = page
8+
self.header = "[id='eps_header']"
9+
self.footer = "[id='eps_footer']"
10+
self.confirm_role_link = self.page.get_by_test_id("eps_header_confirmRoleLink")
11+
self.find_a_prescription_link = self.page.get_by_test_id(
12+
"eps_header_prescriptionSearchLink"
13+
)
14+
self.menu_button = self.page.get_by_role("button", name="Browse Menu")

pages/home_page.py

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)