mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:30:42 +00:00
test: trim duplicate runtime smoke work
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user