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.

fix(tests): stabilize browser interactions and Windows dtype checks

Josh Corbett42492c335945
diff --git a/invokeai/frontend/webv2/scripts/browser-test-viewport.ts b/invokeai/frontend/webv2/scripts/browser-test-viewport.ts
index 1262cbb182..5fe892373a 100644
--- a/invokeai/frontend/webv2/scripts/browser-test-viewport.ts
+++ b/invokeai/frontend/webv2/scripts/browser-test-viewport.ts
@@ -1,4 +1,11 @@
import { beforeEach } from 'vitest';
+import { server } from 'vitest/browser';
+
+declare module 'vitest/browser' {
+ interface BrowserCommands {
+ resetBrowserPointer: () => Promise<void>;
+ }
+}
/**
* Start every browser test with the pages around the test iframe scrolled to the origin.
@@ -9,7 +16,8 @@ import { beforeEach } from 'vitest';
* action on them times out (FeatureHint's corner parking element fails all five of its tests this way). The test's
* own document is left alone: its scroll belongs to the test.
*/
-beforeEach(() => {
+beforeEach(async () => {
+ await server.commands.resetBrowserPointer();
let frame: Window = window;
while (frame.parent !== frame) {
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.browser.test.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.browser.test.tsx
index 1ac2718156..baf1bfa5d6 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.browser.test.tsx
@@ -430,7 +430,7 @@ describe('GraphPreviewDialog', () => {
});
// List mode loads on demand; wait for its rows before acting on them.
if (mode === 'list') {
- await vi.waitFor(() => expect(document.querySelector('[role="list"] [data-list-primary]')).not.toBeNull());
+ await expect.element(page.getByRole('list').getByRole('button').first()).toBeVisible();
}
};
diff --git a/invokeai/frontend/webv2/src/platform/ui/list/ListItem.browser.test.tsx b/invokeai/frontend/webv2/src/platform/ui/list/ListItem.browser.test.tsx
index 5952be601c..80c9e11dbd 100644
--- a/invokeai/frontend/webv2/src/platform/ui/list/ListItem.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/platform/ui/list/ListItem.browser.test.tsx
@@ -61,6 +61,8 @@ describe('ListItem', () => {
await act(() => action.click());
expect(onAction).toHaveBeenCalledTimes(1);
expect(onPress).not.toHaveBeenCalled();
+ // Leave a real pointer over the row: the next test must not inherit a hover on its new controls.
+ await userEvent.hover(primary());
});
it('renders a static row without a press handler as plain content, not a button', async () => {
@@ -77,6 +79,10 @@ describe('ListItem', () => {
await render(<ListItem title={longPrompt} titleTruncate="end" onIntent={onIntent} onPress={() => undefined} />);
+ await new Promise<void>((resolve) => {
+ requestAnimationFrame(() => requestAnimationFrame(() => resolve()));
+ });
+ expect(onIntent).not.toHaveBeenCalled();
await act(() => primary().focus());
expect(onIntent).toHaveBeenCalledTimes(1);
await userEvent.hover(primary());
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/image-map/ClusterStrengthField.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/image-map/ClusterStrengthField.browser.test.tsx
index fffcb111f0..f9ff818147 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/image-map/ClusterStrengthField.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/image-map/ClusterStrengthField.browser.test.tsx
@@ -212,9 +212,8 @@ describe('ClusterStrengthField', () => {
await settle();
settings.patch.mockClear();
- // Cleared by key, not by setValue: the empty box and the "." are one keystroke sequence here.
- await userEvent.clear(spinner());
- await userEvent.type(spinner(), '.');
+ // One keyboard sequence: clear() waits long enough to commit the intentionally empty box before type() runs.
+ await userEvent.type(spinner(), '{selectall}{Backspace}.', { skipClick: true });
// The box reads as empty here, which is the whole trap.
expect(spinner().value).toBe('');
expect(spinner().validity.badInput).toBe(true);
diff --git a/invokeai/frontend/webv2/vitest.browser.config.mts b/invokeai/frontend/webv2/vitest.browser.config.mts
index dc98c71523..1cc5ab77c0 100644
--- a/invokeai/frontend/webv2/vitest.browser.config.mts
+++ b/invokeai/frontend/webv2/vitest.browser.config.mts
@@ -6,6 +6,11 @@ import { defineConfig } from 'vitest/config';
import viteConfig from './vite.config.mts';
+/** A previous test's pointer must not hover controls mounted by the next test. */
+const resetBrowserPointer: BrowserCommand<[]> = async ({ page }) => {
+ await page.mouse.move(-1, -1);
+};
+
/** Drives Chromium's own IME over CDP: `compose` replaces the in-progress text, `commit` inserts the final text. */
const imeCompose: BrowserCommand<[steps: readonly { kind: 'commit' | 'compose'; text: string }[]]> = async (
{ context, page },
@@ -52,7 +57,7 @@ export default mergeConfig(
},
test: {
browser: {
- commands: { imeCompose },
+ commands: { imeCompose, resetBrowserPointer },
enabled: true,
headless: true,
instances: [{ browser: 'chromium' }],
diff --git a/tests/backend/ideogram4/test_denoise_conditioning_dtype.py b/tests/backend/ideogram4/test_denoise_conditioning_dtype.py
index 36a224070a..351c7b74a4 100644
--- a/tests/backend/ideogram4/test_denoise_conditioning_dtype.py
+++ b/tests/backend/ideogram4/test_denoise_conditioning_dtype.py
@@ -40,8 +40,10 @@ def _recording_transformer(seen: list[torch.dtype], dtype: torch.dtype) -> Ideog
def test_the_loop_hands_the_model_conditioning_in_its_own_dtype() -> None:
seen: list[torch.dtype] = []
- conditional = _recording_transformer(seen, torch.bfloat16)
- unconditional = _recording_transformer(seen, torch.bfloat16)
+ # Distinguish the model from the float32 encoder without CPU bf16 matmul, which can
+ # raise an illegal instruction on Windows runners. This tests allocation, not low-precision arithmetic.
+ conditional = _recording_transformer(seen, torch.float64)
+ unconditional = _recording_transformer(seen, torch.float64)
run_ideogram4_denoise(
conditional_transformer=conditional,
@@ -56,7 +58,7 @@ def test_the_loop_hands_the_model_conditioning_in_its_own_dtype() -> None:
)
# Both branches, and float32 nowhere: the encoder's dtype must not reach the buffers.
- assert seen == [torch.bfloat16, torch.bfloat16]
+ assert seen == [torch.float64, torch.float64]
def test_a_quantized_build_is_read_from_its_compute_dtype_not_its_weights() -> None: