Files
feuerwerk/tools/e2e/11-menus.mjs
T
rootandClaude Opus 5 5a6af74e44 Add textures for sprites
Images are uploaded to a content-addressed blob endpoint and stored as
data/textures/<sha256>.<ext>; the project only keeps the file name. The
sprite points at a texture asset through an ordinary property of the new
kind `asset`, so instance overrides, "Apply to container", "Reset to
asset", undo and `Set property` work without any extra code. The new kind
also replaces the ad-hoc asset picker the graph nodes faked as an enum.

Import goes through + -> Texture, drag & drop onto the canvas or Ctrl+V.
Images wider than 2048px are downscaled client-side and re-encoded to
WebP if needed, because nginx caps uploads at 1MB; an image that already
fits is uploaded byte for byte so pixel art is never resampled.

The sprite colour default changes from red to white, since colour tints
the texture multiplicatively and a tint of white shows an image as it is.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-08 13:43:08 +02:00

70 lines
3.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Menus that can grow with the project. Runs last: it fills the scene with throwaway objects
* to make the parent picker overflow, which the earlier steps' object counts would not survive.
*/
export async function menus(t) {
const { check, sleep, json, shot, click, locate, mouse, mutate } = t;
await mutate(`
const scene = __gm.state.activeScene;
const source = scene.objects.find(o => o.id === 'o1');
for (let i = 1; i <= 40; i++) {
const copy = structuredClone(source);
copy.id = 'filler' + i;
copy.name = 'Filler ' + i;
copy.parentId = '';
scene.objects.push(copy);
}
__gm.state.select({ kind: 'object', sceneId: 'scene1', objectIds: ['otext'], objectId: 'otext' })`);
await sleep(150);
// 18. A picker with 40+ entries is capped in height and stays fully on screen instead of
// running off the bottom edge.
// The dropdown sits right of the 64 px label column; locate() gives the label's text centre.
const parentRow = await locate('Parent');
await click(parentRow.x + 55, parentRow.y);
const rect = await json('__gm.overlayRect()');
const screenHeight = await json('window.innerHeight');
check(
'a long parent picker is capped instead of growing with the object count',
rect && rect.h < 420,
JSON.stringify(rect),
);
check(
'the capped picker stays fully on screen',
rect && rect.y >= 0 && rect.y + rect.h <= screenHeight,
JSON.stringify({ rect, screenHeight }),
);
await shot('31-long-parent-menu');
// 18a. The entries scroll under the wheel; the search box above them does not move.
//
// Anchored on a filler row rather than the list's "None" entry: "None" is also what an empty
// dropdown reads, so `locate('None', true)` could just as well find a *field* in the
// inspector behind the menu – one that never moves, whatever the wheel does. "Filler 1"
// exists only inside this list.
const firstBefore = await locate('Filler 1', true);
const searchBefore = await locate('Search…', true);
// Move onto the list before turning the wheel. A wheel event is delivered to whatever is
// *hovered*, and the last thing the pointer touched was the field above the menu – without
// this the scroll is routed at that field instead, which is what a user could never do.
await mouse('mouseMoved', rect.x + rect.w / 2, rect.y + rect.h / 2);
await sleep(50);
await mouse('mouseWheel', rect.x + rect.w / 2, rect.y + rect.h / 2, 'none', { deltaX: 0, deltaY: 240 });
// Read twice, and wait properly. The scroll lands a frame or two later than one might
// expect: measured here, the list had not moved 40 ms after the wheel and had moved at
// 340 ms. A single early reading made this check fail in the full suite while passing on
// its own — the two readings keep that visible instead of turning it back into a mystery.
await sleep(40);
const rightAfter = await locate('Filler 1', true);
await sleep(300);
const firstAfter = await locate('Filler 1', true);
const searchAfter = await locate('Search…', true);
check(
'the wheel scrolls the entries',
firstAfter.y < firstBefore.y - 100,
JSON.stringify({ firstBefore, rightAfter, firstAfter }),
);
check('the search box stays put while the entries scroll', searchAfter.y === searchBefore.y);
}