Files
Miguel Ángel 70ed332a45 test(studio): score edits on GSAP-animated size, scale, rotation and keyframes (#4866)
* test(studio): score edits on GSAP-animated size, scale, rotation, keyframes and from/fromTo

* test(studio): settle the edit bench only once no shadow preview is waiting to be swapped in

* test(studio): end a drag at its recorded pointer-up, even when no frame painted while held

* ci(studio): run the keyframed edit accuracy cases in CI across 20 shards

* refactor(studio): split the keyframe render and stray-css checks into small helpers

* test(studio): bank the edit bench's smooth verdict as smooth, judged on the worst frame's work

* style(studio): name the edit gate's smooth count helper

* test(studio): count smooth edit cases only among the accurate ones

* test(studio): only keyframed cases wait for the preview swap, so others keep main's undo timing

* refactor(studio): keep the edit bench's keyframe check apart from the hidden preview scan

* test(studio): check the keyframed cases are in the full grid without pinning its size

* test(studio): quarantine the nudge sequence whose redo waits behind preview videos (#4889)

* test(studio): bank the 255 keyframed edit cases that pass
2026-10-02 03:26:08 -07:00

48 lines
1.8 KiB
JavaScript

import { describe, expect, it } from "vitest";
import { swapPending, unsettledBy } from "./case.mjs";
describe("settling on the shown preview", () => {
const read = (pending, x = 0, frames = "a") => ({
pending,
frames,
m: {
visible: [
[x, 0],
[x + 1, 0],
[x + 1, 1],
[x, 1],
],
},
});
it("keeps waiting while a shadow preview is loading, and restarts once it is promoted", () => {
expect(unsettledBy(read(false), read(false))).toBe(false);
expect(unsettledBy(read(false), read(true))).toBe(true);
expect(unsettledBy(read(true), read(false))).toBe(true);
expect(unsettledBy(read(false), read(false, 0.02))).toBe(true);
});
const frame = (url, shown, holds) => ({
url: () => url,
frameElement: async () => ({ evaluate: async () => shown }),
$: async () => (holds ? {} : null),
});
const keys = { times: [0, 3] };
const page = (...frames) => ({ frames: () => frames });
const swapping = page(frame("/preview/a", true, true), frame("/preview/a?_t=1", false, true));
it("calls a swap pending only for a hidden preview that holds the target", async () => {
expect(await swapPending({ page: page(frame("/preview/a", true, true)), keys })).toBe(false);
expect(await swapPending({ page: swapping, keys })).toBe(true);
expect(await swapPending({ page: page(frame("/preview/a?_t=1", false, false)), keys })).toBe(
false,
);
expect(await swapPending({ page: page(frame("/studio", false, true)), keys })).toBe(false);
});
it("never waits on a swap in a case without keyframes, so its undo keeps main's timing", async () => {
expect(await swapPending({ page: swapping })).toBe(false);
expect(await swapPending({ page: swapping, keys: undefined, selector: "#other" })).toBe(false);
});
});