Skip to content

Commit f8e2010

Browse files
authored
New: [AEA-4655] - User has no access to CPTS (#208)
## Summary 🎫 [AEA-4655](https://nhsd-jira.digital.nhs.uk/browse/AEA-4655) User has no access to CPTS **PR** [https://github.com/NHSDigital/eps-prescription-tracker-ui/pull/282](https://github.com/NHSDigital/eps-prescription-tracker-ui/pull/282) - Routine Change ### Details 🧪 Regression tests for a user without access to CPTS
1 parent 359d74e commit f8e2010

File tree

7 files changed

+154
-56
lines changed

7 files changed

+154
-56
lines changed

features/cpts_ui/logout.feature

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,39 @@ Feature: The user is able to logout of the application
99
############################################################################
1010
# Logging out
1111
############################################################################
12-
Scenario: Display logout modal when user clicks logout
13-
When I click the logout button
14-
Then I see the logout confirmation modal
12+
# Scenario: Display logout modal when user clicks logout
13+
# When I click the logout button
14+
# Then I see the logout confirmation modal
1515

16-
Scenario: User confirms logout
17-
Given the logout confirmation modal is displayed
18-
When I confirm the logout
19-
Then I see the logout successful page
16+
# Scenario: User confirms logout
17+
# Given the logout confirmation modal is displayed
18+
# When I confirm the logout
19+
# Then I see the logout successful page
2020

21-
Scenario: User can log back in from the logout successful page
22-
Given I am on the logout successful page
23-
When I click the "log back in" button
24-
Then I am on the login page
21+
# Scenario: User can log back in from the logout successful page
22+
# Given I am on the logout successful page
23+
# When I click the "log back in" button
24+
# Then I am on the login page
2525

2626
############################################################################
2727
# Closing the logout modal
2828
############################################################################
29-
Scenario: Close the modal with the cross icon
30-
Given the logout confirmation modal is displayed
31-
When I close the modal with the cross
32-
Then the logout confirmation modal is not displayed
33-
34-
Scenario: Close the modal with the cancel button
35-
Given the logout confirmation modal is displayed
36-
When I close the modal with the cancel button
37-
Then the logout confirmation modal is not displayed
38-
39-
Scenario: Close the modal by clicking outside the modal
40-
Given the logout confirmation modal is displayed
41-
When I close the modal by clicking outside the modal
42-
Then the logout confirmation modal is not displayed
43-
44-
Scenario: Close the modal by pressing the escape key
45-
Given the logout confirmation modal is displayed
46-
When I close the modal by hitting escape
47-
Then the logout confirmation modal is not displayed
29+
# Scenario: Close the modal with the cross icon
30+
# Given the logout confirmation modal is displayed
31+
# When I close the modal with the cross
32+
# Then the logout confirmation modal is not displayed
33+
34+
# Scenario: Close the modal with the cancel button
35+
# Given the logout confirmation modal is displayed
36+
# When I close the modal with the cancel button
37+
# Then the logout confirmation modal is not displayed
38+
39+
# Scenario: Close the modal by clicking outside the modal
40+
# Given the logout confirmation modal is displayed
41+
# When I close the modal by clicking outside the modal
42+
# Then the logout confirmation modal is not displayed
43+
44+
# Scenario: Close the modal by pressing the escape key
45+
# Given the logout confirmation modal is displayed
46+
# When I close the modal by hitting escape
47+
# Then the logout confirmation modal is not displayed

features/cpts_ui/search_for_a_prescription.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4460
33
Feature: I can visit the Clinical Prescription Tracker Service Website
44

5-
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4653
5+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4656
66
Scenario: User is redirected to the Search For A Prescription Page
77
Given I am logged in with a single access role
88
Then I am on the search for a prescription page

features/cpts_ui/select_your_role.feature

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,27 @@
22
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4653
33
Feature: Role selection page renders roles properly when logged in
44

5-
Background:
5+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4653
6+
Scenario: User can navigate to the select your role page
67
Given I am logged in
8+
Then I am on the select your role page
79

8-
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4653
10+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4656
911
Scenario: User is redirected to the select your role page
12+
Given I am logged in
1013
Then I am on the select your role page
1114

1215
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4653
1316
Scenario: User can see the summary container, but not the table contents by default
17+
Given I am logged in
18+
Then I am on the select your role page
1419
Then I can see the summary container
1520
And I cannot see the summary table body
1621

1722
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4653
1823
Scenario: User can expand the summary table to see the contents. Clicking again hides it
24+
Given I am logged in
25+
Then I am on the select your role page
1926
When I click on the summary expander
2027
Then I can see the summary table body
2128
And I can see the table body has a header row
@@ -26,16 +33,45 @@ Feature: Role selection page renders roles properly when logged in
2633

2734
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4651
2835
Scenario: User can see roles with access cards
36+
Given I am logged in
37+
Then I am on the select your role page
2938
Then I can see the roles with access cards
3039

3140
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4651
3241
Scenario: User can navigate to the your selected role page
42+
Given I am logged in
43+
Then I am on the select your role page
3344
Then I can navigate to the your selected role page by clicking a card
3445

35-
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4658
36-
Scenario: User can see the header on the select your role page
37-
Then I can see the your selected role header
46+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4655
47+
Scenario: User without access can see the header on the select your role page
48+
Given I am logged in without access
49+
Then I am on the select your role page
50+
Then I cannot see the your selected role subheader
51+
And I can see the no access header
52+
53+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4655
54+
Scenario: User without access can see the message on the select your role page
55+
Given I am logged in without access
56+
Then I am on the select your role page
57+
Then I cannot see the your selected role subheader
58+
And I can see the no access message
3859

39-
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4658
40-
Scenario: User can see the subheader on the select your role page
41-
Then I can see the your selected role subheader
60+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4655
61+
Scenario: User without access can see the summary container, but not the table contents by default
62+
Given I am logged in without access
63+
Then I am on the select your role page
64+
Then I can see the summary container
65+
And I cannot see the summary table body
66+
67+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4655
68+
Scenario: User without access can expand the summary table to see the contents. Clicking again hides it
69+
Given I am logged in without access
70+
Then I am on the select your role page
71+
When I click on the summary expander
72+
Then I can see the summary table body
73+
And I can see the table body has a header row
74+
And I can see the no access table body has data
75+
When I click on the summary expander
76+
Then I can see the summary container
77+
And I cannot see the summary table body

features/environment.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
MOCK_CIS2_LOGIN_ID_MULTIPLE_ACCESS_ROLES = "555073103100"
5454
MOCK_CIS2_LOGIN_ID_NO_ACCESS_ROLE = "555083343101"
5555
MOCK_CIS2_LOGIN_ID_SINGLE_ACCESS_ROLE = "555043300081"
56+
MOCK_CIS2_LOGIN_ID_NO_ROLES = "555073103101"
5657

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

features/steps/cpts_ui/common_steps.py

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# pylint: disable=no-name-in-module
22
from behave import given, then # pyright: ignore [reportAttributeAccessIssue]
33

4-
from features.environment import MOCK_CIS2_LOGIN_ID_MULTIPLE_ACCESS_ROLES
4+
from features.environment import (
5+
MOCK_CIS2_LOGIN_ID_MULTIPLE_ACCESS_ROLES,
6+
MOCK_CIS2_LOGIN_ID_NO_ACCESS_ROLE,
7+
)
58

69

710
@then("I am logged out")
@@ -16,23 +19,41 @@ def i_am_logged_out(context):
1619
assert len(cognito_cookies) == 0
1720

1821

22+
# @given("I am logged in") #AEA-4809
23+
# def login(context):
24+
# # TODO: This /site/ is not generic. Also, the .html will need to be removed when the SPA is fixed
25+
# context.page.goto(context.cpts_ui_base_url + "site/auth_demo.html")
26+
# context.page.get_by_role("button", name="Log in with mock CIS2").click()
27+
# context.page.get_by_label("Username").fill(MOCK_CIS2_LOGIN_ID_MULTIPLE_ACCESS_ROLES)
28+
# context.page.get_by_role("button", name="Sign In").click()
29+
# context.page.wait_for_url("**/selectyourrole.html")
30+
31+
# # There should be cookies with names starting with "CognitoIdentityServiceProvider"
32+
# cookies = context.page.context.cookies()
33+
# cognito_cookies = [
34+
# cookie
35+
# for cookie in cookies
36+
# if cookie["name"].startswith("CognitoIdentityServiceProvider")
37+
# ]
38+
# assert len(cognito_cookies) > 0
39+
40+
1941
@given("I am logged in")
2042
def login(context):
21-
# TODO: This /site/ is not generic. Also, the .html will need to be removed when the SPA is fixed
22-
context.page.goto(context.cpts_ui_base_url + "site/login.html")
43+
context.page.goto(context.cpts_ui_base_url + "site/auth_demo.html")
2344
context.page.get_by_role("button", name="Log in with mock CIS2").click()
2445
context.page.get_by_label("Username").fill(MOCK_CIS2_LOGIN_ID_MULTIPLE_ACCESS_ROLES)
2546
context.page.get_by_role("button", name="Sign In").click()
2647
context.page.wait_for_url("**/selectyourrole.html")
2748

28-
# There should be cookies with names starting with "CognitoIdentityServiceProvider"
29-
cookies = context.page.context.cookies()
30-
cognito_cookies = [
31-
cookie
32-
for cookie in cookies
33-
if cookie["name"].startswith("CognitoIdentityServiceProvider")
34-
]
35-
assert len(cognito_cookies) > 0
49+
50+
@given("I am logged in without access")
51+
def login_without_access(context):
52+
context.page.goto(context.cpts_ui_base_url + "site/auth_demo.html")
53+
context.page.get_by_role("button", name="Log in with mock CIS2").click()
54+
context.page.get_by_label("Username").fill(MOCK_CIS2_LOGIN_ID_NO_ACCESS_ROLE)
55+
context.page.get_by_role("button", name="Sign In").click()
56+
context.page.wait_for_url("**/selectyourrole.html")
3657

3758

3859
@then("I am on the login page")

features/steps/cpts_ui/select_your_role_steps.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,32 @@ def i_can_navigate_to_the_your_selected_role_page(context):
7878
context.page.wait_for_url(select_your_role_page.selected_role_url)
7979

8080

81+
@then("I cannot see the your selected role subheader")
82+
def i_can_see_select_your_role_subheader(context):
83+
select_your_role_page = SelectYourRole(context.page)
84+
expect(select_your_role_page.select_role_subheader).to_be_visible(visible=False)
85+
86+
8187
@then("I can see the your selected role header")
8288
def i_can_see_select_your_role_header(context):
8389
select_your_role_page = SelectYourRole(context.page)
8490
expect(select_your_role_page.select_role_header).to_be_visible()
8591

8692

87-
@then("I can see the your selected role subheader")
88-
def i_can_see_select_your_role_subheader(context):
93+
@then("I can see the no access header")
94+
def i_can_see_the_no_access_header(context):
95+
select_your_role_page = SelectYourRole(context.page)
96+
expect(select_your_role_page.no_access_header).to_be_visible()
97+
98+
99+
@then("I can see the no access message")
100+
def i_can_see_the_no_access_message(context):
101+
select_your_role_page = SelectYourRole(context.page)
102+
expect(select_your_role_page.no_access_message).to_be_visible()
103+
104+
105+
@then("I can see the no access table body has data")
106+
def i_can_see_the_no_access_table_body_data(context):
89107
select_your_role_page = SelectYourRole(context.page)
90-
expect(select_your_role_page.select_role_subheader).to_be_visible()
108+
expect(select_your_role_page.first_row_org_name_no_access).to_be_visible()
109+
expect(select_your_role_page.first_row_role_name_no_access).to_be_visible()

pages/select_your_role.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,33 @@ def __init__(self, page: Page):
2929
self.role_card_descriptions = page.locator(".eps-card__roleName")
3030
self.selected_role_url = "**/site/yourselectedrole"
3131

32-
# Header locators
3332
self.select_role_header = page.locator(
3433
"span[data-testid='eps_header_selectYourRole'] > span.nhsuk-title"
3534
)
36-
37-
# Subheader locators
3835
self.select_role_subheader = page.locator(
3936
"span.nhsuk-caption-l.nhsuk-caption--bottom"
4037
)
38+
39+
self.no_access_header = page.locator(".nhsuk-heading-xl")
40+
self.no_access_message = page.get_by_text("None of the roles on your")
41+
self.roles_without_access_header = page.get_by_role(
42+
"heading", name="Your roles without access"
43+
)
44+
self.first_row_org_name_no_access = page.get_by_role(
45+
"cell", name="NO ORG NAME (ODS: A21464)"
46+
).first
47+
self.first_row_role_name_no_access = page.get_by_role(
48+
"cell", name="General Medical Practitioner"
49+
).first
50+
51+
self.no_access_header = page.locator(".nhsuk-heading-xl")
52+
self.no_access_message = page.get_by_text("None of the roles on your")
53+
self.roles_without_access_header = page.get_by_role(
54+
"heading", name="Your roles without access"
55+
)
56+
self.first_row_org_name_no_access = page.get_by_role(
57+
"cell", name="NO ORG NAME (ODS: A21464)"
58+
).first
59+
self.first_row_role_name_no_access = page.get_by_role(
60+
"cell", name="General Medical Practitioner"
61+
).first

0 commit comments

Comments
 (0)