mirror of https://github.com/openclaw/openclaw.git
test: debrand policy and registry fixtures
This commit is contained in:
parent
12923eb612
commit
b95a81498f
|
|
@ -696,7 +696,7 @@ describe("AcpSessionManager", () => {
|
|||
id: "acpx",
|
||||
runtime: runtimeState.runtime,
|
||||
});
|
||||
const sessionKey = "agent:codex:acp:binding:discord:default:deadbeef";
|
||||
const sessionKey = "agent:codex:acp:binding:demo-binding:default:deadbeef";
|
||||
hoisted.readAcpSessionEntryMock.mockImplementation((paramsUnknown: unknown) => {
|
||||
const key = (paramsUnknown as { sessionKey?: string }).sessionKey ?? sessionKey;
|
||||
return {
|
||||
|
|
@ -739,7 +739,7 @@ describe("AcpSessionManager", () => {
|
|||
id: "acpx",
|
||||
runtime: runtimeState.runtime,
|
||||
});
|
||||
const sessionKey = "agent:codex:acp:binding:discord:default:oneshot";
|
||||
const sessionKey = "agent:codex:acp:binding:demo-binding:default:oneshot";
|
||||
hoisted.readAcpSessionEntryMock.mockImplementation((paramsUnknown: unknown) => {
|
||||
const key = (paramsUnknown as { sessionKey?: string }).sessionKey ?? sessionKey;
|
||||
return {
|
||||
|
|
@ -811,7 +811,7 @@ describe("AcpSessionManager", () => {
|
|||
id: "acpx",
|
||||
runtime: runtimeState.runtime,
|
||||
});
|
||||
const sessionKey = "agent:codex:acp:binding:discord:default:retry-fresh";
|
||||
const sessionKey = "agent:codex:acp:binding:demo-binding:default:retry-fresh";
|
||||
let currentMeta: SessionAcpMeta = {
|
||||
...readySessionMeta(),
|
||||
runtimeSessionName: sessionKey,
|
||||
|
|
|
|||
|
|
@ -49,9 +49,9 @@ describe("ensurePluginRegistryLoaded", () => {
|
|||
it("uses the auto-enabled config snapshot for configured channel scope", async () => {
|
||||
const baseConfig = {
|
||||
channels: {
|
||||
slack: {
|
||||
botToken: "xoxb-test",
|
||||
appToken: "xapp-test",
|
||||
"demo-chat": {
|
||||
botToken: "demo-bot-token",
|
||||
appToken: "demo-app-token",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
@ -59,7 +59,7 @@ describe("ensurePluginRegistryLoaded", () => {
|
|||
...baseConfig,
|
||||
plugins: {
|
||||
entries: {
|
||||
slack: {
|
||||
"demo-chat": {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
|
|
@ -69,7 +69,7 @@ describe("ensurePluginRegistryLoaded", () => {
|
|||
mocks.loadConfig.mockReturnValue(baseConfig);
|
||||
mocks.applyPluginAutoEnable.mockReturnValue({ config: autoEnabledConfig, changes: [] });
|
||||
mocks.loadPluginManifestRegistry.mockReturnValue({
|
||||
plugins: [{ id: "slack", channels: ["slack"] }],
|
||||
plugins: [{ id: "demo-chat", channels: ["demo-chat"] }],
|
||||
diagnostics: [],
|
||||
});
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ describe("ensurePluginRegistryLoaded", () => {
|
|||
expect(mocks.loadOpenClawPlugins).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
config: autoEnabledConfig,
|
||||
onlyPluginIds: ["slack"],
|
||||
onlyPluginIds: ["demo-chat"],
|
||||
throwOnLoadError: true,
|
||||
workspaceDir: "/tmp/workspace",
|
||||
}),
|
||||
|
|
@ -102,16 +102,16 @@ describe("ensurePluginRegistryLoaded", () => {
|
|||
it("reloads when escalating from configured-channels to channels", async () => {
|
||||
const config = {
|
||||
plugins: { enabled: true },
|
||||
channels: { telegram: { enabled: false } },
|
||||
channels: { "demo-channel-a": { enabled: false } },
|
||||
};
|
||||
|
||||
mocks.loadConfig.mockReturnValue(config);
|
||||
mocks.applyPluginAutoEnable.mockReturnValue({ config, changes: [] });
|
||||
mocks.loadPluginManifestRegistry.mockReturnValue({
|
||||
plugins: [
|
||||
{ id: "telegram", channels: ["telegram"] },
|
||||
{ id: "slack", channels: ["slack"] },
|
||||
{ id: "openai", channels: [] },
|
||||
{ id: "demo-channel-a", channels: ["demo-channel-a"] },
|
||||
{ id: "demo-channel-b", channels: ["demo-channel-b"] },
|
||||
{ id: "demo-provider", channels: [] },
|
||||
],
|
||||
diagnostics: [],
|
||||
});
|
||||
|
|
@ -122,8 +122,8 @@ describe("ensurePluginRegistryLoaded", () => {
|
|||
tools: [],
|
||||
})
|
||||
.mockReturnValue({
|
||||
plugins: [{ id: "telegram" }],
|
||||
channels: [{ plugin: { id: "telegram" } }],
|
||||
plugins: [{ id: "demo-channel-a" }],
|
||||
channels: [{ plugin: { id: "demo-channel-a" } }],
|
||||
tools: [],
|
||||
});
|
||||
|
||||
|
|
@ -140,7 +140,7 @@ describe("ensurePluginRegistryLoaded", () => {
|
|||
expect(mocks.loadOpenClawPlugins).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
expect.objectContaining({
|
||||
onlyPluginIds: ["telegram", "slack"],
|
||||
onlyPluginIds: ["demo-channel-a", "demo-channel-b"],
|
||||
throwOnLoadError: true,
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ describe("resolveSendPolicy", () => {
|
|||
rules: [
|
||||
{
|
||||
action: "deny",
|
||||
match: { channel: "discord", chatType: "group" },
|
||||
match: { channel: "demo-channel", chatType: "group" },
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
@ -38,10 +38,10 @@ describe("resolveSendPolicy", () => {
|
|||
const entry: SessionEntry = {
|
||||
sessionId: "s",
|
||||
updatedAt: 0,
|
||||
channel: "discord",
|
||||
channel: "demo-channel",
|
||||
chatType: "group",
|
||||
};
|
||||
expect(resolveSendPolicy({ cfg, entry, sessionKey: "discord:group:dev" })).toBe("deny");
|
||||
expect(resolveSendPolicy({ cfg, entry, sessionKey: "demo-channel:group:dev" })).toBe("deny");
|
||||
});
|
||||
|
||||
it("rule match by keyPrefix", () => {
|
||||
|
|
@ -61,11 +61,15 @@ describe("resolveSendPolicy", () => {
|
|||
session: {
|
||||
sendPolicy: {
|
||||
default: "allow",
|
||||
rules: [{ action: "deny", match: { rawKeyPrefix: "agent:main:discord:" } }],
|
||||
rules: [{ action: "deny", match: { rawKeyPrefix: "agent:main:demo-channel:" } }],
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
expect(resolveSendPolicy({ cfg, sessionKey: "agent:main:discord:group:dev" })).toBe("deny");
|
||||
expect(resolveSendPolicy({ cfg, sessionKey: "agent:main:slack:group:dev" })).toBe("allow");
|
||||
expect(resolveSendPolicy({ cfg, sessionKey: "agent:main:demo-channel:group:dev" })).toBe(
|
||||
"deny",
|
||||
);
|
||||
expect(resolveSendPolicy({ cfg, sessionKey: "agent:main:other-channel:group:dev" })).toBe(
|
||||
"allow",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -54,16 +54,16 @@ describe("speech provider registry", () => {
|
|||
...createEmptyPluginRegistry(),
|
||||
speechProviders: [
|
||||
{
|
||||
pluginId: "test-openai",
|
||||
pluginId: "test-demo-speech",
|
||||
source: "test",
|
||||
provider: createSpeechProvider("openai"),
|
||||
provider: createSpeechProvider("demo-speech"),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const providers = listSpeechProviders();
|
||||
|
||||
expect(providers.map((provider) => provider.id)).toEqual(["openai"]);
|
||||
expect(providers.map((provider) => provider.id)).toEqual(["demo-speech"]);
|
||||
expect(loadOpenClawPluginsMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ describe("speech provider registry", () => {
|
|||
|
||||
it("returns no providers when neither plugins nor active registry provide speech support", () => {
|
||||
expect(listSpeechProviders()).toEqual([]);
|
||||
expect(getSpeechProvider("openai")).toBeUndefined();
|
||||
expect(getSpeechProvider("demo-speech")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("canonicalizes the legacy edge alias to microsoft", () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue