mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
fix(catalog): payload check treats the optional caption-overrides.json as absent, not failed (#7813)
* fix(registry): catalog payload check passes a missing caption-overrides.json The runtime requests an optional caption-overrides.json on any page with a .caption-group and reads a 404 as "no overrides". The docs host has no such file, so every caption payload that uses .caption-group (caption-emoji-pop, caption-neon-accent, caption-pill-karaoke, caption-weight-shift) failed verify:catalog-payloads with a 404, its console line, and an aborted request. The check only ran on those payloads once a change regenerated them. The verifier now sets that miss aside, as `hyperframes validate` already does through shouldIgnoreHttpError. A non-404 status, any other failure on that URL, and an invalid overrides file still fail. To match the console line by URL, checkPageLoads now appends the resource URL to Chrome's "Failed to load resource" message, whose text leaves it out. * style(producer): name the failed resource URL instead of commenting it
This commit is contained in:
@@ -37,7 +37,13 @@ export async function checkPageLoads(
|
||||
failures.push(`pageerror: ${err instanceof Error ? err.message : String(err)}`);
|
||||
});
|
||||
page.on("console", (msg) => {
|
||||
if (msg.type() === "error") failures.push(`console.error: ${msg.text()}`);
|
||||
if (msg.type() !== "error") return;
|
||||
const failedResourceUrl = msg.text().startsWith("Failed to load resource")
|
||||
? msg.location().url
|
||||
: "";
|
||||
failures.push(
|
||||
`console.error: ${msg.text()}${failedResourceUrl ? ` (${failedResourceUrl})` : ""}`,
|
||||
);
|
||||
});
|
||||
try {
|
||||
await page.goto(originUrl, { waitUntil: "domcontentloaded" });
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
declaresWebgpu,
|
||||
itemsFromDiff,
|
||||
withoutAbortedMedia,
|
||||
withoutMissingCaptionOverrides,
|
||||
parsePayload,
|
||||
remainingFailures,
|
||||
withoutWebgpuAbsence,
|
||||
@@ -94,6 +95,26 @@ describe("withoutAbortedMedia", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("withoutMissingCaptionOverrides", () => {
|
||||
it("drops the runtime's missing caption-overrides.json and keeps every other failure", () => {
|
||||
const url = "http://localhost:4000/caption-overrides.json";
|
||||
const miss = [
|
||||
`404 GET ${url}`,
|
||||
`console.error: Failed to load resource: the server responded with a status of 404 (Not Found) (${url})`,
|
||||
`request failed: ${url} (net::ERR_ABORTED)`,
|
||||
];
|
||||
const kept = [
|
||||
`500 GET ${url}`,
|
||||
`request failed: ${url} (net::ERR_NAME_NOT_RESOLVED)`,
|
||||
"404 GET http://localhost:4000/public/catalog/caption-overrides.json.png",
|
||||
"404 GET http://localhost:4000/assets/caption-overrides.json",
|
||||
"console.error: Failed to load resource: the server responded with a status of 404 (Not Found) (http://localhost:4000/x.png)",
|
||||
"console.error: [HyperFrames] Invalid caption-overrides.json: expected an array",
|
||||
];
|
||||
assert.deepEqual(withoutMissingCaptionOverrides([...miss, ...kept]), kept);
|
||||
});
|
||||
});
|
||||
|
||||
it("browser selection includes regenerated edits and new untracked payloads", (t) => {
|
||||
const root = mkdtempSync(join(tmpdir(), "catalog-selection-"));
|
||||
t.after(() => rmSync(root, { recursive: true, force: true }));
|
||||
|
||||
@@ -96,7 +96,36 @@ export function withoutWebgpuAbsence(webgpu: boolean, failures: string[]): strin
|
||||
|
||||
/** What still counts as a failure for one item once the environment's own noise is set aside. */
|
||||
export function remainingFailures(kindDir: string, item: string, failures: string[]): string[] {
|
||||
return withoutAbortedMedia(withoutWebgpuAbsence(declaresWebgpu(kindDir, item), failures));
|
||||
return withoutMissingCaptionOverrides(
|
||||
withoutAbortedMedia(withoutWebgpuAbsence(declaresWebgpu(kindDir, item), failures)),
|
||||
);
|
||||
}
|
||||
|
||||
const CAPTION_OVERRIDES_MISS = [
|
||||
/^404 GET (\S+)$/,
|
||||
/^request failed: (\S+) \(net::ERR_ABORTED\)$/,
|
||||
/^console\.error: Failed to load resource: the server responded with a status of 404 \(Not Found\) \((\S+)\)$/,
|
||||
];
|
||||
|
||||
function isCaptionOverridesUrl(url: string): boolean {
|
||||
try {
|
||||
return new URL(url).pathname === "/caption-overrides.json";
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** The runtime asks for an optional caption-overrides.json on any page with a .caption-group and
|
||||
* reads a 404 as "no overrides"; the docs host has none. `hyperframes validate` passes the same
|
||||
* miss (shouldIgnoreHttpError). Any other status, or an invalid file, still counts. */
|
||||
export function withoutMissingCaptionOverrides(failures: string[]): string[] {
|
||||
return failures.filter(
|
||||
(failure) =>
|
||||
!CAPTION_OVERRIDES_MISS.some((pattern) => {
|
||||
const url = pattern.exec(failure)?.[1];
|
||||
return url !== undefined && isCaptionOverridesUrl(url);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export type Payload = { kind: "live"; html: string } | { kind: "marker"; reason: string };
|
||||
|
||||
Reference in New Issue
Block a user