Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
test: fail client tests on React act(...) warnings (#2406)
[._.]/ Adam Eivye5de1b430aba
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 5dd9bd7d0b..f09ee1b4c7 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -59,7 +59,7 @@## Fixed-- **The client test suite no longer floods CI logs with ~100 React `act(...)` warnings.** Twelve test files rendered components whose mount effects fetch data through pre-resolved mock promises and never settled them, so the `.then(setState)` microtasks landed outside `act` — invisible locally (vitest hides console output from passing tests) but printed in full by the CI reporter, burying real failures, and marking exactly the unsettled-async pattern behind our known CI test flakes. Each affected file now drains those updates inside act via a small settle-after-render helper (`await act(async () => {})`), with no assertion changes; tests that deliberately assert an in-flight pending state settle at the end instead. Promoting this to an enforced zero-warning gate in `src/test/setup.js` is tracked in #2406.+- **The client test suite no longer floods CI logs with ~100 React `act(...)` warnings.** Twelve test files rendered components whose mount effects fetch data through pre-resolved mock promises and never settled them, so the `.then(setState)` microtasks landed outside `act` — invisible locally (vitest hides console output from passing tests) but printed in full by the CI reporter, burying real failures, and marking exactly the unsettled-async pattern behind our known CI test flakes. Each affected file now drains those updates inside act via a small settle-after-render helper (`await act(async () => {})`), with no assertion changes; tests that deliberately assert an in-flight pending state settle at the end instead. And so it can't creep back, the shared test setup now enforces it (#2406): any test that triggers an act warning fails with a message naming the offending component and pointing at the settle idiom.- **CoS tasks with Review Loop turned off now explicitly disable saved external-review defaults when opening a PR.** Their completion prompt passes `--review-with none`, so an inherited Copilot (or other reviewer) default cannot launch a review that was not requested.diff --git a/client/src/test/setup.js b/client/src/test/setup.jsindex d5d057653c..1d45df82db 100644--- a/client/src/test/setup.js+++ b/client/src/test/setup.js@@ -7,10 +7,36 @@ import { installTestStorage } from './storagePolyfill.js';// of how jsdom exposes Storage in this environment. See storagePolyfill.js / #1438.installTestStorage();+// Fail any test that triggers React's "not wrapped in act(...)" warning (#2406).+// These mark unsettled async state updates — usually a mount-effect fetch whose+// mocked promise resolves after the sync test body — which vitest hides locally+// for passing tests but which flood CI logs and are the mechanism behind+// timing-dependent CI flakes. Fix by settling inside act after render:+// await act(async () => {});+// (see renderConfig in src/components/meatspace/post/PostDrillConfig.test.jsx).+// Tests that assert an in-flight pending state should settle at the END instead.+const actWarnings = [];+const originalConsoleError = console.error;+console.error = (...args) => {+ originalConsoleError(...args);+ if (typeof args[0] === 'string' && args[0].includes('not wrapped in act')) {+ actWarnings.push(String(args[1] ?? 'unknown component'));+ }+};+afterEach(() => {cleanup();// Reset storage between tests so a file that forgets its own `clear()` can't leak// state into the next — reinforces the isolation the polyfill restores.globalThis.localStorage?.clear();globalThis.sessionStorage?.clear();+ if (actWarnings.length > 0) {+ const components = [...new Set(actWarnings)].join(', ');+ actWarnings.length = 0;+ throw new Error(+ `React state updated outside act(...) in: ${components}. ` ++ 'Settle pending mount/interaction promises inside the test — e.g. ' ++ '`await act(async () => {})` after render — see src/test/setup.js for the idiom.'+ );+ }});