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

推荐订阅源

腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - Franky
博客园_首页
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
IT之家
IT之家
The Cloudflare Blog
V
Visual Studio Blog
罗磊的独立博客
T
Tailwind CSS Blog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
D
Docker
Last Week in AI
Last Week in AI
B
Blog RSS Feed
C
Check Point Blog
J
Java Code Geeks
The GitHub Blog
The GitHub Blog
有赞技术团队
有赞技术团队
博客园 - 聂微东
MongoDB | Blog
MongoDB | 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 matrix reply assertions · openclaw/openclaw...
steipete · 2026-05-11 · via Recent Commits to openclaw:main

@@ -22,6 +22,12 @@ vi.mock("../send.js", () => ({

2222

import { setMatrixRuntime } from "../../runtime.js";

2323

import { deliverMatrixReplies } from "./replies.js";

242425+

function sendOptions(index: number): Record<string, unknown> {

26+

const options = sendMessageMatrixMock.mock.calls[index]?.[2];

27+

expect(options).toBeDefined();

28+

return options as Record<string, unknown>;

29+

}

30+2531

describe("deliverMatrixReplies", () => {

2632

const cfg = { channels: { matrix: {} } };

2733

const loadConfigMock = vi.fn(() => ({}));

@@ -90,15 +96,12 @@ describe("deliverMatrixReplies", () => {

9096

});

91979298

expect(sendMessageMatrixMock).toHaveBeenCalledTimes(3);

93-

expect(sendMessageMatrixMock.mock.calls[0]?.[2]).toEqual(

94-

expect.objectContaining({ replyToId: "reply-1", threadId: undefined }),

95-

);

96-

expect(sendMessageMatrixMock.mock.calls[1]?.[2]).toEqual(

97-

expect.objectContaining({ replyToId: "reply-1", threadId: undefined }),

98-

);

99-

expect(sendMessageMatrixMock.mock.calls[2]?.[2]).toEqual(

100-

expect.objectContaining({ replyToId: undefined, threadId: undefined }),

101-

);

99+

expect(sendOptions(0).replyToId).toBe("reply-1");

100+

expect(sendOptions(0).threadId).toBeUndefined();

101+

expect(sendOptions(1).replyToId).toBe("reply-1");

102+

expect(sendOptions(1).threadId).toBeUndefined();

103+

expect(sendOptions(2).replyToId).toBeUndefined();

104+

expect(sendOptions(2).threadId).toBeUndefined();

102105

});

103106104107

it("keeps replyToId on every reply when replyToMode=all", async () => {

@@ -122,27 +125,17 @@ describe("deliverMatrixReplies", () => {

122125

});

123126124127

expect(sendMessageMatrixMock).toHaveBeenCalledTimes(3);

125-

expect(sendMessageMatrixMock.mock.calls[0]).toEqual([

126-

"room:2",

127-

"caption",

128-

expect.objectContaining({

129-

mediaUrl: "https://example.com/a.jpg",

130-

mediaLocalRoots: ["/tmp/openclaw-matrix-test"],

131-

replyToId: "reply-media",

132-

}),

133-

]);

134-

expect(sendMessageMatrixMock.mock.calls[1]).toEqual([

135-

"room:2",

136-

"",

137-

expect.objectContaining({

138-

mediaUrl: "https://example.com/b.jpg",

139-

mediaLocalRoots: ["/tmp/openclaw-matrix-test"],

140-

replyToId: "reply-media",

141-

}),

142-

]);

143-

expect(sendMessageMatrixMock.mock.calls[2]?.[2]).toEqual(

144-

expect.objectContaining({ replyToId: "reply-text" }),

145-

);

128+

expect(sendMessageMatrixMock.mock.calls[0]?.[0]).toBe("room:2");

129+

expect(sendMessageMatrixMock.mock.calls[0]?.[1]).toBe("caption");

130+

expect(sendOptions(0).mediaUrl).toBe("https://example.com/a.jpg");

131+

expect(sendOptions(0).mediaLocalRoots).toEqual(["/tmp/openclaw-matrix-test"]);

132+

expect(sendOptions(0).replyToId).toBe("reply-media");

133+

expect(sendMessageMatrixMock.mock.calls[1]?.[0]).toBe("room:2");

134+

expect(sendMessageMatrixMock.mock.calls[1]?.[1]).toBe("");

135+

expect(sendOptions(1).mediaUrl).toBe("https://example.com/b.jpg");

136+

expect(sendOptions(1).mediaLocalRoots).toEqual(["/tmp/openclaw-matrix-test"]);

137+

expect(sendOptions(1).replyToId).toBe("reply-media");

138+

expect(sendOptions(2).replyToId).toBe("reply-text");

146139

});

147140148141

it("suppresses replyToId when threadId is set", async () => {

@@ -166,12 +159,10 @@ describe("deliverMatrixReplies", () => {

166159

});

167160168161

expect(sendMessageMatrixMock).toHaveBeenCalledTimes(2);

169-

expect(sendMessageMatrixMock.mock.calls[0]?.[2]).toEqual(

170-

expect.objectContaining({ replyToId: undefined, threadId: "thread-77" }),

171-

);

172-

expect(sendMessageMatrixMock.mock.calls[1]?.[2]).toEqual(

173-

expect.objectContaining({ replyToId: undefined, threadId: "thread-77" }),

174-

);

162+

expect(sendOptions(0).replyToId).toBeUndefined();

163+

expect(sendOptions(0).threadId).toBe("thread-77");

164+

expect(sendOptions(1).replyToId).toBeUndefined();

165+

expect(sendOptions(1).threadId).toBe("thread-77");

175166

});

176167177168

it("suppresses reasoning-only text before Matrix sends", async () => {

@@ -190,11 +181,9 @@ describe("deliverMatrixReplies", () => {

190181

});

191182192183

expect(sendMessageMatrixMock).toHaveBeenCalledTimes(1);

193-

expect(sendMessageMatrixMock).toHaveBeenCalledWith(

194-

"room:5",

195-

"Visible answer",

196-

expect.objectContaining({ cfg }),

197-

);

184+

expect(sendMessageMatrixMock.mock.calls[0]?.[0]).toBe("room:5");

185+

expect(sendMessageMatrixMock.mock.calls[0]?.[1]).toBe("Visible answer");

186+

expect(sendOptions(0).cfg).toBe(cfg);

198187

});

199188200189

it("uses supplied cfg for chunking and send delivery without reloading runtime config", async () => {

@@ -230,15 +219,11 @@ describe("deliverMatrixReplies", () => {

230219

accountId: "ops",

231220

tableMode: "code",

232221

});

233-

expect(sendMessageMatrixMock).toHaveBeenCalledWith(

234-

"room:4",

235-

"hello",

236-

expect.objectContaining({

237-

cfg: explicitCfg,

238-

accountId: "ops",

239-

replyToId: "reply-1",

240-

}),

241-

);

222+

expect(sendMessageMatrixMock.mock.calls[0]?.[0]).toBe("room:4");

223+

expect(sendMessageMatrixMock.mock.calls[0]?.[1]).toBe("hello");

224+

expect(sendOptions(0).cfg).toBe(explicitCfg);

225+

expect(sendOptions(0).accountId).toBe("ops");

226+

expect(sendOptions(0).replyToId).toBe("reply-1");

242227

});

243228244229

it("passes raw media captions through to sendMessageMatrix without pre-converting them", async () => {

@@ -254,12 +239,8 @@ describe("deliverMatrixReplies", () => {

254239

replyToMode: "off",

255240

});

256241257-

expect(sendMessageMatrixMock).toHaveBeenCalledWith(

258-

"room:6",

259-

"caption",

260-

expect.objectContaining({

261-

mediaUrl: "https://example.com/a.jpg",

262-

}),

263-

);

242+

expect(sendMessageMatrixMock.mock.calls[0]?.[0]).toBe("room:6");

243+

expect(sendMessageMatrixMock.mock.calls[0]?.[1]).toBe("caption");

244+

expect(sendOptions(0).mediaUrl).toBe("https://example.com/a.jpg");

264245

});

265246

});