mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-08 10:46:06 +00:00
chore(engine): add capture navigation timeout diagnostics (#1238)
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { isFontResourceError } from "./frameCapture.js";
|
||||
import {
|
||||
formatHttpErrorDiagnostic,
|
||||
formatNavigationFailureDiagnostic,
|
||||
formatRequestFailureDiagnostic,
|
||||
isFontResourceError,
|
||||
sanitizeDiagnosticUrl,
|
||||
} from "./frameCapture.js";
|
||||
|
||||
describe("isFontResourceError", () => {
|
||||
it("matches Google Fonts CSS load failures via location.url", () => {
|
||||
@@ -110,3 +116,62 @@ describe("isFontResourceError", () => {
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("navigation diagnostics", () => {
|
||||
it("redacts credentials, query strings, and fragments from diagnostic URLs", () => {
|
||||
expect(
|
||||
sanitizeDiagnosticUrl("https://user:pass@example.com/assets/video.mp4?token=secret#frag"),
|
||||
).toBe("https://example.com/assets/video.mp4");
|
||||
});
|
||||
|
||||
it("redacts data and blob URLs", () => {
|
||||
expect(sanitizeDiagnosticUrl("data:image/png;base64,abc123")).toBe("data:<redacted>");
|
||||
expect(sanitizeDiagnosticUrl("blob:https://example.com/abc123")).toBe("blob:<redacted>");
|
||||
});
|
||||
|
||||
it("redacts query strings from relative URLs", () => {
|
||||
expect(sanitizeDiagnosticUrl("/relative/path.png?token=secret#frag")).toBe(
|
||||
"/relative/path.png",
|
||||
);
|
||||
});
|
||||
|
||||
it("formats page.goto failures with mode, timeout, elapsed time, and sanitized URL", () => {
|
||||
const diagnostic = formatNavigationFailureDiagnostic({
|
||||
captureMode: "screenshot",
|
||||
url: "http://127.0.0.1:4173/index.html?claim_token=secret",
|
||||
timeoutMs: 60_000,
|
||||
elapsedMs: 60_123,
|
||||
error: new Error("Navigation timeout of 60000 ms exceeded"),
|
||||
});
|
||||
|
||||
expect(diagnostic).toContain("[FrameCapture:ERROR] page.goto failed");
|
||||
expect(diagnostic).toContain("mode=screenshot");
|
||||
expect(diagnostic).toContain("timeoutMs=60000");
|
||||
expect(diagnostic).toContain("elapsedMs=60123");
|
||||
expect(diagnostic).toContain("url=http://127.0.0.1:4173/index.html");
|
||||
expect(diagnostic).not.toContain("claim_token");
|
||||
});
|
||||
|
||||
it("formats request and HTTP failures with sanitized URLs", () => {
|
||||
expect(
|
||||
formatRequestFailureDiagnostic({
|
||||
method: "GET",
|
||||
resourceType: "media",
|
||||
url: "https://cdn.example.com/video.mp4?token=secret",
|
||||
failureText: "net::ERR_FAILED",
|
||||
}),
|
||||
).toBe(
|
||||
"[Browser:REQUESTFAILED] GET https://cdn.example.com/video.mp4 resource=media error=net::ERR_FAILED",
|
||||
);
|
||||
|
||||
expect(
|
||||
formatHttpErrorDiagnostic({
|
||||
method: "GET",
|
||||
resourceType: "image",
|
||||
url: "https://cdn.example.com/frame.png?token=secret",
|
||||
status: 403,
|
||||
statusText: "Forbidden",
|
||||
}),
|
||||
).toBe("[Browser:HTTP403] GET https://cdn.example.com/frame.png resource=image Forbidden");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user