From 446021cd7524be7f26b12903e81dac946970a1b9 Mon Sep 17 00:00:00 2001 From: vl Date: Sun, 20 Sep 2026 23:13:58 +0200 Subject: [PATCH] test: add the end-to-end suite, on desktop and on a phone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Twenty-six tests across two viewports, covering what the spec asks for: changing today's hours reaches the panel, a message survives the translation service being unavailable, a closure period closes the days it covers — plus the authorisation paths and the sign-out regression. They run against the standalone build served the way the container serves it, not `next start`, which refuses to work with standalone output anyway. The suite therefore exercises the artifact that ships rather than a second arrangement that could drift from it. Sign-in mints the session cookie Auth.js would have issued rather than driving Authentik. What is under test is the application's behaviour for a given role; the handshake itself is verified against the live provider separately, and standing up an identity provider per run would trade a lot of machinery for coverage of somebody else's code. The secret lives in one module imported by both the config and the fixtures — when it differed, every signed-in test failed at once while looking like an authorisation bug. Database access goes through plain SQL rather than the Prisma client, whose generated module format Playwright's loader and Next's bundler disagree about. That traded one problem for a subtler one: node-postgres parses a DATE column into a local-midnight Date, so reading it back shifted the day at UTC+2. Dates are read as text now. The mobile profile runs on Chromium: WebKit needs system packages only root can install, and a suite nobody can run locally is a suite nobody runs. The config says how to switch to the real engine. Two real defects surfaced, both found by the tests rather than by reading. The seven "Ouvert" checkboxes on the hours page were indistinguishable to a screen reader; each now names its day. And on a phone the signed-in address appeared nowhere at all — the header hides it to save room — so nobody could tell which account was about to sign an audit entry on a device the shop shares. It is on the dashboard now. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_012cSY9pVhZmJUKNN7wf1Myd --- .github/workflows/ci.yml | 42 +++++++++++ app/admin/horaires/WeekEditor.tsx | 4 ++ app/admin/page.tsx | 12 ++-- e2e/auth.spec.ts | 52 ++++++++++++++ e2e/constants.ts | 13 ++++ e2e/fixtures.ts | 114 ++++++++++++++++++++++++++++++ e2e/global-setup.ts | 24 +++++++ e2e/messages.spec.ts | 61 ++++++++++++++++ e2e/schedule.spec.ts | 102 ++++++++++++++++++++++++++ package-lock.json | 46 ++++++++++++ package.json | 4 +- playwright.config.ts | 80 +++++++++++++++++++++ scripts/e2e-server.sh | 17 +++++ 13 files changed, 565 insertions(+), 6 deletions(-) create mode 100644 e2e/auth.spec.ts create mode 100644 e2e/constants.ts create mode 100644 e2e/fixtures.ts create mode 100644 e2e/global-setup.ts create mode 100644 e2e/messages.spec.ts create mode 100644 e2e/schedule.spec.ts create mode 100644 playwright.config.ts create mode 100755 scripts/e2e-server.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bdcb5ee..bb62910 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,6 +50,48 @@ jobs: - run: npm run coverage - run: npm run build + e2e: + name: End-to-end + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:16-alpine + env: + POSTGRES_DB: horaires_e2e + POSTGRES_USER: horaires + POSTGRES_PASSWORD: horaires + ports: + - 5432:5432 + options: >- + --health-cmd "pg_isready -U horaires -d horaires_e2e" + --health-interval 5s + --health-timeout 5s + --health-retries 20 + + env: + DATABASE_URL: postgresql://horaires:horaires@localhost:5432/horaires_e2e?schema=public + TEST_DATABASE_URL: postgresql://horaires:horaires@localhost:5432/horaires_e2e?schema=public + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '22' + cache: npm + - run: npm ci + - run: npx prisma generate + - run: npx prisma migrate deploy + # The runner can install the system packages a local machine cannot. + - run: npx playwright install --with-deps chromium + - run: npm run e2e + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: playwright-report + path: playwright-report/ + retention-days: 7 + docker: name: Docker image runs-on: ubuntu-latest diff --git a/app/admin/horaires/WeekEditor.tsx b/app/admin/horaires/WeekEditor.tsx index 7c0d3f0..2555876 100644 --- a/app/admin/horaires/WeekEditor.tsx +++ b/app/admin/horaires/WeekEditor.tsx @@ -121,6 +121,10 @@ export default function WeekEditor({ initial, canEdit }: Props) {