Skip to content

Commit 085013d

Browse files
committed
fix(feishu): move parse-failure test into getMessageFeishu suite
The test 'logs a safe diagnostic (not raw content) when message content is not valid JSON' was declared after the closing brace of describe('getMessageFeishu'), so it did not inherit that suite's fixture setup and reset hooks (beforeEach/afterAll). Move it inside the suite so it benefits from the shared mock reset and cleanup. Fixes ClawSweeper P2: 'Keep the parse-failure test inside the fetch suite'
1 parent 273268e commit 085013d

1 file changed

Lines changed: 31 additions & 30 deletions

File tree

‎extensions/feishu/src/send.test.ts‎

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -704,43 +704,44 @@ describe("getMessageFeishu", () => {
704704
},
705705
]);
706706
});
707-
});
708707

709-
it("logs a safe diagnostic (not raw content) when message content is not valid JSON", async () => {
710-
mockClientGet.mockResolvedValueOnce({
711-
code: 0,
712-
data: {
713-
message_id: "om_bad_json",
714-
chat_id: "oc_test",
715-
chat_type: "group",
716-
msg_type: "text",
717-
body: {
718-
content: "{bad json}",
719-
},
720-
sender: {
721-
id: "ou_1",
722-
sender_type: "user",
708+
it("logs a safe diagnostic (not raw content) when message content is not valid JSON", async () => {
709+
mockClientGet.mockResolvedValueOnce({
710+
code: 0,
711+
data: {
712+
message_id: "om_bad_json",
713+
chat_id: "oc_test",
714+
chat_type: "group",
715+
msg_type: "text",
716+
body: {
717+
content: "{bad json}",
718+
},
719+
sender: {
720+
id: "ou_1",
721+
sender_type: "user",
722+
},
723723
},
724-
},
725-
});
724+
});
726725

727-
const result = await getMessageFeishu({
728-
cfg: {} as ClawdbotConfig,
729-
messageId: "om_bad_json",
730-
});
726+
const result = await getMessageFeishu({
727+
cfg: {} as ClawdbotConfig,
728+
messageId: "om_bad_json",
729+
});
731730

732-
expect(mockLogVerbose).toHaveBeenCalledWith(
733-
expect.stringContaining("feishu message content parse failed for text message"),
734-
);
735-
// Ensure raw content is NOT logged (security: prevent message content leaks)
736-
expect(mockLogVerbose).not.toHaveBeenCalledWith(expect.stringContaining("{bad json}"));
737-
expect(result).toMatchObject({
738-
messageId: "om_bad_json",
739-
contentType: "text",
740-
content: "{bad json}",
731+
expect(mockLogVerbose).toHaveBeenCalledWith(
732+
expect.stringContaining("feishu message content parse failed for text message"),
733+
);
734+
// Ensure raw content is NOT logged (security: prevent message content leaks)
735+
expect(mockLogVerbose).not.toHaveBeenCalledWith(expect.stringContaining("{bad json}"));
736+
expect(result).toMatchObject({
737+
messageId: "om_bad_json",
738+
contentType: "text",
739+
content: "{bad json}",
740+
});
741741
});
742742
});
743743

744+
744745
describe("editMessageFeishu", () => {
745746
beforeEach(() => {
746747
vi.clearAllMocks();

0 commit comments

Comments
 (0)