2024-02-23 11:24:03 -05:00
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
import pytest
|
2024-09-11 12:36:58 -07:00
|
|
|
from axe_core_python.sync_playwright import Axe
|
2024-02-23 11:24:03 -05:00
|
|
|
|
|
|
|
|
E2E_TEST_URI = os.getenv("NOTIFY_E2E_TEST_URI")
|
|
|
|
|
|
|
|
|
|
|
2024-07-15 08:07:18 -07:00
|
|
|
@pytest.fixture
|
2024-02-23 17:10:41 -05:00
|
|
|
def end_to_end_context(browser):
|
|
|
|
|
context = browser.new_context()
|
|
|
|
|
return context
|
2024-02-23 16:02:16 -05:00
|
|
|
|
2024-02-23 11:24:03 -05:00
|
|
|
|
2024-07-15 08:07:18 -07:00
|
|
|
@pytest.fixture
|
2024-02-23 16:02:16 -05:00
|
|
|
def authenticated_page(end_to_end_context):
|
|
|
|
|
# Open a new page and go to the site.
|
|
|
|
|
page = end_to_end_context.new_page()
|
2024-08-28 11:17:52 -07:00
|
|
|
page.goto(f"{E2E_TEST_URI}/sign-in")
|
2024-02-23 11:24:03 -05:00
|
|
|
|
|
|
|
|
# Wait for the next page to fully load.
|
|
|
|
|
page.wait_for_load_state("domcontentloaded")
|
2024-02-23 16:02:16 -05:00
|
|
|
|
2024-02-23 11:24:03 -05:00
|
|
|
return page
|
2024-09-11 12:36:58 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_axe_report(page):
|
|
|
|
|
axe = Axe()
|
|
|
|
|
|
|
|
|
|
results = axe.run(page)
|
|
|
|
|
|
2024-09-24 08:44:01 -07:00
|
|
|
# TODO fix remaining 'moderate' failures
|
|
|
|
|
# so we can set the level we skip to minor only
|
2024-09-11 12:57:10 -07:00
|
|
|
for violation in results["violations"]:
|
2024-09-11 13:31:50 -07:00
|
|
|
assert violation["impact"] in [
|
2024-10-07 07:54:14 -07:00
|
|
|
"minor", "moderate"
|
2024-09-11 13:31:50 -07:00
|
|
|
], f"Accessibility violation: {violation}"
|