Skip to content

Commit a523981

Browse files
committed
fix(cli): a check stopped by the copy wait stays browserSkipped; count only abort-caused unfinished
1 parent 5cbc9a1 commit a523981

4 files changed

Lines changed: 26 additions & 4 deletions

File tree

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ import { contrastRatio, parseColorRGBA } from "./contrast-bg.js";
1616
import { createCheckCommand, parseCheckRange } from "./check.js";
1717
import { assertKnownFlags } from "../utils/reject-unknown-flags.js";
1818
import { readConfig } from "../telemetry/config.js";
19-
import { CheckDeadlineError, CheckStoppedError } from "../utils/checkDeadline.js";
19+
import {
20+
CheckCopiesUnfinishedError,
21+
CheckDeadlineError,
22+
CheckStoppedError,
23+
} from "../utils/checkDeadline.js";
2024
import { trackCommandFailures } from "../utils/command-failure-tracking.js";
2125
import type { CommandDef } from "citty";
2226

@@ -3612,6 +3616,20 @@ describe("check report telemetry", () => {
36123616
expect(report.ok).toBe(true);
36133617
});
36143618

3619+
it("a check stopped by the copy wait still sends the copy facts and stays browserSkipped", async () => {
3620+
const { deps } = dependencies(fakeDriver());
3621+
deps.runBrowserCheck = async (_project, _options, _motion, deadline) => {
3622+
deadline?.keepPartial(() => ({ mediaCopies: { total: 47, waitedMs: 120_000, unfinished: 12 } }));
3623+
throw new CheckCopiesUnfinishedError(120_000, ["a.mp4 40%"]);
3624+
};
3625+
const report = await runCheckPipeline(PROJECT, DEFAULT_CHECK_OPTIONS, deps);
3626+
3627+
expect(report.browserSkipped).toBe(true);
3628+
expect(trackCheckReport).toHaveBeenCalledWith(
3629+
expect.objectContaining({ mediaCopies: { total: 47, waitedMs: 120_000, unfinished: 12 } }),
3630+
);
3631+
});
3632+
36153633
it("reports one failing contrast run with its section error count", async () => {
36163634
const collectContrast = vi.fn(async (time: number) => ({
36173635
entries: time === 0.5 ? [contrastEntry()] : [],

‎packages/cli/src/utils/checkBrowser.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,11 @@ export async function preResolveHostileMediaProxies(
334334
const unfinished = sources.flatMap(({ file }, index) =>
335335
results[index]!.status === "rejected" ? [`${file} ${heartbeat.percent(index)}`] : [],
336336
);
337-
record?.({ total, waitedMs: Date.now() - startedAt, unfinished: unfinished.length });
337+
record?.({
338+
total,
339+
waitedMs: Date.now() - startedAt,
340+
unfinished: overBudget === undefined ? 0 : unfinished.length,
341+
});
338342
if (overBudget !== undefined && unfinished.length > 0) {
339343
throw new CheckCopiesUnfinishedError(overBudget, unfinished);
340344
}

‎packages/cli/src/utils/checkPipeline.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1747,7 +1747,8 @@ export async function runCheckPipeline(
17471747
);
17481748
} catch (error) {
17491749
const found = deadline.partialResult();
1750-
browser = { ...emptyBrowserResult(), ...found, skipped: Object.keys(found).length === 0 };
1750+
const ran = Object.keys(found).filter((key) => key !== "mediaCopies");
1751+
browser = { ...emptyBrowserResult(), ...found, skipped: ran.length === 0 };
17511752
browser.runtimeFindings = [...browser.runtimeFindings, runtimeFailure(error)];
17521753
}
17531754

‎packages/cli/src/utils/checkTypes.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ export interface CheckTimings {
322322
overlapMs: number;
323323
}
324324

325-
/** What a check's browser-playable copies cost: videos, ms waited, videos not done. */
326325
export interface MediaCopyFacts {
327326
total: number;
328327
waitedMs: number;

0 commit comments

Comments
 (0)