Skip to content

test: fix two flaky tests (contact sheet teardown, domain-auth org lookup) - #243

Merged
stewartjarod merged 2 commits into
mainfrom
fix/contact-sheet-flake
Nov 1, 2026
Merged

stewartjarod merged 2 commits into
mainfrom
fix/contact-sheet-flake

Conversation

@stewartjarod

@stewartjarod stewartjarod commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two flaky tests, both test-only fixes.

1. test-web: contact-details-sheet.test.tsx unhandled error. It failed #242 and agent-tier3 with every test passing:

TypeError: Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.
  ❯ @radix-ui/react-focus-scope/dist/index.mjs:92  (Timeout._onTimeout)

Radix FocusScope dispatches its unmount event from a setTimeout(0). If the last test's cleanup runs right before vitest tears down jsdom, that timer fires against Node's CustomEvent. This applies the afterEach that contacts-table-analytics.test.tsx already uses:

-afterEach(cleanup);
+afterEach(async () => {
+  cleanup();
+  await new Promise((resolve) => setTimeout(resolve, 0));
+});

2. test-db: repository-domain-auth-db.test.ts › "neither reads nor updates another org's rows". The test writes an orgB row with the same awsAccountId and recordName as orgA's. rowFor didn't filter by org and took [row], so it compared orgA's "before" against whichever row Postgres returned first. The repository was correct: orgB got its own row.

 rowFor(name)
   where
+    organizationId = orgA
     awsAccountId = acctA
     recordName = name

This still catches a real leak: if recordDomainAuthCheck updated orgA's row from orgB, the scoped after would differ from before.

Evidence

  • Before:
    • run 41243060571 test-web: 3846 passed, Errors 1 error, exit 1. The same error also appears in run 41219334790.
    • This PR's first run, test-db: Received … "organizationId": "repo-dac-org-b-…" at repository-domain-auth-db.test.ts:207.
  • After: run locally 3 times each, with no unhandled errors:
    • contact-details-sheet.test.tsx: 19 passed.
    • repository-domain-auth-db.test.ts: 8 passed.
  • Caveat: both are races and neither failed locally before the fix. Evidence for the fixes is the cause visible in the CI logs, plus CI staying green.

Merge Danger

Door: two-way

Blast Radius: none (two test files)

🤖 Generated with Claude Code

https://claude.ai/code/session_01GxJAQNczULQx7FgrxWxAyE

…act sheet test

The sheet's FocusScope dispatches a CustomEvent from a setTimeout(0) on
unmount. When the last test's cleanup ran just before vitest tore down
jsdom, the timer fired against Node's CustomEvent and test-web failed
with an unhandled error even though every test passed. Mirror the
afterEach already used in contacts-table-analytics.test.tsx.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GxJAQNczULQx7FgrxWxAyE
@vercel

vercel Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
wraps-web Ready Ready Preview Nov 1, 2026 5:23am UTC
1 Skipped Deployment
Project Deployment Actions Updated
wraps-website Skipped Skipped Nov 1, 2026 5:23am UTC

Request Review

The isolation test writes an orgB row with the same awsAccountId and
recordName as orgA's. rowFor filtered by account and record name only
and took the first row, so test-db failed whenever Postgres returned
orgB's row first. Scope rowFor (and the MAIL FROM query) to orgA.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GxJAQNczULQx7FgrxWxAyE
@vercel
vercel Bot temporarily deployed to Preview – wraps-website November 1, 2026 05:21 Inactive
@stewartjarod stewartjarod changed the title test(web): flush Radix FocusScope timer in contact sheet test test: fix two flaky tests (contact sheet teardown, domain-auth org lookup) Nov 1, 2026
@stewartjarod
stewartjarod merged commit ab99912 into main Nov 1, 2026
21 checks passed
@stewartjarod
stewartjarod deleted the fix/contact-sheet-flake branch November 1, 2026 16:49

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – wraps-web — b1ccd45b Deployed Nov 1, 2026 by vercel[bot]
Preview – wraps-website — b1ccd45b Deployed Nov 1, 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.

1 participant