mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-05 15:18:26 -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_EMAIL: ${{ secrets.NOTIFY_E2E_TEST_EMAIL }}
|
||||||
NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }}
|
NOTIFY_E2E_TEST_PASSWORD: ${{ secrets.NOTIFY_E2E_TEST_PASSWORD }}
|
||||||
# Run the E2E tests against the code found in this PR.
|
# 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:
|
validate-new-relic-config:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ from . import (
|
|||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
|
E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI")
|
||||||
|
|
||||||
|
|
||||||
class ElementNotFound(Exception):
|
class ElementNotFound(Exception):
|
||||||
pass
|
pass
|
||||||
@@ -529,7 +531,7 @@ def mock_update_service(mocker):
|
|||||||
"sms_sender",
|
"sms_sender",
|
||||||
"permissions",
|
"permissions",
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
return {"data": service}
|
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_page_title=True,
|
||||||
_test_for_elements_without_class=True,
|
_test_for_elements_without_class=True,
|
||||||
_optional_args="",
|
_optional_args="",
|
||||||
**endpoint_kwargs
|
**endpoint_kwargs,
|
||||||
):
|
):
|
||||||
return ClientRequest.get_url(
|
return ClientRequest.get_url(
|
||||||
url_for(endpoint, **(endpoint_kwargs or {})) + _optional_args,
|
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,
|
_expected_redirect=None,
|
||||||
_test_page_title=True,
|
_test_page_title=True,
|
||||||
_test_for_elements_without_class=True,
|
_test_for_elements_without_class=True,
|
||||||
**endpoint_kwargs
|
**endpoint_kwargs,
|
||||||
):
|
):
|
||||||
resp = logged_in_client.get(
|
resp = logged_in_client.get(
|
||||||
url,
|
url,
|
||||||
@@ -2414,7 +2416,7 @@ def client_request(logged_in_client, mocker, service_one): # noqa (C901 too com
|
|||||||
_follow_redirects=False,
|
_follow_redirects=False,
|
||||||
_expected_redirect=None,
|
_expected_redirect=None,
|
||||||
_content_type=None,
|
_content_type=None,
|
||||||
**endpoint_kwargs
|
**endpoint_kwargs,
|
||||||
):
|
):
|
||||||
return ClientRequest.post_url(
|
return ClientRequest.post_url(
|
||||||
url_for(endpoint, **(endpoint_kwargs or {})),
|
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,
|
_expected_status=302,
|
||||||
_optional_args="",
|
_optional_args="",
|
||||||
_content_type=None,
|
_content_type=None,
|
||||||
**endpoint_kwargs
|
**endpoint_kwargs,
|
||||||
):
|
):
|
||||||
return ClientRequest.post_response_from_url(
|
return ClientRequest.post_response_from_url(
|
||||||
url_for(endpoint, **(endpoint_kwargs or {})) + _optional_args,
|
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.
|
# Open a new page and go to the staging site.
|
||||||
context = browser.new_context()
|
context = browser.new_context()
|
||||||
page = context.new_page()
|
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")
|
sign_in_button = page.get_by_role("link", name="Sign in")
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,14 @@ import re
|
|||||||
|
|
||||||
from playwright.sync_api import expect
|
from playwright.sync_api import expect
|
||||||
|
|
||||||
|
E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI")
|
||||||
|
|
||||||
|
|
||||||
def _bypass_sign_in(end_to_end_context):
|
def _bypass_sign_in(end_to_end_context):
|
||||||
# Open a new page and go to the staging site.
|
# Open a new page and go to the staging site.
|
||||||
page = end_to_end_context.new_page()
|
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")
|
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):
|
def test_add_new_service_workflow(end_to_end_context):
|
||||||
# page = end_to_end_context.new_page()
|
# page = end_to_end_context.new_page()
|
||||||
page = _bypass_sign_in(end_to_end_context)
|
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")
|
# 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,
|
browser_type=end_to_end_context.browser.browser_type.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
accounts_uri = "{}accounts".format(os.getenv("NOTIFY_E2E_TEST_URI"))
|
page.goto(f"{E2E_TEST_URI}/accounts")
|
||||||
|
|
||||||
page.goto(accounts_uri)
|
|
||||||
|
|
||||||
# Check to make sure that we've arrived at the next page.
|
# Check to make sure that we've arrived at the next page.
|
||||||
page.wait_for_load_state("domcontentloaded")
|
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.
|
# Retrieve some prominent elements on the page for testing.
|
||||||
service_name_input = page.locator('xpath=//input[@name="name"]')
|
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"))
|
add_service_button = page.get_by_role("button", name=re.compile("Add service"))
|
||||||
|
|
||||||
expect(service_name_input).to_be_visible()
|
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()
|
expect(add_service_button).to_be_visible()
|
||||||
|
|
||||||
# Fill in the form.
|
# Fill in the form.
|
||||||
service_name_input.fill(new_service_name)
|
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.
|
# Click on add service.
|
||||||
add_service_button.click()
|
add_service_button.click()
|
||||||
@@ -108,7 +97,7 @@ def test_add_new_service_workflow(end_to_end_context):
|
|||||||
page.wait_for_load_state("domcontentloaded")
|
page.wait_for_load_state("domcontentloaded")
|
||||||
|
|
||||||
# Check for the service name title and heading.
|
# 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(service_heading).to_be_visible()
|
||||||
expect(page).to_have_title(re.compile(new_service_name))
|
expect(page).to_have_title(re.compile(new_service_name))
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,13 @@ import re
|
|||||||
|
|
||||||
from playwright.sync_api import expect
|
from playwright.sync_api import expect
|
||||||
|
|
||||||
|
E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI")
|
||||||
|
|
||||||
|
|
||||||
def test_landing_page(end_to_end_context):
|
def test_landing_page(end_to_end_context):
|
||||||
# Open a new page and go to the staging site.
|
# Open a new page and go to the staging site.
|
||||||
page = end_to_end_context.browser.new_page()
|
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.
|
# Check to make sure that we've arrived at the next page.
|
||||||
page.wait_for_load_state("domcontentloaded")
|
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.
|
# Retrieve some prominent elements on the page for testing.
|
||||||
main_header = page.get_by_role(
|
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")
|
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")
|
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):
|
# def test_sign_in_and_mfa_pages(end_to_end_context):
|
||||||
# # Open a new page and go to the staging site.
|
# # Open a new page and go to the staging site.
|
||||||
# page = end_to_end_context.new_page()
|
# 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}")
|
# print(f"test_sign_in_and_mfa_pages initial {page}")
|
||||||
#
|
#
|
||||||
# sign_in_button = page.get_by_role("link", name="Sign in")
|
# sign_in_button = page.get_by_role("link", name="Sign in")
|
||||||
|
|||||||
Reference in New Issue
Block a user