|
| 1 | +# pylint: disable=no-name-in-module |
| 2 | +from behave import given, when, then # pyright: ignore [reportAttributeAccessIssue] |
| 3 | +from playwright.sync_api import expect |
| 4 | + |
| 5 | +from pages.logout import Logout |
| 6 | + |
| 7 | + |
| 8 | +############################################################################### |
| 9 | +# GIVEN |
| 10 | +############################################################################### |
| 11 | + |
| 12 | + |
| 13 | +@given("the logout confirmation modal is displayed") |
| 14 | +def given_logout_modal_is_displayed(context): |
| 15 | + logout_page = Logout(context.page) |
| 16 | + logout_page.logout_modal_header_link.click() |
| 17 | + expect(logout_page.logout_modal_content).to_be_visible() |
| 18 | + |
| 19 | + |
| 20 | +@given("I am on the logout successful page") |
| 21 | +def given_on_logout_successful_page(context): |
| 22 | + context.execute_steps("Given the logout confirmation modal is displayed") |
| 23 | + context.execute_steps("When I confirm the logout") |
| 24 | + |
| 25 | + logout_page = Logout(context.page) |
| 26 | + |
| 27 | + expect(logout_page.logout_page_heading).to_be_visible() |
| 28 | + expect(logout_page.logout_page_content).to_be_visible() |
| 29 | + expect(logout_page.logout_page_login_link).to_be_visible() |
| 30 | + |
| 31 | + |
| 32 | +############################################################################### |
| 33 | +# WHEN |
| 34 | +############################################################################### |
| 35 | + |
| 36 | + |
| 37 | +@when("I click the logout button") |
| 38 | +def when_i_click_logout_button(context): |
| 39 | + logout_page = Logout(context.page) |
| 40 | + logout_page.logout_modal_header_link.click() |
| 41 | + |
| 42 | + |
| 43 | +@when("I confirm the logout") |
| 44 | +def when_i_confirm_the_logout(context): |
| 45 | + logout_page = Logout(context.page) |
| 46 | + logout_page.logout_modal_logout_button.click() |
| 47 | + |
| 48 | + |
| 49 | +@when('I click the "log back in" button') |
| 50 | +def when_i_click_log_back_in_button(context): |
| 51 | + logout_page = Logout(context.page) |
| 52 | + logout_page.logout_page_login_link.click() |
| 53 | + |
| 54 | + |
| 55 | +@when("I close the modal with the cross") |
| 56 | +def when_i_close_modal_with_cross(context): |
| 57 | + logout_page = Logout(context.page) |
| 58 | + logout_page.logout_modal_close_button.click() |
| 59 | + |
| 60 | + |
| 61 | +@when("I close the modal with the cancel button") |
| 62 | +def when_i_close_modal_with_cancel_button(context): |
| 63 | + logout_page = Logout(context.page) |
| 64 | + logout_page.logout_modal_cancel_button.click() |
| 65 | + |
| 66 | + |
| 67 | +@when("I close the modal by clicking outside the modal") |
| 68 | +def when_i_close_modal_with_overlay(context): |
| 69 | + logout_page = Logout(context.page) |
| 70 | + logout_page.logout_modal_overlay.click(force=True, position={"x": 0, "y": 0}) |
| 71 | + |
| 72 | + |
| 73 | +@when("I close the modal by hitting escape") |
| 74 | +def when_i_close_modal_by_hitting_escape(context): |
| 75 | + logout_page = Logout(context.page) |
| 76 | + logout_page.page.keyboard.press("Escape") |
| 77 | + |
| 78 | + |
| 79 | +############################################################################### |
| 80 | +# THEN STEPS |
| 81 | +############################################################################### |
| 82 | + |
| 83 | + |
| 84 | +@then("I see the logout confirmation modal") |
| 85 | +def then_i_see_logout_confirmation_modal(context): |
| 86 | + logout_page = Logout(context.page) |
| 87 | + expect(logout_page.logout_modal_content.get_by_role("heading")).to_contain_text( |
| 88 | + "Are you sure you want to log out?" |
| 89 | + ) |
| 90 | + expect(logout_page.logout_modal_content.get_by_role("paragraph")).to_contain_text( |
| 91 | + "Logging out will end your session." |
| 92 | + ) |
| 93 | + |
| 94 | + |
| 95 | +@then("the logout confirmation modal is not displayed") |
| 96 | +def then_logout_confirmation_modal_not_displayed(context): |
| 97 | + logout_page = Logout(context.page) |
| 98 | + expect(logout_page.logout_modal_content).not_to_be_visible() |
| 99 | + |
| 100 | + |
| 101 | +@then("I see the logout successful page") |
| 102 | +def then_i_see_logout_successful_page(context): |
| 103 | + logout_page = Logout(context.page) |
| 104 | + expect(logout_page.logout_page_heading).to_be_visible() |
| 105 | + expect(logout_page.logout_page_content).to_be_visible() |
0 commit comments