perf(test): bypass queue debounce in fast mode and tighten announce defaults

This commit is contained in:
Peter Steinberger
2026-02-22 09:12:55 +00:00
parent f101d59d57
commit c3e13175d2
2 changed files with 20 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { SILENT_REPLY_TOKEN } from "../auto-reply/tokens.js";
import {
__testing as sessionBindingServiceTesting,
@@ -61,7 +61,7 @@ let configOverride: ReturnType<(typeof import("../config/config.js"))["loadConfi
};
const defaultOutcomeAnnounce = {
task: "do thing",
timeoutMs: 1000,
timeoutMs: 10,
cleanup: "keep" as const,
waitForCompletion: false,
startedAt: 10,
@@ -141,7 +141,22 @@ vi.mock("../config/config.js", async (importOriginal) => {
});
describe("subagent announce formatting", () => {
let previousFastTestEnv: string | undefined;
beforeAll(() => {
previousFastTestEnv = process.env.OPENCLAW_TEST_FAST;
});
afterAll(() => {
if (previousFastTestEnv === undefined) {
delete process.env.OPENCLAW_TEST_FAST;
return;
}
process.env.OPENCLAW_TEST_FAST = previousFastTestEnv;
});
beforeEach(() => {
vi.stubEnv("OPENCLAW_TEST_FAST", "1");
agentSpy
.mockClear()
.mockImplementation(async (_req: AgentCallRequest) => ({ runId: "run-main", status: "ok" }));

View File

@@ -112,6 +112,9 @@ export function waitForQueueDebounce(queue: {
debounceMs: number;
lastEnqueuedAt: number;
}): Promise<void> {
if (process.env.OPENCLAW_TEST_FAST === "1") {
return Promise.resolve();
}
const debounceMs = Math.max(0, queue.debounceMs);
if (debounceMs <= 0) {
return Promise.resolve();