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
fix: remove real-timer/real-disk flakes in two test suites
[._.]/ Adam Eivy89a641c4f1f3
diff --git a/client/src/lib/pitchDetect.test.js b/client/src/lib/pitchDetect.test.jsindex 97050e8e49..431c356afc 100644--- a/client/src/lib/pitchDetect.test.js+++ b/client/src/lib/pitchDetect.test.js@@ -360,15 +360,21 @@ describe('createPitchTracker — emit throttle', () => {getFloatTimeDomainData: (out) => { for (let i = 0; i < out.length; i++) out[i] = 0.5 * Math.sin((2 * Math.PI * A4 * i) / SAMPLE_RATE); },});+ // Fake timers (which also mock performance.now) make this deterministic:+ // advancing 120ms of virtual time always fires exactly 120 ticks on the+ // unthrottled tracker, no matter how loaded the machine running the suite+ // is. A real-timer wait here previously let CPU contention starve the+ // unthrottled setTimeout(intervalMs: 1) loop down to the same tick count+ // as the throttled one, flaking the inequality below.+ beforeEach(() => { vi.useFakeTimers(); });+ afterEach(() => { vi.useRealTimers(); });+it('throttles emits to ~updateHz for a steady tone (vs every frame unthrottled)', async () => {- // Real timers here: the throttle keys on wall-clock time (performance.now), so- // this asserts a robust inequality (throttled ≪ unthrottled) rather than an- // exact count.const unthrottled = [];const throttled = [];const t1 = createPitchTracker(steady(), { intervalMs: 1, onUpdate: (u) => unthrottled.push(u) });const t2 = createPitchTracker(steady(), { intervalMs: 1, updateHz: 12, onUpdate: (u) => throttled.push(u) });- await new Promise((r) => setTimeout(r, 120));+ await vi.advanceTimersByTimeAsync(120);t1.stop();t2.stop();// A steady note has no material change after acquisition, so the throttle capsdiff --git a/server/services/localLlm.test.js b/server/services/localLlm.test.jsindex b05116a18a..6523acbce7 100644--- a/server/services/localLlm.test.js+++ b/server/services/localLlm.test.js@@ -19,10 +19,15 @@ vi.mock('./localModelAssessmentStore.js', () => ({getMeasuredFits: async (backend) => measured[backend] || {},}));// Forces assessDownloadPreflight's verdict on its NEXT call only, then-// reverts to real behavior (real statfs) — so a two-model migrateBackend-// test can make model #1's preflight fail without also failing model #2's,-// and the other ~14 installModel/migrateBackend call sites in this file-// that never set `once` are unaffected.+// reverts to a fake-abundant statfs — so a two-model migrateBackend test can+// make model #1's preflight fail without also failing model #2's, and the+// other ~14 installModel/migrateBackend call sites in this file that never+// set `once` are unaffected. The statfs itself is faked (not real) so these+// tests never depend on how much free space the machine running them+// actually has — a real disk under a curated model's advertised size (e.g.+// the 16.5GB Qwen3.8-27B GGUF) would otherwise force every plain-install+// test into a false DISK_INSUFFICIENT.+const { ABUNDANT_STATFS } = vi.hoisted(() => ({ ABUNDANT_STATFS: async () => ({ bavail: 1024 ** 4, bsize: 1 }) }));const preflightOverride = vi.hoisted(() => ({ once: null, lastCall: null }));vi.mock('../lib/downloadPreflight.js', async (importOriginal) => {const actual = await importOriginal();@@ -30,7 +35,7 @@ vi.mock('../lib/downloadPreflight.js', async (importOriginal) => {...actual,assessDownloadPreflight: async (opts) => {preflightOverride.lastCall = opts;- const real = await actual.assessDownloadPreflight(opts);+ const real = await actual.assessDownloadPreflight({ ...opts, statfsImpl: ABUNDANT_STATFS });if (!preflightOverride.once) return real;const verdict = preflightOverride.once;preflightOverride.once = null;