Skip to content

test(harness): the Deno suite is not flaky — it is 132 failures from one broken magic link - #710

Merged
thinkclay merged 2 commits into
mainfrom
claude/478-680-harness
Sep 2, 2026
Merged

thinkclay merged 2 commits into
mainfrom
claude/478-680-harness

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

#478's premise does not reproduce

The issue says the suite moves by about ±2 run to run. Three consecutive runs against the same database, nothing changed between them:

205 passed | 185 failed  (51s)
205 passed | 185 failed  (46s)
205 passed | 185 failed  (48s)

The sets of failing test names are byte-identical across all three — zero in run 1 that are not in run 3, zero in run 3 that are not in run 1. Whatever produced the ±2 in March is gone. Determinism is not what is wrong with this suite now.

What is wrong: 132 failures are one cause

101x   Auth setup is incomplete. Run auth.test.ts first.
 31x   Failed to get or create auth token

Following it down:

  1. Those suites call requireAuthSetup(), which reads tests/fixtures/tokens.json.
  2. Only auth.test.ts writes that file — a whole suite hinging on a file produced by one test.
  3. auth.test.ts fails before it gets there, so the file does not exist on a fresh checkout.
  4. It fails because the magic link it is handed is unparseable:
TypeError: Invalid URL: 'env%28EXPO_PUBLIC_URL%29/auth/confirm?token_hash=...'

config.toml:52 sets site_url = "env(EXPO_PUBLIC_URL)" and the CLI never substituted it. The running container has it literally:

$ docker exec supabase_auth_scaffald env | grep SITE_URL
GOTRUE_SITE_URL=env(EXPO_PUBLIC_URL)

pnpm supa loads .env through dotenv (env-local → dotenv -e .env), and EXPO_PUBLIC_URL is defined only in .env.template. So every magic link GoTrue mints is built on a placeholder, and the suite falls over behind it.

Three fixes, in increasing order of how much they matter

The credentials did not match the seed

TEST_USERS.regular said testpassword123. seeds/002a_seed-api-test-user.sql creates [email protected] with test123456. Measured against the running stack:

credential /auth/v1/token
[email protected] / test123456 (seeded) 200
[email protected] / testpassword123 (constant) 400

Aligned to the seed, which is the source of truth for local users. Worth 15 tests on its own: 185 → 170.

TEST_USERS.admin was never created by anything

No [email protected] in auth.users at all. New seed 002b, mirroring 002a.

Deliberately an ordinary confirmed user, not an elevated one: the suites use this identity as a second distinct user — office.test.ts guards on tokens.admin.token !== tokens.regular.token — rather than for platform privileges. If some test does need elevation it will now fail on authorization, which is a true failure about the thing under test instead of vanishing into a setup cascade.

The placeholder now announces itself

