Add E2E documentation and clean E2E tests

This changeset adds additional documentation for how to write new E2E tests and cleans up the two existing tests slightly to make better use of the fixtures that are defined.

Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
This commit is contained in:
Carlo Costino
2024-02-23 16:02:16 -05:00
parent 15c1863ab0
commit e71351d949
4 changed files with 118 additions and 15 deletions

View File

@@ -89,17 +89,30 @@ def end_to_end_authenticated_context(browser):
@pytest.fixture(scope="session")
def authenticated_page(end_to_end_context):
# Open a new page and go to the staging site.
def unauthenticated_page(end_to_end_context):
page = end_to_end_context.new_page()
page.goto(f"{E2E_TEST_URI}/")
sign_in_button = page.get_by_role("link", name="Sign in")
# Wait for the next page to fully load.
page.wait_for_load_state("domcontentloaded")
return page
@pytest.fixture(scope="session")
def authenticated_page(end_to_end_context):
# Open a new page and go to the site.
page = end_to_end_context.new_page()
page.goto(f"{E2E_TEST_URI}/")
# Wait for the next page to fully load.
page.wait_for_load_state("domcontentloaded")
# Sign in to the site - E2E test accounts are set to flow through.
sign_in_button = page.get_by_role("link", name="Sign in")
sign_in_button.click()
# Wait for the next page to fully load.
page.wait_for_load_state("domcontentloaded")
return page

View File

@@ -9,10 +9,6 @@ E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI")
def test_add_new_service_workflow(authenticated_page, end_to_end_context):
page = authenticated_page
page.goto(f"{E2E_TEST_URI}/")
# Wait for the next page to fully load.
page.wait_for_load_state("domcontentloaded")
# Prepare for adding a new service later in the test.
current_date_time = datetime.datetime.now()

View File

@@ -6,13 +6,8 @@ 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(f"{E2E_TEST_URI}/")
# Check to make sure that we've arrived at the next page.
page.wait_for_load_state("domcontentloaded")
def test_landing_page(unauthenticated_page):
page = unauthenticated_page
# Check the page title exists and matches what we expect.
expect(page).to_have_title(re.compile("Notify.gov"))