Skip to content

test(e2e): improve e2e setup - #762

Draft
adriangohjw wants to merge 17 commits into
mainfrom
cursor/e2e-combined-db13
Draft

adriangohjw wants to merge 17 commits into
mainfrom
cursor/e2e-combined-db13

Conversation

@adriangohjw

@adriangohjw adriangohjw commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

This branch stacks four Playwright e2e PRs on current main, which already includes #761. The source PRs stay open.

Source PRs

  1. test(e2e): set up the database once per run in Playwright globalSetup #735 test/e2e-global-setup, draft. Set up the database once per run in Playwright globalSetup.
  2. test(e2e): run Playwright e2e tests in CI #736 ci/e2e-job, open. Run Playwright e2e tests in CI.
  3. test(e2e): sign in via minted storage state, with role projects #738 test/e2e-auth, draft. Sign in via minted storage state, with role projects.
  4. test(e2e): add feature folders, page objects, DB helpers and network mocks #739 test/e2e-conventions, draft. Feature folders, page objects, DB helpers, and network mocks.

Skipped #641, which runs e2e against a Vercel preview. The four PRs combined without it.
Skipped BP-20 on cursor/e2e-oxlint-offs-c9ad. #735 deletes app-fixture.ts, so those oxlint offs were not needed.

Merge order

Cherry-picked onto origin/main as 735, then 736, then 738, then 739. Then two commits for #761 oxlint and for dropping AAA comments.

Conflicts

On app-fixture.ts, #735 deletes the file and #761 edited hook order. We deleted it, matching #735. globalSetup starts the containers.

On smoke.e2e.ts, #735 changes the import and #761 changes locators. We import test from @playwright/test and keep #761's locators: getByRole('contentinfo'), no waitForSelector, and no conditional 404 throw.

On ci.yml and package.json, git auto-merged #736 onto main. We kept main's action pins and eslint-plugin-playwright, and added build-e2e, start-e2e, and the e2e job. We did not put lodash-es back.

On smoke.e2e.ts again, #739 deletes the file. We deleted it and split the tests into public/landing and public/not-found.

The #761 playwright plugin wants literal test tags and an expect() in each test. Tags are '@role:user' / '@role:otherUser'. Assertions live in the tests. URL regexes are module-scoped. auth.setup.ts uses expect(baseURL).toBeDefined().

Later commits on this branch

Removed Arrange / Act / Assert comments from the e2e tests and the README line that required them. #739 added those. Other tests in this repo do not use them.

CI e2e failed on the landing test: getByRole('contentinfo') does not match RestrictedFooter because public layout wraps the page in <main>, so the <footer> is not a contentinfo landmark. The landing assertion now uses the page heading.

The e2e job runs through turbo with --log-order=stream so Playwright output is not held until the task ends (same as isomer).

Dropped the e2e oxlint workarounds for valid-test-tags and expect-expect.

Verification

pnpm --filter @acme/web lint passed.
oxfmt --check passed on the changed web files.
Playwright e2e was not run locally. This environment has no Docker.

Open in Web Open in Cursor 

adriangohjw and others added 11 commits November 11, 2026 15:56
The worker fixture used a test-scoped container fixture in beforeAll and
reset the database after every test, which forced serial runs. Move
container startup, schema reset, migrations and Redis flush into a
globalSetup that runs once, so tests can run fully in parallel with their
own uniquely named data.

- Refuse to run when DATABASE_URL does not point at the e2e container
  (a shell-exported dev URL would otherwise send test writes to dev)
- Drop and recreate the public schema so reused containers match the
  current migrations
- forbidOnly and 2 workers on CI, github + list reporters
- Keep traces and videos on failure: 'on-first-retry' never fired since
  no retries are configured

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: adriangoh <adriangoh@open.gov.sg>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- New `e2e` job builds the app with .env.e2e and runs Playwright against
  `next start` (dev server stays the local default)
- Uploads traces and videos of failed tests as an artifact (7 days)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Playwright 1.57 cannot install system deps on ubuntu-latest (26.04).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signing in through the OTP UI in every test is slow, so each role gets a
pre-signed-in session cookie instead. globalSetup seeds one user per
role; a `setup:<role>` project (auth.setup.ts) mints that role's cookie,
and the `<role>` project depends on it and runs the tests tagged
`roleTag(role)`. Playwright only runs a setup project when selected
tests need it, so a run without a role's tests never mints its cookie.
Untagged tests run signed out.

- Roles: `user`, plus `otherUser` as a second account for authorization
  tests
- login-flow.e2e.ts is the one test that signs in through the UI, using a
  known OTP written over the stored hash
- admin.e2e.ts shows both modes: signed-out redirect, signed-in page, and
  a per-role test that each session sees its own account
- Move sessionOptions/SessionData to session-options.ts so code outside
  Next can import them without next/headers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mocks

Builds on isomer's apps/studio/tests/e2e conventions, grouping by feature:

- <feature>/ (auth/, admin/, public/): tests plus the page objects only
  that feature uses, one <screen>.e2e.ts and <screen>.po.ts per screen
- fixtures/: helpers shared across features
  - <entity>.db.ts: read-only queries returning rows (user.db.ts)
  - <entity>-expect.ts: expect.poll wrappers over .db.ts getters
  - network.ts: page.route stubs (mockTrpcFailure)
- auth/sign-in.e2e.ts replaces login-flow.e2e.ts, adding an error-state
  test; smoke.e2e.ts splits into public/landing and public/not-found
- tests/e2e/README.md documents layout and rules; AGENTS.md points to it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: adriangoh <adriangoh@open.gov.sg>
#761 enabled eslint-plugin-playwright on tests/e2e. Keep roleTag() and
page-object expect* methods, and adjust the e2e override plus a few
call sites so the combined stack lints on current main.

Co-authored-by: adriangoh <adriangoh@open.gov.sg>
They were only in the new e2e suite and are not a repo convention.

Co-authored-by: adriangoh <adriangoh@open.gov.sg>
@cursor

cursor Bot commented Nov 15, 2026

Copy link
Copy Markdown

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@vercel

vercel Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
starter-kit Ready Ready Preview Nov 16, 2026 3:15pm UTC

Request Review

@adriangohjw adriangohjw changed the title test(e2e): combine #735, #736, #738, #739 onto current main test(e2e): improve e2e setup Nov 15, 2026
@datadog-opengovsg

datadog-opengovsg Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 61.69% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c8bf011 | Docs | Give us feedback!

Co-authored-by: adriangoh <adriangoh@open.gov.sg>
Drop comments that restate the code. Keep the ones that document
vendor limits we cannot change. expectUserLastLogin now asserts
lastLogin directly instead of polling behind a lint suppression.

Co-authored-by: adriangoh <adriangoh@open.gov.sg>
Public layout wraps the page in <main>, so the RestrictedFooter
<footer> is not exposed as a contentinfo landmark. That made
shows the landing page time out on CI.

Co-authored-by: adriangoh <adriangoh@open.gov.sg>
Same as isomer: turbo groups task output in CI unless --log-order=stream.

Co-authored-by: adriangoh <adriangoh@open.gov.sg>
Changed import statements in various test files to utilize the `~tests/e2e` alias for better clarity and consistency. This includes updates in `playwright.config.ts`, `auth.setup.ts`, `global-setup.ts`, and other related files, enhancing the maintainability of the codebase.

This branch was successfully deployed

1 active deployment
Preview — c8bf011b Deployed Nov 16, 2026 by vercel[bot]
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.

2 participants