mirror of https://github.com/openclaw/openclaw.git
fix(ci): align loader and channel test expectations
This commit is contained in:
parent
54479220f5
commit
d9e59f7329
|
|
@ -11,7 +11,10 @@ import {
|
|||
resetDiscordComponentRuntimeMocks,
|
||||
upsertPairingRequestMock,
|
||||
} 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";
|
||||
|
||||
describe("agent components", () => {
|
||||
|
|
@ -30,6 +33,30 @@ describe("agent components", () => {
|
|||
|
||||
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 reply = 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.",
|
||||
ephemeral: true,
|
||||
});
|
||||
expect(peekSystemEvents(defaultGroupDmSessionKey)).toEqual([]);
|
||||
expect(peekSystemEvents(defaultDmSessionKey)).toEqual([]);
|
||||
expect(peekSystemEvents(resolvedDefaultGroupDmSessionKey())).toEqual([]);
|
||||
expect(peekSystemEvents(resolvedDefaultDmSessionKey())).toEqual([]);
|
||||
expect(readAllowFromStoreMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
|
@ -204,10 +231,10 @@ describe("agent components", () => {
|
|||
|
||||
expect(defer).not.toHaveBeenCalled();
|
||||
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
||||
expect(peekSystemEvents(defaultGroupDmSessionKey)).toEqual([
|
||||
expect(peekSystemEvents(resolvedDefaultGroupDmSessionKey())).toEqual([
|
||||
"[Discord component: hello clicked by Alice#1234 (123456789)]",
|
||||
]);
|
||||
expect(peekSystemEvents(defaultDmSessionKey)).toEqual([]);
|
||||
expect(peekSystemEvents(resolvedDefaultDmSessionKey())).toEqual([]);
|
||||
expect(readAllowFromStoreMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
|
@ -224,7 +251,7 @@ describe("agent components", () => {
|
|||
|
||||
expect(defer).not.toHaveBeenCalled();
|
||||
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
||||
expect(peekSystemEvents(defaultDmSessionKey)).toEqual([
|
||||
expect(peekSystemEvents(resolvedDefaultDmSessionKey())).toEqual([
|
||||
"[Discord component: hello clicked by Alice#1234 (123456789)]",
|
||||
]);
|
||||
expect(upsertPairingRequestMock).not.toHaveBeenCalled();
|
||||
|
|
@ -244,7 +271,7 @@ describe("agent components", () => {
|
|||
|
||||
expect(defer).not.toHaveBeenCalled();
|
||||
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
||||
expect(peekSystemEvents(defaultDmSessionKey)).toEqual([
|
||||
expect(peekSystemEvents(resolvedDefaultDmSessionKey())).toEqual([
|
||||
"[Discord component: hello clicked by Alice#1234 (123456789)]",
|
||||
]);
|
||||
expect(readAllowFromStoreMock).not.toHaveBeenCalled();
|
||||
|
|
@ -266,7 +293,7 @@ describe("agent components", () => {
|
|||
content: "DM interactions are disabled.",
|
||||
ephemeral: true,
|
||||
});
|
||||
expect(peekSystemEvents(defaultDmSessionKey)).toEqual([]);
|
||||
expect(peekSystemEvents(resolvedDefaultDmSessionKey())).toEqual([]);
|
||||
expect(readAllowFromStoreMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
|
@ -284,7 +311,7 @@ describe("agent components", () => {
|
|||
|
||||
expect(defer).not.toHaveBeenCalled();
|
||||
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)]",
|
||||
]);
|
||||
expect(readAllowFromStoreMock).not.toHaveBeenCalled();
|
||||
|
|
@ -303,7 +330,7 @@ describe("agent components", () => {
|
|||
|
||||
expect(defer).not.toHaveBeenCalled();
|
||||
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
||||
expect(peekSystemEvents(defaultDmSessionKey)).toEqual([
|
||||
expect(peekSystemEvents(resolvedDefaultDmSessionKey())).toEqual([
|
||||
"[Discord component: hello_cid clicked by Alice#1234 (123456789)]",
|
||||
]);
|
||||
expect(readAllowFromStoreMock).not.toHaveBeenCalled();
|
||||
|
|
@ -322,7 +349,7 @@ describe("agent components", () => {
|
|||
|
||||
expect(defer).not.toHaveBeenCalled();
|
||||
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
||||
expect(peekSystemEvents(defaultDmSessionKey)).toEqual([
|
||||
expect(peekSystemEvents(resolvedDefaultDmSessionKey())).toEqual([
|
||||
"[Discord component: hello%2G clicked by Alice#1234 (123456789)]",
|
||||
]);
|
||||
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 { createPluginSetupWizardStatus } from "../../../test/helpers/plugins/setup-wizard.js";
|
||||
import { signalPlugin } from "./channel.js";
|
||||
|
|
@ -275,7 +276,7 @@ describe("signal setup parsing", () => {
|
|||
});
|
||||
|
||||
it("uses configured defaultAccount for omitted DM policy account context", () => {
|
||||
const cfg = {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: {
|
||||
signal: {
|
||||
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: {
|
||||
channels: {
|
||||
telegram: {
|
||||
|
|
@ -744,8 +744,8 @@ describe("loadOpenClawPlugins", () => {
|
|||
} satisfies PluginLoadConfig,
|
||||
assert: (registry: ReturnType<typeof loadOpenClawPlugins>) => {
|
||||
const telegram = registry.plugins.find((entry) => entry.id === "telegram");
|
||||
expect(telegram?.status).toBe("disabled");
|
||||
expect(telegram?.error).toBe("not in allowlist");
|
||||
expect(telegram?.status).toBe("loaded");
|
||||
expect(telegram?.error).toBeUndefined();
|
||||
expect(telegram?.explicitlyEnabled).toBe(true);
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue