diff --git a/packages/cli/src/commands/validate.test.ts b/packages/cli/src/commands/validate.test.ts index 08277945b..1cc7ce36d 100644 --- a/packages/cli/src/commands/validate.test.ts +++ b/packages/cli/src/commands/validate.test.ts @@ -1,10 +1,11 @@ -import { describe, expect, it } from "vitest"; +import { describe, expect, it, vi } from "vitest"; import { extractCompositionErrorsFromLint, navigationTimeoutHint, raceMediaReady, resolveNavigationTimeoutMs, shouldIgnoreRequestFailure, + waitForPreferredSeekTarget, } from "./validate.js"; import type { ProjectLintResult } from "../utils/lintProject.js"; @@ -91,6 +92,28 @@ describe("shouldIgnoreRequestFailure", () => { }); }); +describe("waitForPreferredSeekTarget", () => { + it("waits for the runtime player/bridge target before falling back to raw timelines", async () => { + const page = { + waitForFunction: vi.fn(async () => undefined), + }; + + await waitForPreferredSeekTarget(page, 123); + + expect(page.waitForFunction).toHaveBeenCalledWith(expect.any(Function), { timeout: 123 }); + }); + + it("does not fail validation when only the legacy raw timeline fallback is available", async () => { + const page = { + waitForFunction: vi.fn(async () => { + throw new Error("waiting failed: timeout"); + }), + }; + + await expect(waitForPreferredSeekTarget(page, 1)).resolves.toBeUndefined(); + }); +}); + describe("extractCompositionErrorsFromLint", () => { // `bundleToSingleHtml` (the inliner validate.ts bundles through) is // intentionally tolerant of missing/empty/unparsable data-composition-src diff --git a/packages/cli/src/commands/validate.ts b/packages/cli/src/commands/validate.ts index 29ecf80af..9b20f9b97 100644 --- a/packages/cli/src/commands/validate.ts +++ b/packages/cli/src/commands/validate.ts @@ -32,6 +32,7 @@ interface ContrastEntry { const CONTRAST_SAMPLES = 5; const SEEK_SETTLE_MS = 150; +const PREFERRED_SEEK_TARGET_WAIT_MS = 500; const MEDIA_EXTENSIONS = /\.(aac|flac|m4a|mov|mp3|mp4|oga|ogg|wav|webm)$/i; // Floor for the initial page navigation. A blocking external