test: require extension async gates

This commit is contained in:
Peter Steinberger
2026-05-08 19:07:11 +01:00
parent b5c8f6dd01
commit 8100984e0e
2 changed files with 22 additions and 6 deletions

View File

@@ -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<void>((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<void>((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<void>((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;
}