Clean up and fix the E2E tests so that they run

Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
This commit is contained in:
Carlo Costino
2024-01-04 17:30:47 -05:00
parent 46be3cd7b3
commit c652c17617
4 changed files with 21 additions and 27 deletions

View File

@@ -4,12 +4,14 @@ import re
from playwright.sync_api import expect
E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI")
def _bypass_sign_in(end_to_end_context):
# Open a new page and go to the staging site.
page = end_to_end_context.new_page()
page.goto(os.getenv("NOTIFY_E2E_TEST_URI"))
page.goto(f"{E2E_TEST_URI}/")
sign_in_button = page.get_by_role("link", name="Sign in")
@@ -24,7 +26,7 @@ def _bypass_sign_in(end_to_end_context):
def test_add_new_service_workflow(end_to_end_context):
# page = end_to_end_context.new_page()
page = _bypass_sign_in(end_to_end_context)
page.goto(os.getenv("NOTIFY_E2E_TEST_URI"))
page.goto(f"{E2E_TEST_URI}/")
# sign_in_button = page.get_by_role("link", name="Sign in")
#
@@ -41,9 +43,7 @@ def test_add_new_service_workflow(end_to_end_context):
browser_type=end_to_end_context.browser.browser_type.name,
)
accounts_uri = "{}accounts".format(os.getenv("NOTIFY_E2E_TEST_URI"))
page.goto(accounts_uri)
page.goto(f"{E2E_TEST_URI}/accounts")
# Check to make sure that we've arrived at the next page.
page.wait_for_load_state("domcontentloaded")
@@ -82,24 +82,13 @@ def test_add_new_service_workflow(end_to_end_context):
# Retrieve some prominent elements on the page for testing.
service_name_input = page.locator('xpath=//input[@name="name"]')
federal_radio_button = page.locator('xpath=//input[@value="federal"]')
state_radio_button = page.locator('xpath=//input[@value="state"]')
other_radio_button = page.locator('xpath=//input[@value="other"]')
add_service_button = page.get_by_role("button", name=re.compile("Add service"))
expect(service_name_input).to_be_visible()
expect(federal_radio_button).to_be_visible()
expect(state_radio_button).to_be_visible()
expect(other_radio_button).to_be_visible()
expect(add_service_button).to_be_visible()
# Fill in the form.
service_name_input.fill(new_service_name)
expect(federal_radio_button).to_be_enabled()
# Trying to click directly on the radio button resulted in a "not in viewport error" and this is the
# suggested workaround. Googling, the reason seems to be that there might be some (invisible?) css positioned
# above the radio button itself.
page.click("text='Federal government'")
# Click on add service.
add_service_button.click()
@@ -108,7 +97,7 @@ def test_add_new_service_workflow(end_to_end_context):
page.wait_for_load_state("domcontentloaded")
# Check for the service name title and heading.
service_heading = page.get_by_text(new_service_name)
service_heading = page.get_by_text(new_service_name, exact=True)
expect(service_heading).to_be_visible()
expect(page).to_have_title(re.compile(new_service_name))

View File

@@ -3,11 +3,13 @@ import re
from playwright.sync_api import expect
E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI")
def test_landing_page(end_to_end_context):
# Open a new page and go to the staging site.
page = end_to_end_context.browser.new_page()
page.goto(os.getenv("NOTIFY_E2E_TEST_URI"))
page.goto(f"{E2E_TEST_URI}/")
# Check to make sure that we've arrived at the next page.
page.wait_for_load_state("domcontentloaded")
@@ -17,7 +19,8 @@ def test_landing_page(end_to_end_context):
# Retrieve some prominent elements on the page for testing.
main_header = page.get_by_role(
"heading", name="Send text messages to your participants"
"heading",
name="Reach people where they are with government-powered text messages",
)
sign_in_button = page.get_by_role("link", name="Sign in")
benefits_studio_email = page.get_by_role("link", name="tts-benefits-studio@gsa.gov")
@@ -51,7 +54,7 @@ def test_landing_page(end_to_end_context):
# def test_sign_in_and_mfa_pages(end_to_end_context):
# # Open a new page and go to the staging site.
# page = end_to_end_context.new_page()
# page.goto(os.getenv("NOTIFY_E2E_TEST_URI"))
# page.goto(f"{E2E_TEST_URI}/")
# print(f"test_sign_in_and_mfa_pages initial {page}")
#
# sign_in_button = page.get_by_role("link", name="Sign in")