mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 05:30:21 +00:00
test: harden package-root mocks after setup slimming
This commit is contained in:
@@ -48,10 +48,14 @@ vi.mock("../infra/update-runner.js", () => ({
|
||||
runGatewayUpdate: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("../infra/openclaw-root.js", () => ({
|
||||
resolveOpenClawPackageRoot: vi.fn(),
|
||||
resolveOpenClawPackageRootSync: vi.fn(() => process.cwd()),
|
||||
}));
|
||||
vi.mock("../infra/openclaw-root.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("../infra/openclaw-root.js")>();
|
||||
return {
|
||||
...actual,
|
||||
resolveOpenClawPackageRoot: vi.fn(),
|
||||
resolveOpenClawPackageRootSync: vi.fn(() => process.cwd()),
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("../config/config.js", () => ({
|
||||
readConfigFileSnapshot: vi.fn(),
|
||||
|
||||
@@ -448,10 +448,14 @@ vi.mock("../gateway/session-utils.js", async (importOriginal) => {
|
||||
...actual,
|
||||
};
|
||||
});
|
||||
vi.mock("../infra/openclaw-root.js", () => ({
|
||||
resolveOpenClawPackageRoot: vi.fn().mockResolvedValue("/tmp/openclaw"),
|
||||
resolveOpenClawPackageRootSync: vi.fn(() => "/tmp/openclaw"),
|
||||
}));
|
||||
vi.mock("../infra/openclaw-root.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("../infra/openclaw-root.js")>();
|
||||
return {
|
||||
...actual,
|
||||
resolveOpenClawPackageRoot: vi.fn().mockResolvedValue("/tmp/openclaw"),
|
||||
resolveOpenClawPackageRootSync: vi.fn(() => "/tmp/openclaw"),
|
||||
};
|
||||
});
|
||||
vi.mock("../infra/os-summary.js", () => ({
|
||||
resolveOsSummary: () => ({
|
||||
platform: "darwin",
|
||||
|
||||
@@ -32,9 +32,13 @@ vi.mock("../../config/sessions.js", () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
vi.mock("../../infra/openclaw-root.js", () => ({
|
||||
resolveOpenClawPackageRoot: async () => "/tmp/openclaw",
|
||||
}));
|
||||
vi.mock("../../infra/openclaw-root.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("../../infra/openclaw-root.js")>();
|
||||
return {
|
||||
...actual,
|
||||
resolveOpenClawPackageRoot: async () => "/tmp/openclaw",
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("../../infra/restart-sentinel.js", async (importOriginal) => {
|
||||
const actual = await importOriginal();
|
||||
|
||||
@@ -5,9 +5,13 @@ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi }
|
||||
import { captureEnv } from "../test-utils/env.js";
|
||||
import type { UpdateCheckResult } from "./update-check.js";
|
||||
|
||||
vi.mock("./openclaw-root.js", () => ({
|
||||
resolveOpenClawPackageRoot: vi.fn(),
|
||||
}));
|
||||
vi.mock("./openclaw-root.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("./openclaw-root.js")>();
|
||||
return {
|
||||
...actual,
|
||||
resolveOpenClawPackageRoot: vi.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("./update-check.js", async () => {
|
||||
const parse = (value: string) => value.split(".").map((part) => Number.parseInt(part, 10));
|
||||
|
||||
@@ -270,6 +270,11 @@ function installDefaultPluginRegistry(): void {
|
||||
setActivePluginRegistry(resolveDefaultPluginRegistryProxy());
|
||||
}
|
||||
|
||||
// Some suites import channel/plugin consumers at module top level, before
|
||||
// Vitest runs hooks. Seed the lazy registry during setup module evaluation so
|
||||
// import-time lookups still see the default test registry.
|
||||
installDefaultPluginRegistry();
|
||||
|
||||
beforeAll(() => {
|
||||
installDefaultPluginRegistry();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user