From e3d5fff264367512b95e4706d27be12f22c7b097 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 15 Feb 2026 01:24:20 +0000 Subject: [PATCH] perf(test): avoid importing update-check in startup suite --- src/infra/update-startup.test.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/infra/update-startup.test.ts b/src/infra/update-startup.test.ts index 64dcc25f95b..49732e12ce7 100644 --- a/src/infra/update-startup.test.ts +++ b/src/infra/update-startup.test.ts @@ -9,11 +9,23 @@ vi.mock("./openclaw-root.js", () => ({ })); vi.mock("./update-check.js", async () => { - const actual = await vi.importActual("./update-check.js"); + const parse = (value: string) => value.split(".").map((part) => Number.parseInt(part, 10)); + const compareSemverStrings = (a: string, b: string) => { + const left = parse(a); + const right = parse(b); + for (let idx = 0; idx < 3; idx += 1) { + const l = left[idx] ?? 0; + const r = right[idx] ?? 0; + if (l !== r) { + return l < r ? -1 : 1; + } + } + return 0; + }; + return { - ...actual, checkUpdateStatus: vi.fn(), - fetchNpmTagVersion: vi.fn(), + compareSemverStrings, resolveNpmChannelTag: vi.fn(), }; });