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

推荐订阅源

D
Docker
Apple Machine Learning Research
Apple Machine Learning Research
宝玉的分享
宝玉的分享
博客园 - 叶小钗
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 司徒正美
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - Franky
爱范儿
爱范儿
罗磊的独立博客
IT之家
IT之家
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
N
Netflix TechBlog - Medium
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
U
Unit 42
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
博客园 - 三生石上(FineUI控件)
T
Tailwind CSS Blog
H
Help Net Security
博客园_首页
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
人人都是产品经理
人人都是产品经理

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
perf: slim msteams hot test imports · openclaw/openclaw@b...
steipete · 2026-04-24 · via Recent Commits to openclaw:main

@@ -2,16 +2,8 @@ import fs from "node:fs";

22

import os from "node:os";

33

import path from "node:path";

44

import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

5-

import type { OpenClawConfig, PluginRuntime, RuntimeEnv } from "../runtime-api.js";

6-

import {

7-

type MSTeamsActivityHandler,

8-

type MSTeamsMessageHandlerDeps,

9-

registerMSTeamsHandlers,

10-

} from "./monitor-handler.js";

11-

import {

12-

createActivityHandler,

13-

createMSTeamsMessageHandlerDeps,

14-

} from "./monitor-handler.test-helpers.js";

5+

import type { PluginRuntime } from "../runtime-api.js";

6+

import { respondToMSTeamsFileConsentInvoke } from "./file-consent-invoke.js";

157

import { getPendingUploadFs, storePendingUploadFs } from "./pending-uploads-fs.js";

168

import { clearPendingUploads, getPendingUpload, storePendingUpload } from "./pending-uploads.js";

179

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

