test: Playwright e2e suite (auth, chat, projects, tabular reviews, workflows) - #43
Open
amal66 wants to merge 9 commits into
Open
test: Playwright e2e suite (auth, chat, projects, tabular reviews, workflows)#43amal66 wants to merge 9 commits into
amal66 wants to merge 9 commits into
Conversation
…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
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
force-pushed
the
upstream-pr/e2e-playwright
branch
from
July 17, 2026 23:19
5d95d7e to
066da0f
Compare
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 confirmede2e@mike.localuser via the Supabase admin API, reading the service-role key from the environment orbackend/.env, and saves PlaywrightstorageState),auth-flows,critical-path,chat-management,project-management,tabular-reviews,workflows-accountspecs, andfixtures/test.pdf.playwright.config.ts— single worker (the suite shares one backend and one test user; concurrency races on shared list views), asetupproject that runs before achromiumproject reusing the saved auth state. ThewebServerblock is adapted from the fork's monorepo command (npm run dev --workspace apps/web) to upstream's layout: backendnpm run dev(health-checked on:3001/health) and frontendnpm run dev(:3000), both withreuseExistingServer.package.json(upstream has none) with@playwright/test,typescriptdev-deps andtest:e2e*scripts, trimmed from the fork's root manifest; roottsconfig.jsonscoped toe2e/+playwright.config.tssonpx tsc --noEmittypechecks the suite;.gitignoreentries for Playwright artifacts ande2e/.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 tofrontend/.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 --listenumerates 27 tests in 7 files with no collection errors.npx tsc --noEmit(root tsconfig coveringe2e/+ the config) passes.npm install+npm run buildgreen from clean (this branch does not touchbackend/orfrontend/).frontend/srcshows 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.txtare 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.Provenance
All added lines are mechanical ports of amal66/mike@origin/main (b3166dd); exceptions:
webServercommands rewritten from monorepo workspaces tobackend//frontendcwds (backend entry added per upstream's two-process dev setup);apps/api→backendandapps/web→frontendpath rewrites inauth.setup.tsand comments; rootpackage.json/tsconfig.jsonare new files trimmed from the fork's root manifest andtsconfig.base.jsonbecause upstream has no repo-root toolchain to host the Playwright dep; three inert{ timeout: 60_000 }test-details objects dropped inproject-management.spec.ts(not part of Playwright'sTestDetailstype and ignored by the runner — removing them changes nothing at runtime and lets the suite typecheck);.gitignoreentries 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 everypull_requestintomain(andupstream-main, the fork mirror) plus manualworkflow_dispatch, thee2e / playwrightjob boots a full stack — MinIO object storage, local Supabase (Auth + Postgres, loadingbackend/schema.sql), the backend API (:3001) and the Next.js web app (:3000) — then runsnpx playwright testand uploads the HTML report + traces on pass or fail.playwright.config.tsalready setswebServer: undefinedwhenCI=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:
main.e2e / playwright(appears once it has run on a PR); recommended alongsidebackendandlicense/cla.CLI equivalent and local-run instructions are in
docs/e2e-ci.md.Update — suite is green in CI ✅
e2e / playwrightnow 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:schema.sqllags the migrations.GET /workflows/:idqueriesworkflow_open_source_submissions, a table only a migration creates → 500 that broke the workflow specs. The workflow now applies every dated migration on top ofschema.sql(idempotent — 0 errors on a fresh DB), grantsservice_roleafter (schema.sql revokes client grants assuming a hosted Supabase), and reloads PostgREST.next devmade the suite flaky. On-demand route compilation (slow first hit →waitForResponsetimeouts) and the dev hydration-error overlay (injectsnextjs__container_errorsDOM 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).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) — seedocs/e2e-ci.md.