惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
Microsoft Azure Blog
Microsoft Azure Blog
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
小众软件
小众软件
F
Fortinet All Blogs
Microsoft Security Blog
Microsoft Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Google DeepMind News
Google DeepMind News
Jina AI
Jina AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
aimingoo的专栏
aimingoo的专栏
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
宝玉的分享
宝玉的分享
有赞技术团队
有赞技术团队
J
Java Code Geeks
WordPress大学
WordPress大学
The Cloudflare Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
test: tighten discord action handler assertions · opencla...
shakkernerd · 2026-05-11 · via Recent Commits to openclaw:main

@@ -21,6 +21,22 @@ function defaultActionOptions() {

2121

};

2222

}

232324+

function expectDiscordActionCall(params: {

25+

payload: unknown;

26+

cfg: OpenClawConfig;

27+

options?: unknown;

28+

}) {

29+

expect(handleDiscordActionMock).toHaveBeenCalledTimes(1);

30+

const [payload, cfg, options] = handleDiscordActionMock.mock.calls[0] ?? [];

31+

expect(payload).toEqual(params.payload);

32+

expect(cfg).toBe(params.cfg);

33+

if ("options" in params) {

34+

expect(options).toEqual(params.options);

35+

} else {

36+

expect(options).toBeUndefined();

37+

}

38+

}

39+2440

describe("handleDiscordMessageAction", () => {

2541

beforeEach(() => {

2642

handleDiscordActionMock.mockClear();

@@ -41,16 +57,20 @@ describe("handleDiscordMessageAction", () => {

4157

toolContext: { currentChannelProvider: "discord" },

4258

});

435944-

expect(handleDiscordActionMock).toHaveBeenCalledWith(

45-

expect.objectContaining({

60+

expectDiscordActionCall({

61+

payload: {

4662

action: "timeout",

63+

accountId: undefined,

4764

guildId: "guild-1",

4865

userId: "user-2",

4966

durationMinutes: 5,

67+

until: undefined,

68+

reason: undefined,

69+

deleteMessageDays: undefined,

5070

senderUserId: "trusted-sender-id",

51-

}),

71+

},

5272

cfg,

53-

);

73+

});

5474

});

55755676

it("falls back to toolContext.currentMessageId for reactions", async () => {

@@ -65,16 +85,18 @@ describe("handleDiscordMessageAction", () => {

6585

toolContext: { currentMessageId: "9001" },

6686

});

678768-

expect(handleDiscordActionMock).toHaveBeenCalledWith(

69-

expect.objectContaining({

88+

expectDiscordActionCall({

89+

payload: {

7090

action: "react",

91+

accountId: undefined,

7192

channelId: "123",

7293

messageId: "9001",

7394

emoji: "ok",

74-

}),

95+

remove: undefined,

96+

},

7597

cfg,

76-

defaultActionOptions(),

77-

);

98+

options: defaultActionOptions(),

99+

});

78100

});

7910180102

it("falls back to Discord toolContext.currentChannelId for reaction targets", async () => {

@@ -92,16 +114,18 @@ describe("handleDiscordMessageAction", () => {

92114

},

93115

});

9411695-

expect(handleDiscordActionMock).toHaveBeenCalledWith(

96-

expect.objectContaining({

117+

expectDiscordActionCall({

118+

payload: {

97119

action: "react",

120+

accountId: undefined,

98121

channelId: "user:U1",

99122

messageId: "9001",

100123

emoji: "ok",

101-

}),

124+

remove: undefined,

125+

},

102126

cfg,

103-

defaultActionOptions(),

104-

);

127+

options: defaultActionOptions(),

128+

});

105129

});

106130107131

it("falls back to Discord toolContext.currentChannelId for sends", async () => {

@@ -118,15 +142,25 @@ describe("handleDiscordMessageAction", () => {

118142

},

119143

});

120144121-

expect(handleDiscordActionMock).toHaveBeenCalledWith(

122-

expect.objectContaining({

145+

expectDiscordActionCall({

146+

payload: {

123147

action: "sendMessage",

148+

accountId: undefined,

124149

to: "channel:123",

125150

content: "hello",

126-

}),

151+

mediaUrl: undefined,

152+

filename: undefined,

153+

replyTo: undefined,

154+

components: undefined,

155+

embeds: undefined,

156+

asVoice: false,

157+

silent: false,

158+

__sessionKey: undefined,

159+

__agentId: undefined,

160+

},

127161

cfg,

128-

defaultActionOptions(),

129-

);

162+

options: defaultActionOptions(),

163+

});

130164

});

