test: trim duplicate runtime smoke work

This commit is contained in:
Peter Steinberger
2026-04-23 11:28:26 +01:00
parent 0da53b54a0
commit 158a0d4ab4
2 changed files with 10 additions and 49 deletions

View File

@@ -2,19 +2,18 @@ import { describe, expect, it } from "vitest";
import { runDirectImportSmoke } from "../../test/helpers/plugins/direct-smoke.js";
describe("irc bundled api seams", () => {
it("loads the narrow channel plugin api in direct smoke", async () => {
it("loads narrow public api modules in direct smoke", async () => {
const stdout = await runDirectImportSmoke(
'const mod = await import("./extensions/irc/channel-plugin-api.ts"); process.stdout.write(JSON.stringify({keys:Object.keys(mod).sort(), id: mod.ircPlugin.id}));',
`const channel = await import("./extensions/irc/channel-plugin-api.ts");
const runtime = await import("./extensions/irc/runtime-api.ts");
process.stdout.write(JSON.stringify({
channel: { keys: Object.keys(channel).sort(), id: channel.ircPlugin.id },
runtime: { keys: Object.keys(runtime).sort(), type: typeof runtime.setIrcRuntime },
}));`,
);
expect(stdout).toBe('{"keys":["ircPlugin"],"id":"irc"}');
}, 45_000);
it("loads the narrow runtime api in direct smoke", async () => {
const stdout = await runDirectImportSmoke(
'const mod = await import("./extensions/irc/runtime-api.ts"); process.stdout.write(JSON.stringify({keys:Object.keys(mod).sort(), type: typeof mod.setIrcRuntime}));',
expect(stdout).toBe(
'{"channel":{"keys":["ircPlugin"],"id":"irc"},"runtime":{"keys":["setIrcRuntime"],"type":"function"}}',
);
expect(stdout).toBe('{"keys":["setIrcRuntime"],"type":"function"}');
}, 45_000);
});

View File

@@ -1,44 +1,6 @@
import { beforeAll, describe, expect, it, vi } from "vitest";
import type { PluginWebSearchProviderEntry } from "../plugins/types.js";
import { beforeAll, describe, expect, it } from "vitest";
import { asConfig, setupSecretsRuntimeSnapshotTestHooks } from "./runtime.test-support.ts";
const { resolvePluginWebSearchProvidersMock } = vi.hoisted(() => ({
resolvePluginWebSearchProvidersMock: vi.fn<() => PluginWebSearchProviderEntry[]>(() => [
{
pluginId: "google",
id: "gemini",
label: "gemini",
hint: "gemini test provider",
envVars: ["GEMINI_API_KEY"],
placeholder: "gemini-...",
signupUrl: "https://example.com/gemini",
autoDetectOrder: 20,
credentialPath: "plugins.entries.google.config.webSearch.apiKey",
inactiveSecretPaths: ["plugins.entries.google.config.webSearch.apiKey"],
getCredentialValue: (searchConfig) => searchConfig?.apiKey,
setCredentialValue: (searchConfigTarget, value) => {
searchConfigTarget.apiKey = value;
},
getConfiguredCredentialValue: (config) =>
(config?.plugins?.entries?.google?.config as { webSearch?: { apiKey?: unknown } })
?.webSearch?.apiKey,
setConfiguredCredentialValue: (configTarget, value) => {
const plugins = (configTarget.plugins ??= {}) as { entries?: Record<string, unknown> };
const entries = (plugins.entries ??= {});
const entry = (entries.google ??= {}) as { config?: Record<string, unknown> };
const config = (entry.config ??= {});
const webSearch = (config.webSearch ??= {}) as { apiKey?: unknown };
webSearch.apiKey = value;
},
createTool: () => null,
},
]),
}));
vi.mock("../plugins/web-search-providers.runtime.js", () => ({
resolvePluginWebSearchProviders: resolvePluginWebSearchProvidersMock,
}));
let activateSecretsRuntimeSnapshot: typeof import("./runtime.js").activateSecretsRuntimeSnapshot;
let getActiveRuntimeWebToolsMetadata: typeof import("./runtime.js").getActiveRuntimeWebToolsMetadata;
const { prepareSecretsRuntimeSnapshot } = setupSecretsRuntimeSnapshotTestHooks();