Skip to content

Commit 4e12559

Browse files
authored
Feature/bcss 20580 selenium to playwright generate fobt invitations (#95)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> This is part of the selenium to playwright migration and includes the migration of the generate fobt invitations scenario. Also includes a new function "open_letter_batch" on the batch_list_page to open a batch on the table by matching given criteria. ## Context <!-- Why is this change required? What problem does it solve? --> This is part of the selenium to playwright migration work. ## Type of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [x] Refactoring (non-breaking change) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would change existing functionality) - [ ] Bug fix (non-breaking change which fixes an issue) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I am familiar with the [contributing guidelines](https://github.com/nhs-england-tools/playwright-python-blueprint/blob/main/CONTRIBUTING.md) - [x] I have followed the code style of the project - [x] I have added tests to cover my changes (where appropriate) - [x] I have updated the documentation accordingly - [ ] This PR is a result of pair or mob programming --- ## Sensitive Information Declaration To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including [PII (Personal Identifiable Information) / PID (Personal Identifiable Data)](https://digital.nhs.uk/data-and-information/keeping-data-safe-and-benefitting-the-public) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter. - [x] I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.
1 parent e41fb01 commit 4e12559

File tree

4 files changed

+66
-37
lines changed

4 files changed

+66
-37
lines changed

pages/call_and_recall/generate_invitations_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def wait_for_invitation_generation_complete(
9191
value = value.strip() # Get text and remove extra spaces
9292
if int(value) < number_of_invitations:
9393
pytest.fail(
94-
f"There are less than {number_of_invitations} invitations generated"
94+
f"Expected {number_of_invitations} invitations generated but got {value}"
9595
)
9696

9797
self_referrals_total_text = self.self_referrals_total.text_content()

pages/communication_production/batch_list_page.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,33 @@ def clear_deadline_filter_date(self) -> None:
9393
def verify_deadline_date_filter_input(self, expected_text: str) -> None:
9494
expect(self.deadline_date_filter_with_input).to_have_value(expected_text)
9595

96+
def open_letter_batch(
97+
self, batch_type: str, status: str, level: str, description: str
98+
) -> None:
99+
"""
100+
Finds and opens the batch row based on type, status, level, and description.
101+
Args:
102+
batch_type (str): The type of the batch (e.g., "Original").
103+
status (str): The status of the batch (e.g., "Open").
104+
level (str): The level of the batch (e.g., "S1").
105+
description (str): The description of the batch (e.g., "Pre-invitation (FIT)").
106+
"""
107+
# Step 1: Match the row using nested filters, one per column value
108+
row = (
109+
self.page.locator("table tbody tr")
110+
.filter(has=self.page.locator("td", has_text=batch_type))
111+
.filter(has=self.page.locator("td", has_text=status))
112+
.filter(has=self.page.locator("td", has_text=level))
113+
.filter(has=self.page.locator("td", has_text=description))
114+
)
115+
116+
# Step 2: Click the "View" link in the matched row
117+
view_link = row.locator(
118+
"a"
119+
) # Click the first link in the row identified in step 1
120+
expect(view_link).to_be_visible()
121+
view_link.click()
122+
96123

97124
class ActiveBatchListPage(BatchListPage):
98125
"""Active Batch List Page locators, and methods for interacting with the Active Batch List page"""

tests/bcss_tests.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ episode_closed_date=22/09/2020
2525
# ----------------------------------
2626
# CALL AND RECALL TEST DATA
2727
# ----------------------------------
28-
daily_invitation_rate=28
28+
daily_invitation_rate=6
2929
weekly_invitation_rate=130
Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import pytest
22
from playwright.sync_api import Page
3+
import logging
34
from pages.base_page import BasePage
45
from pages.call_and_recall.call_and_recall_page import CallAndRecallPage
5-
from pages.call_and_recall.invitations_monitoring_page import InvitationsMonitoringPage
66
from pages.call_and_recall.generate_invitations_page import GenerateInvitationsPage
7-
from pages.call_and_recall.non_invitations_days_page import NonInvitationDaysPage
8-
from pages.call_and_recall.invitations_plans_page import InvitationsPlansPage
9-
from pages.call_and_recall.create_a_plan_page import CreateAPlanPage
7+
from pages.communication_production.batch_list_page import BatchListPage
8+
from pages.communication_production.communications_production_page import (
9+
CommunicationsProductionPage,
10+
)
11+
from pages.communication_production.manage_active_batch_page import (
12+
ManageActiveBatchPage,
13+
)
1014
from utils.user_tools import UserTools
1115

1216

@@ -22,43 +26,41 @@ def before_each(page: Page):
2226
BasePage(page).go_to_call_and_recall_page()
2327

2428

25-
# Scenario: Run FOBT invitations and process the S1 letter batch
26-
# Many feature scenarios need a subject at S9.
27-
# When I generate invitations
28-
# And I view the active batch list
29-
# And I view the "Original" type "Open" status active letter batch for "S1" "Pre-invitation (FIT)"
30-
# And I prepare the letter batch
31-
# And I retrieve and confirm the letters
32-
# Then there is a subject who meets the following criteria:
33-
# | Latest episode kit class | FIT |
34-
# | Latest event status | S9 |
35-
# | Latest episode type | FOBT |
36-
# | Subject hub code | BCS01 |
37-
38-
# Scenario: User generates invitations for screening episodes (#3)
39-
# # Version copied from now-deleted UserPathway.feature - duplicate steps etc need to be sorted out
40-
# Given I log in to BCSS "England" as user role "Hub Manager - State Registered"
41-
# When I navigate to the Call and Recall > Generate Invitations Page
42-
# And I press the Generate Invitations button and generate invitations
43-
# Then Invitations are successfully generated
44-
45-
4629
@pytest.mark.regression
4730
@pytest.mark.call_and_recall
48-
def test_generate_fobt_invitations(page: Page) -> None:
31+
def test_run_fobt_invitations_and_process_s1_batch(
32+
page: Page, general_properties: dict
33+
):
4934
"""
50-
Verifies that a user can generate FOBT invitations and process the S1 letter batch.
35+
Run FOBT invitations, open the S1 batch, prepare, retrieve and confirm.
5136
"""
37+
# Navigate to generate invitations
5238
CallAndRecallPage(page).go_to_generate_invitations_page()
53-
GenerateInvitationsPage(page).click_generate_invitations_button()
5439

55-
GenerateInvitationsPage(page).view_active_batch_list()
56-
GenerateInvitationsPage(page).view_original_open_status_batch(
57-
"S1", "Pre-invitation (FIT)"
40+
# When I generate invitations
41+
logging.info("Generating invitations based on the invitation plan")
42+
GenerateInvitationsPage(page).click_generate_invitations_button()
43+
GenerateInvitationsPage(page).wait_for_invitation_generation_complete(
44+
int(general_properties["daily_invitation_rate"])
5845
)
59-
GenerateInvitationsPage(page).prepare_letter_batch()
60-
GenerateInvitationsPage(page).retrieve_and_confirm_letters()
46+
logging.info("Invitations generated successfully")
47+
48+
# And I view the active batch list
49+
BasePage(page).click_main_menu_link()
50+
BasePage(page).go_to_communications_production_page()
51+
CommunicationsProductionPage(page).go_to_active_batch_list_page()
6152

62-
GenerateInvitationsPage(page).verify_subject_meets_criteria(
63-
kit_class="FIT", event_status="S9", episode_type="FOBT", hub_code="BCS01"
53+
# And I open the "Original" / "Open" / "S1" / "Pre-invitation (FIT)" batch
54+
BatchListPage(page).open_letter_batch(
55+
batch_type="Original",
56+
status="Open",
57+
level="S1",
58+
description="Pre-invitation (FIT)",
6459
)
60+
61+
# Then I retrieve and confirm the letters
62+
ManageActiveBatchPage(page).click_prepare_button()
63+
ManageActiveBatchPage(page).click_retrieve_button()
64+
BasePage(page).safe_accept_dialog(
65+
page.get_by_role("button", name="Confirm Printed")
66+
) # Click the confirm button and accept the confirmation dialog

0 commit comments

Comments
 (0)