From 8100984e0e89b213ddce879a8d967d30d9d8aa43 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 8 May 2026 19:07:11 +0100 Subject: [PATCH] test: require extension async gates --- .../cloudflare-ai-gateway/index.test.ts | 4 ++++ extensions/feishu/src/monitor.startup.test.ts | 24 ++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/extensions/cloudflare-ai-gateway/index.test.ts b/extensions/cloudflare-ai-gateway/index.test.ts index cb06a205f42..e4f0733e8ff 100644 --- a/extensions/cloudflare-ai-gateway/index.test.ts +++ b/extensions/cloudflare-ai-gateway/index.test.ts @@ -42,6 +42,10 @@ describe("cloudflare-ai-gateway plugin", () => { model: { api: "anthropic-messages" }, streamFn: baseStreamFn, } as never); + expect(wrapped).toBeTypeOf("function"); + if (!wrapped) { + throw new Error("expected Cloudflare AI Gateway wrapped stream function"); + } void wrapped( { provider: "cloudflare-ai-gateway", api: "anthropic-messages" } as never, diff --git a/extensions/feishu/src/monitor.startup.test.ts b/extensions/feishu/src/monitor.startup.test.ts index c8f2bdc6b7b..3e7d0cf1b84 100644 --- a/extensions/feishu/src/monitor.startup.test.ts +++ b/extensions/feishu/src/monitor.startup.test.ts @@ -64,10 +64,14 @@ describe("Feishu monitor startup preflight", () => { let inFlight = 0; let maxInFlight = 0; const started: string[] = []; - let releaseProbes!: () => void; + let releaseProbes: (() => void) | undefined; const probesReleased = new Promise((resolve) => { releaseProbes = () => resolve(); }); + if (!releaseProbes) { + throw new Error("Expected probe release callback to be initialized"); + } + const releaseStartedProbes = releaseProbes; probeFeishuMock.mockImplementation(async (account: { accountId: string }) => { started.push(account.accountId); inFlight += 1; @@ -88,7 +92,7 @@ describe("Feishu monitor startup preflight", () => { expect(started).toEqual(["alpha"]); expect(maxInFlight).toBe(1); } finally { - releaseProbes(); + releaseStartedProbes(); abortController.abort(); await monitorPromise; } @@ -96,10 +100,14 @@ describe("Feishu monitor startup preflight", () => { it("does not refetch bot info after a failed sequential preflight", async () => { const started: string[] = []; - let releaseBetaProbe!: () => void; + let releaseBetaProbe: (() => void) | undefined; const betaProbeReleased = new Promise((resolve) => { releaseBetaProbe = () => resolve(); }); + if (!releaseBetaProbe) { + throw new Error("Expected beta probe release callback to be initialized"); + } + const releaseStartedBetaProbe = releaseBetaProbe; probeFeishuMock.mockImplementation(async (account: { accountId: string }) => { started.push(account.accountId); @@ -121,7 +129,7 @@ describe("Feishu monitor startup preflight", () => { expect(started).toEqual(["alpha", "beta"]); expect(started.filter((accountId) => accountId === "alpha")).toHaveLength(1); } finally { - releaseBetaProbe(); + releaseStartedBetaProbe(); abortController.abort(); await monitorPromise; } @@ -129,10 +137,14 @@ describe("Feishu monitor startup preflight", () => { it("continues startup when probe layer reports timeout", async () => { const started: string[] = []; - let releaseBetaProbe!: () => void; + let releaseBetaProbe: (() => void) | undefined; const betaProbeReleased = new Promise((resolve) => { releaseBetaProbe = () => resolve(); }); + if (!releaseBetaProbe) { + throw new Error("Expected beta probe release callback to be initialized"); + } + const releaseStartedBetaProbe = releaseBetaProbe; probeFeishuMock.mockImplementation((account: { accountId: string }) => { started.push(account.accountId); @@ -157,7 +169,7 @@ describe("Feishu monitor startup preflight", () => { expect.stringContaining("bot info probe timed out"), ); } finally { - releaseBetaProbe(); + releaseStartedBetaProbe(); abortController.abort(); await monitorPromise; }