From 1f8cc43a6e3e584bc4775777cf5544033cc34b13 Mon Sep 17 00:00:00 2001 From: David Murdoch Date: Tue, 12 Nov 2024 16:28:01 +0000 Subject: [PATCH] test(playwright): add axe playwright tests in bruno room --- pnpm-lock.yaml | 3 ++ react-apps/bruno-room/package.json | 1 + .../bruno-room/playwright-tests/home.spec.ts | 33 +++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ce640e1..78c14c6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -655,6 +655,9 @@ importers: specifier: ^2.34.0 version: 2.34.0(three@0.169.0) devDependencies: + '@axe-core/playwright': + specifier: ^4.10.0 + version: 4.10.0(playwright-core@1.48.2) '@playwright/test': specifier: ^1.48.2 version: 1.48.2 diff --git a/react-apps/bruno-room/package.json b/react-apps/bruno-room/package.json index 543378b..e729e6c 100644 --- a/react-apps/bruno-room/package.json +++ b/react-apps/bruno-room/package.json @@ -22,6 +22,7 @@ "three-stdlib": "^2.34.0" }, "devDependencies": { + "@axe-core/playwright": "^4.10.0", "@playwright/test": "^1.48.2", "@repo/eslint-config": "workspace:*", "@repo/playwright-config": "workspace:*", diff --git a/react-apps/bruno-room/playwright-tests/home.spec.ts b/react-apps/bruno-room/playwright-tests/home.spec.ts index 2ef1b11..2e0c580 100644 --- a/react-apps/bruno-room/playwright-tests/home.spec.ts +++ b/react-apps/bruno-room/playwright-tests/home.spec.ts @@ -1,3 +1,4 @@ +import AxeBuilder from "@axe-core/playwright"; import { expect, test } from "@playwright/test"; test("has title", async ({ page }) => { @@ -5,3 +6,35 @@ test("has title", async ({ page }) => { await expect(page).toHaveTitle("React App - Bruno Room | Threejs Journey"); }); + +test("has heading", async ({ browserName, page }) => { + // https://playwright.dev/docs/api/class-page#page-goto + test.fixme( + browserName === "firefox", + "Errors are occurring in firefox in CI pipeline", + ); + + await page.goto("/"); + + await expect( + page.getByRole("heading", { + name: "Bruno room", + }), + ).toBeVisible(); +}); + +test("should not have any automatically detectable accessibility issues", async ({ + browserName, + page, +}) => { + // https://playwright.dev/docs/api/class-page#page-goto + test.fixme( + browserName === "firefox", + "Errors are occurring in firefox in CI pipeline", + ); + await page.goto("/"); + + const accessibilityScanResults = await new AxeBuilder({ page }).analyze(); + + expect(accessibilityScanResults.violations).toEqual([]); +});