Skip to content

Commit 1840707

Browse files
committed
Added test_check_that_s1_has_supplementary_batches
1 parent 09f07c7 commit 1840707

File tree

2 files changed

+113
-46
lines changed

2 files changed

+113
-46
lines changed

pages/communication_production/letter_library_index_page.py

Lines changed: 88 additions & 3 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 LetterLibraryIndexPage(BasePage):
@@ -8,8 +9,14 @@ class LetterLibraryIndexPage(BasePage):
89
def __init__(self, page: Page):
910
super().__init__(page)
1011
self.page = page
12+
self.table_utils = TableUtils(page, "#displayRS")
1113
# Letter Library Index - page locators, methods
1214

15+
self.letter_library_index_table = page.locator("#displayRS")
16+
self.define_supplementary_letter_button = page.locator(
17+
"input.HeaderButtons[value='Define Supplementary Letter']"
18+
)
19+
1320
def verify_letter_library_index_title(self) -> None:
1421
"""Verify the Letter Library Index page title is displayed as expected"""
1522
self.bowel_cancer_screening_page_title_contains_text("Letter Library Index")
@@ -20,7 +27,22 @@ def filter_by_letters_group(self, group_name: str) -> None:
2027
Triggers the postback and waits for the page to update.
2128
2229
Args:
23-
group_name (str): Visible label of the desired letter group (e.g., 'Supplementary Letters')
30+
group_name (str): Visible label of the desired letter group. Must be one of:
31+
- 'Discharge Letters (Patient)'
32+
- 'Discharge Letters (GP)'
33+
- 'Discharge Notification Cards To GP Practice'
34+
- '30 Day Questionnaire'
35+
- 'Surveillance Selection'
36+
- 'Invitation Letters'
37+
- 'MDT Referral Letter to GP'
38+
- 'Practitioner Clinic Letters'
39+
- 'Reminder Letters'
40+
- 'Result Letters (Patient)'
41+
- 'Result Communications (GP)'
42+
- 'Retest Letters'
43+
- 'Supplementary Letters'
44+
- 'Bowel Scope Hub Letters'
45+
- 'Genetic Service Letters'
2446
"""
2547
dropdown = self.page.locator("#selLetterType")
2648
expect(dropdown).to_be_visible()
@@ -31,5 +53,68 @@ def filter_by_letters_group(self, group_name: str) -> None:
3153
# Wait for the page to reload—this form triggers a postback
3254
self.page.wait_for_load_state("load")
3355

34-
# Optional: wait for something specific to confirm the filter applied
35-
expect(self.page.locator("text=" + group_name)).to_be_visible()
56+
def filter_by_event_code(self, event_code: str) -> None:
57+
"""
58+
Filters the letter library index by event code using the textbox input.
59+
60+
Args:
61+
event_code (str): The event code to filter the list (e.g., 'S1')
62+
"""
63+
event_code_input = self.page.get_by_role(
64+
"textbox", name="Enter text to filter the list"
65+
)
66+
expect(event_code_input).to_be_visible()
67+
event_code_input.click()
68+
event_code_input.fill(event_code)
69+
event_code_input.press("Enter")
70+
71+
# Optional: wait for the filtered list to update
72+
self.page.wait_for_timeout(500) # tweak or replace with smart wait
73+
74+
def click_first_letter_code_link_in_table(self) -> None:
75+
"""Clicks the first link from the Letter Library Index table."""
76+
self.table_utils.click_first_link_in_column("Code")
77+
78+
def click_define_supplementary_letter_button(self) -> None:
79+
"""
80+
Clicks the 'Define Supplementary Letter' button
81+
82+
Raises:
83+
AssertionError: If the button is not visible or interactive
84+
"""
85+
button = self.define_supplementary_letter_button
86+
expect(button).to_be_visible()
87+
button.click()
88+
89+
def define_supplementary_letter(
90+
self,
91+
description: str = "Define Letter",
92+
destination_id: str = "12057",
93+
priority_id: str = "12016",
94+
signatory: str = "signatory",
95+
job_title: str = "job title",
96+
paragraph_text: str = "body text"
97+
) -> None:
98+
"""
99+
Fills out the form to define a supplementary letter and confirms save via modal.
100+
101+
Args:
102+
description (str): Letter description
103+
destination_id (str): Dropdown option for destination
104+
priority_id (str): Dropdown option for priority
105+
signatory (str): Signatory name
106+
job_title (str): Signatory's job title
107+
paragraph_text (str): Main body text of the letter
108+
"""
109+
self.page.locator('input[name="A_C_LETT_DESC"]').fill(description)
110+
self.page.locator("#A_C_DESTINATION_ID").select_option(destination_id)
111+
self.page.locator("#A_C_PRIORITY_ID").select_option(priority_id)
112+
self.page.locator("#A_C_SIGNATORY").fill(signatory)
113+
self.page.locator("#A_C_JOB_TITLE").fill(job_title)
114+
self.page.locator("#A_C_PARAGRAPH_1").fill(paragraph_text)
115+
116+
# Handle the modal popup when saving
117+
self.page.once("dialog", lambda dialog: dialog.accept())
118+
self.page.get_by_role("button", name="Save").click()
119+
120+

tests/regression/communications_production/test_basic_manage_archived_batch_functionality.py

Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import pytest
2-
from playwright.sync_api import Page
2+
from playwright.sync_api import Page, expect
33
from pages.base_page import BasePage
44
from pages.communication_production.communications_production_page import (
55
CommunicationsProductionPage,
@@ -15,7 +15,6 @@
1515
from pages.communication_production.letter_library_index_page import (
1616
LetterLibraryIndexPage,
1717
)
18-
from pages.communication_production import letter_library_index_page
1918
from utils.batch_processing import prepare_and_print_batch
2019

2120

@@ -90,61 +89,44 @@ def test_reprint_and_archive_letter_batch(select_user) -> None:
9089
manage_archived_page.confirm_archived_message_visible()
9190

9291

93-
@pytest.mark.wip
9492
@pytest.mark.letters_tests
9593
@pytest.mark.regression
9694
def test_check_that_s1_has_supplementary_batches(select_user) -> None:
9795
"""
9896
Scenario: I can create a supplementary batch for S1 and archive it
9997
Given I log in to BCSS "England" as user role "HubManagerStateRegistered"
10098
When I view the letter library index
101-
And I filter the letter library index list to view the "Supplementary Letters" letters group
102-
And I ensure that I can create "S1" supplementary batches
103-
And I view the archived batch list
104-
And I view the "Original" type archived letter batch for "S1" "Pre"
105-
And I create a supplementary batch
106-
And I prepare the letter batch
107-
And I retrieve and confirm the letters
108-
And my batch is now archived
99+
And I filter the letter library index list to view the "Invitation Letters" letters group
100+
And I ensure that I can create (define) "S1" supplementary batches
101+
And I Go to letter library index and filter by Supplementary Letters
102+
And I Open a supplementary letter
109103
"""
110104
# Step 1: Log in as user and navigate to Letter Library Index
111105
page = select_user("Hub Manager State Registered at BCS01")
112106
CommunicationsProductionPage(page).go_to_letter_library_index_page()
113107

114-
# Step 2: Filter for "Supplementary Letters" group
115-
LetterLibraryIndexPage(page).filter_by_letters_group("Supplementary Letters")
116-
117-
# TODO: Is this below step required? There is no button to create a supplementary batch in the letter library index page.
118-
# and there are no supplementary letters in the letter library index page.
108+
# Step 2: Filter for "Invitation Letters" group
109+
LetterLibraryIndexPage(page).filter_by_letters_group("Invitation Letters")
119110

120111
# Step 3: Ensure S1 supplementary batches can be created
121-
if not letter_library_index_page.can_create_supplementary_batches("S1"):
122-
pytest.skip("No S1 supplementary batches available for creation.")
123-
124-
# Step 4: Navigate to Archived Batch List
125-
archived_batch_list_page = ArchivedBatchListPage(page)
126-
archived_batch_list_page.assert_batch_table_visible()
127-
128-
# Step 5: Find and open archived batch with Type "Original", Event Code "S1", and Description "Pre"
129-
row = archived_batch_list_page.get_archived_batch_row(
130-
"Original", "S1", "Pre-invitation (FIT)"
112+
LetterLibraryIndexPage(page).filter_by_event_code("S1")
113+
LetterLibraryIndexPage(page).click_first_letter_code_link_in_table()
114+
LetterLibraryIndexPage(page).click_define_supplementary_letter_button()
115+
LetterLibraryIndexPage(page).define_supplementary_letter(
116+
description="Pre-invitation (FIT)",
117+
destination_id="12057", # Patient
118+
priority_id="12016", # Medium
119+
signatory="signatory",
120+
job_title="job title",
121+
paragraph_text="body text",
131122
)
132-
if not row:
133-
pytest.skip("No archived 'Original' S1 Pre batches found to reprint.")
134-
135-
batch_id = row.locator("a").first.inner_text()
136-
row.locator("a").first.click()
137-
138-
# Step 6: Create a supplementary batch
139-
manage_active_page = ManageActiveBatchPage(page)
140-
manage_active_page.click_prepare_button()
141-
142-
# Step 7: Prepare the letter batch
143-
manage_active_page.prepare_and_print()
123+
expect(page.locator("#ntshPageTitle")).to_contain_text("Version History")
144124

145-
# Step 8: Retrieve and confirm letters
146-
manage_active_page.retrieve_and_confirm_letters()
125+
# Step 4: Go to letter library index and filter by Supplementary Letters
126+
BasePage(page).click_main_menu_link()
127+
BasePage(page).go_to_communications_production_page()
128+
CommunicationsProductionPage(page).go_to_letter_library_index_page()
129+
LetterLibraryIndexPage(page).filter_by_letters_group("Supplementary Letters")
147130

148-
# Step 9: Confirm the batch is now archived
149-
manage_archived_page = ManageArchivedBatchPage(page)
150-
manage_archived_page.confirm_archived_message_visible()
131+
# Step 5: Open a supplementary letter
132+
LetterLibraryIndexPage(page).click_first_letter_code_link_in_table()

0 commit comments

Comments
 (0)