fix: harden feishu startup probe sequencing (#29941) (thanks @bmendonca3)

This commit is contained in:
Peter Steinberger
2026-03-02 03:58:34 +00:00
parent abc7b6fbec
commit 3fc19ed7d7
5 changed files with 170 additions and 10 deletions

View File

@@ -6,7 +6,7 @@ vi.mock("./client.js", () => ({
createFeishuClient: createFeishuClientMock,
}));
import { probeFeishu, clearProbeCache } from "./probe.js";
import { FEISHU_PROBE_REQUEST_TIMEOUT_MS, probeFeishu, clearProbeCache } from "./probe.js";
function makeRequestFn(response: Record<string, unknown>) {
return vi.fn().mockResolvedValue(response);
@@ -59,6 +59,23 @@ describe("probeFeishu", () => {
expect(requestFn).toHaveBeenCalledTimes(1);
});
it("uses explicit timeout for bot info request", async () => {
const requestFn = setupClient({
code: 0,
bot: { bot_name: "TestBot", open_id: "ou_abc123" },
});
await probeFeishu({ appId: "cli_123", appSecret: "secret" });
expect(requestFn).toHaveBeenCalledWith(
expect.objectContaining({
method: "GET",
url: "/open-apis/bot/v3/info",
timeout: FEISHU_PROBE_REQUEST_TIMEOUT_MS,
}),
);
});
it("returns cached result on subsequent calls within TTL", async () => {
const requestFn = setupClient({
code: 0,