@@ -64,14 +56,11 @@ function createRuntimeStub(stateDir?: string): PluginRuntime {

64566557

const runtimeStub: PluginRuntime = createRuntimeStub();

665867-

function createDeps(): MSTeamsMessageHandlerDeps {

68-

return createMSTeamsMessageHandlerDeps({

69-

cfg: {} as OpenClawConfig,

70-

runtime: {

71-

error: vi.fn(),

72-

} as unknown as RuntimeEnv,

73-

});

74-

}

59+

const log = {

60+

debug: vi.fn(),

61+

info: vi.fn(),

62+

error: vi.fn(),

63+

};

75647665

function createInvokeContext(params: {

7766

conversationId: string;

@@ -129,18 +118,12 @@ function createConsentInvokeHarness(params: {

129118

conversationId: params.pendingConversationId ?? "19:victim@thread.v2",

130119

consentCardActivityId: params.consentCardActivityId,

131120

});

132-

const handler = registerMSTeamsHandlers(

133-

createActivityHandler(),

134-

createDeps(),

135-

) as MSTeamsActivityHandler & {

136-

run: NonNullable<MSTeamsActivityHandler["run"]>;

137-

};

138121

const { context, sendActivity, updateActivity } = createInvokeContext({

139122

conversationId: params.invokeConversationId,

140123

uploadId,

141124

action: params.action,

142125

});

143-

return { uploadId, handler, context, sendActivity, updateActivity };

126+

return { uploadId, context, sendActivity, updateActivity };

144127

}

145128146129

function requirePendingUpload(uploadId: string) {

@@ -155,17 +138,18 @@ describe("msteams file consent invoke authz", () => {

155138

beforeEach(() => {

156139

setMSTeamsRuntime(runtimeStub);

157140

clearPendingUploads();

141+

vi.clearAllMocks();

158142

fileConsentMockState.uploadToConsentUrl.mockReset();

159143

fileConsentMockState.uploadToConsentUrl.mockResolvedValue(undefined);

160144

});

161145162146

it("uploads when invoke conversation matches pending upload conversation", async () => {

163-

const { uploadId, handler, context, sendActivity } = createConsentInvokeHarness({

147+

const { uploadId, context, sendActivity } = createConsentInvokeHarness({

164148

invokeConversationId: "19:victim@thread.v2;messageid=abc123",

165149

action: "accept",

166150

});

167151168-

await handler.run(context);

152+

await respondToMSTeamsFileConsentInvoke(context, log);

169153170154

// invokeResponse should be sent immediately

171155

expect(sendActivity).toHaveBeenCalledWith(

@@ -185,13 +169,13 @@ describe("msteams file consent invoke authz", () => {

185169

});

186170187171

it("calls updateActivity to replace the consent card when consentCardActivityId is set", async () => {

188-

const { handler, context, sendActivity, updateActivity } = createConsentInvokeHarness({

172+

const { context, sendActivity, updateActivity } = createConsentInvokeHarness({

189173

invokeConversationId: "19:victim@thread.v2;messageid=abc123",

190174

action: "accept",

191175

consentCardActivityId: "consent-card-activity-id-123",

192176

});

193177194-

await handler.run?.(context);

178+

await respondToMSTeamsFileConsentInvoke(context, log);

195179196180

expect(sendActivity).toHaveBeenCalledWith(expect.objectContaining({ type: "invokeResponse" }));

197181

expect(fileConsentMockState.uploadToConsentUrl).toHaveBeenCalledTimes(1);

@@ -212,13 +196,13 @@ describe("msteams file consent invoke authz", () => {

212196

});

213197214198

it("does not send file info card via sendActivity when updateActivity succeeds", async () => {

215-

const { handler, context, sendActivity, updateActivity } = createConsentInvokeHarness({

199+

const { context, sendActivity, updateActivity } = createConsentInvokeHarness({

216200

invokeConversationId: "19:victim@thread.v2;messageid=abc123",

217201

action: "accept",

218202

consentCardActivityId: "consent-card-activity-id-happy",

219203

});

220204221-

await handler.run?.(context);

205+

await respondToMSTeamsFileConsentInvoke(context, log);

222206223207

// updateActivity should replace the consent card in-place

224208

expect(updateActivity).toHaveBeenCalledTimes(1);

@@ -240,27 +224,27 @@ describe("msteams file consent invoke authz", () => {

240224

});

241225242226

it("does not call updateActivity when no consentCardActivityId is stored", async () => {

243-

const { handler, context, updateActivity } = createConsentInvokeHarness({

227+

const { context, updateActivity } = createConsentInvokeHarness({

244228

invokeConversationId: "19:victim@thread.v2;messageid=abc123",

245229

action: "accept",

246230

// no consentCardActivityId

247231

});

248232249-

await handler.run?.(context);

233+

await respondToMSTeamsFileConsentInvoke(context, log);

250234251235

expect(fileConsentMockState.uploadToConsentUrl).toHaveBeenCalledTimes(1);

252236

expect(updateActivity).not.toHaveBeenCalled();

253237

});

254238255239

it("still completes upload if updateActivity throws", async () => {

256-

const { uploadId, handler, context, updateActivity } = createConsentInvokeHarness({

240+

const { uploadId, context, updateActivity } = createConsentInvokeHarness({

257241

invokeConversationId: "19:victim@thread.v2;messageid=abc123",

258242

action: "accept",

259243

consentCardActivityId: "consent-card-activity-id-fail",

260244

});

261245

updateActivity.mockRejectedValueOnce(new Error("Teams API error"));

262246263-

await handler.run?.(context);

247+

await respondToMSTeamsFileConsentInvoke(context, log);

264248265249

// Upload should have completed despite updateActivity failure

266250

expect(fileConsentMockState.uploadToConsentUrl).toHaveBeenCalledTimes(1);

@@ -269,12 +253,12 @@ describe("msteams file consent invoke authz", () => {

269253

});

270254271255

it("rejects cross-conversation accept invoke and keeps pending upload", async () => {

272-

const { uploadId, handler, context, sendActivity } = createConsentInvokeHarness({

256+

const { uploadId, context, sendActivity } = createConsentInvokeHarness({

273257

invokeConversationId: "19:attacker@thread.v2",

274258

action: "accept",

275259

});

276260277-

await handler.run(context);

261+

await respondToMSTeamsFileConsentInvoke(context, log);

278262279263

// invokeResponse should be sent immediately

280264

expect(sendActivity).toHaveBeenCalledWith(

@@ -296,12 +280,12 @@ describe("msteams file consent invoke authz", () => {

296280

});

297281298282

it("ignores cross-conversation decline invoke and keeps pending upload", async () => {

299-

const { uploadId, handler, context, sendActivity } = createConsentInvokeHarness({

283+

const { uploadId, context, sendActivity } = createConsentInvokeHarness({

300284

invokeConversationId: "19:attacker@thread.v2",

301285

action: "decline",

302286

});

303287304-

await handler.run(context);

288+

await respondToMSTeamsFileConsentInvoke(context, log);

305289306290

// invokeResponse should be sent immediately

307291

expect(sendActivity).toHaveBeenCalledWith(

@@ -330,6 +314,7 @@ describe("msteams file consent invoke FS fallback", () => {

330314

process.env.OPENCLAW_STATE_DIR = tmpDir;

331315

setMSTeamsRuntime(createRuntimeStub(tmpDir));

332316

clearPendingUploads();

317+

vi.clearAllMocks();

333318

fileConsentMockState.uploadToConsentUrl.mockReset();

334319

fileConsentMockState.uploadToConsentUrl.mockResolvedValue(undefined);

335320

});

@@ -387,14 +372,7 @@ describe("msteams file consent invoke FS fallback", () => {

387372

updateActivity,

388373

} as unknown as MSTeamsTurnContext;

389374390-

const handler = registerMSTeamsHandlers(

391-

createActivityHandler(),

392-

createDeps(),

393-

) as MSTeamsActivityHandler & {

394-

run: NonNullable<MSTeamsActivityHandler["run"]>;

395-

};

396-397-

await handler.run(context);

375+

await respondToMSTeamsFileConsentInvoke(context, log);

398376399377

// The upload should have run using the FS-loaded buffer

400378

expect(fileConsentMockState.uploadToConsentUrl).toHaveBeenCalledTimes(1);

@@ -437,14 +415,7 @@ describe("msteams file consent invoke FS fallback", () => {

437415

updateActivity,

438416

} as unknown as MSTeamsTurnContext;

439417440-

const handler = registerMSTeamsHandlers(

441-

createActivityHandler(),

442-

createDeps(),

443-

) as MSTeamsActivityHandler & {

444-

run: NonNullable<MSTeamsActivityHandler["run"]>;

445-

};

446-447-

await handler.run(context);

418+

await respondToMSTeamsFileConsentInvoke(context, log);

448419449420

expect(fileConsentMockState.uploadToConsentUrl).not.toHaveBeenCalled();

450421

expect(await getPendingUploadFs(uploadId)).toBeUndefined();