diff --git a/tests/end_to_end/conftest.py b/tests/end_to_end/conftest.py index 64e48a8fd..cf52a88f0 100644 --- a/tests/end_to_end/conftest.py +++ b/tests/end_to_end/conftest.py @@ -2,6 +2,7 @@ import os import re import pytest +from axe_core_python.sync_playwright import Axe E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") @@ -105,3 +106,13 @@ def authenticated_page(end_to_end_context): page.wait_for_load_state("domcontentloaded") return page + + +def check_axe_report(page): + axe = Axe() + + results = axe.run(page) + + assert ( + len(results["violations"]) == 0 + ), f"Accessibility violations: {results['violations']}" diff --git a/tests/end_to_end/test_a11y.py b/tests/end_to_end/test_a11y.py index 17ee6e5cd..2de01feab 100644 --- a/tests/end_to_end/test_a11y.py +++ b/tests/end_to_end/test_a11y.py @@ -1,6 +1,6 @@ import os -from axe_core_python.sync_playwright import Axe +from tests.end_to_end.conftest import check_axe_report E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") @@ -19,11 +19,4 @@ def test_a11y(authenticated_page, end_to_end_context): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") - - axe = Axe() - - results = axe.run(page) - - assert ( - len(results["violations"]) == 0 - ), f"Accessibility violations: {results['violations']}" + check_axe_report(page) diff --git a/tests/end_to_end/test_accounts_page.py b/tests/end_to_end/test_accounts_page.py index b6fe8c5ac..87bb8c459 100644 --- a/tests/end_to_end/test_accounts_page.py +++ b/tests/end_to_end/test_accounts_page.py @@ -4,6 +4,8 @@ import re from playwright.sync_api import expect +from tests.end_to_end.conftest import check_axe_report + E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI") @@ -21,6 +23,7 @@ def test_add_new_service_workflow(authenticated_page, end_to_end_context): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") + check_axe_report(page) # Check to make sure that we've arrived at the next page. # Check the page title exists and matches what we expect. @@ -49,6 +52,7 @@ def test_add_new_service_workflow(authenticated_page, end_to_end_context): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") + check_axe_report(page) # Check for the sign in heading. about_heading = page.get_by_role("heading", name="About your service") @@ -69,6 +73,7 @@ def test_add_new_service_workflow(authenticated_page, end_to_end_context): # Check to make sure that we've arrived at the next page. page.wait_for_load_state("domcontentloaded") + check_axe_report(page) # Check for the service name title and heading. service_heading = page.get_by_text(new_service_name, exact=True)