mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 16:00:22 +00:00
fix(ci): align loader and channel test expectations
This commit is contained in:
@@ -11,7 +11,10 @@ import {
|
|||||||
resetDiscordComponentRuntimeMocks,
|
resetDiscordComponentRuntimeMocks,
|
||||||
upsertPairingRequestMock,
|
upsertPairingRequestMock,
|
||||||
} from "../test-support/component-runtime.js";
|
} from "../test-support/component-runtime.js";
|
||||||
import { resolveComponentInteractionContext } from "./agent-components-helpers.js";
|
import {
|
||||||
|
resolveAgentComponentRoute,
|
||||||
|
resolveComponentInteractionContext,
|
||||||
|
} from "./agent-components-helpers.js";
|
||||||
import { createAgentComponentButton, createAgentSelectMenu } from "./agent-components.js";
|
import { createAgentComponentButton, createAgentSelectMenu } from "./agent-components.js";
|
||||||
|
|
||||||
describe("agent components", () => {
|
describe("agent components", () => {
|
||||||
@@ -30,6 +33,30 @@ describe("agent components", () => {
|
|||||||
|
|
||||||
const createCfg = (): OpenClawConfig => ({}) as OpenClawConfig;
|
const createCfg = (): OpenClawConfig => ({}) as OpenClawConfig;
|
||||||
|
|
||||||
|
const resolvedDefaultDmSessionKey = () =>
|
||||||
|
resolveAgentComponentRoute({
|
||||||
|
ctx: { cfg: createCfg(), accountId: "default" },
|
||||||
|
rawGuildId: undefined,
|
||||||
|
memberRoleIds: [],
|
||||||
|
isDirectMessage: true,
|
||||||
|
isGroupDm: false,
|
||||||
|
userId: "123456789",
|
||||||
|
channelId: "dm-channel",
|
||||||
|
parentId: undefined,
|
||||||
|
}).sessionKey;
|
||||||
|
|
||||||
|
const resolvedDefaultGroupDmSessionKey = () =>
|
||||||
|
resolveAgentComponentRoute({
|
||||||
|
ctx: { cfg: createCfg(), accountId: "default" },
|
||||||
|
rawGuildId: undefined,
|
||||||
|
memberRoleIds: [],
|
||||||
|
isDirectMessage: false,
|
||||||
|
isGroupDm: true,
|
||||||
|
userId: "123456789",
|
||||||
|
channelId: "group-dm-channel",
|
||||||
|
parentId: undefined,
|
||||||
|
}).sessionKey;
|
||||||
|
|
||||||
const createBaseDmInteraction = (overrides: Record<string, unknown> = {}) => {
|
const createBaseDmInteraction = (overrides: Record<string, unknown> = {}) => {
|
||||||
const reply = vi.fn().mockResolvedValue(undefined);
|
const reply = vi.fn().mockResolvedValue(undefined);
|
||||||
const defer = vi.fn().mockResolvedValue(undefined);
|
const defer = vi.fn().mockResolvedValue(undefined);
|
||||||
@@ -181,8 +208,8 @@ describe("agent components", () => {
|
|||||||
content: "You are not authorized to use this button.",
|
content: "You are not authorized to use this button.",
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
expect(peekSystemEvents(defaultGroupDmSessionKey)).toEqual([]);
|
expect(peekSystemEvents(resolvedDefaultGroupDmSessionKey())).toEqual([]);
|
||||||
expect(peekSystemEvents(defaultDmSessionKey)).toEqual([]);
|
expect(peekSystemEvents(resolvedDefaultDmSessionKey())).toEqual([]);
|
||||||
expect(readAllowFromStoreMock).not.toHaveBeenCalled();
|
expect(readAllowFromStoreMock).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -204,10 +231,10 @@ describe("agent components", () => {
|
|||||||
|
|
||||||
expect(defer).not.toHaveBeenCalled();
|
expect(defer).not.toHaveBeenCalled();
|
||||||
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
||||||
expect(peekSystemEvents(defaultGroupDmSessionKey)).toEqual([
|
expect(peekSystemEvents(resolvedDefaultGroupDmSessionKey())).toEqual([
|
||||||
"[Discord component: hello clicked by Alice#1234 (123456789)]",
|
"[Discord component: hello clicked by Alice#1234 (123456789)]",
|
||||||
]);
|
]);
|
||||||
expect(peekSystemEvents(defaultDmSessionKey)).toEqual([]);
|
expect(peekSystemEvents(resolvedDefaultDmSessionKey())).toEqual([]);
|
||||||
expect(readAllowFromStoreMock).not.toHaveBeenCalled();
|
expect(readAllowFromStoreMock).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -224,7 +251,7 @@ describe("agent components", () => {
|
|||||||
|
|
||||||
expect(defer).not.toHaveBeenCalled();
|
expect(defer).not.toHaveBeenCalled();
|
||||||
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
||||||
expect(peekSystemEvents(defaultDmSessionKey)).toEqual([
|
expect(peekSystemEvents(resolvedDefaultDmSessionKey())).toEqual([
|
||||||
"[Discord component: hello clicked by Alice#1234 (123456789)]",
|
"[Discord component: hello clicked by Alice#1234 (123456789)]",
|
||||||
]);
|
]);
|
||||||
expect(upsertPairingRequestMock).not.toHaveBeenCalled();
|
expect(upsertPairingRequestMock).not.toHaveBeenCalled();
|
||||||
@@ -244,7 +271,7 @@ describe("agent components", () => {
|
|||||||
|
|
||||||
expect(defer).not.toHaveBeenCalled();
|
expect(defer).not.toHaveBeenCalled();
|
||||||
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
||||||
expect(peekSystemEvents(defaultDmSessionKey)).toEqual([
|
expect(peekSystemEvents(resolvedDefaultDmSessionKey())).toEqual([
|
||||||
"[Discord component: hello clicked by Alice#1234 (123456789)]",
|
"[Discord component: hello clicked by Alice#1234 (123456789)]",
|
||||||
]);
|
]);
|
||||||
expect(readAllowFromStoreMock).not.toHaveBeenCalled();
|
expect(readAllowFromStoreMock).not.toHaveBeenCalled();
|
||||||
@@ -266,7 +293,7 @@ describe("agent components", () => {
|
|||||||
content: "DM interactions are disabled.",
|
content: "DM interactions are disabled.",
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
expect(peekSystemEvents(defaultDmSessionKey)).toEqual([]);
|
expect(peekSystemEvents(resolvedDefaultDmSessionKey())).toEqual([]);
|
||||||
expect(readAllowFromStoreMock).not.toHaveBeenCalled();
|
expect(readAllowFromStoreMock).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -284,7 +311,7 @@ describe("agent components", () => {
|
|||||||
|
|
||||||
expect(defer).not.toHaveBeenCalled();
|
expect(defer).not.toHaveBeenCalled();
|
||||||
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
||||||
expect(peekSystemEvents(defaultDmSessionKey)).toEqual([
|
expect(peekSystemEvents(resolvedDefaultDmSessionKey())).toEqual([
|
||||||
"[Discord select menu: hello interacted by Alice#1234 (123456789) (selected: alpha)]",
|
"[Discord select menu: hello interacted by Alice#1234 (123456789) (selected: alpha)]",
|
||||||
]);
|
]);
|
||||||
expect(readAllowFromStoreMock).not.toHaveBeenCalled();
|
expect(readAllowFromStoreMock).not.toHaveBeenCalled();
|
||||||
@@ -303,7 +330,7 @@ describe("agent components", () => {
|
|||||||
|
|
||||||
expect(defer).not.toHaveBeenCalled();
|
expect(defer).not.toHaveBeenCalled();
|
||||||
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
||||||
expect(peekSystemEvents(defaultDmSessionKey)).toEqual([
|
expect(peekSystemEvents(resolvedDefaultDmSessionKey())).toEqual([
|
||||||
"[Discord component: hello_cid clicked by Alice#1234 (123456789)]",
|
"[Discord component: hello_cid clicked by Alice#1234 (123456789)]",
|
||||||
]);
|
]);
|
||||||
expect(readAllowFromStoreMock).not.toHaveBeenCalled();
|
expect(readAllowFromStoreMock).not.toHaveBeenCalled();
|
||||||
@@ -322,7 +349,7 @@ describe("agent components", () => {
|
|||||||
|
|
||||||
expect(defer).not.toHaveBeenCalled();
|
expect(defer).not.toHaveBeenCalled();
|
||||||
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
||||||
expect(peekSystemEvents(defaultDmSessionKey)).toEqual([
|
expect(peekSystemEvents(resolvedDefaultDmSessionKey())).toEqual([
|
||||||
"[Discord component: hello%2G clicked by Alice#1234 (123456789)]",
|
"[Discord component: hello%2G clicked by Alice#1234 (123456789)]",
|
||||||
]);
|
]);
|
||||||
expect(readAllowFromStoreMock).not.toHaveBeenCalled();
|
expect(readAllowFromStoreMock).not.toHaveBeenCalled();
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
|
||||||
import { describe, expect, it, vi } from "vitest";
|
import { describe, expect, it, vi } from "vitest";
|
||||||
import { createPluginSetupWizardStatus } from "../../../test/helpers/plugins/setup-wizard.js";
|
import { createPluginSetupWizardStatus } from "../../../test/helpers/plugins/setup-wizard.js";
|
||||||
import { signalPlugin } from "./channel.js";
|
import { signalPlugin } from "./channel.js";
|
||||||
@@ -275,7 +276,7 @@ describe("signal setup parsing", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("uses configured defaultAccount for omitted DM policy account context", () => {
|
it("uses configured defaultAccount for omitted DM policy account context", () => {
|
||||||
const cfg = {
|
const cfg: OpenClawConfig = {
|
||||||
channels: {
|
channels: {
|
||||||
signal: {
|
signal: {
|
||||||
defaultAccount: "work",
|
defaultAccount: "work",
|
||||||
|
|||||||
@@ -731,7 +731,7 @@ describe("loadOpenClawPlugins", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "keeps bundled channel plugins behind restrictive allowlists even when channels.<id>.enabled=true",
|
name: "lets explicit bundled channel enablement bypass restrictive allowlists",
|
||||||
config: {
|
config: {
|
||||||
channels: {
|
channels: {
|
||||||
telegram: {
|
telegram: {
|
||||||
@@ -744,8 +744,8 @@ describe("loadOpenClawPlugins", () => {
|
|||||||
} satisfies PluginLoadConfig,
|
} satisfies PluginLoadConfig,
|
||||||
assert: (registry: ReturnType<typeof loadOpenClawPlugins>) => {
|
assert: (registry: ReturnType<typeof loadOpenClawPlugins>) => {
|
||||||
const telegram = registry.plugins.find((entry) => entry.id === "telegram");
|
const telegram = registry.plugins.find((entry) => entry.id === "telegram");
|
||||||
expect(telegram?.status).toBe("disabled");
|
expect(telegram?.status).toBe("loaded");
|
||||||
expect(telegram?.error).toBe("not in allowlist");
|
expect(telegram?.error).toBeUndefined();
|
||||||
expect(telegram?.explicitlyEnabled).toBe(true);
|
expect(telegram?.explicitlyEnabled).toBe(true);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user