Skip to content

Commit 576bed9

Browse files
committed
Working on organisation test
1 parent 0b8378e commit 576bed9

File tree

8 files changed

+335
-9
lines changed

8 files changed

+335
-9
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import logging
2+
from playwright.sync_api import Page,expect
3+
from pages.base_page import BasePage
4+
5+
6+
class CreateOrganisation(BasePage):
7+
"""Create Organisation Page locators, and methods for interacting with the page."""
8+
9+
def __init__(self, page: Page):
10+
super().__init__(page)
11+
self.page = page
12+
13+
# Create Organisation links
14+
self.organisation_code = self.page.get_by_label("Organisation Code*")
15+
self.organisation_name = self.page.get_by_label("Organisation Name*")
16+
self.start_date_calendar = self.page.locator("#UI_START_DATE_LinkOrButton")
17+
self.audit_reason = self.page.get_by_label("Audit Reason*")
18+
self.date_of_diagnosis_textbox = self.page.get_by_role(
19+
"textbox", name="Date of Diagnosis"
20+
)
21+
self.save_button = self.page.get_by_role("button", name="Save")
22+
23+
def fill_organisation_code(self, text: str) -> None:
24+
"""
25+
This method is designed to fill in the Organisation Code field on the Create Organisation page.
26+
Returns:
27+
None
28+
"""
29+
logging.info("Filling Organisation Code on Create Organisation page")
30+
self.organisation_code.fill(text)
31+
32+
def fill_organisation_name(self, text: str) -> None:
33+
"""
34+
This method is designed to fill in the Organisation Name field on the Create Organisation page.
35+
Returns:
36+
None
37+
"""
38+
logging.info("Filling Organisation Name on Create Organisation page")
39+
self.organisation_name.fill(text)
40+
41+
def click_start_date_calendar(self) -> None:
42+
"""
43+
This method is designed to click the Start Date Calendar button on the Create Organisation page.
44+
Returns:
45+
None
46+
"""
47+
logging.info("Clicking Start Date Calendar on Create Organisation page")
48+
self.start_date_calendar.click()
49+
def fill_audit_reason(self, text: str) -> None:
50+
"""
51+
This method is designed to fill in the Audit Reason field on the Create Organisation page.
52+
Returns:
53+
None
54+
"""
55+
logging.info("Filling Audit Reason on Create Organisation page")
56+
self.audit_reason.fill(text)
57+
def click_save_button(self) -> None:
58+
"""
59+
This method is designed to click the Save button on the Create Organisation page.
60+
Returns:
61+
None
62+
"""
63+
logging.info("Clicking Save button on Create Organisation page")
64+
self.save_button.click()
65+
66+
def verify_success_message(self) -> None:
67+
""" Verifies that the success message is displayed after saving the organisation.
68+
69+
"""
70+
logging.info("Verifying success message on Create Organisation page")
71+
expect(self.page.locator("th")).to_contain_text("The action was performed successfully")

pages/organisations/create_site.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import logging
2+
from playwright.sync_api import Page, expect
3+
from pages.base_page import BasePage
4+
5+
6+
class CreateSite(BasePage):
7+
"""Create Site Page locators, and methods for interacting with the page."""
8+
9+
def __init__(self, page: Page):
10+
super().__init__(page)
11+
self.page = page
12+
13+
# Create Site links
14+
self.site_code = self.page.get_by_label("Site Code*")
15+
self.site_name = self.page.get_by_label("Site Name*")
16+
self.start_date_calendar = self.page.locator("#START_DATE_LinkOrButton")
17+
self.audit_reason = self.page.get_by_label("Audit Reason*")
18+
self.save_button = self.page.get_by_role("button", name="Save")
19+
20+
def fill_site_code(self, text: str) -> None:
21+
"""
22+
This method is designed to fill in the site Code field on the Create site page.
23+
Returns:
24+
None
25+
"""
26+
logging.info("Filling Site Code on Create Organisation page")
27+
self.site_code.fill(text)
28+
29+
def fill_site_name(self, text: str) -> None:
30+
"""
31+
This method is designed to fill in the Site Name field on the Create Site page.
32+
Returns:
33+
None
34+
"""
35+
logging.info("Filling Site Name on Create Site page")
36+
self.site_name.fill(text)
37+
38+
def click_start_date_calendar(self) -> None:
39+
"""
40+
This method is designed to click the Start Date Calendar button on the Create Site page.
41+
Returns:
42+
None
43+
"""
44+
logging.info("Clicking Start Date Calendar on Create Site page")
45+
self.start_date_calendar.click()
46+
47+
def fill_audit_reason(self, text: str) -> None:
48+
"""
49+
This method is designed to fill in the Audit Reason field on the Create Site page.
50+
Returns:
51+
None
52+
"""
53+
logging.info("Filling Audit Reason on Create Site page")
54+
self.audit_reason.fill(text)
55+
56+
def click_save_button(self) -> None:
57+
"""
58+
This method is designed to click the Save button on the Create Site page.
59+
Returns:
60+
None
61+
"""
62+
logging.info("Clicking Save button on Create Site page")
63+
self.save_button.click()
64+
65+
def verify_success_message(self) -> None:
66+
"""Verifies that the success message is displayed after saving the Site."""
67+
logging.info("Verifying success message on Create Site page")
68+
expect(self.page.locator("th")).to_contain_text(
69+
"The action was performed successfully"
70+
)

