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

推荐订阅源

Y
Y Combinator Blog
IT之家
IT之家
博客园_首页
人人都是产品经理
人人都是产品经理
博客园 - Franky
I
InfoQ
Recent Announcements
Recent Announcements
P
Proofpoint News Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
GbyAI
GbyAI
大猫的无限游戏
大猫的无限游戏
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
月光博客
月光博客
Microsoft Security Blog
Microsoft Security Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
B
Blog RSS Feed
MongoDB | Blog
MongoDB | Blog
雷峰网
雷峰网
博客园 - 聂微东
N
Netflix TechBlog - Medium
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The GitHub Blog
The GitHub Blog
D
Docker

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 media failure assertions · openclaw/...
steipete · 2026-05-11 · via Recent Commits to openclaw:main

@@ -73,6 +73,35 @@ function createImageEvent(content: Record<string, unknown>) {

7373

});

7474

}

757576+

type MockWithCalls = {

77+

mock: { calls: unknown[][] };

78+

};

79+80+

function firstObjectArg(mock: MockWithCalls): Record<string, unknown> {

81+

const value = mock.mock.calls[0]?.[0];

82+

if (value === undefined || value === null || typeof value !== "object" || Array.isArray(value)) {

83+

throw new Error("expected first mock call object argument");

84+

}

85+

return value as Record<string, unknown>;

86+

}

87+88+

function objectArgAt(mock: MockWithCalls, index: number): Record<string, unknown> {

89+

const value = mock.mock.calls[0]?.[index];

90+

if (value === undefined || value === null || typeof value !== "object" || Array.isArray(value)) {

91+

throw new Error(`expected first mock call argument ${index} to be an object`);

92+

}

93+

return value as Record<string, unknown>;

94+

}

95+96+

function firstInboundContext(recordInboundSession: unknown): Record<string, unknown> {

97+

const payload = firstObjectArg(recordInboundSession as MockWithCalls);

98+

const ctx = payload.ctx;

99+

if (ctx === undefined || ctx === null || typeof ctx !== "object" || Array.isArray(ctx)) {

100+

throw new Error("expected inbound session ctx");

101+

}

102+

return ctx as Record<string, unknown>;

103+

}

104+76105

describe("createMatrixRoomMessageHandler media failures", () => {

77106

beforeEach(() => {

78107

downloadMatrixMediaMock.mockReset();

@@ -96,13 +125,10 @@ describe("createMatrixRoomMessageHandler media failures", () => {

96125

}),

97126

);

9812799-

expect(downloadMatrixMediaMock).toHaveBeenCalledWith(

100-

expect.objectContaining({

101-

mxcUrl: "mxc://example/image",

102-

maxBytes: 5 * 1024 * 1024,

103-

originalFilename: "Screenshot 2026-03-27.png",

104-

}),

105-

);

128+

const downloadOptions = firstObjectArg(downloadMatrixMediaMock);

129+

expect(downloadOptions.mxcUrl).toBe("mxc://example/image");

130+

expect(downloadOptions.maxBytes).toBe(5 * 1024 * 1024);

131+

expect(downloadOptions.originalFilename).toBe("Screenshot 2026-03-27.png");

106132

});

107133108134

it("prefers content.filename over body text when deriving originalFilename", async () => {

@@ -123,10 +149,8 @@ describe("createMatrixRoomMessageHandler media failures", () => {

123149

}),

124150

);

125151126-

expect(downloadMatrixMediaMock).toHaveBeenCalledWith(

127-

expect.objectContaining({

128-

originalFilename: "Screenshot 2026-03-27.png",

129-

}),

152+

expect(firstObjectArg(downloadMatrixMediaMock).originalFilename).toBe(

153+

"Screenshot 2026-03-27.png",

130154

);

131155

});

132156

@@ -143,23 +167,15 @@ describe("createMatrixRoomMessageHandler media failures", () => {

143167

}),

144168

);

145169146-

expect(recordInboundSession).toHaveBeenCalledWith(

147-

expect.objectContaining({

148-

ctx: expect.objectContaining({

149-

RawBody: "[matrix image attachment unavailable]",

150-

CommandBody: "[matrix image attachment unavailable]",

151-

MediaPath: undefined,

152-

}),

153-

}),

154-

);

155-

