mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-08 10:28:57 -04:00
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:
2
.github/workflows/checks.yml
vendored
2
.github/workflows/checks.yml
vendored
@@ -125,7 +125,7 @@ jobs:
|
||||
NOTIFY_E2E_TEST_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }}
|
||||
NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }}
|
||||
# Run the E2E tests against the code found in this PR.
|
||||
NOTIFY_E2E_TEST_URI: http://localhost:6012/
|
||||
NOTIFY_E2E_TEST_URI: http://localhost:6012
|
||||
|
||||
validate-new-relic-config:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -36,6 +36,8 @@ from . import (
|
||||
|
||||
load_dotenv()
|
||||
|
||||
E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI")
|
||||
|
||||
|
||||
class ElementNotFound(Exception):
|
||||
pass
|
||||
@@ -529,7 +531,7 @@ def mock_update_service(mocker):
|
||||
"sms_sender",
|
||||
"permissions",
|
||||
]
|
||||
}
|
||||
},
|
||||
)
|
||||
return {"data": service}
|
||||
|
||||
@@ -2353,7 +2355,7 @@ def client_request(logged_in_client, mocker, service_one): # noqa (C901 too com
|
||||
_test_page_title=True,
|
||||
_test_for_elements_without_class=True,
|
||||
_optional_args="",
|
||||
**endpoint_kwargs
|
||||
**endpoint_kwargs,
|
||||
):
|
||||
return ClientRequest.get_url(
|
||||
url_for(endpoint, **(endpoint_kwargs or {})) + _optional_args,
|
||||
@@ -2372,7 +2374,7 @@ def client_request(logged_in_client, mocker, service_one): # noqa (C901 too com
|
||||
_expected_redirect=None,
|
||||
_test_page_title=True,
|
||||
_test_for_elements_without_class=True,
|
||||
**endpoint_kwargs
|
||||
**endpoint_kwargs,
|
||||
):
|
||||
resp = logged_in_client.get(
|
||||
url,
|
||||
@@ -2414,7 +2416,7 @@ def client_request(logged_in_client, mocker, service_one): # noqa (C901 too com
|
||||
_follow_redirects=False,
|
||||
_expected_redirect=None,
|
||||
_content_type=None,
|
||||
**endpoint_kwargs
|
||||
**endpoint_kwargs,
|
||||
):
|
||||
return ClientRequest.post_url(
|
||||
url_for(endpoint, **(endpoint_kwargs or {})),
|
||||
@@ -2473,7 +2475,7 @@ def client_request(logged_in_client, mocker, service_one): # noqa (C901 too com
|
||||
_expected_status=302,
|
||||
_optional_args="",
|
||||
_content_type=None,
|
||||
**endpoint_kwargs
|
||||
**endpoint_kwargs,
|
||||
):
|
||||
return ClientRequest.post_response_from_url(
|
||||
url_for(endpoint, **(endpoint_kwargs or {})) + _optional_args,
|
||||
@@ -3523,7 +3525,7 @@ def login_for_end_to_end_testing(browser):
|
||||
# Open a new page and go to the staging site.
|
||||
context = browser.new_context()
|
||||
page = 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")
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user