test(subagent-announce): fix flaky Windows-only test failure (#31298) (openclaw#31370) thanks @zwffff

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check (fails on main baseline issues in extensions/googlechat and extensions/phone-control)
- pnpm test:e2e src/agents/subagent-announce.format.e2e.test.ts

Co-authored-by: zwffff <5809959+zwffff@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
zwffff
2026-03-03 00:33:07 +08:00
committed by GitHub
parent 4dd6c7a509
commit 8828418111
2 changed files with 9 additions and 2 deletions

View File

@@ -147,8 +147,13 @@ describe("subagent announce formatting", () => {
let runSubagentAnnounceFlow: (typeof import("./subagent-announce.js"))["runSubagentAnnounceFlow"];
beforeAll(async () => {
({ runSubagentAnnounceFlow } = await import("./subagent-announce.js"));
// Set FAST_TEST_MODE before importing the module to ensure the module-level
// constant picks it up. This fixes flaky Windows CI failures where the test
// timeout budget is too tight without fast mode enabled.
// See: https://github.com/openclaw/openclaw/issues/31298
previousFastTestEnv = process.env.OPENCLAW_TEST_FAST;
process.env.OPENCLAW_TEST_FAST = "1";
({ runSubagentAnnounceFlow } = await import("./subagent-announce.js"));
});
afterAll(() => {
@@ -160,7 +165,8 @@ describe("subagent announce formatting", () => {
});
beforeEach(() => {
vi.stubEnv("OPENCLAW_TEST_FAST", "1");
// OPENCLAW_TEST_FAST is set in beforeAll before module import
// to ensure the module-level constant picks it up.
agentSpy
.mockClear()
.mockImplementation(async (_req: AgentCallRequest) => ({ runId: "run-main", status: "ok" }));