test: harden command queue timer cleanup

This commit is contained in:
Shakker 2026-04-03 12:45:57 +01:00 committed by Peter Steinberger
parent 1877a2ea26
commit 2fa3a09137
1 changed files with 6 additions and 1 deletions

View File

@ -1,4 +1,4 @@
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { importFreshModule } from "../../test/helpers/import-fresh.js";
import { CommandLane } from "./lanes.js";
@ -74,6 +74,7 @@ describe("command queue", () => {
});
beforeEach(() => {
vi.useRealTimers();
resetCommandQueueStateForTest();
// Queue state is global across module instances, so reset main lane
// concurrency explicitly to avoid cross-file leakage.
@ -85,6 +86,10 @@ describe("command queue", () => {
diagnosticMocks.diag.error.mockClear();
});
afterEach(() => {
vi.useRealTimers();
});
it("resetAllLanes is safe when no lanes have been created", () => {
expect(getActiveTaskCount()).toBe(0);
expect(() => resetAllLanes()).not.toThrow();