Skip to content

test: Playwright e2e suite (auth, chat, projects, tabular reviews, workflows) - #43

Open
amal66 wants to merge 9 commits into
upstream-mainfrom
upstream-pr/e2e-playwright
Open

test: Playwright e2e suite (auth, chat, projects, tabular reviews, workflows)#43
amal66 wants to merge 9 commits into
upstream-mainfrom
upstream-pr/e2e-playwright

Conversation

@amal66

@amal66 amal66 commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

Ports the amal66/mike fork's Playwright end-to-end suite onto upstream's backend/ + frontend/ layout: 27 tests in 7 files covering auth flows, the critical path (create project → upload PDF → ask a question → streamed response), chat management, project management, tabular reviews, and workflows/account settings.

Changes

  • e2e/auth.setup.ts (idempotently creates a confirmed e2e@mike.local user via the Supabase admin API, reading the service-role key from the environment or backend/.env, and saves Playwright storageState), auth-flows, critical-path, chat-management, project-management, tabular-reviews, workflows-account specs, and fixtures/test.pdf.
  • playwright.config.ts — single worker (the suite shares one backend and one test user; concurrency races on shared list views), a setup project that runs before a chromium project reusing the saved auth state. The webServer block is adapted from the fork's monorepo command (npm run dev --workspace apps/web) to upstream's layout: backend npm run dev (health-checked on :3001/health) and frontend npm run dev (:3000), both with reuseExistingServer.
  • Root package.json (upstream has none) with @playwright/test, typescript dev-deps and test:e2e* scripts, trimmed from the fork's root manifest; root tsconfig.json scoped to e2e/ + playwright.config.ts so npx tsc --noEmit typechecks the suite; .gitignore entries for Playwright artifacts and e2e/.auth/ (session tokens).

No app-code changes: the specs select exclusively by ARIA role/accessible name and placeholder text — none use data-testid, so no test-id attributes needed adding to frontend/.

Why

Upstream has no end-to-end coverage; unit tests can't catch a broken login redirect, an upload pipeline regression, or an SSE stream that stops rendering. This suite pins the user-visible critical paths.

Testing

  • npx playwright test --list enumerates 27 tests in 7 files with no collection errors.
  • npx tsc --noEmit (root tsconfig covering e2e/ + the config) passes.
  • Backend npm install + npm run build green from clean (this branch does not touch backend/ or frontend/).
  • NOT run against a live stack — that needs a running Supabase with service-role credentials. Two known gaps for whoever first runs it live, stated plainly:
    1. A string-level audit of every literal selector in the specs against frontend/src shows 8 of 45 accessible-name/placeholder strings do not appear in the current UI source (+ Create New, Add Subfolder, Ask a question about your documents..., New review, Workflow name, Demo (no key needed), Demo mode; test.pdf/test.txt are runtime filenames and fine). The specs were written against an earlier UI iteration — those selectors will need updating to the current accessible names before the affected tests pass.
    2. The critical-path chat test selects the fork's keyless demo model, which does not exist upstream — running it here requires a configured provider API key and a selector update.

Provenance

All added lines are mechanical ports of amal66/mike@origin/main (b3166dd); exceptions: webServer commands rewritten from monorepo workspaces to backend//frontend cwds (backend entry added per upstream's two-process dev setup); apps/apibackend and apps/webfrontend path rewrites in auth.setup.ts and comments; root package.json/tsconfig.json are new files trimmed from the fork's root manifest and tsconfig.base.json because upstream has no repo-root toolchain to host the Playwright dep; three inert { timeout: 60_000 } test-details objects dropped in project-management.spec.ts (not part of Playwright's TestDetails type and ignored by the runner — removing them changes nothing at runtime and lets the suite typecheck); .gitignore entries copied from the fork's.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CEguyEgXa9JjCciXCcVemC

CI: running e2e as a merge gate (added)

This PR now ships the workflow that makes the suite actually run and block, not just exist:

  • .github/workflows/e2e.yml — on every pull_request into main (and upstream-main, the fork mirror) plus manual workflow_dispatch, the e2e / playwright job boots a full stack — MinIO object storage, local Supabase (Auth + Postgres, loading backend/schema.sql), the backend API (:3001) and the Next.js web app (:3000) — then runs npx playwright test and uploads the HTML report + traces on pass or fail. playwright.config.ts already sets webServer: undefined when CI=true, so the job owns the stack.
  • docs/e2e-ci.md — the required secret and how to make the check merge-blocking.

