mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
feat(cli): check_report names the finding that stopped the check (#7305)
* feat(cli): check_report names the finding that stopped the check * fix(cli): type stop_code as a closed union instead of a comment
This commit is contained in:
@@ -2562,6 +2562,9 @@ describe("check pipeline", () => {
|
||||
expect(reached?.message).toMatch(
|
||||
/^Check reached its --budget of 70 s while running the overlap pass .*Seconds per phase: /,
|
||||
);
|
||||
expect(trackCheckReport).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ ok: false, stopCode: "check_budget_reached" }),
|
||||
);
|
||||
expect(report.ok).toBe(false);
|
||||
expect(report.layout.findings.some((finding) => finding.code === "container_overflow")).toBe(
|
||||
true,
|
||||
@@ -3626,6 +3629,7 @@ describe("check report telemetry", () => {
|
||||
}),
|
||||
);
|
||||
expect(report.contrast.errorCount).toBe(1);
|
||||
expect(trackCheckReport.mock.calls[0]?.[0].stopCode).toBeUndefined();
|
||||
});
|
||||
|
||||
it("reports zero browser samples and timings after a lint short circuit", async () => {
|
||||
|
||||
@@ -167,6 +167,46 @@ describe("trackCheckReport", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("names the finding that stopped the check, and omits it when none did", () => {
|
||||
const props = {
|
||||
contrastGate: false,
|
||||
motionGate: false,
|
||||
captionZoneGate: false,
|
||||
frameCheckGate: false,
|
||||
snapshotsGate: false,
|
||||
lintErrors: 0,
|
||||
lintWarnings: 0,
|
||||
runtimeErrors: 1,
|
||||
runtimeWarnings: 0,
|
||||
layoutErrors: 0,
|
||||
layoutWarnings: 0,
|
||||
motionErrors: 0,
|
||||
motionWarnings: 0,
|
||||
contrastErrors: 0,
|
||||
contrastWarnings: 0,
|
||||
craftWarnings: 0,
|
||||
launchSettleMs: 0,
|
||||
renderReadyTimedOut: false,
|
||||
seekLoopMs: 0,
|
||||
contrastMs: 0,
|
||||
gridMs: 0,
|
||||
craftMs: 0,
|
||||
overlapMs: 0,
|
||||
durationSec: 0,
|
||||
gridPoints: 0,
|
||||
contrastPoints: 0,
|
||||
ok: false,
|
||||
exitCode: 1,
|
||||
};
|
||||
trackCheckReport({ ...props, stopCode: "media_copies_unfinished" });
|
||||
expect(trackEvent).toHaveBeenLastCalledWith(
|
||||
"check_report",
|
||||
expect.objectContaining({ stop_code: "media_copies_unfinished" }),
|
||||
);
|
||||
trackCheckReport(props);
|
||||
expect(trackEvent.mock.calls.at(-1)?.[1]).not.toHaveProperty("stop_code");
|
||||
});
|
||||
|
||||
it("omits run_id when no run ID is provided", () => {
|
||||
trackCheckReport({
|
||||
contrastGate: false,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { BrowserInstallFacts } from "../browser/installFacts.js";
|
||||
import type { StopCode } from "../utils/checkPipeline.js";
|
||||
import type { OutputResolutionIssueKind } from "@hyperframes/core";
|
||||
import { redactTelemetryString } from "@hyperframes/core/telemetry-redaction";
|
||||
import type { SubTimelineWaitOutcome } from "@hyperframes/engine";
|
||||
@@ -1193,6 +1194,7 @@ export function trackCheckReport(props: {
|
||||
contrastPoints: number;
|
||||
ok: boolean;
|
||||
exitCode: number;
|
||||
stopCode?: StopCode;
|
||||
runId?: string;
|
||||
}): void {
|
||||
trackEvent("check_report", {
|
||||
@@ -1224,6 +1226,7 @@ export function trackCheckReport(props: {
|
||||
contrast_points: props.contrastPoints,
|
||||
ok: props.ok,
|
||||
exit_code: props.exitCode,
|
||||
...(props.stopCode && { stop_code: props.stopCode }),
|
||||
...runIdField(props.runId),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2130,6 +2130,9 @@ function buildReport(
|
||||
contrastPoints: browser.contrastChecked,
|
||||
ok: report.ok,
|
||||
exitCode: checkExitCode(report),
|
||||
stopCode: browser.runtimeFindings
|
||||
.map((finding) => finding.code)
|
||||
.find((code): code is StopCode => (STOP_CODES as readonly string[]).includes(code)),
|
||||
runId: getRunId(),
|
||||
});
|
||||
return filterComponentReport(report, options);
|
||||
@@ -2264,6 +2267,13 @@ function emptyBrowserResult(): CheckBrowserResult {
|
||||
};
|
||||
}
|
||||
|
||||
export const STOP_CODES = [
|
||||
"media_copies_unfinished",
|
||||
"check_budget_reached",
|
||||
"check_runtime_failure",
|
||||
] as const;
|
||||
export type StopCode = (typeof STOP_CODES)[number];
|
||||
|
||||
function runtimeFailure(error: unknown, code?: string): CheckFinding {
|
||||
return findingAtRoot(
|
||||
code ??
|
||||
|
||||
Reference in New Issue
Block a user