Skip to content

Commit 5511f28

Browse files
committed
wip - created files to cover call and recall features and scenarios
Added methods to table utils
1 parent f858e9e commit 5511f28

File tree

7 files changed

+368
-71
lines changed

7 files changed

+368
-71
lines changed

pages/call_and_recall/create_a_plan_page.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from playwright.sync_api import Page, expect
22
from pages.base_page import BasePage
3+
from utils.table_util import TableUtils
34

45

56
class CreateAPlanPage(BasePage):
@@ -23,6 +24,19 @@ def __init__(self, page: Page):
2324
self.save_note_button = self.page.locator("#saveNote").get_by_role(
2425
"button", name="Save"
2526
)
27+
# Create A Plan Table Locators
28+
self.weekly_invitation_rate_field_on_table = self.page.locator(
29+
"#invitationRateField"
30+
)
31+
self.invitations_sent_value = self.page.locator(
32+
"#invitationPlan > tbody > tr:nth-child(1) > td:nth-child(8)"
33+
)
34+
self.resulting_position_value = self.page.locator(
35+
"#invitationPlan > tbody > tr:nth-child(1) > td:nth-child(9)"
36+
)
37+
38+
# Initialize TableUtils for different tables
39+
self.create_a_plan_table = TableUtils(page, "#invitationPlan")
2640

2741
def click_set_all_button(self) -> None:
2842
"""Clicks the Set all button to set all values"""
@@ -59,3 +73,58 @@ def click_save_note_button(self) -> None:
5973
def verify_create_a_plan_title(self) -> None:
6074
"""Verifies the Create a Plan page title"""
6175
self.bowel_cancer_screening_page_title_contains_text("View a plan")
76+
77+
def verify_weekly_invitation_rate_for_weeks(
78+
self, start_week: int, end_week: int, expected_weekly_rate: str
79+
) -> None:
80+
"""
81+
Verifies that the weekly invitation rate is correctly calculated and displayed for the specified range of weeks.
82+
83+
Args:
84+
start_week (int): The starting week of the range.
85+
end_week (int): The ending week of the range.
86+
expected_weekly_rate (str): The expected weekly invitation rate.
87+
"""
88+
# Get the current weekly invitation rate for the starting week
89+
weekly_invitation_rate = self.page.query_selector_all(
90+
"css:nth-child(" + str(start_week) + ") .text"
91+
)[0].text
92+
assert (
93+
weekly_invitation_rate == expected_weekly_rate
94+
), f"Expected weekly invitation rate '{expected_weekly_rate}' for week {start_week} but got '{weekly_invitation_rate}'"
95+
96+
# Verify the rate for the specified range of weeks
97+
for week in range(start_week + 1, end_week + 1):
98+
weekly_rate_locator = f".week-{week} .text"
99+
assert (
100+
self.page.query_selector_all(weekly_rate_locator)[0].text
101+
== expected_weekly_rate
102+
), f"Week {week} invitation rate should be '{expected_weekly_rate}', but found '{self.page.query_selector_all(weekly_rate_locator)[0].text}'"
103+
104+
def increment_invitation_rate_and_verify_changes(self) -> None:
105+
"""
106+
Increments the invitation rate by 1, then verifies that both the 'Invitations Sent' and 'Resulting Position' have increased by 1.
107+
"""
108+
# Get the current value of the Weekly Invitation Rate field
109+
current_value = int(
110+
self.create_a_plan_table.get_cell_value("Invitation Rate", 0)
111+
)
112+
# Increments by 1, fills the field with the new value, and Tabs out of the field
113+
new_value = str(current_value + 1)
114+
locator = self.weekly_invitation_rate_field_on_table
115+
locator.fill(new_value)
116+
locator.press("Tab")
117+
118+
# Verifies 'Invitations Sent' has increased by 1
119+
initial_invitations_sent = int(self.invitations_sent_value.inner_text())
120+
assert (
121+
int(self.invitations_sent_value.inner_text())
122+
== initial_invitations_sent + 1
123+
), "Invitations Sent did not increase by 1."
124+
125+
# Verifies 'Resulting Position' has increased by 1
126+
initial_resulting_position = int(self.resulting_position_value.inner_text())
127+
assert (
128+
int(self.resulting_position_value.inner_text())
129+
== initial_resulting_position - 1
130+
), "Resulting Position did not decrease by 1."

