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

推荐订阅源

V
Visual Studio Blog
Y
Y Combinator Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Hugging Face - Blog
Hugging Face - Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Cloudflare Blog
L
LangChain Blog
美团技术团队
N
Netflix TechBlog - Medium
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog
博客园 - 司徒正美
爱范儿
爱范儿
D
DataBreaches.Net
月光博客
月光博客
U
Unit 42
B
Blog RSS Feed
Engineering at Meta
Engineering at Meta
Apple Machine Learning Research
Apple Machine Learning Research
Jina AI
Jina AI
MongoDB | Blog
MongoDB | Blog
腾讯CDC

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 account propagation assertions · ope...
steipete · 2026-05-11 · via Recent Commits to openclaw:main

@@ -14,6 +14,18 @@ const { matrixMessageActions } = await import("./actions.js");

14141515

const profileAction = "set-profile" as ChannelMessageActionContext["action"];

161617+

function matrixActionCall() {

18+

const call = mocks.handleMatrixAction.mock.calls[0];

19+

if (!call) {

20+

throw new Error("expected handleMatrixAction call");

21+

}

22+

return {

23+

input: call[0] as Record<string, unknown>,

24+

cfg: call[1],

25+

options: call[2],

26+

};

27+

}

28+1729

function createContext(

1830

overrides: Partial<ChannelMessageActionContext>,

1931

): ChannelMessageActionContext {

@@ -56,14 +68,11 @@ describe("matrixMessageActions account propagation", () => {

5668

}),

5769

);

587059-

expect(mocks.handleMatrixAction).toHaveBeenCalledWith(

60-

expect.objectContaining({

61-

action: "sendMessage",

62-

accountId: "ops",

63-

}),

64-

expect.any(Object),

65-

{ mediaLocalRoots: undefined },

66-

);

71+

const call = matrixActionCall();

72+

expect(call.input.action).toBe("sendMessage");

73+

expect(call.input.accountId).toBe("ops");

74+

expect(call.cfg).toBeTypeOf("object");

75+

expect(call.options).toEqual({ mediaLocalRoots: undefined });

6776

});

68776978

it("forwards accountId for permissions actions", async () => {

@@ -77,14 +86,11 @@ describe("matrixMessageActions account propagation", () => {

7786

}),

7887

);

798880-

expect(mocks.handleMatrixAction).toHaveBeenCalledWith(

81-

expect.objectContaining({

82-

action: "verificationList",

83-

accountId: "ops",

84-

}),

85-

expect.any(Object),

86-

{ mediaLocalRoots: undefined },

87-

);

89+

const call = matrixActionCall();

90+

expect(call.input.action).toBe("verificationList");

91+

expect(call.input.accountId).toBe("ops");

92+

expect(call.cfg).toBeTypeOf("object");

93+

expect(call.options).toEqual({ mediaLocalRoots: undefined });

8894

});

89959096

it("forwards accountId for self-profile updates", async () => {

@@ -100,21 +106,18 @@ describe("matrixMessageActions account propagation", () => {

100106

}),

101107

);

102108103-

expect(mocks.handleMatrixAction).toHaveBeenCalledWith(

104-

expect.objectContaining({

105-

action: "setProfile",

106-

accountId: "ops",

107-

displayName: "Ops Bot",

108-

avatarUrl: "mxc://example/avatar",

109-

}),

110-

expect.any(Object),

111-

{ mediaLocalRoots: undefined },

112-

);

109+

const call = matrixActionCall();

110+

expect(call.input.action).toBe("setProfile");

111+

expect(call.input.accountId).toBe("ops");

112+

expect(call.input.displayName).toBe("Ops Bot");

113+

expect(call.input.avatarUrl).toBe("mxc://example/avatar");

114+

expect(call.cfg).toBeTypeOf("object");

115+

expect(call.options).toEqual({ mediaLocalRoots: undefined });

113116

});

114117115118

it("rejects self-profile updates for non-owner callers", async () => {

116-

await expect(

117-

matrixMessageActions.handleAction?.(

119+

try {

120+

await matrixMessageActions.handleAction?.(

118121

createContext({

119122

action: profileAction,

120123

senderIsOwner: false,

@@ -123,30 +126,32 @@ describe("matrixMessageActions account propagation", () => {

123126

displayName: "Ops Bot",

124127

},

125128

}),

126-

),

127-

).rejects.toMatchObject({

128-

name: "ToolAuthorizationError",

129-

message: "Matrix profile updates require owner access.",

130-

});

129+

);

130+

throw new Error("expected non-owner self-profile update to reject");

131+

} catch (error) {

132+

expect((error as Error).name).toBe("ToolAuthorizationError");

133+

expect((error as Error).message).toBe("Matrix profile updates require owner access.");

134+

}

131135132136

expect(mocks.handleMatrixAction).not.toHaveBeenCalled();

133137

});

134138135139

it("rejects self-profile updates when owner status is unknown", async () => {

136-

await expect(

137-

matrixMessageActions.handleAction?.(

140+

try {

141+

await matrixMessageActions.handleAction?.(

138142

createContext({

139143

action: profileAction,

140144

accountId: "ops",

141145

params: {

142146

displayName: "Ops Bot",

143147

},

144148

}),

145-

),

146-

).rejects.toMatchObject({

147-

name: "ToolAuthorizationError",

148-

message: "Matrix profile updates require owner access.",

149-

});

149+

);

150+

throw new Error("expected unknown-owner self-profile update to reject");

151+

} catch (error) {

152+

expect((error as Error).name).toBe("ToolAuthorizationError");

153+

expect((error as Error).message).toBe("Matrix profile updates require owner access.");

154+

}

150155151156

expect(mocks.handleMatrixAction).not.toHaveBeenCalled();

152157

});

@@ -163,15 +168,12 @@ describe("matrixMessageActions account propagation", () => {

163168

}),

164169

);

165170166-

expect(mocks.handleMatrixAction).toHaveBeenCalledWith(

167-

expect.objectContaining({

168-

action: "setProfile",

169-

accountId: "ops",

170-

avatarPath: "/tmp/avatar.jpg",

171-

}),

172-

expect.any(Object),

173-

{ mediaLocalRoots: undefined },

174-

);

171+

const call = matrixActionCall();

172+

expect(call.input.action).toBe("setProfile");

173+

expect(call.input.accountId).toBe("ops");

174+

expect(call.input.avatarPath).toBe("/tmp/avatar.jpg");

175+

expect(call.cfg).toBeTypeOf("object");

176+

expect(call.options).toEqual({ mediaLocalRoots: undefined });

175177

});

176178177179

it("forwards mediaLocalRoots for media sends", async () => {

@@ -188,15 +190,12 @@ describe("matrixMessageActions account propagation", () => {

188190

}),

189191

);

190192191-

expect(mocks.handleMatrixAction).toHaveBeenCalledWith(

192-

expect.objectContaining({

193-

action: "sendMessage",

194-

accountId: "ops",

195-

mediaUrl: "file:///tmp/photo.png",

196-

}),

197-

expect.any(Object),

198-

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

199-

);

193+

const call = matrixActionCall();

194+

expect(call.input.action).toBe("sendMessage");

195+

expect(call.input.accountId).toBe("ops");

196+

expect(call.input.mediaUrl).toBe("file:///tmp/photo.png");

197+

expect(call.cfg).toBeTypeOf("object");

198+

expect(call.options).toEqual({ mediaLocalRoots: ["/tmp/openclaw-matrix-test"] });

200199

});

201200202201

it("allows media-only sends without requiring a message body", async () => {

@@ -211,16 +210,13 @@ describe("matrixMessageActions account propagation", () => {

211210

}),

212211

);

213212214-

expect(mocks.handleMatrixAction).toHaveBeenCalledWith(

215-

expect.objectContaining({

216-

action: "sendMessage",

217-

accountId: "ops",

218-

content: undefined,

219-

mediaUrl: "file:///tmp/photo.png",

220-

}),

221-

expect.any(Object),

222-

{ mediaLocalRoots: undefined },

223-

);

213+

const call = matrixActionCall();

214+

expect(call.input.action).toBe("sendMessage");

215+

expect(call.input.accountId).toBe("ops");

216+

expect(call.input.content).toBeUndefined();

217+

expect(call.input.mediaUrl).toBe("file:///tmp/photo.png");

218+

expect(call.cfg).toBeTypeOf("object");

219+

expect(call.options).toEqual({ mediaLocalRoots: undefined });

224220

});

225221226222

it("accepts shared media aliases and forwards voice-send intent", async () => {

@@ -236,16 +232,13 @@ describe("matrixMessageActions account propagation", () => {

236232

}),

237233

);

238234239-

expect(mocks.handleMatrixAction).toHaveBeenCalledWith(

240-

expect.objectContaining({

241-

action: "sendMessage",

242-

accountId: "ops",

243-

content: undefined,

244-

mediaUrl: "/tmp/clip.mp3",

245-

audioAsVoice: true,

246-

}),

247-

expect.any(Object),

248-

{ mediaLocalRoots: undefined },

249-

);

235+

const call = matrixActionCall();

236+

expect(call.input.action).toBe("sendMessage");

237+

expect(call.input.accountId).toBe("ops");

238+

expect(call.input.content).toBeUndefined();

239+

expect(call.input.mediaUrl).toBe("/tmp/clip.mp3");

240+

expect(call.input.audioAsVoice).toBe(true);

241+

expect(call.cfg).toBeTypeOf("object");

242+

expect(call.options).toEqual({ mediaLocalRoots: undefined });

250243

});

251244

});