Skip to content

Commit 11b2360

Browse files
wildjameskris-szlapaanthony-nhs
authored
New: [AEA-4531] - Change Role page (#217)
## Summary - ✨ New Feature ### Details This adds the tests for PR [317](NHSDigital/eps-prescription-tracker-ui#317) --------- Co-authored-by: Kris Szlapa <[email protected]> Co-authored-by: anthony-nhs <[email protected]>
1 parent ef93267 commit 11b2360

13 files changed

+283
-27
lines changed

.devcontainer/devcontainer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
"timonwong.shellcheck",
4444
"github.vscode-github-actions",
4545
"ms-python.pylint",
46-
"ms-python.black-formatter"
46+
"ms-python.black-formatter",
47+
"jimasp.behave-vsc"
4748
],
4849
"settings": {
4950
"python.defaultInterpreterPath": "/workspaces/electronic-prescription-service-api-regression-tests/venv/bin/python",

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Any file that begins with `.env` is automatically ignored by Git
3636
This test pack utilises the power of Docker to quickly and easily spin up a dev environment for you to work in
3737
the Dockerfile is located in `{project_root}/.devcontainer/Dockerfile`
3838

39+
You may need to run `poetry shell` to activate the poetry shell, followed by `make install-playwright` to install the playwright tools. To check if these are installed properly, run `playwright codegen` and check that you see a browser window pop up.
40+
3941
### Setup without docker development environment
4042
If you'd like to use your own machine without containerisation. You will need the following;
4143
* Ubuntu (WSL)
@@ -48,7 +50,7 @@ If you'd like to use your own machine without containerisation. You will need th
4850
#### Once the plugins are added you can install them
4951
`asdf install` This will install the versions as described in .tool-versions
5052

51-
Now you can run `make install` to install the virtualenv and packages
53+
Now you can run `make install` to install the virtualenv and packages. You may need to run `poetry shell` to activate the poetry shell, followed by `make install-playwright` to install the playwright tools. To check if these are installed properly, run `playwright codegen` and check that you see a browser window pop up.
5254

5355
## Developing/Debugging Tests
5456

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
@cpts_ui @change_role @multiple_access @regression @blocker @smoke @ui
2+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4653
3+
Feature: Users are able to change their roles, if they have multiple roles with access.
4+
5+
Background:
6+
Given I am logged in
7+
And I am on the change your role page
8+
9+
############################################################################
10+
# Successfully changing role scenarios
11+
############################################################################
12+
Scenario: User can change their role
13+
When I click a change role role card
14+
Then I am on the 'your selected role' page
15+
16+
Scenario: User can see roles with access cards
17+
Then I see the change role roles with access cards
18+
And I can see multiple change role roles with access cards
19+
20+
############################################################################
21+
# Expanding/collapsing the summary
22+
############################################################################
23+
24+
Scenario: Change role roles without access table body is not visible by default
25+
Then the change role roles without access table body is not visible
26+
27+
Scenario: User can expand the change role 'Roles without access' to see table contents
28+
When I click on the change role summary expander
29+
Then I see the change role roles without access table
30+
31+
Scenario: User can collapse the change role 'Roles without access' to hide table contents
32+
Given the summary table body is displayed
33+
When I click on the change role summary expander
34+
Then The change role roles without access table body is not visible
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@cpts_ui @change_role @no_access @regression @blocker @smoke @ui
2+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4653
3+
Feature: Users are able to change their roles, if they have no role with access.
4+
5+
Background:
6+
Given I am logged in without access
7+
8+
############################################################################
9+
# Unable to change role
10+
############################################################################
11+
Scenario: User sees the 'No role with access' warning
12+
Then I see the change role page 'no role with access' warning message
13+
And I cannot see any change role roles with access cards
14+
15+
############################################################################
16+
# Expanding/collapsing the summary
17+
############################################################################
18+
Scenario: User can expand the change role 'Roles without access' to see table contents
19+
When I click on the change role summary expander
20+
Then I see the change role roles without access table
21+
22+
Scenario: User can collapse the change role 'Roles without access' to hide table contents
23+
Given the summary table body is displayed
24+
When I click on the change role summary expander
25+
Then the change role roles without access table body is not visible
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@cpts_ui @change_role @single_access @regression @blocker @smoke @ui
2+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4653
3+
Feature: Users are able to change their roles, if they have one role with access.
4+
5+
Background:
6+
Given I am logged in with a single access role
7+
8+
9+
Scenario: User is automatically redirected to the 'search for a prescription' page
10+
When I navigate to the change your role page
11+
Then I am on the search for a prescription page
12+
13+
Scenario: User does not have the change role link in the header
14+
Then I do not see the change role page header link

features/cpts_ui/logout.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Feature: The user is able to logout of the application
44

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

99
############################################################################
1010
# Logging out

features/cpts_ui/select_your_role.feature

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@ Feature: Role selection page renders roles properly when logged in
55
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4653
66
Scenario: User can navigate to the select your role page
77
Given I am logged in
8-
And I am on the select your role page
8+
And I go to the select your role page
99

1010
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4656
1111
Scenario: User is redirected to the select your role page
1212
Given I am logged in
13-
And I am on the select your role page
13+
And I go to the select your role page
1414

1515
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4653
1616
Scenario: User can see the summary container, but not the table contents by default
1717
Given I am logged in
18-
And I am on the select your role page
18+
And I go to the select your role page
1919
Then I can see the summary container
2020
And I cannot see the summary table body
2121

2222
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4653
2323
Scenario: User can expand the summary table to see the contents. Clicking again hides it
2424
Given I am logged in
25-
And I am on the select your role page
25+
And I go to the select your role page
2626
When I click on the summary expander
2727
Then I can see the summary table body
2828
And I can see the table body has a header row
@@ -34,40 +34,40 @@ Feature: Role selection page renders roles properly when logged in
3434
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4651
3535
Scenario: User can see roles with access cards
3636
Given I am logged in
37-
And I am on the select your role page
37+
And I go to the select your role page
3838
Then I can see the roles with access cards
3939

4040
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4651
4141
Scenario: User can navigate to the your selected role page
4242
Given I am logged in
43-
And I am on the select your role page
43+
And I go to the select your role page
4444
Then I can navigate to the your selected role page by clicking a card
4545

4646
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4655
4747
Scenario: User without access can see the header on the select your role page
4848
Given I am logged in without access
49-
And I am on the select your role page
49+
And I go to the select your role page
5050
Then I cannot see the your selected role subheader
5151
And I can see the no access header
5252

5353
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4655
5454
Scenario: User without access can see the message on the select your role page
5555
Given I am logged in without access
56-
And I am on the select your role page
56+
And I go to the select your role page
5757
Then I cannot see the your selected role subheader
5858
And I can see the no access message
5959

6060
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4655
6161
Scenario: User without access can see the summary container, but not the table contents by default
6262
Given I am logged in without access
63-
And I am on the select your role page
63+
And I go to the select your role page
6464
Then I can see the summary container
6565
And I cannot see the summary table body
6666

6767
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4655
6868
Scenario: User without access can expand the summary table to see the contents. Clicking again hides it
6969
Given I am logged in without access
70-
And I am on the select your role page
70+
And I go to the select your role page
7171
When I click on the summary expander
7272
Then I can see the summary table body
7373
And I can see the table body has a header row

features/steps/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
from cpts_ui.search_for_a_prescription_steps import * # noqa: F403,F401
33
from cpts_ui.home_steps import * # noqa: F403,F401
44
from cpts_ui.select_your_role_steps import * # noqa: F403,F401
5+
from cpts_ui.change_role_steps import * # noqa: F403,F401
56
from cpts_ui.logout_steps import * # noqa: F403,F401
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# pylint: disable=no-name-in-module
2+
import re
3+
from behave import given, when, then # pyright: ignore [reportAttributeAccessIssue]
4+
from playwright.sync_api import expect
5+
6+
from pages.change_role import ChangeRole
7+
8+
9+
selected_role_url_pattern = re.compile(r".*/yourselectedrole(?:/|\.html)?$")
10+
change_role_url_pattern = re.compile(r".*/changerole(?:/|\.html)?$")
11+
12+
13+
############################################################################
14+
# GIVEN STEPS
15+
############################################################################
16+
17+
18+
@given("I am on the change your role page")
19+
def given_i_am_on_the_change_role_page(context):
20+
context.execute_steps("when I navigate to the change your role page")
21+
change_role_page = ChangeRole(context.page)
22+
23+
change_role_page.page.wait_for_url(change_role_url_pattern)
24+
25+
26+
@given("the summary table body is displayed")
27+
def given_the_summary_table_body_is_displayed(context):
28+
change_role_page = ChangeRole(context.page)
29+
30+
# Expand the summary if it's not visible yet
31+
if not change_role_page.roles_without_access_table_body.is_visible():
32+
change_role_page.roles_without_access_table.click()
33+
expect(change_role_page.roles_without_access_table_body).to_be_visible()
34+
35+
36+
@given("I am on the 'your selected role' page")
37+
def given_i_am_on_your_selected_role_page(context):
38+
change_role_page = ChangeRole(context.page)
39+
context.execute_steps("given I am on the change your role page")
40+
context.execute_steps("when I click a role card")
41+
expect(change_role_page.select_role_header).to_be_visible()
42+
43+
44+
############################################################################
45+
# WHEN STEPS
46+
############################################################################
47+
48+
49+
@when("I click on the change role summary expander")
50+
def when_i_click_on_the_summary_expander(context):
51+
change_role_page = ChangeRole(context.page)
52+
change_role_page.roles_without_access_table.click()
53+
54+
55+
@when("I click a change role role card")
56+
def when_i_click_a_role_card(context):
57+
change_role_page = ChangeRole(context.page)
58+
expect(change_role_page.first_role_card).to_be_visible()
59+
change_role_page.first_role_card.click()
60+
61+
# Wait for the page or route change
62+
context.page.wait_for_url(selected_role_url_pattern)
63+
64+
65+
@when("I click the change role header link")
66+
def when_i_click_change_role_header_link(context):
67+
change_role_page = ChangeRole(context.page)
68+
change_role_page.page.get_by_test_id("eps_header_changeRoleLink").click()
69+
70+
71+
@when("I navigate to the change your role page")
72+
def when_i_navigate_to_the_change_your_role_page(context):
73+
change_role_page = ChangeRole(context.page)
74+
75+
change_role_page.page.goto(context.cpts_ui_base_url + "site")
76+
change_role_page.change_role_header.click()
77+
change_role_page.page.wait_for_url(change_role_url_pattern, timeout=5000)
78+
79+
80+
############################################################################
81+
# THEN STEPS
82+
############################################################################
83+
84+
85+
@then("I see the change role roles without access table")
86+
def then_i_see_the_roles_without_access_table(context):
87+
change_role_page = ChangeRole(context.page)
88+
expect(change_role_page.roles_without_access_table).to_be_visible()
89+
90+
# Check header row
91+
expect(
92+
change_role_page.roles_without_access_organisation_column_header
93+
).to_be_visible()
94+
expect(change_role_page.roles_without_access_role_column_header).to_be_visible()
95+
96+
# Check data
97+
expect(change_role_page.first_row_org_name).to_be_visible()
98+
expect(change_role_page.first_row_role_name).to_be_visible()
99+
100+
101+
@then("the change role roles without access table body is not visible")
102+
def then_roles_without_access_table_body_is_not_visible(context):
103+
change_role_page = ChangeRole(context.page)
104+
expect(change_role_page.roles_without_access_table_body).not_to_be_visible()
105+
106+
107+
@then("I see the change role roles with access cards")
108+
def then_i_see_the_roles_with_access_cards(context):
109+
change_role_page = ChangeRole(context.page)
110+
expect(change_role_page.first_role_card).to_be_visible()
111+
112+
113+
@then("I can see multiple change role roles with access cards")
114+
def then_i_see_multiple_change_role_roles_with_access_cards(context):
115+
change_role_page = ChangeRole(context.page)
116+
assert change_role_page.roles_with_access_cards.count() > 1
117+
118+
119+
@then("I can see one change role roles with access cards")
120+
def then_i_see_one_change_role_roles_with_access_cards(context):
121+
change_role_page = ChangeRole(context.page)
122+
assert change_role_page.roles_with_access_cards.count() == 1
123+
124+
125+
@then("I cannot see any change role roles with access cards")
126+
def then_i_cant_see_roles_with_access_cards(context):
127+
change_role_page = ChangeRole(context.page)
128+
expect(change_role_page.first_role_card).not_to_be_visible()
129+
130+
131+
@then("I am on the 'your selected role' page")
132+
def then_i_am_on_your_selected_role_page(context):
133+
context.page.wait_for_url(selected_role_url_pattern)
134+
135+
136+
@then("I do not see the change role page header link")
137+
def then_i_can_not_see_the_change_your_role_page_header_link(context):
138+
change_role_page = ChangeRole(context.page)
139+
expect(change_role_page.change_role_header).not_to_be_visible()
140+
141+
142+
@then("I see the change role page 'no role with access' warning message")
143+
def i_see_the_change_role_page_no_role_with_access_warning_message(context):
144+
change_role_page = ChangeRole(context.page)
145+
expect(change_role_page.no_access_title).to_be_visible()
146+
expect(change_role_page.no_access_content).to_be_visible()

features/steps/cpts_ui/common_steps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def i_am_on_home_page(context):
2323
@given("I am on the login page")
2424
def i_am_on_login_page(context):
2525
context.execute_steps("given I am on the home page")
26-
context.page.get_by_test_id("eps_header_placeholder2").click()
26+
context.page.get_by_test_id("eps_header_serviceName").click()
2727

2828

2929
@given("I am logged in")

0 commit comments

Comments
 (0)