mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-17 04:01:05 +00:00
Tests: fix gateway reconnect and mocks
This commit is contained in:
@@ -12,6 +12,7 @@ import type { DoctorRepairMode } from "./doctor-repair-mode.js";
|
||||
const resolvePluginProvidersMock = vi.fn<() => ProviderPlugin[]>(() => []);
|
||||
|
||||
vi.mock("../plugins/providers.runtime.js", () => ({
|
||||
isPluginProvidersLoadInFlight: () => false,
|
||||
resolvePluginProviders: () => resolvePluginProvidersMock(),
|
||||
}));
|
||||
|
||||
|
||||
@@ -8,10 +8,8 @@ const mockLoadPluginManifestRegistry = vi.hoisted(() => vi.fn());
|
||||
let readBestEffortRuntimeConfigSchema: typeof import("./runtime-schema.js").readBestEffortRuntimeConfigSchema;
|
||||
let loadGatewayRuntimeConfigSchema: typeof import("./runtime-schema.js").loadGatewayRuntimeConfigSchema;
|
||||
|
||||
vi.mock("./config.js", async () => {
|
||||
const actual = await vi.importActual<typeof import("./config.js")>("./config.js");
|
||||
vi.mock("./config.js", () => {
|
||||
return {
|
||||
...actual,
|
||||
loadConfig: () => mockLoadConfig(),
|
||||
readConfigFileSnapshot: () => mockReadConfigFileSnapshot(),
|
||||
};
|
||||
|
||||
@@ -267,6 +267,9 @@ export class GatewayClient {
|
||||
const ws = new WebSocket(url, wsOptions as ClientOptions);
|
||||
this.ws = ws;
|
||||
this.socketOpened = false;
|
||||
this.connectNonce = null;
|
||||
this.connectSent = false;
|
||||
this.clearConnectChallengeTimeout();
|
||||
|
||||
ws.on("open", () => {
|
||||
this.socketOpened = true;
|
||||
|
||||
@@ -96,6 +96,7 @@ describe("plugin-sdk exports", () => {
|
||||
it("keeps the root runtime surface intentionally small", async () => {
|
||||
const runtimeExports = await readIndexRuntimeExports();
|
||||
expect([...runtimeExports].toSorted()).toEqual([
|
||||
"buildMemorySystemPromptAddition",
|
||||
"delegateCompactionToRuntime",
|
||||
"emptyPluginConfigSchema",
|
||||
"onDiagnosticEvent",
|
||||
|
||||
@@ -31,6 +31,7 @@ function getBundledChannelDirName(channelId: string): string | undefined {
|
||||
bundledChannelDirNameByChannelId = new Map(
|
||||
loadPluginManifestRegistry({})
|
||||
.plugins.filter((entry) => entry.origin === "bundled")
|
||||
.filter((entry) => typeof entry.rootDir === "string" && entry.rootDir.trim().length > 0)
|
||||
.flatMap((entry) =>
|
||||
entry.channels.map(
|
||||
(candidateChannelId) =>
|
||||
|
||||
Reference in New Issue
Block a user