131165132166

it("maps upload-file to Discord sendMessage with media read context", async () => {

@@ -155,9 +189,10 @@ describe("handleDiscordMessageAction", () => {

155189

mediaReadFile,

156190

});

157191158-

expect(handleDiscordActionMock).toHaveBeenCalledWith(

159-

expect.objectContaining({

192+

expectDiscordActionCall({

193+

payload: {

160194

action: "sendMessage",

195+

accountId: undefined,

161196

to: "channel:123",

162197

content: "caption",

163198

mediaUrl: "/tmp/agent-root/image.png",

@@ -166,14 +201,14 @@ describe("handleDiscordMessageAction", () => {

166201

silent: true,

167202

__sessionKey: "session-1",

168203

__agentId: "agent-1",

169-

}),

204+

},

170205

cfg,

171-

{

206+

options: {

172207

mediaAccess,

173208

mediaLocalRoots: ["/tmp/agent-root"],

174209

mediaReadFile,

175210

},

176-

);

211+

});

177212

});

178213179214

it("falls back to Discord toolContext.currentChannelId for upload-file", async () => {

@@ -190,16 +225,22 @@ describe("handleDiscordMessageAction", () => {

190225

},

191226

});

192227193-

expect(handleDiscordActionMock).toHaveBeenCalledWith(

194-

expect.objectContaining({

228+

expectDiscordActionCall({

229+

payload: {

195230

action: "sendMessage",

231+

accountId: undefined,

196232

to: "channel:123",

197233

content: "",

198234

mediaUrl: "/tmp/agent-root/image.png",

199-

}),

235+

filename: undefined,

236+

replyTo: undefined,

237+

silent: false,

238+

__sessionKey: undefined,

239+

__agentId: undefined,

240+

},

200241

cfg,

201-

defaultActionOptions(),

202-

);

242+

options: defaultActionOptions(),

243+

});

203244

});

204245205246

it("requires a file path for upload-file", async () => {

@@ -232,20 +273,21 @@ describe("handleDiscordMessageAction", () => {

232273

mediaReadFile,

233274

});

234275235-

expect(handleDiscordActionMock).toHaveBeenCalledWith(

236-

expect.objectContaining({

276+

expectDiscordActionCall({

277+

payload: {

237278

action: "threadReply",

279+

accountId: undefined,

238280

channelId: "thread-123",

239281

content: "thread update",

240282

mediaUrl: "/tmp/agent-root/report.md",

241-

}),

283+

replyTo: undefined,

284+

},

242285

cfg,

243-

{

286+

options: {

244287

mediaLocalRoots: ["/tmp/agent-root"],

245-

mediaAccess: undefined,

246288

mediaReadFile,

247289

},

248-

);

290+

});

249291

});

250292251293

it("forwards top-level components on sends", async () => {

@@ -265,16 +307,25 @@ describe("handleDiscordMessageAction", () => {

265307

},

266308

});

267309268-

expect(handleDiscordActionMock).toHaveBeenCalledWith(

269-

expect.objectContaining({

310+

expectDiscordActionCall({

311+

payload: {

270312

action: "sendMessage",

313+

accountId: undefined,

271314

to: "channel:123",

272315

content: "hello",

316+

mediaUrl: undefined,

317+

filename: undefined,

318+

replyTo: undefined,

273319

components,

274-

}),

320+

embeds: undefined,

321+

asVoice: false,

322+

silent: false,

323+

__sessionKey: undefined,

324+

__agentId: undefined,

325+

},

275326

cfg,

276-

defaultActionOptions(),

277-

);

327+

options: defaultActionOptions(),

328+

});

278329

});

279330280331

it("does not use another provider's current target for Discord sends", async () => {