Skip to content

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.

test(webv2): wait for the new-from-image submenu instead of sleeping

Lincoln Stein425808da1c84
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.tsx
index edd838da51..639947cbd1 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
@@ -303,16 +303,19 @@ 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.
+ // 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' }))
);
- await act(
+ await settleUntil(
() =>
- new Promise<void>((resolve) => {
- globalThis.setTimeout(resolve, 300);
- })
+ Array.from(document.querySelectorAll('[role="menuitem"]')).some(
+ (candidate) => candidate.textContent?.trim() === 'widgets.canvas.import.newCanvasFromImage'
+ ),
+ 'the new-from-image submenu to open',
+ 5000
);
await interact(() => getMenuItem('widgets.canvas.import.newCanvasFromImage').click());