mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-25 08:32:45 +00:00
test(studio): soft reload wait rows stop failing on a slow Windows runner (#8778)
This commit is contained in:
@@ -173,7 +173,7 @@ const STEPS: Record<Step, (preview: Preview, sealed: boolean) => Promise<unknown
|
||||
await p.frame.evaluate(
|
||||
() => new Promise((done) => requestAnimationFrame(() => requestAnimationFrame(done))),
|
||||
);
|
||||
pausedAt = Math.round((await p.time()) * 100) / 100;
|
||||
pausedAt = await p.time();
|
||||
},
|
||||
// Studio's editing port gives a request 5 s (editingPort.ts); the plugin stays held past that.
|
||||
late: () => new Promise((done) => setTimeout(done, 5_500)),
|
||||
@@ -233,7 +233,7 @@ async function play(mode: string, steps: Step[]) {
|
||||
const sealed = mode === "sealed";
|
||||
pausedAt = undefined;
|
||||
const preview = await openPreview(mode);
|
||||
const { page, frame, held, seek, time } = preview;
|
||||
const { page, frame, pluginRequested, seek, time } = preview;
|
||||
await seek(4);
|
||||
if (!sealed) await restoreLeftOfC(preview, sealed, 1);
|
||||
const older = rerun(
|
||||
@@ -243,7 +243,7 @@ async function play(mode: string, steps: Step[]) {
|
||||
sealed ? restoreC(1) : [],
|
||||
true,
|
||||
);
|
||||
await expect.poll(() => held.length).toBeGreaterThan(0);
|
||||
await pluginRequested;
|
||||
for (const step of steps) await STEPS[step](preview, sealed);
|
||||
const answer = await Promise.race([older, Promise.resolve("kept")]);
|
||||
const state = await frame.evaluate(() => {
|
||||
@@ -255,12 +255,16 @@ async function play(mode: string, steps: Step[]) {
|
||||
x: Math.round(new DOMMatrix(getComputedStyle(target).transform).m41),
|
||||
};
|
||||
});
|
||||
const at = Math.round((await time()) * 100) / 100;
|
||||
const now = await time();
|
||||
const at = Math.round(now * 100) / 100;
|
||||
const outcome = {
|
||||
answer,
|
||||
...state,
|
||||
at,
|
||||
...(pausedAt === undefined ? {} : { moved: Math.abs(at - pausedAt) > 1 / 30, pausedAt }),
|
||||
// The swap seeks to the frame at or below the paused time; only a whole frame or more is a move.
|
||||
...(pausedAt === undefined
|
||||
? {}
|
||||
: { moved: Math.abs(now - pausedAt) >= 1 / 30, pausedAt: Math.round(pausedAt * 100) / 100 }),
|
||||
};
|
||||
await page.close();
|
||||
return outcome;
|
||||
@@ -489,7 +493,7 @@ describe("late answers held in transit, sealed", () => {
|
||||
const older = rerun(p.page, timeline("main", "older", 60, true), 2, [], true).catch(
|
||||
() => "closed",
|
||||
);
|
||||
await expect.poll(() => p.held.length).toBeGreaterThan(0);
|
||||
await p.pluginRequested;
|
||||
await hold(p.page, true);
|
||||
await p.release(404);
|
||||
await expect.poll(() => heldCount(p.page)).toBe(1);
|
||||
@@ -504,7 +508,7 @@ describe("late answers held in transit, sealed", () => {
|
||||
it("re-runs the newest script when a patch refusal held across the swap arrives late", async () => {
|
||||
const p = await openPreview("sealed");
|
||||
void rerun(p.page, timeline("main", "older", 60, true), 2, [], true).catch(() => {});
|
||||
await expect.poll(() => p.held.length).toBeGreaterThan(0);
|
||||
await p.pluginRequested;
|
||||
await hold(p.page, true);
|
||||
await commit(p.page, timeline("main", "p1", 10), 10);
|
||||
await expect.poll(() => heldCount(p.page)).toBe(1);
|
||||
@@ -522,7 +526,7 @@ describe("late answers held in transit, sealed", () => {
|
||||
it("still recovers an older script refusal after an unrelated successful patch", async () => {
|
||||
const p = await openPreview("sealed");
|
||||
const older = rerun(p.page, timeline("main", "older", 60, true), 2, [], true);
|
||||
await expect.poll(() => p.held.length).toBeGreaterThan(0);
|
||||
await p.pluginRequested;
|
||||
await hold(p.page, true);
|
||||
await p.release(404);
|
||||
await expect.poll(() => heldCount(p.page)).toBe(1);
|
||||
@@ -536,7 +540,7 @@ describe("late answers held in transit, sealed", () => {
|
||||
it("still recovers an older run that times out after an attribute-only undo", async () => {
|
||||
const p = await openPreview("sealed");
|
||||
const older = rerun(p.page, timeline("main", "older", 60, true), 2, [], true);
|
||||
await expect.poll(() => p.held.length).toBeGreaterThan(0);
|
||||
await p.pluginRequested;
|
||||
expect(await undoLeftOfC(p.page, 5)).toBe("soft");
|
||||
await expect
|
||||
.poll(() => p.frame.evaluate(() => document.getElementById("c")!.style.left))
|
||||
|
||||
@@ -142,12 +142,16 @@ export async function openPreview(
|
||||
const plugin = readFileSync(require.resolve("gsap/dist/MotionPathPlugin.min.js"), "utf8");
|
||||
const held: HTTPRequest[] = [];
|
||||
let holding = true;
|
||||
let markRequested!: () => void;
|
||||
// A fresh Chrome's first intercepted request took up to 0.7 s on a Windows runner: await this, never a short poll.
|
||||
const pluginRequested = new Promise<void>((resolve) => (markRequested = resolve));
|
||||
await page.setRequestInterception(true);
|
||||
page.on("request", (request) => {
|
||||
const script = scripts[request.url()];
|
||||
if (script !== undefined)
|
||||
return void request.respond({ status: 200, contentType: "text/javascript", body: script });
|
||||
if (!/MotionPathPlugin/.test(request.url())) return void request.continue();
|
||||
markRequested();
|
||||
const serve = () =>
|
||||
request.respond({ status: 200, contentType: "text/javascript", body: plugin });
|
||||
if (holding) held.push(request);
|
||||
@@ -201,7 +205,7 @@ export async function openPreview(
|
||||
}, to);
|
||||
await expect.poll(time).toBeCloseTo(to, 2);
|
||||
};
|
||||
return { page, frame, held, release, seek, time };
|
||||
return { page, frame, pluginRequested, release, seek, time };
|
||||
}
|
||||
|
||||
export type Preview = Awaited<ReturnType<typeof openPreview>>;
|
||||
|
||||
Reference in New Issue
Block a user