Skip to content

Commit 7532b00

Browse files
committed
Merge branch 'main' into feature/BCSS-20605-regression-tests-subject-notes
2 parents e1ad06c + d29325e commit 7532b00

File tree

4 files changed

+122
-2
lines changed

4 files changed

+122
-2
lines changed

pages/organisations/organisations_page.py

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from playwright.sync_api import Page
22
from pages.base_page import BasePage
3-
3+
from typing import List
44

55
class OrganisationsPage(BasePage):
66
"""Organisations Page locators, and methods for interacting with the page."""
@@ -50,3 +50,76 @@ def go_to_upload_nacs_data_bureau_page(self) -> None:
5050
def go_to_bureau_page(self) -> None:
5151
"""Clicks the 'Bureau' link."""
5252
self.click(self.bureau_page)
53+
54+
class OrganisationSwitchPage:
55+
"""Page Object Model for interacting with the Organisation Switch page."""
56+
57+
def __init__(self, page: Page):
58+
"""
59+
Initializes the OrganisationSwitchPage with locators for key elements.
60+
61+
Args:
62+
page (Page): The Playwright Page object representing the browser page.
63+
"""
64+
self.page = page
65+
self.radio_buttons = self.page.locator("input[type='radio']")
66+
self.selected_radio = self.page.locator("input[name='organisation']:checked")
67+
self.continue_button = self.page.get_by_role("button", name="Continue")
68+
self.select_org_link = self.page.get_by_role("link", name="Select Org")
69+
self.login_info = self.page.locator("td.loginInfo")
70+
71+
def click(self, locator) -> None:
72+
"""
73+
Clicks the given locator element.
74+
75+
Args:
76+
locator: A Playwright Locator object to be clicked.
77+
"""
78+
locator.click()
79+
80+
def get_available_organisation_ids(self) -> List[str]:
81+
"""
82+
Retrieves the list of available organisation IDs from the radio button on the page.
83+
84+
Returns:
85+
List[str]: A list of organisation ID strings.
86+
"""
87+
org_ids = []
88+
count = self.radio_buttons.count()
89+
for element in range(count):
90+
org_id = self.radio_buttons.nth(element).get_attribute("id")
91+
if org_id:
92+
org_ids.append(org_id)
93+
return org_ids
94+
95+
def select_organisation_by_id(self, org_id: str) -> None:
96+
"""
97+
Selects an organisation radio button by its ID.
98+
99+
Args:
100+
org_id (str): The ID of the organisation to select.
101+
"""
102+
self.click(self.page.locator(f"#{org_id}"))
103+
104+
def click_continue(self) -> None:
105+
"""
106+
Clicks the 'Continue' button on the page.
107+
"""
108+
self.click(self.continue_button)
109+
110+
def click_select_org_link(self) -> None:
111+
"""
112+
Clicks the 'Select Org' link to return to the organisation selection page.
113+
"""
114+
self.click(self.select_org_link)
115+
116+
def get_logged_in_text(self) -> str:
117+
"""
118+
Retrieves the logged-in user information from the login info section.
119+
120+
Returns:
121+
str: The text indicating the logged-in user's role or name.
122+
"""
123+
return self.login_info.inner_text()
124+
125+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import pytest
2+
import logging
3+
from utils.user_tools import UserTools
4+
from playwright.sync_api import Page
5+
from pages.organisations.organisations_page import OrganisationSwitchPage
6+
7+
8+
@pytest.mark.regression
9+
def test_user_can_switch_between_organisations(page: Page) -> None:
10+
"""
11+
Feature: Change Organisation
12+
Scenario: Check that an English user with multiple organisations is able to switch between them
13+
Given I log in to BCSS "England" as user role "MultiOrgUser"
14+
When I change organisation
15+
Then I will be logged in as the alternative organisation.
16+
"""
17+
18+
# Log in as a user with multiple organisations
19+
UserTools.user_login(page, "Specialist Screening Practitioner at BCS009 & BCS001")
20+
org_switch_page = OrganisationSwitchPage(page)
21+
22+
# Get the list of available organisation IDs
23+
org_ids = org_switch_page.get_available_organisation_ids()
24+
25+
# Select available organisations in turn and verify the switch
26+
for org_id in org_ids:
27+
# Select the organisation
28+
org_switch_page.select_organisation_by_id(org_id)
29+
30+
# Click continue
31+
org_switch_page.click_continue()
32+
33+
# Assert logged-in org matches expected
34+
login_text = org_switch_page.get_logged_in_text()
35+
logging.info(f"The user's current organisation is: {login_text}")
36+
assert (
37+
org_id in login_text
38+
), f"Expected to be logged in as '{org_id}', but got: {login_text}"
39+
40+
# Return to selection screen
41+
org_switch_page.click_select_org_link()

tests/regression/subject_search_criteria/test_screening_subject_search_criteria_page_regression.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
)
1010

1111
@pytest.mark.regression
12-
@pytest.mark.subject_search
1312
def test_user_can_search_for_subject_and_results_are_returned(page: Page):
1413
"""
1514
Verify that User can log in to BCSS "England" as user role "Hub Manager - State Registered"

users.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,12 @@
4242
"roles": [
4343
"Hub Manager, Southern Bowel Cancer Screening Programme Hub"
4444
]
45+
},
46+
"Specialist Screening Practitioner at BCS009 & BCS001": {
47+
"username": "BCSS120",
48+
"roles": [
49+
"Coventry and Warwickshire Bowel Cancer Screening Centre, MultiOrgUser",
50+
"Wolverhampton Bowel Cancer Screening Centre, MultiOrgUser"
51+
]
4552
}
4653
}

0 commit comments

Comments
 (0)