Skip to content

Commit 1e327aa

Browse files
committed
wip - non invitation days
1 parent ee3caf2 commit 1e327aa

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

pages/base_page.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,30 @@ def safe_accept_dialog(self, locator: Locator) -> None:
239239
Safely accepts a dialog triggered by a click, avoiding the error:
240240
playwright._impl._errors.Error: Dialog.accept: Cannot accept dialog which is already handled!
241241
If no dialog appears, continues without error.
242+
Args:
243+
locator (Locator): The locator that triggers the dialog when clicked.
244+
example: If clicking a save button opens a dialog, pass that save button's locator.
242245
"""
243246
self.page.once("dialog", self._accept_dialog)
244247
try:
245248
self.click(locator)
246249
except Exception as e:
247250
logging.error(f"Click failed: {e}")
251+
252+
253+
def assert_dialog_text(self, expected_text: str) -> None:
254+
"""
255+
Asserts that a dialog appears and contains the expected text.
256+
If no dialog appears, logs an error.
257+
Args:
258+
expected_text (str): The text that should be present in the dialog.
259+
"""
260+
261+
def handle_dialog(dialog):
262+
actual_text = dialog.message
263+
assert (
264+
actual_text == expected_text
265+
), f"Expected '{expected_text}', but got '{actual_text}'"
266+
dialog.dismiss() # Dismiss dialog
267+
268+
self.page.once("dialog", handle_dialog)

tests/regression/call_and_recall/test_non_invitation_days_regression.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
from playwright.sync_api import Page
33
from pages.base_page import BasePage
44
from pages.call_and_recall.call_and_recall_page import CallAndRecallPage
5-
from pages.call_and_recall.invitations_monitoring_page import InvitationsMonitoringPage
6-
from pages.call_and_recall.generate_invitations_page import GenerateInvitationsPage
75
from pages.call_and_recall.non_invitations_days_page import NonInvitationDaysPage
8-
from pages.call_and_recall.invitations_plans_page import InvitationsPlansPage
9-
from pages.call_and_recall.create_a_plan_page import CreateAPlanPage
106
from utils.user_tools import UserTools
117

128

@@ -46,9 +42,9 @@ def test_add_then_delete_non_invitation_day(page: Page) -> None:
4642
# Then todays date is visible in the non-invitation days table
4743
NonInvitationDaysPage(page).verify_date_is_visible()
4844
# When I click the delete button for the non-invitation day
49-
NonInvitationDaysPage(page).click_delete_button()
50-
# And I press OK on my confirmation prompt TODO: This is a modal/popup that needs to be handled
51-
NonInvitationDaysPage(page).confirm_delete_action()
45+
# NonInvitationDaysPage(page).click_delete_button() TODO: this step should be executed as part of the next step (delete this step once confirmed working)
46+
# And I press OK on my confirmation prompt
47+
BasePage(page).safe_accept_dialog(page.get_by_role("button", name="Delete"))
5248
# Then todays date is not visible in the non-invitation days table
5349
NonInvitationDaysPage(page).verify_date_is_not_visible()
5450

@@ -65,7 +61,5 @@ def test_non_invitation_day_note_is_mandatory(page: Page) -> None:
6561
NonInvitationDaysPage(page).enter_date("14/11/2030")
6662
# And I click the "Add Non-Invitation Day" button
6763
NonInvitationDaysPage(page).click_add_non_invitation_day_button()
68-
# Then I get an alert message that "contains" "The Note field is mandatory" TODO: This is a modal/popup that needs to be handled
69-
NonInvitationDaysPage(page).verify_alert_message_contains(
70-
"The Note field is mandatory"
71-
)
64+
# Then I get an alert message that "contains" "The Note field is mandatory"
65+
BasePage(page).assert_dialog_text("The Note field is mandatory")

0 commit comments

Comments
 (0)