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

推荐订阅源

D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Google DeepMind News
Google DeepMind News
博客园 - 聂微东
Microsoft Azure Blog
Microsoft Azure Blog
V
Visual Studio Blog
IT之家
IT之家
博客园 - 【当耐特】
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
B
Blog
爱范儿
爱范儿
阮一峰的网络日志
阮一峰的网络日志
云风的 BLOG
云风的 BLOG
Vercel News
Vercel News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
H
Help Net Security
J
Java Code Geeks
aimingoo的专栏
aimingoo的专栏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog RSS Feed
Blog — PlanetScale
Blog — PlanetScale
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research

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

@@ -63,6 +63,30 @@ type ToolResultWithDetails = {

63636464

const WORKSPACE_ROOT = path.resolve("/workspace");

656566+

function requireRecord(value: unknown, label: string): Record<string, unknown> {

67+

expect(value, label).toBeTypeOf("object");

68+

expect(value, label).not.toBeNull();

69+

return value as Record<string, unknown>;

70+

}

71+72+

function callArg(mock: unknown, callIndex: number, argIndex: number, label: string) {

73+

const calls = (mock as { mock?: { calls?: Array<Array<unknown>> } }).mock?.calls ?? [];

74+

const call = calls.at(callIndex);

75+

expect(call, label).toBeDefined();

76+

return call?.[argIndex];

77+

}

78+79+

function expectLoadWebMediaCall(fileName: string, localRoots: unknown[] | undefined) {

80+

const source = callArg(loadWebMediaMock, 0, 0, "loadWebMedia source");

81+

const options = requireRecord(

82+

callArg(loadWebMediaMock, 0, 1, "loadWebMedia options"),

83+

"loadWebMedia options",

84+

);

85+

expect(String(source)).toContain(fileName);

86+

expect(options.optimizeImages).toBe(false);

87+

expect(options.localRoots).toEqual(localRoots);

88+

}

89+6690

describe("feishu_doc image fetch hardening", () => {

6791

afterAll(() => {

6892

vi.restoreAllMocks();

@@ -208,7 +232,9 @@ describe("feishu_doc image fetch hardening", () => {

208232

expect(blockDescendantCreateMock).toHaveBeenCalledTimes(1);

209233

const call = blockDescendantCreateMock.mock.calls[0]?.[0];

210234

expect(call?.data.children_id).toEqual(["h1", "t1", "h2"]);

211-

expect(call?.data.descendants).toEqual(expect.arrayContaining(blocks));

235+

for (const block of blocks) {

236+

expect(call?.data.descendants).toContainEqual(block);

237+

}

212238

expect(call?.data.descendants).toHaveLength(3);

213239214240

expect(result.details.blocks_added).toBe(3);

@@ -398,15 +424,14 @@ describe("feishu_doc image fetch hardening", () => {

398424

expect(result.details.requester_permission_added).toBe(true);

399425

expect(result.details.requester_open_id).toBe("ou_123");

400426

expect(result.details.requester_perm_type).toBe("edit");

401-

expect(permissionMemberCreateMock).toHaveBeenCalledWith(

402-

expect.objectContaining({

403-

data: expect.objectContaining({

404-

member_type: "openid",

405-

member_id: "ou_123",

406-

perm: "edit",

407-

}),

408-

}),

427+

const permissionPayload = requireRecord(

428+

callArg(permissionMemberCreateMock, 0, 0, "permission create payload"),

429+

"permission create payload",

409430

);

431+

const permissionData = requireRecord(permissionPayload.data, "permission data");

432+

expect(permissionData.member_type).toBe("openid");

433+

expect(permissionData.member_id).toBe("ou_123");

434+

expect(permissionData.perm).toBe("edit");

410435

});

411436412437

it("create skips requester grant when trusted requester identity is unavailable", async () => {

@@ -484,20 +509,16 @@ describe("feishu_doc image fetch hardening", () => {

484509485510

// Without workspace-only policy, localRoots stays undefined so loadWebMedia

486511

// applies its default managed-root access behavior.

487-

expect(loadWebMediaMock).toHaveBeenCalledWith(

488-

expect.stringContaining("test-local.txt"),

489-

expect.objectContaining({ optimizeImages: false, localRoots: undefined }),

490-

);

512+

expectLoadWebMediaCall("test-local.txt", undefined);

491513492-

expect(driveUploadAllMock).toHaveBeenCalledWith(

493-

expect.objectContaining({

494-

data: expect.objectContaining({

495-

parent_type: "docx_file",

496-

parent_node: "doc_1",

497-

file_name: "test-local.txt",

498-

}),

499-

}),

514+

const uploadPayload = requireRecord(

515+

callArg(driveUploadAllMock, 0, 0, "drive upload payload"),

516+

"drive upload payload",

500517

);

518+

const uploadData = requireRecord(uploadPayload.data, "drive upload data");

519+

expect(uploadData.parent_type).toBe("docx_file");

520+

expect(uploadData.parent_node).toBe("doc_1");

521+

expect(uploadData.file_name).toBe("test-local.txt");

501522

});

502523503524

it("passes workspace localRoots for upload_file when workspace-only policy is active", async () => {

@@ -525,10 +546,7 @@ describe("feishu_doc image fetch hardening", () => {

525546

filename: "test-local.txt",

526547

});

527548528-

expect(loadWebMediaMock).toHaveBeenCalledWith(

529-

expect.stringContaining("test-local.txt"),

530-

expect.objectContaining({ optimizeImages: false, localRoots: [WORKSPACE_ROOT] }),

531-

);

549+

expectLoadWebMediaCall("test-local.txt", [WORKSPACE_ROOT]);

532550

});

533551534552

it("passes empty localRoots when workspace-only policy is active without workspaceDir", async () => {

@@ -555,10 +573,7 @@ describe("feishu_doc image fetch hardening", () => {

555573

filename: "test-local.txt",

556574

});

557575558-

expect(loadWebMediaMock).toHaveBeenCalledWith(

559-

expect.stringContaining("test-local.txt"),

560-

expect.objectContaining({ optimizeImages: false, localRoots: [] }),

561-

);

576+

expectLoadWebMediaCall("test-local.txt", []);

562577

});

563578564579

it("passes workspace localRoots for upload_image local paths when workspace-only policy is active", async () => {

@@ -579,10 +594,7 @@ describe("feishu_doc image fetch hardening", () => {

579594

filename: "test-local.png",

580595

});

581596582-

expect(loadWebMediaMock).toHaveBeenCalledWith(

583-

expect.stringContaining("test-local.png"),

584-

expect.objectContaining({ optimizeImages: false, localRoots: [WORKSPACE_ROOT] }),

585-

);

597+

expectLoadWebMediaCall("test-local.png", [WORKSPACE_ROOT]);

586598

});

587599588600

it("passes workspace localRoots for upload_image absolute local paths when workspace-only policy is active", async () => {

@@ -609,10 +621,7 @@ describe("feishu_doc image fetch hardening", () => {

609621

filename: "absolute-image.png",

610622

});

611623612-

expect(loadWebMediaMock).toHaveBeenCalledWith(

613-

expect.stringContaining("absolute-image.png"),

614-

expect.objectContaining({ optimizeImages: false, localRoots: [WORKSPACE_ROOT] }),

615-

);

624+

expectLoadWebMediaCall("absolute-image.png", [WORKSPACE_ROOT]);

616625

} finally {

617626

rmSync(fixtureDir, { recursive: true, force: true });

618627

}