tests/bcss_tests.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ forename=Pentagram
2121
surname=Absurd
2222
subject_dob=11/01/1934
2323
episode_closed_date=22/09/2020
24+
25+
# ----------------------------------
26+
# CALL AND RECALL TEST DATA
27+
# ----------------------------------
28+
daily_invitation_rate=28
29+
weekly_invitation_rate=28
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
import pytest
2+
from playwright.sync_api import Page
3+
from pages.base_page import BasePage
4+
from pages.call_and_recall.call_and_recall_page import CallAndRecallPage
5+
from pages.call_and_recall.invitations_monitoring_page import InvitationsMonitoringPage
6+
from pages.call_and_recall.invitations_plans_page import InvitationsPlansPage
7+
from pages.call_and_recall.create_a_plan_page import CreateAPlanPage
8+
from utils.user_tools import UserTools
9+
10+
11+
@pytest.fixture(scope="function", autouse=True)
12+
def before_each(page: Page):
13+
"""
14+
Before every test is executed, this fixture logs in to BCSS as a test user and navigates to the call and recall page
15+
"""
16+
# Log in to BCSS
17+
UserTools.user_login(page, "Hub Manager State Registered at BCS01")
18+
19+
# Go to call and recall page
20+
BasePage(page).go_to_call_and_recall_page()
21+
22+
23+
@pytest.mark.regression
24+
@pytest.mark.call_and_recall
25+
def test_set_create_a_plan_daily_rate(page: Page, tests_properties: dict) -> None:
26+
"""
27+
Verifies that a user is able to click on the Set all button and enter a daily rate.
28+
"""
29+
30+
# When I go to "Invitations Monitoring - Screening Centre"
31+
CallAndRecallPage(page).go_to_planning_and_monitoring_page()
32+
33+
# And I click the link text "BCS001"
34+
InvitationsMonitoringPage(page).go_to_invitation_plan_page(
35+
tests_properties["screening_centre_code"]
36+
)
37+
# And I click the "Create a Plan" button
38+
InvitationsPlansPage(page).go_to_create_a_plan_page()
39+
40+
# And I click the set all button
41+
CreateAPlanPage(page).click_set_all_button()
42+
43+
# And I enter "28" in the input box with id "dailyRate"
44+
CreateAPlanPage(page).fill_daily_invitation_rate_field(
45+
tests_properties["daily_invitation_rate"]
46+
)
47+
48+
# And I click the "Update" button
49+
CreateAPlanPage(page).click_update_button()
50+
51+
# And I click the "Save" button
52+
CreateAPlanPage(page).click_save_button()
53+
54+
# Then the Weekly Invitation Rate for weeks 0 to 83 is set correctly
55+
# based on a set all daily rate of 28
56+
CreateAPlanPage(page).verify_weekly_invitation_rate_for_weeks(1, 83, "28")
57+
58+
59+
@pytest.mark.regression
60+
@pytest.mark.call_and_recall
61+
def test_create_invitation_plan_weekly_rate(page: Page, tests_properties: dict) -> None:
62+
"""
63+
Verifies that a user can set a weekly invitation rate in Create a Plan.
64+
"""
65+
66+
# When I go to "Invitations Monitoring - Screening Centre"
67+
CallAndRecallPage(page).go_to_planning_and_monitoring_page()
68+
69+
# And I click the link text "BCS001"
70+
InvitationsMonitoringPage(page).go_to_invitation_plan_page(
71+
tests_properties["screening_centre_code"]
72+
)
73+
# And I click the "Create a Plan" button
74+
InvitationsPlansPage(page).go_to_create_a_plan_page()
75+
76+
# And I click the set all button
77+
CreateAPlanPage(page).click_set_all_button()
78+
79+
# And I enter "130" in the input box with id "weeklyRate"
80+
CreateAPlanPage(page).fill_weekly_invitation_rate_field(
81+
tests_properties["weekly_invitation_rate"]
82+
)
83+
84+
# And I click the "Update" button
85+
CreateAPlanPage(page).click_update_button()
86+
87+
# And I click the "Save" button
88+
CreateAPlanPage(page).click_save_button()
89+
90+
# And the Weekly Invitation Rate for weeks 1 to 83 is set to the set all weekly rate of 130
91+
CreateAPlanPage(page).verify_weekly_invitation_rate_for_weeks(1, 83, "28")
92+
93+
94+
@pytest.mark.regression
95+
@pytest.mark.call_and_recall
96+
def test_update_invitation_rate_weekly(page: Page, tests_properties: dict) -> None:
97+
"""
98+
Verifies that a Hub Manager State Registered is able to update a weekly Invitation rate
99+
and the Cumulative 'Invitations sent' and 'Resulting Position' values are updated.
100+
"""
101+
102+
# When I go to "Invitations Monitoring - Screening Centre"
103+
CallAndRecallPage(page).go_to_planning_and_monitoring_page()
104+
105+
# And I click the link text "BCS001"
106+
InvitationsMonitoringPage(page).go_to_invitation_plan_page(
107+
tests_properties["screening_centre_code"]
108+
)
109+
110+
# And I click the "Create a Plan" button
111+
InvitationsPlansPage(page).go_to_create_a_plan_page()
112+
113+
# When I increase the Weekly Invitation Rate for week 1 by 1 and tab out of the cell
114+
# Then the Cumulative Invitations Sent is incremented by 1 for week 1
115+
# And the Cumulative Resulting Position is incremented by 1 for week 1
116+
CreateAPlanPage(page).increment_invitation_rate_and_verify_changes()
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import pytest
2+
import logging
3+
from playwright.sync_api import Page
4+
from pages.base_page import BasePage
5+
from pages.call_and_recall.call_and_recall_page import CallAndRecallPage
6+
from pages.call_and_recall.invitations_monitoring_page import InvitationsMonitoringPage
7+
from pages.call_and_recall.generate_invitations_page import GenerateInvitationsPage
8+
from pages.call_and_recall.non_invitations_days_page import NonInvitationDaysPage
9+
from pages.call_and_recall.invitations_plans_page import InvitationsPlansPage
10+
from pages.call_and_recall.create_a_plan_page import CreateAPlanPage
11+
from utils.user_tools import UserTools
12+
13+
14+
@pytest.fixture(scope="function", autouse=True)
15+
def before_each(page: Page):
16+
"""
17+
Before every test is executed, this fixture logs in to BCSS as a test user and navigates to the call and recall page
18+
"""
19+
# Log in to BCSS
20+
UserTools.user_login(page, "Hub Manager State Registered at BCS01")
21+
22+
# Go to call and recall page
23+
BasePage(page).go_to_call_and_recall_page()
24+
25+
26+
# Scenario: Run FOBT invitations and process the S1 letter batch
27+
# Many feature scenarios need a subject at S9.
28+
# Given I log in to BCSS "England" as user role "Hub Manager"
29+
# When I generate invitations
30+
# And I view the active batch list
31+
# And I view the "Original" type "Open" status active letter batch for "S1" "Pre-invitation (FIT)"
32+
# And I prepare the letter batch
33+
# And I retrieve and confirm the letters
34+
# Then there is a subject who meets the following criteria:
35+
# | Latest episode kit class | FIT |
36+
# | Latest event status | S9 |
37+
# | Latest episode type | FOBT |
38+
# | Subject hub code | BCS01 |
39+
40+
# Scenario: User generates invitations for screening episodes (#3)
41+
# # Version copied from now-deleted UserPathway.feature - duplicate steps etc need to be sorted out
42+
# Given I log in to BCSS "England" as user role "Hub Manager - State Registered"
43+
# When I navigate to the Call and Recall > Generate Invitations Page
44+
# And I press the Generate Invitations button and generate invitations
45+
# Then Invitations are successfully generated
46+
47+
48+
@pytest.mark.regression
49+
@pytest.mark.call_and_recall
50+
def test_generate_fobt_invitations(page: Page) -> None:
51+
"""
52+
Verifies that a user can generate FOBT invitations and process the S1 letter batch.
53+
"""
54+
CallAndRecallPage(page).go_to_generate_invitations_page()
55+
GenerateInvitationsPage(page).click_generate_invitations_button()
56+
57+
GenerateInvitationsPage(page).view_active_batch_list()
58+
GenerateInvitationsPage(page).view_original_open_status_batch(
59+
"S1", "Pre-invitation (FIT)"
60+
)
61+
GenerateInvitationsPage(page).prepare_letter_batch()
62+
GenerateInvitationsPage(page).retrieve_and_confirm_letters()
63+
64+
GenerateInvitationsPage(page).verify_subject_meets_criteria(
65+
kit_class="FIT", event_status="S9", episode_type="FOBT", hub_code="BCS01"
66+
)
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import pytest
2+
import logging
3+
from playwright.sync_api import Page
4+
from pages.base_page import BasePage
5+
from pages.call_and_recall.call_and_recall_page import CallAndRecallPage
6+
from pages.call_and_recall.invitations_monitoring_page import InvitationsMonitoringPage
7+
from pages.call_and_recall.generate_invitations_page import GenerateInvitationsPage
8+
from pages.call_and_recall.non_invitations_days_page import NonInvitationDaysPage
9+
from pages.call_and_recall.invitations_plans_page import InvitationsPlansPage
10+
from pages.call_and_recall.create_a_plan_page import CreateAPlanPage
11+
from utils.user_tools import UserTools
12+
13+
14+
@pytest.fixture(scope="function", autouse=True)
15+
def before_each(page: Page):
16+
"""
17+
Before every test is executed, this fixture logs in to BCSS as a test user and navigates to the call and recall page
18+
"""
19+
# Log in to BCSS
20+
UserTools.user_login(page, "Hub Manager State Registered at BCS01")
21+
22+
# Go to call and recall page
23+
BasePage(page).go_to_call_and_recall_page()
24+
25+
26+
@pytest.mark.regression
27+
@pytest.mark.call_and_recall
28+
def test_add_then_delete_non_invitation_day(page: Page) -> None:
29+
"""
30+
Verifies that a user can add and delete a non-invitation day.
31+
"""
32+
CallAndRecallPage(page).go_to_non_invitation_days_page()
33+
34+
NonInvitationDaysPage(page).enter_date("14/11/2030")
35+
NonInvitationDaysPage(page).enter_note(
36+
"Add a non-invitation day for automated test"
37+
)
38+
NonInvitationDaysPage(page).click_add_non_invitation_day_button()
39+
NonInvitationDaysPage(page).verify_date_is_visible("14/11/2030")
40+
41+
NonInvitationDaysPage(page).click_delete_button("14/11/2030")
42+
NonInvitationDaysPage(page).confirm_delete_action()
43+
NonInvitationDaysPage(page).verify_date_is_not_visible("14/11/2030")
44+
45+
# Scenario: Add then delete a non invitation day
46+
# Given I log in to BCSS "England" as user role "HubManagerAtBCS02"
47+
# And I go to "Non-Invitation Days"
48+
49+
# # The date entered should be a week day, otherwise a warning message will pop up
50+
# When I enter "14/11/2030" in the input box with id "date"
51+
52+
# # Add a new non invitation day
53+
# And I enter "Add a non invitation day for automated test" in the input box with id "note"
54+
# And I click the "Add Non-Invitation Day" button
55+
# Then the text "14/11/2030" is visible
56+
57+
# # Delete the non invitation day using delete button whose element id happens to contain date information
58+
# When I click the element with id "actionButton14/11/2030"
59+
# And I press OK on my confirmation prompt
60+
# Then the text "14/11/2030" is not visible
61+
62+
63+
@pytest.mark.regression
64+
@pytest.mark.call_and_recall
65+
def test_non_invitation_day_note_required(page: Page) -> None:
66+
"""
67+
Verifies that a note is required when adding a non-invitation day.
68+
"""
69+
CallAndRecallPage(page).go_to_non_invitation_days_page()
70+
71+
NonInvitationDaysPage(page).enter_date("14/11/2030")
72+
NonInvitationDaysPage(page).click_add_non_invitation_day_button()
73+
74+
NonInvitationDaysPage(page).verify_alert_message_contains(
75+
"The Note field is mandatory"
76+
)
77+
78+
# Scenario: Non invitation day note is compulsory
79+
# Given I log in to BCSS "England" as user role "HubManagerAtBCS02"
80+
# And I go to "Non-Invitation Days"
81+
# When I enter "14/11/2030" in the input box with id "date"
82+
# And I click the "Add Non-Invitation Day" button
83+
# Then I get an alert message that "contains" "The Note field is mandatory"

0 commit comments

Comments
 (0)