@devries-cameron20 / t3code Mirror · read-only / commits / 30afc56076
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 22:00 UTC

test(web): isolate diff worker idle clock (#22259)

Theo Browne committed Oct 20, 2026 at 03:04 UTC 30afc56076c86580d5d913897280bea660d44c79
1 file changed +6 -1
apps/web/src/components/diffs/StyledDiffCodeView.browser.test.tsx
+6 -1
@@ -184,7 +184,6 @@ describe("code-view worker lifecycle", () => {
184 vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
185 // Pins the pool at two workers whatever machine runs the suite.
186 Object.defineProperty(navigator, "hardwareConcurrency", { configurable: true, value: 2 });
187 - vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout"] });
187 const initialize = WorkerPoolManager.prototype.initialize;
188 vi.spyOn(WorkerPoolManager.prototype, "initialize").mockImplementation(function (
189 this: WorkerPoolManager,
@@ -197,6 +196,7 @@ describe("code-view worker lifecycle", () => {
196 });
197
198 afterEach(async () => {
199 + if (!vi.isFakeTimers()) vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout"] });
200 await unmountAll();
201 await vi.runOnlyPendingTimersAsync();
202 vi.useRealTimers();
@@ -228,6 +228,9 @@ describe("code-view worker lifecycle", () => {
228 expect(pool.getFileResultCache(files[1]!)).toBeDefined();
229 await vi.waitFor(() => expect(codeFile("answer.ts")).toContain("answer"));
230
231 + // Worker startup uses real time. Only advance the clock once highlighting
232 + // has finished, so idle expiry cannot also expire a worker startup timer.
233 + vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout"] });
234 await view.render(renderViews(1));
235 expect(pool.getStats().totalWorkers).toBe(2);
236 expect(testState.terminations).toBe(0);
@@ -249,6 +252,7 @@ describe("code-view worker lifecycle", () => {
252 expect(pool.getStats().totalWorkers).toBe(0);
253 expect(testState.terminations).toBe(2);
254
255 + vi.useRealTimers();
256 await view.render(renderViews(1));
257 const reopenedPool = [...testState.pools.keys()][1]!;
258 await act(async () => testState.pools.get(reopenedPool));
@@ -277,6 +281,7 @@ describe("code-view worker lifecycle", () => {
281 });
282
283 it("keeps an initializing pool until its last view closes and ignores late responses", async () => {
284 + vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout"] });
285 testState.holdInitialization = true;
286 const held = new Promise<void>((resolve) => {
287 testState.onInitializationHeld = resolve;