From 65acfa3781d54608b07a8e7da877ac0e4bf00c2a Mon Sep 17 00:00:00 2001 From: Elarwei Date: Sat, 28 Feb 2026 12:10:34 +0800 Subject: [PATCH] fix(feishu): add documentBlockDescendant mock to docx.test.ts write/append now use the Descendant API (documentBlockDescendant.create) instead of Children API. The existing test mock was missing this SDK method, causing processImages to never be reached and fetchRemoteMedia to go uncalled. Added blockDescendantCreateMock returning an image block so the 'skips image upload when markdown image URL is blocked' test flows through processImages as expected. --- extensions/feishu/src/docx.test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/extensions/feishu/src/docx.test.ts b/extensions/feishu/src/docx.test.ts index 532a6728984..a7a5bbd8a12 100644 --- a/extensions/feishu/src/docx.test.ts +++ b/extensions/feishu/src/docx.test.ts @@ -29,6 +29,7 @@ describe("feishu_doc image fetch hardening", () => { const blockChildrenCreateMock = vi.hoisted(() => vi.fn()); const blockChildrenGetMock = vi.hoisted(() => vi.fn()); const blockChildrenBatchDeleteMock = vi.hoisted(() => vi.fn()); + const blockDescendantCreateMock = vi.hoisted(() => vi.fn()); const driveUploadAllMock = vi.hoisted(() => vi.fn()); const permissionMemberCreateMock = vi.hoisted(() => vi.fn()); const blockPatchMock = vi.hoisted(() => vi.fn()); @@ -52,6 +53,9 @@ describe("feishu_doc image fetch hardening", () => { get: blockChildrenGetMock, batchDelete: blockChildrenBatchDeleteMock, }, + documentBlockDescendant: { + create: blockDescendantCreateMock, + }, }, drive: { media: { @@ -95,6 +99,11 @@ describe("feishu_doc image fetch hardening", () => { data: { items: [{ block_id: "placeholder_block_1" }] }, }); blockChildrenBatchDeleteMock.mockResolvedValue({ code: 0 }); + // write/append use Descendant API; return image block so processImages runs + blockDescendantCreateMock.mockResolvedValue({ + code: 0, + data: { children: [{ block_type: 27, block_id: "img_block_1" }] }, + }); driveUploadAllMock.mockResolvedValue({ file_token: "token_1" }); documentCreateMock.mockResolvedValue({ code: 0,