From b6f5b3240255ef0f4cfb0d22d3c8e18c03e80a59 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Dec 2025 08:33:36 +0000 Subject: [PATCH 1/2] Bump axe-playwright-python from 0.1.6 to 0.1.7 Bumps [axe-playwright-python](https://github.com/pamelafox/axe-playwright-python) from 0.1.6 to 0.1.7. - [Changelog](https://github.com/pamelafox/axe-playwright-python/blob/main/CHANGELOG.md) - [Commits](https://github.com/pamelafox/axe-playwright-python/commits) --- updated-dependencies: - dependency-name: axe-playwright-python dependency-version: 0.1.7 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- uv.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/uv.lock b/uv.lock index 7c3b237b0..80e440af3 100644 --- a/uv.lock +++ b/uv.lock @@ -43,14 +43,14 @@ wheels = [ [[package]] name = "axe-playwright-python" -version = "0.1.6" +version = "0.1.7" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "playwright" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/16/9d/e16f3c0bcf19260dc40e94751222bba3f9d216c9e7c60e154027cac89099/axe_playwright_python-0.1.6.tar.gz", hash = "sha256:377d7f1420b43bba5c62c4e1b3d3e5f564032b284747ab3ac022693098bdec81", size = 189383, upload-time = "2025-10-24T14:05:51.732Z" } +sdist = { url = "https://files.pythonhosted.org/packages/74/90/684e8ae7e7563318d197f1bfbacd561a19716e6cdb6420e7e97ef49d427c/axe_playwright_python-0.1.7.tar.gz", hash = "sha256:f0f3d59061abbaee9990d0309f855210ec8fd6ca5bf076f39210289ac0961258", size = 189815, upload-time = "2025-12-01T05:19:31.061Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/26/4f/465e2c3903ec59daf1eb7cf653a42d75dee2a205b45d9eebc9fb3099ae67/axe_playwright_python-0.1.6-py3-none-any.whl", hash = "sha256:0133432075837eb7d9b6caa5c1b3c9403fee98f10022911b655759ad33d233eb", size = 156504, upload-time = "2025-10-24T14:05:50.242Z" }, + { url = "https://files.pythonhosted.org/packages/02/b0/6460c11d515cb09d90993e948c730a3d4b6673cc5cd99663179bbc48a758/axe_playwright_python-0.1.7-py3-none-any.whl", hash = "sha256:8699e904466cc2206fa2fa414b4d59aab68e34ba8449c6d082896ca1950440e2", size = 156509, upload-time = "2025-12-01T05:19:29.285Z" }, ] [[package]] From 43bcb49af001253efd36da0990b412a4979e6278 Mon Sep 17 00:00:00 2001 From: Mat Moore Date: Thu, 18 Dec 2025 14:36:08 +0000 Subject: [PATCH 2/2] simplify axe tests axe_playwright_python previously had a bug that meant passing in options didn't work. This is now fixed, and the bundled version of axe-core has been updated, so we don't need to manage our own version anymore. --- .../core/utils/acessibility.py | 41 ++++--------------- .../tests/system/system_test_setup.py | 4 +- package.json | 1 - 3 files changed, 11 insertions(+), 35 deletions(-) diff --git a/manage_breast_screening/core/utils/acessibility.py b/manage_breast_screening/core/utils/acessibility.py index 6cfc3a0b5..7bfc5d3e9 100644 --- a/manage_breast_screening/core/utils/acessibility.py +++ b/manage_breast_screening/core/utils/acessibility.py @@ -1,8 +1,5 @@ -import json - from axe_playwright_python.base import AxeResults -from django.conf import settings -from playwright.sync_api import Page +from axe_playwright_python.sync_playwright import Axe AXE_VIOLATIONS_EXCLUDE_LIST = [ "region", # 'Some page content is not contained by landmarks' https://github.com/alphagov/govuk-frontend/issues/1604 @@ -10,34 +7,14 @@ ] -class AxeAdapter: - def __init__( - self, - page: Page, - script_path=settings.BASE_DIR.parent - / "node_modules" - / "axe-core" - / "axe.min.js", - options=None, - ): - self.script_path = script_path - self.options = options or { +class AxeAdapter(Axe): + def __init__(self): + self.default_options = { "rules": {id: {"enabled": False} for id in AXE_VIOLATIONS_EXCLUDE_LIST} } - self.page = page - self._install(page) - - def _install(self, page: Page): - """ - Add the axe script to a playwright Page. - The script will be re-executed any time the page or it's frames are navigated. - """ - page.add_init_script(path=self.script_path) + super().__init__() - def run(self) -> AxeResults: - """ - Run axe on the whole document - """ - options = json.dumps(self.options) - response = self.page.evaluate(rf"axe.run({options})") - return AxeResults(response) + def run(self, page, context=None, options=None) -> AxeResults: + return super().run( + page=page, context=context, options=options or self.default_options + ) diff --git a/manage_breast_screening/tests/system/system_test_setup.py b/manage_breast_screening/tests/system/system_test_setup.py index 80947d48e..e1ab9ce6f 100644 --- a/manage_breast_screening/tests/system/system_test_setup.py +++ b/manage_breast_screening/tests/system/system_test_setup.py @@ -35,7 +35,7 @@ def setUp(self): self.context = self.browser.new_context() self.page = self.context.new_page() self.page.set_default_timeout(5000) - self.axe = AxeAdapter(self.page) + self.axe = AxeAdapter() settings.BASE_URL = self.live_server_url def tearDown(self): @@ -138,7 +138,7 @@ def then_the_accessibility_baseline_is_met(self, require_unique_link_text=True): any interactive elements that appear close together, and avoiding any non-specific links like "click here". """ - results = self.axe.run() + results = self.axe.run(page=self.page) self.assertEqual(results.violations_count, 0, results.generate_report()) if require_unique_link_text: diff --git a/package.json b/package.json index 17c0ae464..0e1caaa8b 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,6 @@ "@types/eslint": "^9.6.1", "@types/jest": "^30.0.0", "@types/node": "^24.10.1", - "axe-core": "^4.11.0", "babel-jest": "^30.2.0", "concurrently": "^9.2.1", "eslint": "^9.37.0",