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(ui): stabilize two load-sensitive browser tests

Josh Corbettc84bb983ceca
diff --git a/invokeai/frontend/webv2/src/platform/ui/theme/ToastContrast.browser.test.tsx b/invokeai/frontend/webv2/src/platform/ui/theme/ToastContrast.browser.test.tsx
index 38569b8444..2b3adc1ead 100644
--- a/invokeai/frontend/webv2/src/platform/ui/theme/ToastContrast.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/platform/ui/theme/ToastContrast.browser.test.tsx
@@ -36,7 +36,12 @@ describe('toast contrast', () => {
);
});
await act(() => {
- toaster.create({ description: 'Layer thumbnail rasterization failed.', title: 'Error', type });
+ toaster.create({
+ description: 'Layer thumbnail rasterization failed.',
+ duration: Infinity,
+ title: 'Error',
+ type,
+ });
});
await expect.poll(() => document.querySelector('[data-part="description"]')).not.toBeNull();
const description = document.querySelector<HTMLElement>('[data-part="description"]')!;
@@ -93,6 +98,8 @@ describe('toast contrast', () => {
{ label: 'Retry', onClick: () => {} },
{ label: 'Show in Gallery', onClick: () => {} },
],
+ // Success toasts expire after 2s; a loaded machine can take longer to hover every button.
+ duration: Infinity,
title: 'Saved',
type,
});
diff --git a/invokeai/frontend/webv2/src/workbench/hotkeys/WorkbenchHotkeyRuntime.modal.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/hotkeys/WorkbenchHotkeyRuntime.modal.browser.test.tsx
index 18ea3a4b3f..fcf669824a 100644
--- a/invokeai/frontend/webv2/src/workbench/hotkeys/WorkbenchHotkeyRuntime.modal.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/hotkeys/WorkbenchHotkeyRuntime.modal.browser.test.tsx
@@ -16,7 +16,7 @@ import { WorkbenchFocusProvider } from '@workbench/WorkbenchRuntime';
import { createWorkbenchStore } from '@workbench/workbenchStore';
import { act, StrictMode, useCallback } from 'react';
import { createRoot, type Root } from 'react-dom/client';
-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { afterEach, beforeEach, describe, expect, it, onTestFinished, vi } from 'vitest';
import { page, userEvent } from 'vitest/browser';
/**
@@ -225,6 +225,12 @@ describe('WorkbenchHotkeyRuntime under a modal dialog', () => {
});
it('runs nothing behind for the Escape or Enter that closes a dialog, and the next press reaches it', async () => {
+ // The next press lands while the closed dialog is still animating out; on a loaded machine a real-length exit
+ // animation can end before then, so it is held for the whole test.
+ const holdExit = document.createElement('style');
+ holdExit.textContent = '[role="alertdialog"][data-state="closed"] { animation-duration: 3600s !important; }';
+ document.head.append(holdExit);
+ onTestFinished(() => holdExit.remove());
await openConfirm();
await userEvent.keyboard('{Escape}');
expect(ran).toEqual([]);