test: require logging async callbacks

This commit is contained in:
Peter Steinberger
2026-05-08 19:43:57 +01:00
parent 1eb876ff8f
commit 7011bbb953
2 changed files with 10 additions and 3 deletions

View File

@@ -324,7 +324,7 @@ describe("stuck session recovery", () => {
});
it("coalesces duplicate recovery attempts for the same session", async () => {
let resolveWait!: (value: boolean) => void;
let resolveWait: ((value: boolean) => void) | undefined;
const waitPromise = new Promise<boolean>((resolve) => {
resolveWait = resolve;
});
@@ -346,6 +346,9 @@ describe("stuck session recovery", () => {
});
expect(mocks.abortEmbeddedPiRun).toHaveBeenCalledTimes(1);
if (!resolveWait) {
throw new Error("Expected diagnostic recovery wait resolver to be initialized");
}
resolveWait(true);
await first;
});

View File

@@ -903,7 +903,7 @@ describe("stuck session diagnostics threshold", () => {
const warnSpy = vi.spyOn(diagnosticLogger, "warn").mockImplementation(() => undefined);
const events: DiagnosticEventPayload[] = [];
const unsubscribe = onDiagnosticEvent((event) => events.push(event));
let finishPhase!: () => void;
let finishPhase: (() => void) | undefined;
const phase = withDiagnosticPhase(
"startup.plugins.load",
() =>
@@ -911,6 +911,10 @@ describe("stuck session diagnostics threshold", () => {
finishPhase = resolve;
}),
);
if (!finishPhase) {
throw new Error("Expected diagnostic phase finish callback to be initialized");
}
const completePhase = finishPhase;
try {
startDiagnosticHeartbeat(
@@ -933,7 +937,7 @@ describe("stuck session diagnostics threshold", () => {
logMessageQueued({ sessionId: "s1", sessionKey: "main", source: "telegram" });
vi.advanceTimersByTime(30_000);
} finally {
finishPhase();
completePhase();
await phase;
unsubscribe();
}