Repository navigation
test: split vitest into projects, switch DOM tests to happy-dom, drop unnecessary tests - #871
Conversation
… unnecessary tests - Core vitest config now has unit (node, isolate: false), isolated, dom (happy-dom), integration and types projects. Node tests share one module graph per worker instead of re-importing the server graph for every file. - The file extension picks the environment: DOM tests are *.test.tsx. The `// @vitest-environment` pragmas are gone. - upload.ts no longer imports the whole date-fns barrel. - Real 2s reconnect waits use fake timers; the package build test builds once for its read-only assertions. - Delete tests that grep source text, test AutoForm/form-field UI, Base UI wrappers, constants or wiring of features already covered elsewhere. - The blog plugin defaults to node; only its DOM test opts into jsdom. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015x559AHZ5rNsyvKusi5pVk
Remove tests that repeat coverage from a canonical file, assert Drizzle schema details, constants, option literals or CSS classes, or grep source text. Import-graph boundary checks, security checks (cookie scoping, passkey ceremonies, password timing) and per-route permission coverage stay. - Merge http-errors into error-contracts, i18n-check into the i18n command test and save-remount into the reducer test. - Drop feed-boundaries and create-start, whose cases are covered elsewhere. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015x559AHZ5rNsyvKusi5pVk
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
React Doctor found 7 issues in 6 files · 7 warnings · score 100 / 100 (Great) · vs 7 warnings
|
Lists the kinds of tests removed in this branch (wiring, schema and SQL text, config and option literals, Base UI behaviour, source greps, locale copy, fixture checks) and adds "one behaviour, one test" rules so the same rule is asserted once, in the layer that owns it. Security checks stay even when they look redundant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015x559AHZ5rNsyvKusi5pVk
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cb4e3c14af
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| test: { | ||
| name: "unit", | ||
| environment: "node", | ||
| isolate: false, |
There was a problem hiding this comment.
Restore leaked globals before sharing test workers
With isolate: false, test files assigned to the same worker reuse its global state, but several included unit tests do not clean up their mutations. For example, src/api/lib/file-download.test.ts:38-43 replaces global fetch in every test without calling vi.unstubAllGlobals(), so whichever file follows it inherits upstreamFetch and becomes order-dependent. Keep isolation enabled, add reliable per-file cleanup, or move every such test into ISOLATED.
AGENTS.md reference: AGENTS.md:L120-L121
Useful? React with 👍 / 👎.
acquireContentFieldLock moved from the deprecated `where` to `setWhere`, which Drizzle renders the same way. The in-memory database only read `where`, so a held lock was overwritten and the 409 test got a 200. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015x559AHZ5rNsyvKusi5pVk
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 437ce8990d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| beforeAll(async () => { | ||
| createPackage(); | ||
| result = await build(); | ||
| }); |
There was a problem hiding this comment.
Preserve the build's 60-second timeout
On slower CI runners where the tsdown/typecheck build takes more than 10 seconds, this setup now fails before any assertions run: the former build tests explicitly allowed 60 seconds, but moving the build into beforeAll drops that allowance, and Vitest documents a 10-second default hook timeout. Pass the previous timeout as the hook's second argument or configure an equivalent hookTimeout for the integration project.
Useful? React with 👍 / 👎.
- Wrap router navigations and timer-driven updates in act, use Testing Library's waitFor, and let the live session's HTTP reads land inside act. - Give fakes what the code under test calls (a draft delete, a logger) and capture output a test deliberately triggers instead of printing it. - permission-matrix answers a handler failure past the permission check with a quiet 500. - ProcessGroup honours `capture`, so the package watch test keeps tsdown and tsc off the terminal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015x559AHZ5rNsyvKusi5pVk
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a80556a7a9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -1,3 +1,4 @@ | |||
| // @vitest-environment jsdom | |||
There was a problem hiding this comment.
Route
.test.tsx files through a DOM project
Changing the plugin's default environment to Node and restoring this test with a per-file pragma bypasses the repository's filename-based environment convention. Future .test.tsx files will silently run under Node unless every author remembers the same exception; configure a DOM project for the suffix and remove this pragma instead.
AGENTS.md reference: AGENTS.md:L132-L135
Useful? React with 👍 / 👎.
| await new Promise(resolve => { | ||
| setTimeout(resolve, 0); | ||
| }); |
There was a problem hiding this comment.
Replace the real timer with deterministic settling
Every mount() now depends on a real setTimeout, making these tests sensitive to event-loop timing; it can also hang subsequent cases if a prior fake-timer test fails before restoring real timers. Wait for an observable condition or explicitly advance fake timers rather than sleeping for a turn.
AGENTS.md reference: AGENTS.md:L132-L137
Useful? React with 👍 / 👎.
(happy-dom), integration and types projects. Node tests share one module
graph per worker instead of re-importing the server graph for every file.
// @vitest-environmentpragmas are gone.for its read-only assertions.
wrappers, constants or wiring of features already covered elsewhere.
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_015x559AHZ5rNsyvKusi5pVk