Skip to content

Commit ace32ba

Browse files
removed underscores from BDD
slimmed down steps and removed not-needed try/excepts moved CIS2 mock user id into environment.py removed content checks
1 parent 2e8497a commit ace32ba

File tree

4 files changed

+28
-71
lines changed

4 files changed

+28
-71
lines changed

features/cpts_ui/select_your_role.feature

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ Feature: Role selection page renders roles properly when logged in
44

55
Background:
66
Given I am logged in
7-
And I am on the select_your_role page
7+
And I am on the select your role page
88

99
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4653
1010
Scenario: User can navigate to the select_your_role page
11-
Then I am on the select_your_role page
11+
Then I am on the select your role page
1212

1313
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4653
1414
Scenario: User can see the summary container, but not the table contents by default
@@ -24,19 +24,19 @@ Feature: Role selection page renders roles properly when logged in
2424
When I click on the summary expander
2525
Then I can see the summary container
2626
And I cannot see the summary table body
27-
27+
2828
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4651
2929
Scenario: User can see roles with access cards
3030
Then I can see the roles with access cards
3131

3232
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4651
33-
Scenario: User can navigate to the your_selected_role page
34-
Then I can navigate to the your_selected_role page by clicking a card
33+
Scenario: User can navigate to the your selected role page
34+
Then I can navigate to the your selected role page by clicking a card
3535

3636
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4658
37-
Scenario: User can see the header on the select_your_role page
38-
Then I can see the your_selected_role header
37+
Scenario: User can see the header on the select your role page
38+
Then I can see the your selected role header
3939

4040
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4658
41-
Scenario: User can see the subheader on the select_your_role page
42-
Then I can see the your_selected_role subheader
41+
Scenario: User can see the subheader on the select your role page
42+
Then I can see the your selected role subheader

features/environment.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"dispenser": {"user_id": "555260695103", "role_id": "555265434108"},
5151
}
5252
LOGIN_USERS = {"user_id": "9449304130"}
53+
MOCK_CIS2_LOGIN_ID = "555073103100"
5354

5455
REPOS = {
5556
"CPTS-UI": "https://github.com/NHSDigital/eps-prescription-tracker-ui",

features/steps/cpts_ui/select_your_role_steps.py

Lines changed: 18 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,22 @@
33
from playwright.sync_api import expect
44

55
from pages.select_your_role import SelectYourRole
6+
from features.environment import MOCK_CIS2_LOGIN_ID
67

78

8-
@when("I go to the select_your_role page")
9+
@when("I go to the select your role page")
910
def i_go_to_the_select_your_role_page(context):
1011
context.page.goto(context.cpts_ui_base_url + "site/selectyourrole.html")
1112

1213

13-
@given("I am on the select_your_role page")
14+
@given("I am on the select your role page")
1415
def i_am_on_select_your_role_page(context):
1516
i_go_to_the_select_your_role_page(context)
1617
select_your_role_page = SelectYourRole(context.page)
1718
expect(select_your_role_page.summary).to_be_visible()
1819

1920

20-
@then("I am on the select_your_role page")
21+
@then("I am on the select your role page")
2122
def verify_on_select_your_role_page(context):
2223
select_your_role_page = SelectYourRole(context.page)
2324
expect(select_your_role_page.summary).to_be_visible()
@@ -27,7 +28,7 @@ def verify_on_select_your_role_page(context):
2728
def login(context):
2829
context.page.goto(context.cpts_ui_base_url + "site/auth_demo.html")
2930
context.page.get_by_role("button", name="Log in with mock CIS2").click()
30-
context.page.get_by_label("Username").fill("555073103100")
31+
context.page.get_by_label("Username").fill(MOCK_CIS2_LOGIN_ID)
3132
context.page.get_by_role("button", name="Sign In").click()
3233
context.page.wait_for_url("**/auth_demo.html")
3334

@@ -75,61 +76,24 @@ def click_on_summary_expander(context):
7576
@then("I can see the roles with access cards")
7677
def i_can_see_the_roles_with_access_cards(context):
7778
select_your_role_page = SelectYourRole(context.page)
78-
try:
79-
expect(select_your_role_page.first_role_card).to_be_visible(timeout=5000)
80-
print("Verified that at least one role card is displayed.")
81-
except Exception as e:
82-
print("Error verifying roles with access cards:", str(e))
83-
print("Page content during error:")
84-
print(context.page.content())
85-
raise
79+
expect(select_your_role_page.first_role_card).to_be_visible()
8680

8781

88-
@then("I can navigate to the your_selected_role page by clicking a card")
82+
@then("I can navigate to the your selected role page by clicking a card")
8983
def i_can_navigate_to_the_your_selected_role_page(context):
9084
select_your_role_page = SelectYourRole(context.page)
91-
try:
92-
expect(select_your_role_page.first_role_card).to_be_visible(timeout=5000)
93-
select_your_role_page.first_role_card.click()
94-
context.page.wait_for_url(select_your_role_page.selected_role_url)
95-
print(
96-
"Navigation to your_selected_role page successful. Current URL:",
97-
context.page.url,
98-
)
99-
except Exception as e:
100-
print("Error navigating to your_selected_role page:", str(e))
101-
print("Page content during error:")
102-
print(context.page.content())
103-
raise
104-
105-
106-
@then("I can see the your_selected_role header")
85+
expect(select_your_role_page.first_role_card).to_be_visible()
86+
select_your_role_page.first_role_card.click()
87+
context.page.wait_for_url(select_your_role_page.selected_role_url)
88+
89+
90+
@then("I can see the your selected role header")
10791
def i_can_see_select_your_role_header(context):
10892
select_your_role_page = SelectYourRole(context.page)
109-
try:
110-
# Validate only the title text
111-
expect(select_your_role_page.select_role_header).to_have_text(
112-
select_your_role_page.select_role_header_text, timeout=5000
113-
)
114-
print("Verified the your_selected_role header text is correct.")
115-
except Exception as e:
116-
print("Error verifying the your_selected_role header text:", str(e))
117-
print("Page content during error:")
118-
print(context.page.content())
119-
raise
120-
121-
122-
@then("I can see the your_selected_role subheader")
93+
expect(select_your_role_page.select_role_header).to_be_visible()
94+
95+
96+
@then("I can see the your selected role subheader")
12397
def i_can_see_select_your_role_subheader(context):
12498
select_your_role_page = SelectYourRole(context.page)
125-
try:
126-
# Validate the subheader text
127-
expect(select_your_role_page.select_role_subheader).to_have_text(
128-
f"- {select_your_role_page.select_role_subheader_text}", timeout=5000
129-
)
130-
print("Verified the your_selected_role subheader text is correct.")
131-
except Exception as e:
132-
print("Error verifying the your_selected_role subheader text:", str(e))
133-
print("Page content during error:")
134-
print(context.page.content())
135-
raise
99+
expect(select_your_role_page.select_role_subheader).to_be_visible()

pages/select_your_role.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,8 @@ def __init__(self, page: Page):
3333
self.select_role_header = page.locator(
3434
"span[data-testid='eps_header_selectYourRole'] > span.nhsuk-title"
3535
)
36-
self.select_role_header_text = "Select your role"
3736

3837
# Subheader locators
3938
self.select_role_subheader = page.locator(
4039
"span.nhsuk-caption-l.nhsuk-caption--bottom"
4140
)
42-
self.select_role_subheader_text = (
43-
"Select the role you wish to use to access the service."
44-
)
45-
46-
# Header and footer locators
47-
self.header = "[id='eps_header']"
48-
self.footer = "[id='eps_footer']"

0 commit comments

Comments
 (0)