/** * A wheel step on one axis of a music tab, once as a jump and once as a transition of 1000 ms (#377). * `read` returns `{ scale, moving }` – the zoom of that axis and whether a transition is on its way. * The step is taken back each time with the opposite wheel, so the view ends where it started. */ export async function sampleZoom(t, at, read, dy = -100) { const { evaluate, json, mouse, settle, wheel, waitUntil } = t; const now = () => json(read); await evaluate('__gm.zoomTransition(0)'); const start = await now(); await wheel(at.x, at.y, dy); const jumped = await now(); await wheel(at.x, at.y, -dy); const back = await now(); await evaluate('__gm.zoomTransition(1000)'); await mouse('mouseMoved', at.x, at.y); await mouse('mouseWheel', at.x, at.y, 'none', { deltaX: 0, deltaY: dy }); await settle(2); const midway = await now(); await waitUntil(`!(${read}).moving`, { label: 'the zoom transition ended' }); const landed = await now(); await evaluate('__gm.zoomTransition(0)'); await wheel(at.x, at.y, -dy); const between = (v, a, b) => v > Math.min(a, b) && v < Math.max(a, b); const ok = jumped.scale !== start.scale && Math.abs(back.scale - start.scale) < 1e-9 && midway.moving === true && between(midway.scale, start.scale, jumped.scale) && landed.moving === false && Math.abs(landed.scale - jumped.scale) < 1e-9; const samples = { start, jumped, back, midway, landed }; return { ok, samples, detail: JSON.stringify(samples) }; }