Skip to content

Commit fec84f0

Browse files
committed
addressing sonarqube issues
1 parent 9d0dbc6 commit fec84f0

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

pages/call_and_recall/generate_invitations_page.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from classes.subject import Subject
99
from utils.table_util import TableUtils
1010

11+
DISPLAY_RS_SELECTOR = "#displayRS"
12+
1113

1214
class GenerateInvitationsPage(BasePage):
1315
"""Generate Invitations page locators, and methods to interact with the page"""
@@ -19,7 +21,7 @@ def __init__(self, page: Page):
1921
self.generate_invitations_button = self.page.get_by_role(
2022
"button", name="Generate Invitations"
2123
)
22-
self.display_rs = self.page.locator("#displayRS")
24+
self.display_rs = self.page.locator(DISPLAY_RS_SELECTOR)
2325
self.refresh_button = self.page.get_by_role("button", name="Refresh")
2426
self.planned_invitations_total = self.page.locator("#col8_total")
2527
self.self_referrals_total = self.page.locator("#col5_total")
@@ -50,7 +52,7 @@ def wait_for_invitation_generation_complete(
5052
Every 5 seconds it refreshes the table and checks to see if the invitations have been generated.
5153
It also checks that enough invitations were generated and checks to see if self referrals are present
5254
"""
53-
self.page.wait_for_selector("#displayRS", timeout=5000)
55+
self.page.wait_for_selector(DISPLAY_RS_SELECTOR, timeout=5000)
5456

5557
if self.planned_invitations_total == "0":
5658
pytest.fail("There are no planned invitations to generate")
@@ -152,7 +154,7 @@ def wait_for_self_referral_invitation_generation_complete(
152154
pytest.fail(f"[ERROR] Invitations not generated successfully: {str(e)}")
153155

154156
# Dynamically check 'Self Referrals Generated'
155-
table_utils = TableUtils(self.page, "#displayRS")
157+
table_utils = TableUtils(self.page, DISPLAY_RS_SELECTOR)
156158

157159
try:
158160
value_text = table_utils.get_footer_value_by_header(
@@ -197,7 +199,9 @@ def check_self_referral_subjects_ready(
197199
self_referrals_text = self.self_referrals_total.text_content()
198200
if self_referrals_text is None:
199201
pytest.fail("Failed to read self-referrals total")
200-
self_referrals_count = int(self_referrals_text.strip())
202+
203+
self_referrals_text = self_referrals_text.strip()
204+
self_referrals_count = int(self_referrals_text)
201205

202206
# Determine if condition is met
203207
condition_met = (

pages/communication_production/batch_list_page.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
from utils.table_util import TableUtils
66
import logging
77

8+
BATCH_LIST_SELECTOR = "table#batchList"
9+
810

911
class BatchListPage(BasePage):
1012
"""Shared base class for both Active and Archived Batch List Pages."""
1113

12-
def __init__(self, page: Page, table_selector: str = "table#batchList"):
14+
def __init__(self, page: Page, table_selector: str = BATCH_LIST_SELECTOR):
1315
super().__init__(page)
1416
self.page = page
1517
self.table_selector = table_selector
@@ -175,7 +177,7 @@ class ActiveBatchListPage(BatchListPage):
175177
"""Active Batch List Page-specific methods."""
176178

177179
def __init__(self, page: Page):
178-
super().__init__(page, table_selector="table#batchList")
180+
super().__init__(page, table_selector=BATCH_LIST_SELECTOR)
179181

180182
def select_first_active_batch(self) -> None:
181183
"""Clicks the first batch ID link in the active batch list."""
@@ -199,7 +201,7 @@ def get_open_original_batch_row(self) -> Locator | None:
199201
Returns:
200202
Locator of the matching <tr> element, or None if not found.
201203
"""
202-
table = TableUtils(self.page, "table#batchList")
204+
table = TableUtils(self.page, BATCH_LIST_SELECTOR)
203205
row_count = table.get_row_count()
204206

205207
for i in range(row_count):
@@ -211,7 +213,6 @@ def get_open_original_batch_row(self) -> Locator | None:
211213
return table.pick_row(i)
212214
return None
213215

214-
215216
def assert_s83f_batch_present(self) -> None:
216217
self.enter_type_filter("Original")
217218
self.enter_event_code_filter("S83")
@@ -227,7 +228,7 @@ class ArchivedBatchListPage(BatchListPage):
227228
"""Archived Batch List Page-specific setup."""
228229

229230
def __init__(self, page: Page):
230-
super().__init__(page, table_selector="table#batchList")
231+
super().__init__(page, table_selector=BATCH_LIST_SELECTOR)
231232

232233
def select_first_archived_batch(self) -> None:
233234
"""Clicks the first batch ID link in the archived batch list."""

pages/communication_production/letter_library_index_page.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
from pages.base_page import BasePage
33
from utils.table_util import TableUtils
44

5+
DISPLAY_RS_SELECTOR = "#displayRS"
6+
57

68
class LetterLibraryIndexPage(BasePage):
79
"""Letter Library Index Page locators, and methods for interacting with the page"""
810

911
def __init__(self, page: Page):
1012
super().__init__(page)
1113
self.page = page
12-
self.table_utils = TableUtils(page, "#displayRS")
14+
self.table_utils = TableUtils(page, DISPLAY_RS_SELECTOR)
1315
# Letter Library Index - page locators, methods
1416

15-
self.letter_library_index_table = page.locator("#displayRS")
17+
self.letter_library_index_table = page.locator(DISPLAY_RS_SELECTOR)
1618
self.define_supplementary_letter_button = page.locator(
1719
"input.HeaderButtons[value='Define Supplementary Letter']"
1820
)
@@ -139,7 +141,7 @@ def assert_definition_setting(self, field_name: str, expected_value: str) -> Non
139141
field_name (str): The label text (e.g., "Description")
140142
expected_value (str): The expected value shown beside the label
141143
"""
142-
label_cell = self.page.locator(f"td.screenTableLabelCell", has_text=field_name)
144+
label_cell = self.page.locator("td.screenTableLabelCell", has_text=field_name)
143145
assert (
144146
label_cell.count() > 0
145147
), f"[ASSERTION FAILED] Field label '{field_name}' not found"
@@ -160,8 +162,10 @@ def has_current_version(self) -> bool:
160162
bool: True if a current version row is present, False otherwise
161163
"""
162164
version_table = self.page.locator("table#displayRS")
163-
current_row = version_table.locator("tr").filter(
164-
has=self.page.locator("td", has_text="Current")
165-
).first
165+
current_row = (
166+
version_table.locator("tr")
167+
.filter(has=self.page.locator("td", has_text="Current"))
168+
.first
169+
)
166170

167171
return current_row.count() > 0

tests/regression/communications_production/test_basic_manage_archived_batch_functionality.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def before_each(page: Page):
2929
# Go to communications production page
3030
BasePage(page).go_to_communications_production_page()
3131

32-
32+
@pytest.mark.wip
3333
@pytest.mark.letters_tests
3434
@pytest.mark.regression
3535
def test_reprint_and_archive_letter_batch(page: Page) -> None:
@@ -53,11 +53,6 @@ def test_reprint_and_archive_letter_batch(page: Page) -> None:
5353
page.wait_for_function(
5454
"document.querySelectorAll('table#batchList tbody tr').length > 1", timeout=8000
5555
)
56-
rows = page.locator("table#batchList tbody tr")
57-
row_count = rows.count()
58-
59-
for i in range(row_count):
60-
row = rows.nth(i)
6156

6257
# Find and open archived batch with Type "Original", Event Code "S1", and Description "Pre"
6358
# You might want to use filters like:

0 commit comments

Comments
 (0)