|
| 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.select_your_role import SelectYourRole |
| 6 | + |
| 7 | + |
| 8 | +@when("I go to the select_your_role page") |
| 9 | +def i_go_to_the_select_your_role_page(context): |
| 10 | + context.page.goto(context.cpts_ui_base_url + "site/selectyourrole.html") |
| 11 | + |
| 12 | + |
| 13 | +@given("I am on the select_your_role page") |
| 14 | +def i_am_on_select_your_role_page(context): |
| 15 | + i_go_to_the_select_your_role_page(context) |
| 16 | + select_your_role_page = SelectYourRole(context.page) |
| 17 | + expect(select_your_role_page.summary).to_be_visible() |
| 18 | + |
| 19 | + |
| 20 | +@then("I am on the select_your_role page") |
| 21 | +def verify_on_select_your_role_page(context): |
| 22 | + select_your_role_page = SelectYourRole(context.page) |
| 23 | + expect(select_your_role_page.summary).to_be_visible() |
| 24 | + |
| 25 | + |
| 26 | +@given("I am logged in") |
| 27 | +def login(context): |
| 28 | + context.page.goto(context.cpts_ui_base_url + "site/auth_demo.html") |
| 29 | + context.page.get_by_role("button", name="Log in with mock CIS2").click() |
| 30 | + context.page.get_by_label("Username").fill("555073103100") |
| 31 | + context.page.get_by_role("button", name="Sign In").click() |
| 32 | + context.page.wait_for_url("**/auth_demo.html") |
| 33 | + |
| 34 | + |
| 35 | +@then("I can see the summary container") |
| 36 | +def i_can_see_the_summary_container(context): |
| 37 | + select_your_role_page = SelectYourRole(context.page) |
| 38 | + expect(select_your_role_page.summary).to_be_visible() |
| 39 | + |
| 40 | + |
| 41 | +@then("I cannot see the summary table body") |
| 42 | +def i_cannot_see_the_summary_table_body(context): |
| 43 | + select_your_role_page = SelectYourRole(context.page) |
| 44 | + expect(select_your_role_page.roles_without_access_table_body).to_be_visible( |
| 45 | + visible=False |
| 46 | + ) |
| 47 | + |
| 48 | + |
| 49 | +@then("I can see the summary table body") |
| 50 | +def i_can_see_the_summary_table_body(context): |
| 51 | + select_your_role_page = SelectYourRole(context.page) |
| 52 | + expect(select_your_role_page.roles_without_access_table_body).to_be_visible() |
| 53 | + |
| 54 | + |
| 55 | +@then("I can see the table body has a header row") |
| 56 | +def i_can_see_the_table_body_header(context): |
| 57 | + select_your_role_page = SelectYourRole(context.page) |
| 58 | + expect(select_your_role_page.organisation_column_header).to_be_visible() |
| 59 | + expect(select_your_role_page.role_column_header).to_be_visible() |
| 60 | + |
| 61 | + |
| 62 | +@then("I can see the table body has data") |
| 63 | +def i_can_see_the_table_body_data(context): |
| 64 | + select_your_role_page = SelectYourRole(context.page) |
| 65 | + expect(select_your_role_page.first_row_org_name).to_be_visible() |
| 66 | + expect(select_your_role_page.first_row_role_name).to_be_visible() |
| 67 | + |
| 68 | + |
| 69 | +@when("I click on the summary expander") |
| 70 | +def click_on_summary_expander(context): |
| 71 | + select_your_role_page = SelectYourRole(context.page) |
| 72 | + select_your_role_page.summary.click() |
| 73 | + |
| 74 | + |
| 75 | +@then("I can see the roles with access cards") |
| 76 | +def i_can_see_the_roles_with_access_cards(context): |
| 77 | + select_your_role_page = SelectYourRole(context.page) |
| 78 | + try: |
| 79 | + expect(select_your_role_page.first_role_card).to_be_visible(timeout=5000) |
| 80 | + print("Verified that at least one role card is displayed.") |
| 81 | + except Exception as e: |
| 82 | + print("Error verifying roles with access cards:", str(e)) |
| 83 | + print("Page content during error:") |
| 84 | + print(context.page.content()) |
| 85 | + raise |
| 86 | + |
| 87 | + |
| 88 | +@then("I can navigate to the your_selected_role page by clicking a card") |
| 89 | +def i_can_navigate_to_the_your_selected_role_page(context): |
| 90 | + select_your_role_page = SelectYourRole(context.page) |
| 91 | + try: |
| 92 | + expect(select_your_role_page.first_role_card).to_be_visible(timeout=5000) |
| 93 | + select_your_role_page.first_role_card.click() |
| 94 | + context.page.wait_for_url(select_your_role_page.selected_role_url) |
| 95 | + print( |
| 96 | + "Navigation to your_selected_role page successful. Current URL:", |
| 97 | + context.page.url, |
| 98 | + ) |
| 99 | + except Exception as e: |
| 100 | + print("Error navigating to your_selected_role page:", str(e)) |
| 101 | + print("Page content during error:") |
| 102 | + print(context.page.content()) |
| 103 | + raise |
0 commit comments