pages/organisations/list_all_organisations.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import logging
12
from playwright.sync_api import Page
23
from pages.base_page import BasePage
34
from enum import StrEnum
5+
from utils.table_util import TableUtils
46

57

68
class ListAllOrganisations(BasePage):
@@ -9,9 +11,13 @@ class ListAllOrganisations(BasePage):
911
def __init__(self, page: Page):
1012
super().__init__(page)
1113
self.page = page
14+
# Initialize TableUtils for the table with id="displayRS"
15+
self.list_all_org_table = TableUtils(page, "#listAllOrgsTable")
1216

1317
# List All Organisations links
1418
self.select_organisation_type = self.page.locator("#organisationType")
19+
self.create_new_org = self.page.get_by_role("button", name="Create New Org")
20+
self.search_org_code = self.page.locator('input[name="ORG_CODE"]')
1521

1622
def select_organisation_type_option(self, option: str) -> None:
1723
"""
@@ -21,8 +27,33 @@ def select_organisation_type_option(self, option: str) -> None:
2127
Returns:
2228
None
2329
"""
30+
logging.info(f"Selecting Organisation Type: {option}")
2431
self.select_organisation_type.select_option(option)
2532

33+
def click_first_link_in_table(self) -> None:
34+
"""Clicks the first Org Code link from the List All Orgs table."""
35+
logging.info(
36+
"Clicking the first Org Code link in the List All Organisations table"
37+
)
38+
self.list_all_org_table.click_first_link_in_column("Org Code↑")
39+
40+
def click_create_new_org(self) -> None:
41+
"""Clicks the 'Create New Org' button."""
42+
logging.info("Clicking the 'Create New Org' button")
43+
self.create_new_org.click()
44+
45+
def search_organisation_code(self, org_code: str) -> None:
46+
"""
47+
This method is designed to search for an organisation by its code.
48+
Args:
49+
org_code (str): The organisation code to search for.
50+
Returns:
51+
None
52+
"""
53+
logging.info(f"Searching for Organisation with code: {org_code}")
54+
self.search_org_code.fill(org_code)
55+
self.search_org_code.press("Enter")
56+
2657

2758
class OrganisationType(StrEnum):
2859
BCS_PROGRAMME_HUB = "1002"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import logging
2+
from playwright.sync_api import Page, expect
3+
from pages.base_page import BasePage
4+
from enum import StrEnum
5+
from utils.table_util import TableUtils
6+
7+
8+
class ListAllSites(BasePage):
9+
"""List All Sites Page locators, and methods for interacting with the page."""
10+
11+
def __init__(self, page: Page):
12+
super().__init__(page)
13+
self.page = page
14+
# Initialize TableUtils for the table with id="displayRS"
15+
self.list_all_org_table = TableUtils(page, "#listAllOrgsTable")
16+
17+
# List All Organisations links
18+
self.select_site_type = self.page.locator("#siteTypeId")
19+
self.create_new_site = self.page.get_by_role("button", name="Create New Site")
20+
21+
22+
def select_site_type_option(self, option: str) -> None:
23+
"""
24+
This method is designed to select a specific site type from the List All Sites page.
25+
"""
26+
self.select_site_type.select_option(option)
27+
28+
29+
def click_create_new_site(self) -> None:
30+
"""Clicks the 'Create New Org' button."""
31+
self.create_new_site.click()
32+
33+
34+
class SiteType(StrEnum):
35+
CARE_TRUST_SITE = "1020"
36+
NHS_TRUST_SITE = "1018"
37+
PCT_SITE = "1019"
38+
PATHOLOGY_LABORATORY_SITE = "306448"
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import logging
12
from playwright.sync_api import Page
23
from pages.base_page import BasePage
34

