Skip to content

Commit 8d5201b

Browse files
committed
test(check): runAuditGrid's analysis must use the progress-reporting driver
1 parent 16d930f commit 8d5201b

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

‎packages/cli/src/commands/check.test.ts‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { CheckProgress } from "../utils/checkProgress.js";
12
import { runCommand } from "citty";
23
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
34
import { tmpdir } from "node:os";
@@ -2280,6 +2281,40 @@ describe("check pipeline", () => {
22802281
}
22812282
});
22822283

2284+
it("slow analysis calls that each finish keep the check alive past 120 s", async () => {
2285+
vi.useFakeTimers();
2286+
try {
2287+
let analysing = false;
2288+
const slowWhenAnalysing = async () => {
2289+
if (analysing) await new Promise((resolve) => setTimeout(resolve, 100_000));
2290+
};
2291+
const hasNoTimelineDeclaration = vi.fn(async () => {
2292+
await slowWhenAnalysing();
2293+
return false;
2294+
});
2295+
const getCanvas = vi.fn(async () => {
2296+
await slowWhenAnalysing();
2297+
return { width: 1920, height: 1080 };
2298+
});
2299+
const driver = fakeDriver({ hasNoTimelineDeclaration, getCanvas });
2300+
const { deps } = dependencies(driver);
2301+
deps.runBrowserCheck = async (_project, options, motion, deadline) => {
2302+
deadline!.start();
2303+
const report: CheckProgress = (phase) => {
2304+
if (phase === "analyze") analysing = true;
2305+
};
2306+
return runAuditGrid(driver, options, motion, undefined, deadline!.enter, report);
2307+
};
2308+
const pending = runCheckPipeline(PROJECT, DEFAULT_CHECK_OPTIONS, deps);
2309+
await vi.advanceTimersByTimeAsync(2_000_000);
2310+
const codes = (await pending).runtime.findings.map((finding) => finding.code);
2311+
expect(codes).not.toContain("check_runtime_failure");
2312+
expect(hasNoTimelineDeclaration).toHaveBeenCalled();
2313+
} finally {
2314+
vi.useRealTimers();
2315+
}
2316+
});
2317+
22832318
it("a long overlap pass that keeps reporting progress finishes instead of hitting a wall clock", async () => {
22842319
vi.useFakeTimers();
22852320
try {

0 commit comments

Comments
 (0)