Tests: fix gateway reconnect and mocks

This commit is contained in:
Peter Steinberger
2026-04-07 11:02:41 +01:00
parent 3fbb229d04
commit 56b0714004
5 changed files with 7 additions and 3 deletions

View File

@@ -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(),
}));

View File

@@ -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(),
};

View File

@@ -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;

View File

@@ -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",

View File

@@ -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) =>