mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-11 09:11:13 +00:00
test: refresh gateway talk and scope fixtures
This commit is contained in:
@@ -141,6 +141,7 @@ describe("resolveOpenAiCompatibleHttpOperatorScopes", () => {
|
||||
"operator.write",
|
||||
"operator.approvals",
|
||||
"operator.pairing",
|
||||
"operator.talk.secrets",
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { clearBundledPluginMetadataCache } from "../plugins/bundled-plugin-metadata.js";
|
||||
import { clearPluginDiscoveryCache } from "../plugins/discovery.js";
|
||||
import { clearPluginManifestRegistryCache } from "../plugins/manifest-registry.js";
|
||||
|
||||
const runChannelPluginStartupMaintenanceMock = vi.fn().mockResolvedValue(undefined);
|
||||
|
||||
@@ -16,9 +20,16 @@ import {
|
||||
installGatewayTestHooks({ scope: "suite" });
|
||||
|
||||
describe("gateway startup channel maintenance wiring", () => {
|
||||
let server: Awaited<ReturnType<typeof startGatewayServer>> | undefined;
|
||||
it("runs startup channel maintenance with the resolved startup config", async () => {
|
||||
const previousBundledPluginsDir = process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;
|
||||
const previousSkipChannels = process.env.OPENCLAW_SKIP_CHANNELS;
|
||||
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = path.resolve(process.cwd(), "extensions");
|
||||
process.env.OPENCLAW_SKIP_CHANNELS = "0";
|
||||
clearBundledPluginMetadataCache();
|
||||
clearPluginDiscoveryCache();
|
||||
clearPluginManifestRegistryCache();
|
||||
runChannelPluginStartupMaintenanceMock.mockClear();
|
||||
|
||||
beforeAll(async () => {
|
||||
testState.channelsConfig = {
|
||||
matrix: {
|
||||
homeserver: "https://matrix.example.org",
|
||||
@@ -26,29 +37,42 @@ describe("gateway startup channel maintenance wiring", () => {
|
||||
accessToken: "tok-123",
|
||||
},
|
||||
};
|
||||
server = await startGatewayServer(await getFreePort());
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await server?.close();
|
||||
});
|
||||
let server: Awaited<ReturnType<typeof startGatewayServer>> | undefined;
|
||||
try {
|
||||
server = await startGatewayServer(await getFreePort());
|
||||
|
||||
it("runs startup channel maintenance with the resolved startup config", () => {
|
||||
expect(runChannelPluginStartupMaintenanceMock).toHaveBeenCalledTimes(1);
|
||||
expect(runChannelPluginStartupMaintenanceMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
cfg: expect.objectContaining({
|
||||
channels: expect.objectContaining({
|
||||
matrix: expect.objectContaining({
|
||||
homeserver: "https://matrix.example.org",
|
||||
userId: "@bot:example.org",
|
||||
accessToken: "tok-123",
|
||||
expect(runChannelPluginStartupMaintenanceMock).toHaveBeenCalledTimes(1);
|
||||
expect(runChannelPluginStartupMaintenanceMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
cfg: expect.objectContaining({
|
||||
channels: expect.objectContaining({
|
||||
matrix: expect.objectContaining({
|
||||
homeserver: "https://matrix.example.org",
|
||||
userId: "@bot:example.org",
|
||||
accessToken: "tok-123",
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
env: process.env,
|
||||
log: expect.anything(),
|
||||
}),
|
||||
env: process.env,
|
||||
log: expect.anything(),
|
||||
}),
|
||||
);
|
||||
);
|
||||
} finally {
|
||||
await server?.close();
|
||||
if (previousBundledPluginsDir === undefined) {
|
||||
delete process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;
|
||||
} else {
|
||||
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = previousBundledPluginsDir;
|
||||
}
|
||||
if (previousSkipChannels === undefined) {
|
||||
delete process.env.OPENCLAW_SKIP_CHANNELS;
|
||||
} else {
|
||||
process.env.OPENCLAW_SKIP_CHANNELS = previousSkipChannels;
|
||||
}
|
||||
clearBundledPluginMetadataCache();
|
||||
clearPluginDiscoveryCache();
|
||||
clearPluginManifestRegistryCache();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -156,7 +156,7 @@ function expectElevenLabsTalkConfig(
|
||||
silenceTimeoutMs?: number;
|
||||
},
|
||||
) {
|
||||
expect(talk?.provider).toBe(expected.provider);
|
||||
expect(talk?.provider).toBe(expected.provider ?? "elevenlabs");
|
||||
expect(talk?.providers?.elevenlabs?.voiceId).toBe(expected.voiceId);
|
||||
expect(talk?.resolved?.provider).toBe("elevenlabs");
|
||||
expect(talk?.resolved?.config?.voiceId).toBe(expected.voiceId);
|
||||
|
||||
@@ -268,6 +268,9 @@ const createStubPluginRegistry = (): PluginRegistry => ({
|
||||
...(trimString(params.outputFormat) == null
|
||||
? {}
|
||||
: { outputFormat: trimString(params.outputFormat) }),
|
||||
...(asNumber(params.latencyTier) == null
|
||||
? {}
|
||||
: { latencyTier: asNumber(params.latencyTier) }),
|
||||
}),
|
||||
synthesize: async (req) => {
|
||||
const config = req.providerConfig as Record<string, unknown>;
|
||||
@@ -282,7 +285,12 @@ const createStubPluginRegistry = (): PluginRegistry => ({
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ text: req.text }),
|
||||
body: JSON.stringify({
|
||||
text: req.text,
|
||||
...(asNumber(overrides.latencyTier) == null
|
||||
? {}
|
||||
: { latency_optimization_level: asNumber(overrides.latencyTier) }),
|
||||
}),
|
||||
},
|
||||
"elevenlabs",
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user