5+
46
class OrganisationsAndSiteDetails(BasePage):
57
"""Organisations And Site Details Page locators, and methods for interacting with the page."""
68

@@ -9,24 +11,23 @@ def __init__(self, page: Page):
911
self.page = page
1012

1113
# Organisations And Site Details Page links
12-
self.my_organisation = self.page.get_by_role(
13-
"link", name="My Organisation"
14-
)
14+
self.my_organisation = self.page.get_by_role("link", name="My Organisation")
1515
self.list_all_organisations = self.page.get_by_role(
1616
"link", name="List All Organisations"
1717
)
18-
self.list_all_sites = self.page.get_by_role(
19-
"link", name="List All Sites"
20-
)
18+
self.list_all_sites = self.page.get_by_role("link", name="List All Sites")
2119

2220
def go_to_my_organisation(self) -> None:
2321
"""Clicks the 'my organisation' link"""
22+
logging.info("Navigating to My Organisation page")
2423
self.click(self.my_organisation)
2524

2625
def go_to_list_all_organisations(self) -> None:
2726
"""Clicks the 'list all organisations' link"""
27+
logging.info("Navigating to List All Organisations page")
2828
self.click(self.list_all_organisations)
2929

3030
def go_to_list_all_sites(self) -> None:
3131
"""Clicks the 'go to list all sites' link."""
32+
logging.info("Navigating to List All Sites page")
3233
self.click(self.list_all_sites)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import logging
2+
from click import option
3+
from playwright.sync_api import Page, expect
4+
from pages.base_page import BasePage
5+
6+
7+
class ViewOrganisation(BasePage):
8+
"""View Organisation Page locators, and methods for interacting with the page."""
9+
10+
def __init__(self, page: Page):
11+
super().__init__(page)
12+
self.page = page
13+
# View Organisation links
14+
self.edit_button = self.page.get_by_role("button", name="Edit")
15+
16+
def verify_page_title(self) -> None:
17+
"""Verifies that the page title contains 'View Organisation'."""
18+
logging.info("Verifying page title for View Organisation")
19+
expect(self.page.locator("#ntshPageTitle")).to_contain_text("View Organisation")
20+
21+
def verify_organisation_code_details(self,text:str) -> None:
22+
"""Verifies that the organisation code details are displayed correctly."""
23+
logging.info("Verifying organisation code details on View Organisation page")
24+
expect(self.page.locator('form[name="frm"]')).to_contain_text(text)
25+
26+
def verify_organisation_type_details(self,text:str) -> None:
27+
"""Verifies that the organisation type details are displayed correctly."""
28+
logging.info("Verifying organisation type details on View Organisation page")
29+
expect(self.page.locator('form[name="frm"]')).to_contain_text(text)
30+
31+
def click_edit_button(self) -> None:
32+
"""Clicks the Edit button on the View Organisation page."""
33+
logging.info("Clicking Edit button on View Organisation page")
34+
self.edit_button.click()

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,6 @@ markers =
4545
subject_search: tests that are part of the subject search test suite
4646
investigation_dataset_tests: tests that are part of the investigation dataset test suite
4747
organisations_users_and_contacts_tests: tests that are part of the Organisations, Users and Contacts test suite
48+
organisations_and_contacts_develop_level_tests: tests that are part of the Organisations and Contacts Develop Level test suite
49+
organisations_and_contacts_build_level_tests: tests that are part of the Organisations and Contacts Build Level test suite
4850
skip_before_test: tests that will not use the before_test fixture

0 commit comments

Comments
 (0)