mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 22:04:30 +00:00
refactor(slack): reuse shared prepare test scaffolding
This commit is contained in:
@@ -7,12 +7,11 @@ import { expectInboundContextContract } from "../../../../test/helpers/inbound-c
|
|||||||
import type { OpenClawConfig } from "../../../config/config.js";
|
import type { OpenClawConfig } from "../../../config/config.js";
|
||||||
import { resolveAgentRoute } from "../../../routing/resolve-route.js";
|
import { resolveAgentRoute } from "../../../routing/resolve-route.js";
|
||||||
import { resolveThreadSessionKeys } from "../../../routing/session-key.js";
|
import { resolveThreadSessionKeys } from "../../../routing/session-key.js";
|
||||||
import type { RuntimeEnv } from "../../../runtime.js";
|
|
||||||
import type { ResolvedSlackAccount } from "../../accounts.js";
|
import type { ResolvedSlackAccount } from "../../accounts.js";
|
||||||
import type { SlackMessageEvent } from "../../types.js";
|
import type { SlackMessageEvent } from "../../types.js";
|
||||||
import type { SlackMonitorContext } from "../context.js";
|
import type { SlackMonitorContext } from "../context.js";
|
||||||
import { createSlackMonitorContext } from "../context.js";
|
|
||||||
import { prepareSlackMessage } from "./prepare.js";
|
import { prepareSlackMessage } from "./prepare.js";
|
||||||
|
import { createInboundSlackTestContext, createSlackTestAccount } from "./prepare.test-helpers.js";
|
||||||
|
|
||||||
describe("slack prepareSlackMessage inbound contract", () => {
|
describe("slack prepareSlackMessage inbound contract", () => {
|
||||||
let fixtureRoot = "";
|
let fixtureRoot = "";
|
||||||
@@ -38,53 +37,7 @@ describe("slack prepareSlackMessage inbound contract", () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function createInboundSlackCtx(params: {
|
const createInboundSlackCtx = createInboundSlackTestContext;
|
||||||
cfg: OpenClawConfig;
|
|
||||||
appClient?: App["client"];
|
|
||||||
defaultRequireMention?: boolean;
|
|
||||||
replyToMode?: "off" | "all";
|
|
||||||
channelsConfig?: Record<string, { systemPrompt: string }>;
|
|
||||||
}) {
|
|
||||||
return createSlackMonitorContext({
|
|
||||||
cfg: params.cfg,
|
|
||||||
accountId: "default",
|
|
||||||
botToken: "token",
|
|
||||||
app: { client: params.appClient ?? {} } as App,
|
|
||||||
runtime: {} as RuntimeEnv,
|
|
||||||
botUserId: "B1",
|
|
||||||
teamId: "T1",
|
|
||||||
apiAppId: "A1",
|
|
||||||
historyLimit: 0,
|
|
||||||
sessionScope: "per-sender",
|
|
||||||
mainKey: "main",
|
|
||||||
dmEnabled: true,
|
|
||||||
dmPolicy: "open",
|
|
||||||
allowFrom: [],
|
|
||||||
allowNameMatching: false,
|
|
||||||
groupDmEnabled: true,
|
|
||||||
groupDmChannels: [],
|
|
||||||
defaultRequireMention: params.defaultRequireMention ?? true,
|
|
||||||
channelsConfig: params.channelsConfig,
|
|
||||||
groupPolicy: "open",
|
|
||||||
useAccessGroups: false,
|
|
||||||
reactionMode: "off",
|
|
||||||
reactionAllowlist: [],
|
|
||||||
replyToMode: params.replyToMode ?? "off",
|
|
||||||
threadHistoryScope: "thread",
|
|
||||||
threadInheritParent: false,
|
|
||||||
slashCommand: {
|
|
||||||
enabled: false,
|
|
||||||
name: "openclaw",
|
|
||||||
sessionPrefix: "slack:slash",
|
|
||||||
ephemeral: true,
|
|
||||||
},
|
|
||||||
textLimit: 4000,
|
|
||||||
ackReactionScope: "group-mentions",
|
|
||||||
typingReaction: "",
|
|
||||||
mediaMaxBytes: 1024,
|
|
||||||
removeAckAfterReply: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function createDefaultSlackCtx() {
|
function createDefaultSlackCtx() {
|
||||||
const slackCtx = createInboundSlackCtx({
|
const slackCtx = createInboundSlackCtx({
|
||||||
@@ -115,19 +68,7 @@ describe("slack prepareSlackMessage inbound contract", () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createSlackAccount(config: ResolvedSlackAccount["config"] = {}): ResolvedSlackAccount {
|
const createSlackAccount = createSlackTestAccount;
|
||||||
return {
|
|
||||||
accountId: "default",
|
|
||||||
enabled: true,
|
|
||||||
botTokenSource: "config",
|
|
||||||
appTokenSource: "config",
|
|
||||||
userTokenSource: "none",
|
|
||||||
config,
|
|
||||||
replyToMode: config.replyToMode,
|
|
||||||
replyToModeByChatType: config.replyToModeByChatType,
|
|
||||||
dm: config.dm,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function createSlackMessage(overrides: Partial<SlackMessageEvent>): SlackMessageEvent {
|
function createSlackMessage(overrides: Partial<SlackMessageEvent>): SlackMessageEvent {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user