|
15 | 15 | from pages.navigation_bar_links import * |
16 | 16 | from pages.subject_screening_page import * |
17 | 17 |
|
| 18 | +# @pytest.mark.wip2 # Not working at the moment |
| 19 | +# def test_prereq(): |
| 20 | +# database_connection_exec("prereq_check") |
| 21 | + |
| 22 | +# paramater_32 = database_connection_query("select DEFAULT_VALUE from PARAMETERS where PARAM_ID = 32") |
| 23 | +# print(f"paramater_32: {paramater_32}") |
| 24 | +# if paramater_32[0] != "-1": |
| 25 | +# database_connection_query("UPDATE PARAMETERS SET DEFAULT_VALUE = -1 WHERE PARAM_ID = 32") |
| 26 | +# database_connection_query("COMMIT") |
| 27 | +# paramater_31 = database_connection_query("select DEFAULT_VALUE from PARAMETERS where PARAM_ID = 31") |
| 28 | +# print(f"paramater_31: {paramater_31}") |
| 29 | +# if paramater_31[0] != "-1": |
| 30 | +# database_connection_query("UPDATE PARAMETERS SET DEFAULT_VALUE = -1 WHERE PARAM_ID = 31") |
| 31 | +# database_connection_query("COMMIT") |
| 32 | + |
| 33 | + |
| 34 | +# To Do: |
| 35 | +# Create more POM |
| 36 | +# Remove as many hard coded timeouts as possible |
| 37 | +# Add more fail states |
| 38 | +# Add more logging to understand what is going on |
| 39 | +# Convert import pages * into 1 line |
| 40 | +# Move functions to utils |
| 41 | + |
18 | 42 | @pytest.mark.wip |
19 | 43 | def test_example(page: Page) -> None: |
20 | 44 | page.goto("/") |
21 | 45 | BcssLoginPage(page).login_as_user_bcss401() |
22 | 46 |
|
23 | | - # Create plan |
| 47 | + # 2 - Create plan |
24 | 48 | MainMenu(page).go_to_call_and_recall_page() |
25 | 49 | CallAndRecall(page).go_to_planning_and_monitoring_page() |
26 | 50 | page.get_by_role("link", name="BCS001").click() |
27 | 51 | page.get_by_role("button", name="Create a Plan").click() |
28 | 52 | page.get_by_role("link", name="Set all").click() |
29 | | - page.get_by_placeholder("Enter weekly invitation rate").fill("1") |
| 53 | + page.get_by_placeholder("Enter daily invitation rate").fill("1") |
30 | 54 | page.get_by_role("button", name="Update").click() |
31 | 55 | page.get_by_role("button", name="Confirm").click() |
32 | 56 | page.get_by_role("link", name="Set all").click() |
@@ -54,7 +78,7 @@ def test_example(page: Page) -> None: |
54 | 78 | # Loop until the table no longer contains "Queued" |
55 | 79 | while elapsed < timeout: |
56 | 80 | table_text = page.locator("#displayRS").text_content() |
57 | | - if "Queued" in table_text: |
| 81 | + if "Queued" in table_text or "In Progress" in table_text: |
58 | 82 | # Click the Refresh button |
59 | 83 | page.get_by_role("button", name="Refresh").click() |
60 | 84 | page.wait_for_timeout(wait_interval) |
@@ -87,25 +111,30 @@ def batch_processing(page: Page, batch_type: str, batch_description: str, latest |
87 | 111 | NavigationBar(page).click_main_menu_link() |
88 | 112 | MainMenu(page).go_to_communications_production_page() |
89 | 113 | CommunicationsProduction(page).go_to_active_batch_list_page() |
90 | | - ActiveBatchList(page).event_code_filter.click() |
91 | | - ActiveBatchList(page).event_code_filter.fill(batch_type) |
| 114 | + ActiveBatchList(page).enter_event_code_filter(batch_type) |
92 | 115 | pre_invitation_cells = page.locator(f"//td[text()='{batch_description}']") |
93 | 116 |
|
| 117 | + if pre_invitation_cells.count() == 0 and batch_description == "Pre-invitation (FIT) (digital leaflet)": |
| 118 | + print(f"No S1 Pre-invitation (FIT) (digital leaflet) batch found. Skipping to next step") |
| 119 | + return |
| 120 | + elif pre_invitation_cells.count() == 0 and page.locator("td", has_text="No matching records found"): |
| 121 | + pytest.fail(f"No {batch_type} {batch_description} batch found") |
| 122 | + |
94 | 123 | for i in range(pre_invitation_cells.count()): |
95 | 124 | row = pre_invitation_cells.nth(i).locator("..") # Get the parent row |
96 | 125 |
|
97 | 126 | # Check if the row contains "Prepared" or "Open" |
98 | | - if row.locator("td", has_text="Prepared").count() > 0 or row.locator("td", has_text="Open").count() > 0 or row.locator("td", has_text="Closed").count() > 0: |
| 127 | + if row.locator("td", has_text="Prepared").count() > 0 or row.locator("td", has_text="Open").count() > 0: |
99 | 128 | # Find the first link in that row and click it |
100 | 129 | link = row.locator("a").first |
101 | 130 | link_text = link.inner_text() # Get the batch id dynamically |
102 | 131 | link.click() |
103 | 132 | break |
104 | 133 | else: |
105 | | - pytest.fail(f"No open/prepared {batch_type} batch found") |
| 134 | + pytest.fail(f"No open/prepared '{batch_type} - {batch_description}' batch found") |
106 | 135 |
|
107 | 136 | # Checks to see if batch is already prepared |
108 | | - page.wait_for_timeout(1000) # Without this timeout prepare_button is always set to false |
| 137 | + page.wait_for_timeout(3000) # Without this timeout prepare_button is always set to false |
109 | 138 | prepare_button = page.get_by_role("button", name="Prepare Batch").is_visible() |
110 | 139 |
|
111 | 140 | #If not prepared it will click on the prepare button |
@@ -142,11 +171,12 @@ def batch_processing(page: Page, batch_type: str, batch_description: str, latest |
142 | 171 | page.get_by_role("button", name="Confirm Printed").nth(0).click() |
143 | 172 | page.wait_for_timeout(1000) |
144 | 173 |
|
| 174 | + # Add wait for batch successfully archived |
| 175 | + |
145 | 176 | NavigationBar(page).click_main_menu_link() |
146 | 177 | MainMenu(page).go_to_communications_production_page() |
147 | 178 | CommunicationsProduction(page).go_to_archived_batch_list_page() |
148 | | - ArchivedBatchList(page).event_code_filter.click() |
149 | | - ArchivedBatchList(page).event_code_filter.fill(link_text) |
| 179 | + ArchivedBatchList(page).enter_id_filter(link_text) |
150 | 180 | expect(page.locator("td").filter(has_text=link_text)).to_be_visible() # Checks to see if the batch is now archived |
151 | 181 |
|
152 | 182 | subject_search_by_nhs_no(page, nhs_no, latest_event_status) |
|
0 commit comments