mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 22:10:44 +00:00
test: require logging async callbacks
This commit is contained in:
@@ -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;
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user