|
1 | | -# @LettersTests |
2 | | -# Feature: Basic Manage Archived Batch functionality |
| 1 | +import pytest |
| 2 | +from playwright.sync_api import Page |
| 3 | +from pages.base_page import BasePage |
| 4 | +from pages.communication_production.communications_production_page import ( |
| 5 | + CommunicationsProductionPage, |
| 6 | +) |
| 7 | +from pages.communication_production.batch_list_page import ArchivedBatchListPage |
| 8 | +from utils.user_tools import UserTools |
| 9 | +from pages.communication_production.manage_active_batch_page import ( |
| 10 | + ManageActiveBatchPage, |
| 11 | +) |
| 12 | +from pages.communication_production.manage_archived_batch_page import ( |
| 13 | + ManageArchivedBatchPage, |
| 14 | +) |
| 15 | +from utils.batch_processing import prepare_and_print_batch |
3 | 16 |
|
4 | 17 |
|
5 | | -# Scenario: I can take an archived batch, reprint it, then archive that new batch |
6 | | -# Given I log in to BCSS "England" as user role "HubManagerStateRegistered" |
7 | | -# When I view the archived batch list |
8 | | -# And I view the "Original" type archived letter batch for "S1" "Pre" |
9 | | -# And I reprint the archived letter batch |
10 | | -# And I prepare the letter batch |
11 | | -# And I retrieve and confirm the letters |
12 | | -# And my batch is now archived |
| 18 | +@pytest.fixture |
| 19 | +def select_user(page: Page): |
| 20 | + def _login_as(user_role: str): |
| 21 | + # Log in with the specified user |
| 22 | + UserTools.user_login(page, user_role) |
| 23 | + # Navigate to Active Batch List |
| 24 | + BasePage(page).go_to_communications_production_page() |
| 25 | + CommunicationsProductionPage(page).go_to_archived_batch_list_page() |
| 26 | + return page |
| 27 | + |
| 28 | + return _login_as |
| 29 | + |
| 30 | + |
| 31 | +@pytest.mark.wip |
| 32 | +@pytest.mark.letters_tests |
| 33 | +@pytest.mark.regression |
| 34 | +def test_reprint_and_archive_letter_batch(select_user) -> None: |
| 35 | + """ |
| 36 | + Scenario: I can take an archived batch, reprint it, then archive that new batch |
| 37 | + Given I log in to BCSS "England" as user role "HubManagerStateRegistered" |
| 38 | + When I view the archived batch list |
| 39 | + And I view the "Original" type archived letter batch for "S1" "Pre" |
| 40 | + And I reprint the archived letter batch |
| 41 | + And I prepare the letter batch |
| 42 | + And I retrieve and confirm the letters |
| 43 | + And my batch is now archived |
| 44 | + """ |
| 45 | + # Step 1: Log in as user and navigate to Archived Batch List |
| 46 | + page = select_user("Hub Manager State Registered at BCS01") |
| 47 | + batch_list_page = ArchivedBatchListPage(page) |
| 48 | + |
| 49 | + # Step 2: Ensure the archived batch list table is visible |
| 50 | + batch_list_page.assert_batch_table_visible() |
| 51 | + # Wait for at least one row to appear |
| 52 | + page.wait_for_function( |
| 53 | + "document.querySelectorAll('table#batchList tbody tr').length > 1", timeout=8000 |
| 54 | + ) |
| 55 | + rows = page.locator("table#batchList tbody tr") |
| 56 | + row_count = rows.count() |
| 57 | + |
| 58 | + for i in range(row_count): |
| 59 | + row = rows.nth(i) |
| 60 | + |
| 61 | + # Step 3: Find and open archived batch with Type "Original", Event Code "S1", and Description "Pre" |
| 62 | + # You might want to use filters like: |
| 63 | + row = batch_list_page.get_archived_batch_row( |
| 64 | + "Original", "S1", "Pre-invitation (FIT)" |
| 65 | + ) |
| 66 | + if not row: |
| 67 | + pytest.skip("No archived 'Original' S1 Pre batches found to reprint.") |
| 68 | + |
| 69 | + batch_id = row.locator("a").first.inner_text() |
| 70 | + row.locator("a").first.click() |
| 71 | + |
| 72 | + # Step 4: Perform reprint from Archived Batch detail screen |
| 73 | + manage_archived_page = ManageArchivedBatchPage(page) # Assuming reuse |
| 74 | + manage_archived_page.assert_archived_batch_details_visible() |
| 75 | + manage_archived_page.click_reprint_button() |
| 76 | + BasePage(page).safe_accept_dialog(page.get_by_role("button", name="Reprint Batch")) |
| 77 | + |
| 78 | + # Step 5: Wait for navigation to new Active Batch screen |
| 79 | + # You’ll likely land back in Active Batch context |
| 80 | + manage_active_page = ManageActiveBatchPage(page) |
| 81 | + manage_active_page.assert_active_batch_details_visible() |
| 82 | + |
| 83 | + # Step 6: Prepare, retrieve and confirm new batch |
| 84 | + prepare_and_print_batch(page, link_text=batch_id) |
| 85 | + |
| 86 | + # Step 7: Assert batch archived successfully |
| 87 | + manage_archived_page.confirm_archived_message_visible() |
13 | 88 |
|
14 | 89 |
|
15 | 90 | # Scenario: Check that S1 has supplementary batches |
|
0 commit comments