Skip to content

test(web): playwright e2e for key flows + axe a11y smoke (#95) - #238

Open
ydimitrof wants to merge 1 commit into
midt-bg:mainfrom
ydimitrof:test/e2e-playwright-a11y
Open

test(web): playwright e2e for key flows + axe a11y smoke (#95)#238
ydimitrof wants to merge 1 commit into
midt-bg:mainfrom
ydimitrof:test/e2e-playwright-a11y

Conversation

@ydimitrof

Copy link
Copy Markdown
Contributor

What & why

Closes #95. Adds the first committed automated E2E for the explorer, plus an axe accessibility smoke — for a government site a11y is effectively mandatory (ties to #71/#73), and until now Playwright QA was only ever run by hand.

Complements the test work already in flight: #93 (coverage), #94/#177 (integration), #99 (golden dataset).

Coverage

Critical user flows (from the issue):

How it runs (hermetic)

pnpm test:e2e is self-contained:

  1. e2e/seed.mjs migrates + seeds an isolated D1 (.wrangler/e2e-state, never the dev DB) with raw entities + 20 domain contracts, then runs the real scripts/precompute.sql to build every rollup and the FTS index — the same read model production serves, with no EOP import.
  2. Playwright starts the dev server under E2E=1: dedicated port (5273) and remoteBindings:false, so Workers AI / Vectorize don't force a remote-proxy login. The assistant is not exercised.

A new e2e job in .github/workflows/ci.yml installs chromium and runs the lane; the Playwright HTML report uploads on failure.

a11y gating

The smoke blocks new serious/critical violations. The two pre-existing ones — definition-list (home) and nested-interactive (list) — are baselined in a11y.spec.ts and tracked to #71/#73; remove them there as those land.

Verification

  • pnpm test:e2e → 10/10 green, stable (chromium + mobile-chrome)
  • pnpm --filter @sigma/web typecheck clean
  • pnpm lint (prettier) clean

Adds a Playwright E2E lane covering the critical explorer flows (search,
list filtering, CSV export, contract detail, pagination, mobile nav) and an
axe accessibility smoke over the key pages, wired into CI.

The suite is hermetic: e2e/seed.mjs seeds an isolated D1 (raw entities +
domain contracts) and runs precompute.sql to build the read model, so it
never touches the developer's dev DB and needs no EOP import. The dev server
runs under E2E=1 with remote bindings off (no Cloudflare login) on a
dedicated port.

The a11y gate blocks new serious/critical violations; the two pre-existing
ones (definition-list, nested-interactive) are baselined and tracked to
midt-bg#71/midt-bg#73.

@lyubomir-bozhinov lyubomir-bozhinov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Прегледах стриктно — стабилен е и тестовете са реални, no cheater tests: seed-ът вкарва 20 договора (> PAGE_SIZE.contracts = 15), така че списъкът винаги пагинира и има ≥1 ред → detail/pagination наистина се изпълняват, а не се no-op-ват. Wiring-ът е коректен end-to-end: seed → .wrangler/e2e-state = E2E клона на vite.config.ts (порт 5273, remoteBindings:false), test:e2e = node e2e/seed.mjs && playwright test сийдва преди Playwright, а CI инсталира chromium. scripts/precompute.sql реално строи FTS search_index, тъй че search пътят е реално покрит. a11y baseline-ът за дълга #71/#73 е добър модел — блокира нови serious/critical регресии без да пада на нескоуп-нат дълг.

Две неща, нито едно не блокира:

1) Документация сочи несъществуващ файл (should-fix). Три коментара представят e2e/global-setup.ts като сийдъра, но такъв файл няма:

  • vite.config.ts (E2E клонът): „seeded by e2e/global-setup.ts"
  • playwright.config.ts (заглавен коментар): „a hermetic D1 (seeded by e2e/global-setup.ts)"
  • .github/workflows/ci.yml (стъпката e2e): „test:e2e is self-contained: e2e/global-setup.ts migrates + seeds…"

Реалният механизъм е test:e2e скриптът; самият seed.mjs в заглавието си обяснява ЗАЩО умишлено не е globalSetup (Playwright транспилира setup файловете в cache dir и мести relative --persist-to). Отделно, webServer коментарът в playwright.config.ts казва „already seeded (pnpm setup)" — това сочи dev базата (.wrangler/state), не херметичния e2e-state. Разработчик ще си загуби времето да търси този файл — предлагам да изравните коментарите с реалния поток.

2) test.skip(count === 0) маскира регресии (optional nit). В pagination.spec.ts и в a11y „contract detail" skip-guard-ът не може легитимно да се задейства при този детерминиран seed (20 > 15 → винаги ≥2 страници и ≥1 ред). Значи единственото, което би ги накарало да skip-нат, е счупен селектор на пейджъра/реда — тоест реална регресия се превръща в тих зелен skip вместо fail. Предлагам да assert-ват наличие (напр. await expect(next).toBeVisible()) вместо да skip-ват, щом seed-ът гарантира данните.

Иначе — чиста работа. Коментар, не блокирам.

@lyubomir-bozhinov

Copy link
Copy Markdown
Collaborator

Critical (регресия извън обхвата на този test-only PR): apps/web/vite.config.ts на HEAD (6cc62e2) изпуска define блока, който е на main:

define: { __SIGMA_DEPLOY_TAG__: JSON.stringify(Date.now().toString(36)) }

Коментарът на main изрично казва „It MUST be a build-time value". Без блока __SIGMA_DEPLOY_TAG__ е undefined и workers/app.ts:42-44 пада към Date.now() при boot на worker-а, не при build. Различни isolate-и получават различен таг → детерминизмът на cache invalidation по fleet-а се чупи при първия deploy след merge.

Поправка: върни define блока в конфигурацията точно както е на main.

(Останалото по lane-а е издържано — hermetic seed с fail-loud проверка, Turnstile-gated chat правилно изключен. Само коментарите сочат несъществуващи pnpm setup / e2e/global-setup.ts вместо реалния e2e/seed.mjs.)

@nedda76

nedda76 commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Този клон е в конфликт с main, тъй че към момента не може да се ревюира — дифът, който GitHub показва, вече не отговаря на това, което би влязло. Ще го пребазираш ли върху актуалния main (или merge на main в клона) и да разрешиш конфликтите? След това веднага го поглеждам. Благодаря! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Тестове: Playwright E2E за ключовите потоци + axe a11y smoke

3 participants