expect(logger.warn).toHaveBeenCalledWith(

156-

"matrix media download failed",

157-

expect.objectContaining({

158-

eventId: "$event1",

159-

msgtype: "m.image",

160-

encrypted: false,

161-

}),

162-

);

170+

const ctx = firstInboundContext(recordInboundSession);

171+

expect(ctx.RawBody).toBe("[matrix image attachment unavailable]");

172+

expect(ctx.CommandBody).toBe("[matrix image attachment unavailable]");

173+

expect(ctx.MediaPath).toBeUndefined();

174+

expect(logger.warn.mock.calls[0]?.[0]).toBe("matrix media download failed");

175+

const warningMetadata = objectArgAt(logger.warn, 1);

176+

expect(warningMetadata.eventId).toBe("$event1");

177+

expect(warningMetadata.msgtype).toBe("m.image");

178+

expect(warningMetadata.encrypted).toBe(false);

163179

expect(runtime.error).not.toHaveBeenCalled();

164180

});

165181

@@ -182,15 +198,10 @@ describe("createMatrixRoomMessageHandler media failures", () => {

182198

}),

183199

);

184200185-

expect(recordInboundSession).toHaveBeenCalledWith(

186-

expect.objectContaining({

187-

ctx: expect.objectContaining({

188-

RawBody: "[matrix image attachment unavailable]",

189-

CommandBody: "[matrix image attachment unavailable]",

190-

MediaPath: undefined,

191-

}),

192-

}),

193-

);

201+

const ctx = firstInboundContext(recordInboundSession);

202+

expect(ctx.RawBody).toBe("[matrix image attachment unavailable]");

203+

expect(ctx.CommandBody).toBe("[matrix image attachment unavailable]");

204+

expect(ctx.MediaPath).toBeUndefined();

194205

});

195206196207

it("preserves a real caption while marking the attachment unavailable", async () => {

@@ -207,13 +218,10 @@ describe("createMatrixRoomMessageHandler media failures", () => {

207218

}),

208219

);

209220210-

expect(recordInboundSession).toHaveBeenCalledWith(

211-

expect.objectContaining({

212-

ctx: expect.objectContaining({

213-

RawBody: "can you see this image?\n\n[matrix image attachment unavailable]",

214-

CommandBody: "can you see this image?\n\n[matrix image attachment unavailable]",

215-

}),

216-

}),

221+

const ctx = firstInboundContext(recordInboundSession);

222+

expect(ctx.RawBody).toBe("can you see this image?\n\n[matrix image attachment unavailable]");

223+

expect(ctx.CommandBody).toBe(

224+

"can you see this image?\n\n[matrix image attachment unavailable]",

217225

);

218226

});

219227

@@ -230,15 +238,10 @@ describe("createMatrixRoomMessageHandler media failures", () => {

230238

}),

231239

);

232240233-

expect(recordInboundSession).toHaveBeenCalledWith(

234-

expect.objectContaining({

235-

ctx: expect.objectContaining({

236-

RawBody: "[matrix image attachment too large]",

237-

CommandBody: "[matrix image attachment too large]",

238-

MediaPath: undefined,

239-

}),

240-

}),

241-

);

241+

const ctx = firstInboundContext(recordInboundSession);

242+

expect(ctx.RawBody).toBe("[matrix image attachment too large]");

243+

expect(ctx.CommandBody).toBe("[matrix image attachment too large]");

244+

expect(ctx.MediaPath).toBeUndefined();

242245

});

243246244247

it("preserves a real caption while marking the attachment too large on size limit error", async () => {

@@ -255,13 +258,8 @@ describe("createMatrixRoomMessageHandler media failures", () => {

255258

}),

256259

);

257260258-

expect(recordInboundSession).toHaveBeenCalledWith(

259-

expect.objectContaining({

260-

ctx: expect.objectContaining({

261-

RawBody: "check this out\n\n[matrix image attachment too large]",

262-

CommandBody: "check this out\n\n[matrix image attachment too large]",

263-

}),

264-

}),

265-

);

261+

const ctx = firstInboundContext(recordInboundSession);

262+

expect(ctx.RawBody).toBe("check this out\n\n[matrix image attachment too large]");

263+

expect(ctx.CommandBody).toBe("check this out\n\n[matrix image attachment too large]");

266264

});

267265

});