1818from utils .batch_processing import prepare_and_print_batch
1919
2020
21- @pytest .fixture
22- def select_user (page : Page ):
23- def _login_as (user_role : str ):
24- # Log in with the specified user
25- UserTools .user_login (page , user_role )
26- # Navigate to communications production page
27- BasePage (page ).go_to_communications_production_page ()
28- return page
21+ @pytest .fixture (scope = "function" , autouse = True )
22+ def before_each (page : Page ):
23+ """
24+ Before every test is executed, this fixture logs in to BCSS as a test user and navigates to the communications production page
25+ """
26+ # Log in to BCSS
27+ UserTools .user_login (page , "Hub Manager at BCS01" )
2928
30- return _login_as
29+ # Go to communications production page
30+ BasePage (page ).go_to_communications_production_page ()
3131
3232
3333@pytest .mark .letters_tests
3434@pytest .mark .regression
35- def test_reprint_and_archive_letter_batch (select_user ) -> None :
35+ def test_reprint_and_archive_letter_batch (page : Page ) -> None :
3636 """
3737 Scenario: I can take an archived batch, reprint it, then archive that new batch
3838 Given I log in to BCSS "England" as user role "HubManagerStateRegistered"
@@ -43,13 +43,12 @@ def test_reprint_and_archive_letter_batch(select_user) -> None:
4343 And I retrieve and confirm the letters
4444 And my batch is now archived
4545 """
46- # Step 1: Log in as user and navigate to Archived Batch List
47- page = select_user ("Hub Manager State Registered at BCS01" )
46+ # Navigate to Archived Batch List
4847 CommunicationsProductionPage (page ).go_to_archived_batch_list_page ()
49- batch_list_page = ArchivedBatchListPage (page )
48+ archived_batch_list_page = ArchivedBatchListPage (page )
5049
51- # Step 2: Ensure the archived batch list table is visible
52- batch_list_page .assert_batch_table_visible ()
50+ # Ensure the archived batch list table is visible
51+ archived_batch_list_page .assert_batch_table_visible ()
5352 # Wait for at least one row to appear
5453 page .wait_for_function (
5554 "document.querySelectorAll('table#batchList tbody tr').length > 1" , timeout = 8000
@@ -60,9 +59,9 @@ def test_reprint_and_archive_letter_batch(select_user) -> None:
6059 for i in range (row_count ):
6160 row = rows .nth (i )
6261
63- # Step 3: Find and open archived batch with Type "Original", Event Code "S1", and Description "Pre"
62+ # Find and open archived batch with Type "Original", Event Code "S1", and Description "Pre"
6463 # You might want to use filters like:
65- row = batch_list_page .get_archived_batch_row (
64+ row = archived_batch_list_page .get_archived_batch_row (
6665 "Original" , "S1" , "Pre-invitation (FIT)"
6766 )
6867 if not row :
@@ -71,27 +70,26 @@ def test_reprint_and_archive_letter_batch(select_user) -> None:
7170 batch_id = row .locator ("a" ).first .inner_text ()
7271 row .locator ("a" ).first .click ()
7372
74- # Step 4: Perform reprint from Archived Batch detail screen
73+ # Perform reprint from Archived Batch detail screen
7574 manage_archived_page = ManageArchivedBatchPage (page ) # Assuming reuse
7675 manage_archived_page .assert_archived_batch_details_visible ()
7776 manage_archived_page .click_reprint_button ()
7877 BasePage (page ).safe_accept_dialog (page .get_by_role ("button" , name = "Reprint Batch" ))
7978
80- # Step 5: Wait for navigation to new Active Batch screen
81- # You’ll likely land back in Active Batch context
79+ # Wait for navigation to new Active Batch screen
8280 manage_active_page = ManageActiveBatchPage (page )
8381 manage_active_page .assert_active_batch_details_visible ()
8482
85- # Step 6: Prepare, retrieve and confirm new batch
83+ # Prepare, retrieve and confirm new batch
8684 prepare_and_print_batch (page , link_text = batch_id )
8785
88- # Step 7: Assert batch archived successfully
86+ # Assert batch archived successfully
8987 manage_archived_page .confirm_archived_message_visible ()
9088
9189
9290@pytest .mark .letters_tests
9391@pytest .mark .regression
94- def test_check_that_s1_has_supplementary_batches (select_user ) -> None :
92+ def test_check_that_s1_has_supplementary_batches (page : Page ) -> None :
9593 """
9694 Scenario: I can create a supplementary batch for S1 and archive it
9795 Given I log in to BCSS "England" as user role "HubManagerStateRegistered"
@@ -101,14 +99,14 @@ def test_check_that_s1_has_supplementary_batches(select_user) -> None:
10199 And I Go to letter library index and filter by Supplementary Letters
102100 And I Open a supplementary letter
103101 """
104- # Step 1: Log in as user and navigate to Letter Library Index
105- page = select_user ( "Hub Manager State Registered at BCS01" )
102+
103+ # Navigate to Letter Library Index
106104 CommunicationsProductionPage (page ).go_to_letter_library_index_page ()
107105
108- # Step 2: Filter for "Invitation Letters" group
106+ # Filter for "Invitation Letters" group
109107 LetterLibraryIndexPage (page ).filter_by_letters_group ("Invitation Letters" )
110108
111- # Step 3: Ensure S1 supplementary batches can be created
109+ # Ensure S1 supplementary batches can be created
112110 LetterLibraryIndexPage (page ).filter_by_event_code ("S1" )
113111 LetterLibraryIndexPage (page ).click_first_letter_code_link_in_table ()
114112 LetterLibraryIndexPage (page ).click_define_supplementary_letter_button ()
@@ -122,11 +120,11 @@ def test_check_that_s1_has_supplementary_batches(select_user) -> None:
122120 )
123121 expect (page .locator ("#ntshPageTitle" )).to_contain_text ("Version History" )
124122
125- # Step 4: Go to letter library index and filter by Supplementary Letters
123+ # Go to letter library index and filter by Supplementary Letters
126124 BasePage (page ).click_main_menu_link ()
127125 BasePage (page ).go_to_communications_production_page ()
128126 CommunicationsProductionPage (page ).go_to_letter_library_index_page ()
129127 LetterLibraryIndexPage (page ).filter_by_letters_group ("Supplementary Letters" )
130128
131- # Step 5: Open a supplementary letter
129+ # Open a supplementary letter
132130 LetterLibraryIndexPage (page ).click_first_letter_code_link_in_table ()
0 commit comments