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

推荐订阅源

A
About on SuperTechFans
Y
Y Combinator Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Microsoft Security Blog
Microsoft Security Blog
aimingoo的专栏
aimingoo的专栏
I
InfoQ
C
Check Point Blog
IT之家
IT之家
MyScale Blog
MyScale Blog
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
Last Week in AI
Last Week in AI
GbyAI
GbyAI
P
Proofpoint News Feed
量子位
Stack Overflow Blog
Stack Overflow Blog
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
人人都是产品经理
人人都是产品经理
B
Blog
T
The Blog of Author Tim Ferriss
H
Help Net Security
云风的 BLOG
云风的 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 feishu drive comment assertions · openclaw/...
steipete · 2026-05-10 · via Recent Commits to openclaw:main

@@ -52,6 +52,17 @@ function createDriveToolApi(params: {

5252

});

5353

}

545455+

function mockCallArg<T>(

56+

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

57+

callIndex: number,

58+

argIndex: number,

59+

_type?: (value: unknown) => value is T,

60+

): T {

61+

const call = mock.mock.calls[callIndex];

62+

expect(call).toBeDefined();

63+

return call?.[argIndex] as T;

64+

}

65+5566

describe("registerFeishuDriveTools", () => {

5667

const requestMock = vi.fn();

5768

@@ -154,25 +165,28 @@ describe("registerFeishuDriveTools", () => {

154165

file_token: "doc_1",

155166

file_type: "docx",

156167

});

157-

expect(requestMock).toHaveBeenNthCalledWith(

158-

1,

159-

expect.objectContaining({

160-

method: "GET",

161-

url: "/open-apis/drive/v1/files/doc_1/comments?file_type=docx&user_id_type=open_id",

162-

}),

163-

);

164-

expect(listResult.details).toEqual(

165-

expect.objectContaining({

166-

comments: [

167-

expect.objectContaining({

168-

comment_id: "c1",

169-

text: "root comment",

170-

quote: "quoted text",

171-

replies: [expect.objectContaining({ reply_id: "r2", text: "reply text" })],

172-

}),

173-

],

174-

}),

175-

);

168+

const listRequest = mockCallArg<{ method?: string; url?: string }>(requestMock, 0, 0);

169+

expect(listRequest.method).toBe("GET");

170+

expect(listRequest.url).toBe(

171+

"/open-apis/drive/v1/files/doc_1/comments?file_type=docx&user_id_type=open_id",

172+

);

173+

const listDetails = listResult.details as

174+

| {

175+

comments?: Array<{

176+

comment_id?: string;

177+

quote?: string;

178+

replies?: Array<{ reply_id?: string; text?: string }>;

179+

text?: string;

180+

}>;

181+

}

182+

| undefined;

183+

expect(listDetails?.comments).toHaveLength(1);

184+

expect(listDetails?.comments?.[0]?.comment_id).toBe("c1");

185+

expect(listDetails?.comments?.[0]?.text).toBe("root comment");

186+

expect(listDetails?.comments?.[0]?.quote).toBe("quoted text");

187+

expect(listDetails?.comments?.[0]?.replies).toHaveLength(1);

188+

expect(listDetails?.comments?.[0]?.replies?.[0]?.reply_id).toBe("r2");

189+

expect(listDetails?.comments?.[0]?.replies?.[0]?.text).toBe("reply text");

176190177191

requestMock.mockResolvedValueOnce({

178192

code: 0,

@@ -201,18 +215,17 @@ describe("registerFeishuDriveTools", () => {

201215

file_type: "docx",

202216

comment_id: "c1",

203217

});

204-

expect(requestMock).toHaveBeenNthCalledWith(

205-

2,

206-

expect.objectContaining({

207-

method: "GET",

208-

url: "/open-apis/drive/v1/files/doc_1/comments/c1/replies?file_type=docx&user_id_type=open_id",

209-

}),

210-

);

211-

expect(repliesResult.details).toEqual(

212-

expect.objectContaining({

213-

replies: [expect.objectContaining({ reply_id: "r3", text: "reply from api" })],

214-

}),

215-

);

218+

const repliesRequest = mockCallArg<{ method?: string; url?: string }>(requestMock, 1, 0);

219+

expect(repliesRequest.method).toBe("GET");

220+

expect(repliesRequest.url).toBe(

221+

"/open-apis/drive/v1/files/doc_1/comments/c1/replies?file_type=docx&user_id_type=open_id",

222+

);

223+

const repliesDetails = repliesResult.details as

224+

| { replies?: Array<{ reply_id?: string; text?: string }> }

225+

| undefined;

226+

expect(repliesDetails?.replies).toHaveLength(1);

227+

expect(repliesDetails?.replies?.[0]?.reply_id).toBe("r3");

228+

expect(repliesDetails?.replies?.[0]?.text).toBe("reply from api");

216229217230

requestMock.mockResolvedValueOnce({

218231

code: 0,

@@ -225,21 +238,26 @@ describe("registerFeishuDriveTools", () => {

225238

block_id: "blk_1",

226239

content: "please update this section",

227240

});

228-

expect(requestMock).toHaveBeenNthCalledWith(

229-

3,

230-

expect.objectContaining({

231-

method: "POST",

232-

url: "/open-apis/drive/v1/files/doc_1/new_comments",

233-

data: {

234-

file_type: "docx",

235-

reply_elements: [{ type: "text", text: "please update this section" }],

236-

anchor: { block_id: "blk_1" },

237-

},

238-

}),

239-

);

240-

expect(addCommentResult.details).toEqual(

241-

expect.objectContaining({ success: true, comment_id: "c2" }),

241+

const addRequest = mockCallArg<{

242+

data?: {

243+

anchor?: { block_id?: string };

244+

file_type?: string;

245+

reply_elements?: Array<{ text?: string; type?: string }>;

246+

};

247+

method?: string;

248+

url?: string;

249+

}>(requestMock, 2, 0);

250+

expect(addRequest.method).toBe("POST");

251+

expect(addRequest.url).toBe("/open-apis/drive/v1/files/doc_1/new_comments");

252+

expect(addRequest.data).toEqual({

253+

file_type: "docx",

254+

reply_elements: [{ type: "text", text: "please update this section" }],

255+

anchor: { block_id: "blk_1" },

256+

});

257+

expect((addCommentResult.details as { comment_id?: string; success?: boolean }).success).toBe(

258+

true,

242259

);

260+

expect((addCommentResult.details as { comment_id?: string }).comment_id).toBe("c2");

243261244262

requestMock

245263

.mockResolvedValueOnce({

@@ -259,39 +277,41 @@ describe("registerFeishuDriveTools", () => {

259277

comment_id: "c1",

260278

content: "handled",

261279

});

262-

expect(requestMock).toHaveBeenNthCalledWith(

263-

4,

264-

expect.objectContaining({

265-

method: "POST",

266-

url: "/open-apis/drive/v1/files/doc_1/comments/batch_query?file_type=docx&user_id_type=open_id",

267-

data: {

268-

comment_ids: ["c1"],

269-

},

270-

}),

271-

);

272-

expect(requestMock).toHaveBeenNthCalledWith(

273-

5,

274-

expect.objectContaining({

275-

method: "POST",

276-

url: "/open-apis/drive/v1/files/doc_1/comments/c1/replies",

277-

params: { file_type: "docx" },

278-

data: {

279-

content: {

280-

elements: [

281-

{

282-

type: "text_run",

283-

text_run: {

284-

text: "handled",

285-

},

286-

},

287-

],

280+

const batchRequest = mockCallArg<{

281+

data?: { comment_ids?: string[] };

282+

method?: string;

283+

url?: string;

284+

}>(requestMock, 3, 0);

285+

expect(batchRequest.method).toBe("POST");

286+

expect(batchRequest.url).toBe(

287+

"/open-apis/drive/v1/files/doc_1/comments/batch_query?file_type=docx&user_id_type=open_id",

288+

);

289+

expect(batchRequest.data).toEqual({ comment_ids: ["c1"] });

290+

const replyRequest = mockCallArg<{

291+

data?: { content?: { elements?: Array<{ text_run?: { text?: string }; type?: string }> } };

292+

method?: string;

293+

params?: { file_type?: string };

294+

url?: string;

295+

}>(requestMock, 4, 0);

296+

expect(replyRequest.method).toBe("POST");

297+

expect(replyRequest.url).toBe("/open-apis/drive/v1/files/doc_1/comments/c1/replies");

298+

expect(replyRequest.params).toEqual({ file_type: "docx" });

299+

expect(replyRequest.data).toEqual({

300+

content: {

301+

elements: [

302+

{

303+

type: "text_run",

304+

text_run: {

305+

text: "handled",

306+

},

288307

},

289-

},

290-

}),

291-

);

292-

expect(replyCommentResult.details).toEqual(

293-

expect.objectContaining({ success: true, reply_id: "r4" }),

308+

],

309+

},

310+

});

311+

expect((replyCommentResult.details as { reply_id?: string; success?: boolean }).success).toBe(

312+

true,

294313

);

314+

expect((replyCommentResult.details as { reply_id?: string }).reply_id).toBe("r4");

295315

});

296316297317

it("defaults add_comment file_type to docx when omitted", async () => {