Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions packages/studio/tests/e2e/edit-accuracy/case.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -719,15 +719,9 @@ async function waitingQuad(page, map) {
}

/** The box as the preview shows it: the waiting marker's quad while a press waits for its replay, else the element. */
export async function measureShown(
ctx,
gesture,
read = measure,
quadOf = contentQuad,
pointerMoved = true,
) {
export async function measureShown(ctx, gesture, read = measure, quadOf = contentQuad) {
for (;;) {
const waiting = pointerMoved ? await ctx.page.$("[data-dom-edit-press-waiting]") : null;
const waiting = await ctx.page.$("[data-dom-edit-press-waiting]");
try {
const m = await read(ctx);
if (gesture === "crop") m.outline = await cropOutline(ctx, m.map);
Expand All @@ -746,8 +740,8 @@ export async function measureShown(
}
}

export async function sample(ctx, gesture, point, pointerScreen, pointerMoved = true) {
const { m, actual } = await measureShown(ctx, gesture, measure, contentQuad, pointerMoved);
export async function sample(ctx, gesture, point, pointerScreen) {
const { m, actual } = await measureShown(ctx, gesture);
return { m, actual, p: point(m), c: m.map.toComp(pointerScreen) };
}

Expand Down Expand Up @@ -935,7 +929,7 @@ export async function pointerGesture(ctx, gesture, pre, route) {
traceBench("press", { gesture });
await ctx.page.mouse.down();
await nextFrame(ctx.page);
const s0 = await sample(ctx, gesture, g.point, press, false);
const s0 = await sample(ctx, gesture, g.point, press);
traceBench("pressed", { gesture, jump: pre && quadDistance(s0.m.visible, pre.visible) });
await recording(ctx.page, true);
const errors = [];
Expand Down
12 changes: 0 additions & 12 deletions packages/studio/tests/e2e/edit-accuracy/settle.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,6 @@ describe("the box a press is measured against", () => {
expect(shown.actual[0][0]).toBe(0);
});

// fails without the fix: the press itself read the waiting outline, so a sealed press jumped 0.2 px.
it("reads the element at the press, before the pointer moves", async () => {
const shown = await measureShown(
{ page: page([marker([true])]) },
"move",
read,
async () => quad(260),
false,
);
expect(shown.m.visible[0][0]).toBe(0);
});

it("reads the element when nothing waits", async () => {
const shown = await measureShown({ page: page([]) }, "move", read, async () => quad(260));
expect(shown.m.visible[0][0]).toBe(0);
Expand Down
17 changes: 3 additions & 14 deletions packages/studio/tests/e2e/edit-accuracy/teleport.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -444,23 +444,12 @@ function trackers(gesture, first, p0) {

const round = (v) => Math.round(v * 100) / 100;

/** A waiting box follows the pointer once it moves; until then it is Studio's resting outline: the element is read. */
function untilPointerMoves(frames) {
const [x, y] = frames[0]?.pointer ?? [];
const moved = frames.findIndex((f) => f.pointer[0] !== x || f.pointer[1] !== y);
return frames.map((f, i) =>
f.waitingQuad && (moved < 0 || i < moved) ? { ...f, waitingQuad: undefined } : f,
);
}

/** Fails a frame whose tracked point outran the pointer or left its path; after release, the release point. */
// fallow-ignore-next-line complexity
export function scoreTeleport(gesture, samples) {
const frames = untilPointerMoves(
samples
.filter((s) => s.quad && s.root && s.pointer)
.map((s) => ({ ...s, map: compositionMapper(s.root, COMPOSITION) })),
);
const frames = samples
.filter((s) => s.quad && s.root && s.pointer)
.map((s) => ({ ...s, map: compositionMapper(s.root, COMPOSITION) }));
if (frames.length < 2) {
const count = (f) => samples.filter(f).length;
const failed = samples.find((s) => s.error)?.error;
Expand Down
5 changes: 0 additions & 5 deletions packages/studio/tests/e2e/edit-accuracy/teleport.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ describe("scoreTeleport", () => {
pass: true,
});
});
// fails without the fix: a sealed press anchored on Studio's outline, which sits off the element in both modes.
it("scores a press that waits with the pointer still like one that never waited", () => {
const sealed = drag.map((f, i) => (i < 2 ? { ...f, waitingQuad: box(0.2) } : f));
expect(scoreTeleport("move", sealed).max).toBe(scoreTeleport("move", drag).max);
});
it("rejects a jumping outline while the element waits", () => {
const jumped = waitingDrag.map((f, i) => (i === 4 ? { ...f, waitingQuad: box(f.t + 37) } : f));
expect(scoreTeleport("move", [...jumped, frame(50, false)]).pass).toBe(false);
Expand Down
Loading