From 49a49f837a46b9d7fcd3dcc2d5ad21c368e83fd9 Mon Sep 17 00:00:00 2001 From: Naiyuan Qing <145280634+NevilleQingNY@users.noreply.github.com> Date: Tue, 14 Jul 2026 16:56:13 +0800 Subject: [PATCH] test(desktop): stabilize updater preference test against slow-disk race MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "skips startup and periodic checks when automatic updates are disabled" case advanced fake timers without awaiting the async preference load. On slow CI the in-flight readFile resolved after afterEach() removed the temp dir, defaulted enabled back to true, and fired a deferred background check into the next test's freshly-cleared shared mock — making "persists the automatic update preference and stops future background checks" flake with checkForUpdates called once. Await updater:get-preferences (which awaits preferencesReady) before advancing timers so the read settles against the existing file and no background work outlives the test. Test-only change; production behavior is unaffected. Co-Authored-By: Claude Opus 4.8 Co-authored-by: multica-agent --- apps/desktop/src/main/updater.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/desktop/src/main/updater.test.ts b/apps/desktop/src/main/updater.test.ts index e62ee9a09b..28221082fe 100644 --- a/apps/desktop/src/main/updater.test.ts +++ b/apps/desktop/src/main/updater.test.ts @@ -160,6 +160,12 @@ describe("setupAutoUpdater", () => { ); setupAutoUpdater(() => null); + // Let the async preference load settle before advancing timers; otherwise + // the in-flight readFile can resolve after afterEach() removes the temp + // dir, default back to enabled=true, and fire a background check into the + // next test's freshly-cleared mock (flake on slow CI). + await invokeIpc("updater:get-preferences"); + await vi.advanceTimersByTimeAsync(60 * 60 * 1000 + 5_000); expect(ctx.checkForUpdates).not.toHaveBeenCalled();