Skip to content

Commit 9cb54b3

Browse files
As per PR # 98 review comments, code change is implemented.
1 parent 4ba9df2 commit 9cb54b3

File tree

1 file changed

+41
-32
lines changed

1 file changed

+41
-32
lines changed
Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,49 @@
11
import pytest
2+
from playwright.sync_api import Page
23
from utils.user_tools import UserTools
3-
from playwright.sync_api import Page, expect
4-
from pages.organisations.organisations_page import OrganisationSwitchPage
4+
from pages.organisations.organisations_page import (
5+
OrganisationSwitchPage,
6+
NoOrganisationAvailableError,
7+
OrganisationNotSelectedError,
8+
ContinueButtonNotFoundError,
9+
)
510

6-
@pytest.mark.wip
711
@pytest.mark.regression
812
@pytest.mark.organisation_switch
9-
def test_user_can_switch_between_organisations(page: Page)-> None:
13+
def test_user_can_switch_between_two_organisations_using_continue_button(page: Page):
1014
"""
11-
Feature: Change Organisation
12-
13-
Scenario: Check that an English user with multiple organisations is able to switch between them
14-
Given I log in to BCSS "England" as user role "MultiOrgUser"
15-
When I change organisation
16-
Then I will be logged in as the alternative organisation.
15+
Scenario:
16+
User switches from Org 1 → Continue → Home → 'Select Organisation' → Org 2 → Continue → Home → Return.
17+
Verifies switch success using aria role-based 'Continue' button logic.
1718
"""
18-
19-
# Log in as MultiOrgUser
2019
UserTools.user_login(page, "Specialist Screening Practitioner at BCS009")
21-
22-
org_switch_page = OrganisationSwitchPage(page)
23-
24-
# Switch between all available organisations by their ids (no hardcoded values)
25-
org_switch_page.switch_between_organisations()
26-
27-
28-
29-
30-
31-
32-
33-
34-
35-
36-
37-
38-
39-
40-
20+
org_page = OrganisationSwitchPage(page)
21+
22+
try:
23+
org_ids = org_page.get_available_organisation_ids()
24+
org1, org2 = org_ids[:2]
25+
26+
# Select Org 1 → Continue → Home
27+
org_page.select_organisation_by_id(org1)
28+
org_page.click_continue_button()
29+
selected_1 = org_page.get_selected_organisation_id()
30+
assert selected_1 == org1, f"Expected org '{org1}', got '{selected_1}'"
31+
32+
# Return to Change Org screen
33+
org_page.return_to_change_org_page()
34+
35+
# Select Org 2 → Continue → Home
36+
org_page.select_organisation_by_id(org2)
37+
org_page.click_continue_button()
38+
selected_2 = org_page.get_selected_organisation_id()
39+
assert selected_2 == org2, f"Expected org '{org2}', got '{selected_2}'"
40+
assert selected_1 != selected_2, "Organisation switch did not occur."
41+
42+
except NoOrganisationAvailableError:
43+
pytest.skip("Skipping test — fewer than two organisations available.")
44+
except (ContinueButtonNotFoundError, OrganisationNotSelectedError) as e:
45+
page.screenshot(path="org_switch_failure.png")
46+
pytest.fail(f"Test failed: {e}")
47+
except Exception as e:
48+
page.screenshot(path="unexpected_error.png")
49+
pytest.fail(f"Unexpected error: {e}")

0 commit comments

Comments
 (0)