All work
Personal project

Playwright UI, API and Accessibility Suite

TypeScript tests across three browsers, with bugs found along the way

PlaywrightTypeScriptaxe-corePage Object ModelGitHub ActionsGitHub Pages
Test cases
42
Browsers
3
Bugs reported
4

Overview

A Playwright suite for the Practice Software Testing Toolshop, a demo hardware store with an Angular frontend and a REST API. It tests the API directly, runs the UI flows on Chromium, Firefox and WebKit, and scans pages for accessibility problems with axe-core.

Writing the tests turned up one API bug and three accessibility defects. The API accepts email addresses like "a@b" at registration because only the frontend checks the format. Each finding is written up with steps and a suggested fix, and each one stays covered by a test.

The accessibility scan found a password toggle with no accessible name, so screen readers announce only "button". It also found a language button whose name does not match its visible text, and two lists with children that are not list items.

Objective

Build a suite that stays reliable on a public server other people use at the same time: no shared accounts, no fixed waits, and no false failures from things outside the app.

Testing scope

  • Products API

    • Pagination math, response contract and sort order
    • Search, unknown ids (404) and the category tree
  • Users and carts API

    • Register (201, 409, 422), login and /users/me with and without a token
    • Malformed emails are accepted (BUG-01, kept as test.fail)
    • Create a cart, add the same product twice, remove an item
  • UI on three browsers

    • Login, wrong password, form validation, sign out
    • Search and sort by price and name, compared with the API
    • Cart totals, and a full checkout checked against /invoices
  • Accessibility

    • axe-core WCAG 2.1 AA scan on home, login, register and contact

Test strategy

  • Every test registers its own user through the API. The shared demo accounts kept getting locked by other people.
  • Most UI tests skip the login form: the API token goes into localStorage before the app loads.
  • No waitForTimeout anywhere. Tests wait for the network response they need, including the HTTP QUERY requests the app uses for filters.
  • Known bugs stay in the suite. A fix turns the test.fail red, and a new accessibility violation fails right away because known issues match on both rule and element.
  • CI runs 3 shards in parallel, merges the reports and publishes them to GitHub Pages every night.

Measurement integrity

The first CI runs failed on every test that opened /account. The screenshots showed Cloudflare's "Verify you are human" page, not the app: the site treats GitHub's runners as bots. Getting around that check would mean defeating someone else's bot protection, so I didn't. Instead, the page fixture watches for the challenge with addLocatorHandler, and a test that fails while it is on screen is marked as skipped. I checked this with a fake challenge page: that test was skipped, and a real failure on a normal page still failed. On my laptop, where Cloudflare doesn't step in, all 70 runs pass.

Architecture

  1. Spec filesapi, ui, a11y projects
  2. Fixturesfresh user, token login
  3. Page Objectshome, product, login, checkout
  4. ToolshopAngular UI and REST API
  5. GitHub Actions3 shards, merged report on Pages

Implementation

The user fixture registers a new account through the API and logs it in, so tests never share state.
user: async ({ api }, use) => {
  const data = newUser();
  const reg = await api.post('/users/register', { data });
  expect(reg.status(), await reg.text()).toBe(201);
  const login = await api.post('/users/login', { data: { email: data.email, password: data.password } });
  expect(login.status(), await login.text()).toBe(200);
  await use({ ...data, id: (await reg.json()).id, token: (await login.json()).access_token });
},
The checkout test compares what the browser showed with what the backend stored.
const invoiceNumber = await checkout.placeOrder('cash-on-delivery');

const res = await api.get('/invoices', { headers: { Authorization: `Bearer ${user.token}` } });
const { data } = await res.json();
expect(data[0]).toMatchObject({ invoice_number: invoiceNumber, status: 'AWAITING_FULFILLMENT' });
expect(Number(data[0].total)).toBeCloseTo(uiTotal, 2);
BUG-01 stays in the suite as an expected failure until the API starts validating emails.
for (const email of ['not-an-email', 'a@b', 'x@@example.com']) {
  test(`register rejects invalid email "${email}"`, async ({ api }) => {
    test.fail(true, 'BUG-01: API accepts malformed emails (201). Only the UI validates the format.');
    const res = await api.post('/users/register', { data: { ...newUser(), email: `${Date.now()}${email}` } });
    expect(res.status()).toBe(422);
  });
}

Results

70/70

Runs passing locally

42 tests, UI on 3 browsers

0

Failures on CI

6 skipped by Cloudflare, 1 flaky

1

API bug

3

Accessibility defects

Evidence

Playwright HTML report from CI: 63 passed, 0 failed, 1 flaky, 6 skipped
The merged CI report on GitHub Pages. The flaky entry is the full checkout on Chromium, which passed on retry. The trace is attached, so a retry can be inspected instead of ignored.

Links