completeMagicLinkAuth() checks for a literal env( before new URL() and prints what is unset, where to set it, and that the stack must be restarted — instead of a TypeError that reappears 132 times wearing a different name.

What this does not do

The suite still cannot pass here, because this stack is running with the bad site_url and restarting someone else's stack is not mine to do. The value is that the next person gets one sentence naming the cause rather than 132 failures pointing at unrelated code.

Also unfixed, and worth its own issue: cleanup leaks. 16 orphaned ccpa-test-* / deadline-test-* users are sitting in auth.users from previous runs, so cleanupCurrentTestData's wall-clock window is not catching everything it creates.


#680: a smoke that loses its server no longer reports as an app failure

The Expo dev server OOMs partway through a back-to-back smoke run; everything after fails with ERR_CONNECTION_REFUSED and exits 1 — indistinguishable from a real assertion failure. One observed run reported three failures that were all the dead server, and all three passed individually against a fresh one.

That is worse than having no gate: the natural response — re-run and see — is exactly how a real failure gets waved through.

scripts/audit/lib/dev-server.mjs adds a preflight plus a finish() that all seven smokes now exit through. A preflight alone is not enough, because the server dies during the run and the scripts tally page errors internally — so finish() re-checks the server at the moment it is about to report failure and converts it to EXIT_INFRA (97).

Verified against a dead port:

⚠ DEV SERVER UNREACHABLE at http://localhost:59999
  This is NOT a smoke failure — nothing was asserted.
$ echo $?
97

This is the honest half of #680 — its first acceptance box. The growth itself is not diagnosed here; the second box stays open.

Refs #478
Refs #680

…one broken magic link

**#478 says the suite moves by about ±2 run to run. It does not.** Three
consecutive runs against the same database, no changes between them:

    205 passed | 185 failed  (51s)
    205 passed | 185 failed  (46s)
    205 passed | 185 failed  (48s)

and the sets of failing test *names* are byte-identical across all three — zero
in run 1 not in run 3, zero in run 3 not in run 1. Whatever produced the ±2 in
March is gone; determinism is not what is wrong with this suite now.

What is wrong is that 132 of the 185 are one root cause wearing 132 costumes:

    101x  Auth setup is incomplete. Run auth.test.ts first.
     31x  Failed to get or create auth token

Following it down: those suites call requireAuthSetup(), which reads
tests/fixtures/tokens.json, which only auth.test.ts writes — and auth.test.ts
fails first, so the file does not exist on a fresh checkout. It fails because
the magic link it is sent is unparseable:

    TypeError: Invalid URL: 'env%28EXPO_PUBLIC_URL%29/auth/confirm?token_hash=...'

config.toml:52 sets `site_url = "env(EXPO_PUBLIC_URL)"`, and the CLI never
substituted it — the running container has `GOTRUE_SITE_URL=env(EXPO_PUBLIC_URL)`
literally. `pnpm supa` loads .env via dotenv, and EXPO_PUBLIC_URL is defined
only in .env.template. So every magic link GoTrue mints is built on a
placeholder, and the whole suite falls over behind it.

Three fixes here, in increasing order of how much they matter:

**The credentials did not match the seed.** TEST_USERS.regular said
'testpassword123'; seeds/002a creates [email protected] with 'test123456'.
Measured against the running stack: the seeded password returns 200 from
/auth/v1/token, the constant here returned 400. Aligned to the seed, which is
the source of truth for local users. Worth 15 tests on its own — 185 failures
to 170.

**TEST_USERS.admin was never created by anything.** No [email protected] in
auth.users at all. New seed 002b, mirroring 002a. Deliberately an ordinary
confirmed user rather than an elevated one: the suites use it as a *second
distinct identity* — office.test.ts guards on
`tokens.admin.token !== tokens.regular.token` — not for platform privileges. If
some test does need elevation it will now fail on authorization, which is a
true failure about the thing under test rather than a setup cascade.

**The placeholder now announces itself.** completeMagicLinkAuth() checks for a
literal `env(` before `new URL()` and explains exactly what is unset and that
the stack must be restarted, instead of throwing a TypeError that reappears
132 times as "Auth setup is incomplete".

The suite still cannot pass here, because this stack is running with the bad
site_url and restarting it is not mine to do. But the next person gets one
sentence naming the cause instead of 132 failures pointing at unrelated code.

Also #680: a smoke that cannot reach the dev server now exits 97, not 1.

The Expo dev server OOMs partway through a back-to-back smoke run; everything
after fails with ERR_CONNECTION_REFUSED and reported as an assertion failure.
One observed run reported three failures that were all the dead server — and
all three passed individually against a fresh one. A gate that fails for
environmental reasons is worse than no gate, because the natural response,
re-run and see, is exactly how a real failure gets waved through.

scripts/audit/lib/dev-server.mjs adds a preflight and a finish() that every
smoke now exits through. A preflight alone would not be enough — the server
dies *during* the run and the scripts tally page errors internally — so
finish() re-checks the server at the moment it is about to report failure, and
turns "the app is broken" into "the harness lost its server, exit 97". Verified
against a dead port: exit code 97, and the output says nothing was asserted.

This is the honest half of #680. The growth itself is not diagnosed here.

Refs #478
Refs #680

Co-Authored-By: Claude Opus 5 <[email protected]>
playwright.config.ts recorded, as the reason not to add the office specs, that
ApplicationsKanbanBoard "renders no testID, data-testid or nativeID at all".
It does. Traced end to end:

  StatusColumn        <DroppableColumn id={status}>
  DroppableColumn     <KanbanColumn id={id}>
  @scaffald/ui        testID={`kanban-column-${id}`}
  react-native-web    domProps['data-testid'] = testID
                      (createDOMProps/index.js:836)

kanban-helpers.ts tries three selectors, and only the first two — [data-column]
and [data-status] — miss. The third, getByTestId(`kanban-column-${column}`),
resolves. The ids line up as well: KANBAN_COLUMNS is
new/screen/interview/offer/hired/rejected, every one of them in the board's
STATUSES. And test-office-jobs-kanban.spec.ts already selects
[data-testid="kanban-column-${status}"] directly against the same component.

Left as a comment rather than acted on, because what remains is not a code fix
but a verified green run, and that needs the full local stack — Supabase, the
api function, a warm dev server, seeded users past onboarding. Adding the spec
without that is still a known-unknown selection, which is the thing this file
warns against.

`npx playwright test --list` plans 103 tests across 10 files, up from the 100
in 9 the issue recorded — #574's setup fix now resolves.

Refs #553

Co-Authored-By: Claude Opus 5 <[email protected]>
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