diff --git a/docs/contributing/actions/testing/playwright.md b/docs/contributing/actions/testing/playwright.md index 12a7cb6601..8dd2436672 100644 --- a/docs/contributing/actions/testing/playwright.md +++ b/docs/contributing/actions/testing/playwright.md @@ -30,7 +30,7 @@ Every Playwright-enabled role MUST provide exactly these two files: `playwright.config.js` MUST remain centralized in `roles/test-e2e-playwright/files/` and `package.json` in `roles/test-e2e-playwright/templates/package.json.j2` (rendered per-deploy into the staging dir). You MUST NOT duplicate or override either per role. -The `@playwright/test` version pinned into the rendered `package.json` comes from `playwright.version` in `roles/test-e2e-playwright/meta/services.yml` via the `image_version` filter. That YAML value is the single source of truth for the Playwright version. +The `@playwright/test` version pinned into the rendered `package.json` comes from `playwright.version` in `roles/test-e2e-playwright/meta/services.yml` via the `image_version` filter. That YAML value is the single source of truth for the Playwright version. The rendered `package.json` also installs `@axe-core/playwright` at `playwright.axe_version` from the same file, so a spec MAY run WCAG checks with `const { default: AxeBuilder } = require("@axe-core/playwright");`. ## CI Image Source 🪞 diff --git a/roles/test-e2e-playwright/README.md b/roles/test-e2e-playwright/README.md index d42483a4a4..e9378dc367 100644 --- a/roles/test-e2e-playwright/README.md +++ b/roles/test-e2e-playwright/README.md @@ -81,7 +81,7 @@ For the file-level contract, use [Contributing `playwright.env.j2`](../../docs/a This role ships central Playwright defaults: -- `templates/package.json.j2`: `@playwright/test` version derived from `meta/services.yml.playwright.version` +- `templates/package.json.j2`: `@playwright/test` version derived from `meta/services.yml.playwright.version`, and `@axe-core/playwright` (WCAG checks through `AxeBuilder`) pinned by `meta/services.yml.playwright.axe_version` - `files/playwright.config.js`: shared Playwright configuration Both are used as central defaults for every app role. diff --git a/roles/test-e2e-playwright/meta/services.yml b/roles/test-e2e-playwright/meta/services.yml index 3289d145ec..8598887194 100644 --- a/roles/test-e2e-playwright/meta/services.yml +++ b/roles/test-e2e-playwright/meta/services.yml @@ -5,3 +5,8 @@ test-e2e-playwright: playwright: image: mcr.microsoft.com/playwright version: "v1.64.1-noble" + axe_version: 4.14.0 + update: + - key: axe_version + type: npm + package: "@axe-core/playwright" diff --git a/roles/test-e2e-playwright/tasks/01_setup.yml b/roles/test-e2e-playwright/tasks/01_setup.yml index 5b5d7cc3fd..fc67383f36 100644 --- a/roles/test-e2e-playwright/tasks/01_setup.yml +++ b/roles/test-e2e-playwright/tasks/01_setup.yml @@ -60,7 +60,7 @@ {{ (not _playwright_shared_stamp_stat.stat.exists) or ((_playwright_shared_stamp_content.content | default('') | b64decode | trim) - != TEST_E2E_PLAYWRIGHT_VERSION) + != TEST_E2E_PLAYWRIGHT_INSTALL_STAMP) }} - name: ⬇️ Pull the Playwright image once for every role of this run @@ -83,7 +83,7 @@ - name: 🔧 Provision the shared Playwright install (npm install + stamp) when: _playwright_shared_install_needed | bool block: - - name: 📦 Install @playwright/test into the shared dir (once per host per version) + - name: 📦 Install @playwright/test and @axe-core/playwright into the shared dir ansible.builtin.command: argv: - container @@ -110,5 +110,5 @@ - name: ✏️ Write shared install stamp ansible.builtin.copy: dest: "{{ TEST_E2E_PLAYWRIGHT_SHARED_STAMP }}" - content: "{{ TEST_E2E_PLAYWRIGHT_VERSION }}" + content: "{{ TEST_E2E_PLAYWRIGHT_INSTALL_STAMP }}" mode: "0644" diff --git a/roles/test-e2e-playwright/templates/package.json.j2 b/roles/test-e2e-playwright/templates/package.json.j2 index b420bb03ea..3ffbacf5ab 100644 --- a/roles/test-e2e-playwright/templates/package.json.j2 +++ b/roles/test-e2e-playwright/templates/package.json.j2 @@ -5,6 +5,7 @@ "test": "playwright test" }, "devDependencies": { + "@axe-core/playwright": "{{ TEST_E2E_PLAYWRIGHT_AXE_VERSION }}", "@playwright/test": "{{ TEST_E2E_PLAYWRIGHT_VERSION }}" } } diff --git a/roles/test-e2e-playwright/vars/main.yml b/roles/test-e2e-playwright/vars/main.yml index 857dbe4328..8c3dc466b8 100644 --- a/roles/test-e2e-playwright/vars/main.yml +++ b/roles/test-e2e-playwright/vars/main.yml @@ -2,6 +2,8 @@ TEST_E2E_PLAYWRIGHT_IMAGE: "{{ lookup('config', 'test-e2e-playwright', 'services.playwright.image') }}:{{ lookup('config', 'test-e2e-playwright', 'services.playwright.version') }}" TEST_E2E_PLAYWRIGHT_VERSION: "{{ lookup('config', 'test-e2e-playwright', 'services.playwright.version') | image_version }}" +TEST_E2E_PLAYWRIGHT_AXE_VERSION: "{{ lookup('config', 'test-e2e-playwright', 'services.playwright.axe_version') }}" +TEST_E2E_PLAYWRIGHT_INSTALL_STAMP: "{{ TEST_E2E_PLAYWRIGHT_VERSION }} axe-{{ TEST_E2E_PLAYWRIGHT_AXE_VERSION }}" TEST_E2E_PLAYWRIGHT_STAGE_BASE_DIR: "/tmp/test-e2e-playwright"