Optional secret

  • ANTHROPIC_API_KEY — the 4 LLM-dependent specs (chat + critical-path) skip without it (e2e/llm.ts), so a keyless run is green on the other ~23. Set it to also run/enforce those 4.

Making it block merges (branch protection — a repo setting, not code)

The workflow reports pass/fail on its own, but GitHub only blocks the merge when the check is required. After it's been green a few times:

  1. Settings → Branches → Add/Edit rule for main.
  2. Enable Require status checks to pass + Require branches to be up to date.
  3. Add e2e / playwright (appears once it has run on a PR); recommended alongside backend and license/cla.

CLI equivalent and local-run instructions are in docs/e2e-ci.md.

Update — suite is green in CI ✅

e2e / playwright now passes: 23 passed, 4 skipped, 0 failed in ~7 min on a keyless run. Getting there surfaced (and fixed) three pre-existing issues, each verified end-to-end against a local stack:

  1. schema.sql lags the migrations. GET /workflows/:id queries workflow_open_source_submissions, a table only a migration creates → 500 that broke the workflow specs. The workflow now applies every dated migration on top of schema.sql (idempotent — 0 errors on a fresh DB), grants service_role after (schema.sql revokes client grants assuming a hosted Supabase), and reloads PostgREST.
  2. next dev made the suite flaky. On-demand route compilation (slow first hit → waitForResponse timeouts) and the dev hydration-error overlay (injects nextjs__container_errors DOM that pollutes text locators — getByText('All') matched the overlay's "Call Stack") caused intermittent failures. The workflow now serves a production build (next build + next start).
  3. LLM specs need a model key. The 4 message-sending specs now test.skip(!process.env.ANTHROPIC_API_KEY) (e2e/llm.ts), so keyless runs (local, fork PRs) stay green and the LLM specs run only when the secret is set.

Merge-blocking still requires enabling branch protection on e2e / playwright (repo setting) — see docs/e2e-ci.md.

…rkflows)

Port of the amal66/mike fork's Playwright end-to-end suite onto the
upstream backend/ + frontend/ layout:

- e2e/: auth.setup (bootstraps a confirmed e2e@mike.local user via the
  Supabase admin API and saves storageState), auth-flows, critical-path
  (create project -> upload PDF -> ask a question -> streamed response),
  chat-management, project-management, tabular-reviews,
  workflows-account; fixtures/test.pdf
- playwright.config.ts: single-worker (shared test user), setup project
  + chromium project with saved auth state; webServer adapted from the
  fork's monorepo command (npm run dev --workspace apps/web) to
  upstream's layouts: backend `npm run dev` (health-checked on :3001)
  and frontend `npm run dev` (:3000)
- root package.json (upstream has none): @playwright/test, typescript
  dev-deps and test:e2e scripts, trimmed from the fork's root manifest
- root tsconfig.json scoped to e2e/ + playwright.config.ts so
  `npx tsc --noEmit` typechecks the suite
- .gitignore: playwright artifacts + e2e/.auth (session tokens)

Specs select by ARIA role/name and placeholder text only - no
data-testid attributes, so no app-code changes are required.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CEguyEgXa9JjCciXCcVemC
upstream-main (olp's tip) ships the Open-Legal-Products#215/Open-Legal-Products#216 liquid-surfaces UI, so the same
selector drifts fixed on the fork's suite (commit 3d46814 on main) also apply
here. Ports those realigned hunks, plus one upstream-specific route fix.

  * Chat input placeholder is "How can I help?", not
    "Ask a question about your documents..." (ChatInput/TRChatInput). Updated in
    chat-management (rename/delete/project-assistant) and critical-path.
  * The project-assistant empty state replaced the "+ Create New" text link with
    a PillButton reading "Create" (ProjectAssistantTable) — critical-path and
    chat-management now use getByRole("button", { name: "Create" }).
  * The sidebar chat row's active marker is APP_SURFACE_ACTIVE_CLASS
    ("bg-app-surface-active"), not "bg-gray-200/60"; the row wrapper is now h-8,
    not h-9 (SidebarChatItem). The rename/delete tests locate the row accordingly.
  * The documents-toolbar folder button is "Folder" (TabPillButton wired to the
    root createFolderAction in ProjectDocumentsView), not "Add Subfolder"; it
    still opens the autofocused "Folder name" root input.
  * NewTRModal's footer submit and the tabular page CTA both read "Create", so
    the create-review helper scopes to the modal submit
    (button[name="modalAction"][value="create-review"]).
  * The built-in workflow detail test navigated to the flat /workflows/[id],
    which upstream does not route — only the typed /workflows/assistant/[id] and
    /workflows/tabular-review/[id] exist. builtin-cp-checklist is assistant-type,
    so it now navigates to /workflows/assistant/builtin-cp-checklist (the path
    the app itself links to via workflowDetailPath; works on the fork too).

Verified: full 27-test suite green against upstream-main + test-harness +
demo-mode(+provider-registry), backend + local Supabase (upstream schema.sql +
backend/migrations) + MinIO, demo model, e2e@mike.local.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CEguyEgXa9JjCciXCcVemC
QA Runner and others added 5 commits July 17, 2026 13:36
Adds .github/workflows/e2e.yml adapted to this repo's backend/ + frontend/
layout: on every pull_request into main (or upstream-main), boot MinIO +
local Supabase (loading backend/schema.sql), start the API and web dev
servers, and run the Playwright suite, uploading the HTML report/traces on
pass or fail. playwright.config.ts already disables its local webServer when
CI=true, so the job owns the stack.

docs/e2e-ci.md documents the one required secret (ANTHROPIC_API_KEY) and the
branch-protection steps that make the 'e2e / playwright' check required, so a
red run blocks the merge button.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Switch the artifact step from !cancelled() to always() so a run that hits the
30-minute job timeout (the failure mode when many specs retry) still uploads
the HTML report and traces instead of skipping the upload — that partial report
is exactly what's needed to diagnose the failing specs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The backend queries exclusively as service_role (lib/supabase.ts, service key,
'bypasses RLS'). schema.sql revokes client grants (anon/authenticated) but
assumes a hosted Supabase where service_role already has full table access — on
a fresh CLI stack loaded via psql it gets none, so the first backend write 500s
with 'permission denied for table user_profiles' and every project/chat spec
fails. Granting service_role after the schema load reproduces the production
grant posture.

Verified in CI: POST /projects 500 -> 201, GET /chat 500 -> 200.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… key

Three fixes that take the suite from ~everything-failing to green (verified end
to end against a local stack):

1. schema.sql lags the migrations (missing e.g. workflow_open_source_submissions,
   which GET /workflows/:id queries → 500). Apply every dated migration on top of
   schema.sql (idempotent; 0 errors on a fresh DB), grant service_role AFTER so
   new tables are covered, then reload PostgREST. Fixes the workflow specs.

2. Serve a production build (next build + next start) instead of next dev. The dev
   server's on-demand compilation (slow first hit → waitForResponse timeouts) and
   hydration-error overlay (injects nextjs__container_errors DOM that pollutes text
   locators, e.g. getByText('All') matching 'Call Stack') made the suite flaky.
   Fixes tabular-reviews list render + the timing flakes.

3. LLM-dependent specs (chat rename/delete/submit, critical-path) require a model
   key to send a message. Guard them with test.skip(!hasLlmKey) (e2e/llm.ts) and
   expose ANTHROPIC_API_KEY to the Playwright process, so a keyless run is green on
   the ~23 other specs and the LLM specs run + enforce only when the secret is set.

Local result (no key, with MinIO+LibreOffice as on ubuntu-latest): 23 passed,
4 skipped, 0 failed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The suite is green with no secret (LLM specs skip). Update docs/e2e-ci.md and the
workflow header to reflect the migrations step, the production build, and the
optional (not required) ANTHROPIC_API_KEY.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@amal66
amal66 force-pushed the upstream-pr/e2e-playwright branch from 5d95d7e to 066da0f Compare July 17, 2026 23:19
QA Runner and others added 2 commits July 20, 2026 09:08
The workflows UI refresh (olp/main fa21ac8) renamed the built-in workflow id
builtin-cp-checklist -> builtin-draft-cp-checklist (title 'Draft CP Checklist'
unchanged). The read-only-detail spec navigated to the old id URL and got a
'workflow not found' page. Point it at the new id.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant