Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
test(webv2): hover the submenu trigger the way zag recognises
Lincoln Steinc89b9e115bc3
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/ImageContextMenu.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/image-actions/ImageContextMenu.browser.test.tsxindex 639947cbd1..73dd737192 100644--- a/invokeai/frontend/webv2/src/workbench/image-actions/ImageContextMenu.browser.test.tsx+++ b/invokeai/frontend/webv2/src/workbench/image-actions/ImageContextMenu.browser.test.tsx@@ -94,22 +94,29 @@ const settleUntil = async (isSettled: () => boolean, description: string, timeou}};-/** Quick icon items select through zag, which needs the item highlighted by a hover before the click. */-const pickQuickItem = async (label: string): Promise<void> => {- const target = document.querySelector<HTMLElement>(`[aria-label="${label}"]`);- expect(target).not.toBeNull();- // zag only treats a move as a real hover when the pointer position changes,- // so approach the item's center from one pixel away instead of a static point.- const rect = target!.getBoundingClientRect();+/**+ * Hovers an item the way zag recognises. zag only treats a move as a real hover when the pointer position changes,+ * so approach the item's center from one pixel away instead of dispatching a static point, which reads as no move+ * at all whenever zag's last recorded position is already there.+ */+const hoverItem = async (target: HTMLElement): Promise<void> => {+ const rect = target.getBoundingClientRect();const clientX = rect.left + rect.width / 2;const clientY = rect.top + rect.height / 2;await interact(() => {for (const x of [clientX - 1, clientX]) {- target!.dispatchEvent(+ target.dispatchEvent(new PointerEvent('pointermove', { bubbles: true, clientX: x, clientY, pointerType: 'mouse' }));}});+};++/** Quick icon items select through zag, which needs the item highlighted by a hover before the click. */+const pickQuickItem = async (label: string): Promise<void> => {+ const target = document.querySelector<HTMLElement>(`[aria-label="${label}"]`);+ expect(target).not.toBeNull();+ await hoverItem(target!);// Wait for Zag's asynchronous highlight before clicking; unhighlighted items ignore clicks.await settleUntil(() => target!.hasAttribute('data-highlighted'), `"${label}" to be highlighted`);await interact(() => target!.click());@@ -303,12 +310,9 @@ describe('ImageContextMenu new canvas from image', () => {const images = Array.from({ length: count }, (_, index) => image(`image-${index}.png`));await renderMenu(actions, images);- // A nested menu opens from a mouse hover on its trigger item, after zag's open delay. Waited for rather than- // slept through: on a loaded CI runner the submenu can take longer than any fixed delay to appear.- const trigger = getMenuItem('widgets.canvas.import.newFromImage');- await interact(() =>- trigger.dispatchEvent(new PointerEvent('pointermove', { bubbles: true, pointerType: 'mouse' }))- );+ // A nested menu opens from a real hover on its trigger item, after zag's open delay, so the open is waited for+ // rather than slept through.+ await hoverItem(getMenuItem('widgets.canvas.import.newFromImage'));await settleUntil(() =>Array.from(document.querySelectorAll('[role="menuitem"]')).some(