Skip to content

Commit 800b280

Browse files
authored
Fix: [AEA-0000] - Fix header link behaviour (#218)
## Summary - Routine Change ### Details The header link behaviour was getting unwieldy and straying a bit too far from what we intended. This brings it back in line.
1 parent 11b2360 commit 800b280

File tree

10 files changed

+164
-14
lines changed

10 files changed

+164
-14
lines changed

features/cpts_ui/change_role_no_access.feature

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@cpts_ui @change_role @no_access @regression @blocker @smoke @ui
22
@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.
3+
Feature: Users are unable to change their roles, if they have no role with access.
44

55
Background:
66
Given I am logged in without access
@@ -15,10 +15,6 @@ Feature: Users are able to change their roles, if they have no role with access.
1515
############################################################################
1616
# Expanding/collapsing the summary
1717
############################################################################
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-
2218
Scenario: User can collapse the change role 'Roles without access' to hide table contents
2319
Given the summary table body is displayed
2420
When I click on the change role summary expander

features/cpts_ui/change_role_one_with_access.feature

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ Feature: Users are able to change their roles, if they have one role with access
55
Background:
66
Given I am logged in with a single access role
77

8-
98
Scenario: User is automatically redirected to the 'search for a prescription' page
10-
When I navigate to the change your role page
119
Then I am on the search for a prescription page
10+
And I do not see the "Change Role" link
1211

1312
Scenario: User does not have the change role link in the header
1413
Then I do not see the change role page header link
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
@cpts_ui @header_links @regression @blocker @smoke @ui
2+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-XXXX
3+
Feature: Header links are displayed according to the user's state and the current page
4+
5+
############################################################################
6+
# EXIT
7+
############################################################################
8+
Scenario: Exit link is shown on the logout page once the user signs out
9+
Given I am logged in
10+
And The logout confirmation modal is displayed
11+
When I confirm the logout
12+
Then I see the "Exit" link
13+
14+
Scenario: Exit link is shown on the select your role page if the user has no roles with access
15+
Given I am logged in without access
16+
Then I see the "Exit" link
17+
18+
Scenario: Exit link is not shown if user has at least one role with access on the select your role page
19+
Given I am logged in with a single access role
20+
Then I do not see the "Exit" link
21+
22+
############################################################################
23+
# LOGOUT
24+
############################################################################
25+
Scenario: Logout link is shown for a logged in user
26+
Given I am logged in
27+
Then I see the "Logout" link
28+
29+
Scenario: Logout link is not shown if user is not logged in
30+
Given I am on the home page
31+
Then I do not see the "Logout" link
32+
33+
############################################################################
34+
# SELECT YOUR ROLE
35+
############################################################################
36+
Scenario: Select Your Role link is shown on the homepage, if we dont select a role
37+
Given I am logged in
38+
And I am on the home page
39+
Then I see the "Select Your Role" link
40+
41+
Scenario: Select Your Role link is not shown if I go to the select your role page
42+
Given I am logged in
43+
And I go to the select your role page
44+
Then I do not see the "Select Your Role" link
45+
46+
Scenario: Select Your Role link is not shown if I already have a selected role
47+
Given I am logged in
48+
And I have a selected role
49+
And I am on the homepage
50+
Then I do not see the "Select Your Role" link
51+
52+
############################################################################
53+
# CHANGE ROLE
54+
############################################################################
55+
Scenario: Change Role link is shown if the user has a selected role
56+
Given I am logged in
57+
And I have a selected role
58+
And I am on the home page
59+
Then I see the "Change Role" link
60+
61+
Scenario: Change Role link is not shown if the user has no selected role
62+
Given I am logged in
63+
And I am on the homepage
64+
Then I do not see the "Change Role" link
65+
66+
# FIXME: Address this when the SPA is fixed!
67+
# Since the SPA is broken, there's actually no reliable way to navigate to the SYR page
68+
# once you've selected a role!
69+
# @fixme
70+
# Scenario: Change Role link is not shown if I go to the select your role page
71+
# Given I am logged in
72+
# And I have a selected role
73+
# And I go to the select your role page
74+
# Then I do not see the "Change Role" link
75+
76+
Scenario: Change Role link is not shown if I am on the change role page
77+
Given I am logged in
78+
When I go to change my role
79+
Then I do not see the "Change Role" link

features/cpts_ui/home.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Feature: I can visit the Clinical Prescription Tracker Service Website
1515
Scenario: user can see the header
1616
Given I am on the homepage
1717
Then I can see the header
18-
# And I can see the links on the header
1918

2019
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4513
2120
Scenario: user sees a menu with links when the screen size is small

features/steps/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
from cpts_ui.select_your_role_steps import * # noqa: F403,F401
55
from cpts_ui.change_role_steps import * # noqa: F403,F401
66
from cpts_ui.logout_steps import * # noqa: F403,F401
7+
from cpts_ui.header_steps import * # noqa: F403,F401

features/steps/cpts_ui/change_role_steps.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# pylint: disable=no-name-in-module
22
import re
3+
from time import sleep
34
from behave import given, when, then # pyright: ignore [reportAttributeAccessIssue]
45
from playwright.sync_api import expect
56

@@ -17,10 +18,10 @@
1718

1819
@given("I am on the change your role page")
1920
def given_i_am_on_the_change_role_page(context):
20-
context.execute_steps("when I navigate to the change your role page")
21+
context.execute_steps("when I go to change my role")
2122
change_role_page = ChangeRole(context.page)
2223

23-
change_role_page.page.wait_for_url(change_role_url_pattern)
24+
expect(change_role_page.change_role_title).to_be_visible(timeout=60000)
2425

2526

2627
@given("the summary table body is displayed")
@@ -68,13 +69,15 @@ def when_i_click_change_role_header_link(context):
6869
change_role_page.page.get_by_test_id("eps_header_changeRoleLink").click()
6970

7071

71-
@when("I navigate to the change your role page")
72-
def when_i_navigate_to_the_change_your_role_page(context):
72+
@when("I go to change my role")
73+
def i_go_to_change_my_role(context):
74+
context.execute_steps("Given I have a selected role")
7375
change_role_page = ChangeRole(context.page)
7476

75-
change_role_page.page.goto(context.cpts_ui_base_url + "site")
77+
# We need to give the backend time to catch up?
78+
sleep(1)
7679
change_role_page.change_role_header.click()
77-
change_role_page.page.wait_for_url(change_role_url_pattern, timeout=5000)
80+
change_role_page.page.wait_for_url(change_role_url_pattern)
7881

7982

8083
############################################################################
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# pylint: disable=no-name-in-module
2+
from behave import then # pyright: ignore [reportAttributeAccessIssue]
3+
from playwright.sync_api import expect
4+
5+
from pages.header_links import HeaderLinks
6+
7+
8+
@then('I see the "Exit" link')
9+
def i_see_exit_link(context):
10+
header_links = HeaderLinks(context.page)
11+
expect(header_links.exit_link).to_be_visible()
12+
13+
14+
@then('I do not see the "Exit" link')
15+
def dont_see_exit_link(context):
16+
header_links = HeaderLinks(context.page)
17+
expect(header_links.exit_link).not_to_be_visible()
18+
19+
20+
@then('I see the "Logout" link')
21+
def i_see_logout_link(context):
22+
header_links = HeaderLinks(context.page)
23+
expect(header_links.logout_link).to_be_visible()
24+
25+
26+
@then('I do not see the "Logout" link')
27+
def dont_see_logout_link(context):
28+
header_links = HeaderLinks(context.page)
29+
expect(header_links.logout_link).not_to_be_visible()
30+
31+
32+
@then('I see the "Select Your Role" link')
33+
def i_see_select_role_link(context):
34+
header_links = HeaderLinks(context.page)
35+
expect(header_links.select_role_link).to_be_visible()
36+
37+
38+
@then('I do not see the "Select Your Role" link')
39+
def dont_see_select_role_link(context):
40+
header_links = HeaderLinks(context.page)
41+
expect(header_links.select_role_link).not_to_be_visible()
42+
43+
44+
@then('I see the "Change Role" link')
45+
def i_see_change_role_link(context):
46+
header_links = HeaderLinks(context.page)
47+
expect(header_links.change_role_link).to_be_visible()
48+
49+
50+
@then('I do not see the "Change Role" link')
51+
def dont_see_change_role_link(context):
52+
header_links = HeaderLinks(context.page)
53+
expect(header_links.change_role_link).not_to_be_visible()

features/steps/cpts_ui/select_your_role_steps.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ def i_go_to_the_select_your_role_page(context):
1111
context.page.get_by_test_id("eps_header_selectYourRoleLink").click()
1212

1313

14+
@given("I have a selected role")
15+
def i_have_selected_role(context):
16+
context.execute_steps("given I go to the select your role page")
17+
18+
select_your_role_page = SelectYourRole(context.page)
19+
select_your_role_page.first_role_card.click()
20+
21+
1422
@then("I can see the summary container")
1523
def i_can_see_the_summary_container(context):
1624
select_your_role_page = SelectYourRole(context.page)

pages/change_role.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def __init__(self, page: Page):
99
self.page = page
1010

1111
# Title and summary locators
12+
self.change_role_title = page.get_by_text("Change your role")
1213
self.roles_without_access_table = page.locator("summary")
1314
self.roles_without_access_organisation_column_header = page.get_by_role(
1415
"columnheader", name="Organisation"

pages/header_links.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 HeaderLinks:
5+
def __init__(self, page: Page):
6+
self.page = page
7+
8+
self.exit_link = page.get_by_test_id("eps_header_exit")
9+
self.logout_link = page.get_by_test_id("eps_header_logout")
10+
self.select_role_link = page.get_by_test_id("eps_header_selectYourRoleLink")
11+
self.change_role_link = page.get_by_test_id("eps_header_changeRoleLink")

0 commit comments

Comments
 (0)