Repository navigation
test(web): replace slow failing waitFor polls with cheap state checks - #526
Conversation
The import button waits used jest-dom's not.toBeDisabled inside waitFor. Its first poll fails while the import is in flight, and building that failure message pretty-prints the happy-dom button with its React fiber references. In a full web suite run one such message took 4.8 seconds of synchronous CPU, which made the too-large file test take about 6 seconds and pushed it toward the timeout under load. Wait on the button's disabled property instead. A failed poll now reports a boolean, and the test still fails if the button never re-enables.
…ibility The AI tool step mounts inside a motion wrapper that enters from opacity 0. findByRole resolves as soon as the heading mounts, so toBeVisible only passed when the first animation frame had already run. Under load it lost that race, and jest-dom's failure message pretty-printed the heading with its document and React fiber references: 66 MB of output and about 35 seconds of synchronous CPU in a full suite run, which stalled the process for whatever tests came next. Wait until no ancestor is fully transparent, reporting a number on each failed poll, then keep the original toBeVisible assertion.
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe document import tests now wait for the Import button to become enabled after two error paths. The onboarding test calculates accumulated opacity and waits for the AI-tool-step heading to become visible. ChangesDocument Import Tests
Onboarding Tests
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~8 minutes Change: Other Suggested reviewers: Merge Risk: ⚪ Minimal · up to These changes only adjust test synchronization around existing import recovery and the onboarding transition; no actionable merge risk remains. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Why
Full web suite runs locally have been timing out on tests that pass alone. The cause is a failing jest-dom assertion whose message pretty-prints a happy-dom element. Bun walks the element's document and React fiber references, so one failure message costs seconds of synchronous CPU in a large process. That blocks whatever test is running next.
How the sites were found
Instead of reviewing every
waitForby hand, I temporarily instrumented@testing-library/dom'swaitForand the jest-dom matchers during full web suite runs (not committed). This logged every poll that failed, with its call site and how long it took.doc-import.test.tsx:52, a 4.8 s message. Every other failing poll in the suite cost 5 ms or less.onboarding-flow.test.tsx:76with a 66 MB, roughly 35 s failure dump. That is the same mechanism through afindByRolethentoBeVisiblerace.filter-bar,team-settings-paneland analytics page tests never fail a poll on currentmain. Their negative waits already hold on the first check, sowaitForElementToBeRemovedwould throw there ("already removed"). They are left unchanged.Changes
doc-import.test.tsx:waitFor(() => expect(button).not.toBeDisabled())now polls the button'sdisabledproperty. Same condition, and a failed poll reports a boolean instead of the element.onboarding-flow.test.tsx: the AI tool step mounts inside a motion wrapper that enters from opacity 0.findByRoleresolves on mount, so the oldtoBeVisiblepassed only when the first animation frame had already run. A probe across 15 runs found opacity between 0.04 and 0.43 at the moment the heading was found. The test now waits until no ancestor is fully transparent (a numeric check), then asserts the unchangedtoBeVisible.Strictness
Expected: false, Received: true).Per-test durations
doc-import > refuses a file too large to be a doc, before it reads itThe other tests in
doc-import.test.tsxstay under 0.1 s both before and after.onboarding-flow > moves from teammates to the AI tool step and labels it in the progress barVerification
bun run verify: exit 0. Lint, comment policy, dependency and Bun import checks, and typecheck pass in every package. Tests: web 2989, services 931, db 318, core 1102, shared 361, mcp-server 218, realtime-server 120, realtime 45, realtime-client 15, with 0 failures. This machine needed environment fixes for verify, and none of them change the repository:@orbit/dbtests run againstDATABASE_URL, so that run pointed it at a fresh database with the current schema pushed, as CI does. The local dev database was left untouched.pg_dumpshim chose the wrong one. For the run,pg_dumpandpg_restoreonPATHwere wrappers that do the same thing, pinned toorbit-postgres.