fix: state every test-gate timeout instead of inheriting a library default

Three of the six Vitest projects ran on Vitest's own testTimeout: 5000 and
five on its hookTimeout/teardownTimeout: 10000, and all 788 Testing Library
waits in the web unit project ran on asyncUtilTimeout: 1000. None of those
numbers was chosen here, and all of them were sized for an idle machine rather
than for three or four concurrent worktree sessions each running a full
local:gate on eight cores. #2292, #2278, #2250, #1942 and #1742 were each that
class, diagnosed one site at a time.

This is the complement of #1596, not a retreat from it: every fix that issue
produced stands, and no race is hidden here. What changes is that a correct,
deterministic test is no longer cut off by a budget nobody picked.

- vitest.shared.mts exports frozen TIMEOUTS / INTEGRATION_TIMEOUTS; all six
  projects spread one of them, clients/launcher importing the shared module for
  the first time to do so.
- Both web projects configure Testing Library's asyncUtilTimeout. The storybook
  one needs its own setup file, deliberately outside .storybook/ and free of
  setProjectAnnotations so the automatic preview-annotation provisioning
  (#1898) is untouched.
- 28 per-suite restatements of the integration project's own budget are gone,
  so raising the shared value now moves every site under it. The handful that
  genuinely differ — cross-process lock contention, a full OAuth round trip —
  keep their budget as a named constant that says why.
- AppRenderer's waitFor no longer asks for exactly its enclosing budget, which
  it could never win (#2292's shape); cli's e2e child timer drops below the
  project budget so the bound carrying the diagnostic is the one that fires.
- The transition auto-settle's slack term is named RAF_SLACK_MS and raised;
  the term derived from HEADER_ANIM_MS is untouched. The two answer to
  different things and must not be scaled as one number.
- The 19 Playwright budgets scattered across three web smokes become four
  named constants in scripts/lib/browser-timeouts.mjs.

scripts/verify-test-timeouts.mjs resolves each project through Vitest itself
and asserts the budgets, the asyncUtilTimeout sites, and that retry stays
unset. It was observed red against the pre-change config: unit/tui/launcher at
testTimeout 5000, five projects at hookTimeout 10000, both asyncUtilTimeout
sites unmet.

Closes #2323

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PsmUAZ6aLUAFqenjJKSSRp
Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
cliffhall 2026-09-12 08:32:34 -04:00
commit 58e53d5a92

View file

@ -14,7 +14,11 @@ import {
} from "./server/vite-base-config";
import { buildWebServerConfigFromEnv } from "./server/web-server-config";
import { createBrowserExternalizedBuiltinGate } from "./server/browser-externalized-builtin-gate";
import { vitestSharedPaths } from "../../vitest.shared.mts";
import {
INTEGRATION_TIMEOUTS,
TIMEOUTS,
vitestSharedPaths,
} from "../../vitest.shared.mts";
const dirname =
typeof __dirname !== "undefined"
? __dirname
@ -330,6 +334,12 @@ export default defineConfig(({ command }) => {
// `container.isConnected` self-checks are the real guard against a
// future regression.
sequence: { hooks: "stack" },
// Shared budgets (#2323). This is the largest test surface in the
// repo — 342 files — and every one of them ran on Vitest's own
// 5000ms until now. The single site that had been patched by hand
// (`App.test.tsx`'s three-modal sequence) named that default as its
// reason for existing.
...TIMEOUTS,
},
},
{
@ -349,9 +359,12 @@ export default defineConfig(({ command }) => {
include: [integrationGlob],
// Integration tests spawn real HTTP/stdio servers via test-servers/,
// bind sockets, run e2e OAuth flows, and exercise filesystem-backed
// storage. 30s matches the v1.5 core/vitest.config.ts.
testTimeout: 30000,
hookTimeout: 30000,
// storage. 30s matches the v1.5 core/vitest.config.ts. Now stated
// once in `vitest.shared.mts` (#2323) rather than here, together
// with the `teardownTimeout` that was left on the 10000ms default —
// teardown is where these suites unlink that filesystem-backed
// storage and reap the servers they spawned.
...INTEGRATION_TIMEOUTS,
// Inline the MCP SDK so vi.mock("@modelcontextprotocol/client")
// hooks the same transformed copy that source files import.
// Externalized node_modules are loaded via Node's loader and bypass
@ -384,7 +397,16 @@ export default defineConfig(({ command }) => {
// (#2292). A larger ceiling does not hide a defect here: a story
// that blows 15s has genuinely failed, and every assertion stays as
// strict as it was.
testTimeout: 15000,
// …which is the shared `TIMEOUTS.testTimeout` today (#2323): this
// project is where the value was first chosen, and the other five
// now follow it rather than restate it. The hook and teardown
// budgets come along with it, having been left on the defaults.
...TIMEOUTS,
// One `configure({ asyncUtilTimeout })` call, and deliberately not
// in `.storybook/` — see the file's own header for why that
// location and the absence of `setProjectAnnotations` are what keep
// the automatic preview-annotation provisioning below intact.
setupFiles: [path.join(dirname, "src/test/storybookSetup.ts")],
browser: {
enabled: true,
headless: true,
@ -395,12 +417,15 @@ export default defineConfig(({ command }) => {
},
],
},
// No `setupFiles`: since Storybook 10.3 `@storybook/addon-vitest`
// The `setupFiles` above is the project's only one, and it
// carries no preview annotations: since Storybook 10.3
// `@storybook/addon-vitest`
// provisions the preview annotations (`.storybook/preview.tsx` plus
// `@storybook/addon-a11y/preview`) itself, and *skips* doing so when
// it finds a setup file calling `setProjectAnnotations` — so the old
// `.storybook/vitest.setup.ts` was both redundant and actively
// opting out of the automatic path (#1898). A green suite doesn't
// it finds a setup file that is both inside `configDir` and calls
// `setProjectAnnotations` — so the old `.storybook/vitest.setup.ts`
// was both redundant and actively opting out of the automatic path
// (#1898). A green suite doesn't
// prove the automatic provisioning works (stories rendered without
// the Mantine decorator would very likely still pass), so
// `src/test/PreviewAnnotations.stories.tsx` asserts it directly.