diff --git a/tools/e2e/47-vectorart.mjs b/tools/e2e/47-vectorart.mjs index dca12528..28919aee 100644 --- a/tools/e2e/47-vectorart.mjs +++ b/tools/e2e/47-vectorart.mjs @@ -1,6 +1,6 @@ import { colourDistance } from '../lib/harness.mjs'; import { FIND_HALVES, HALVES_LEFT, HALVES_RIGHT, PASTE_HALVES } from './lib/pictures.mjs'; -import { LANES, MAKE_OBJECT } from './lib/scaffold.mjs'; +import { inView, LANES, MAKE_OBJECT } from './lib/scaffold.mjs'; /** * Vector art (#129), stages 2 and 3: the drawing is rasterised and travels the picture path of #185. What @@ -574,9 +574,21 @@ export async function vectorArt(t) { ) ?? null ); }; + // The same as a hook expression, for a row the menu has to be scrolled to: the lowest hit between + // the box's sides, which is the entry and not the tab above it. + const menuRow = (text) => `(() => { + const box = __gm.overlayRect(); + const hits = (__gm.locateAll(${JSON.stringify(text)}) ?? []).filter( + (hit) => hit.x >= box.x && hit.x <= box.x + box.w && hit.y >= box.y, + ); + return hits.sort((a, b) => a.y - b.y).at(-1) ?? null; + })()`; + // Vector art is the last of the 25 entries the menu has since the Joint (#154); on a canvas 800 + // high the menu scrolls, and that one is scrolled to. await clickText('+'); const plusRows = (await json('__gm.menuRows()')) ?? []; + await inView(t, '__gm.overlayRect()', menuRow('Vector art')); const entry = await inOverlay('Vector art'); check( 'the + menu offers Vector art among the types that only live in the library',