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(browser): drop the outer-page scroll reset the runner no longer needs
Josh Corbett01417235a7b9
diff --git a/invokeai/frontend/webv2/scripts/browser-test-pointer.ts b/invokeai/frontend/webv2/scripts/browser-test-pointer.tsnew file mode 100644index 0000000000..0f2e716c7b--- /dev/null+++ b/invokeai/frontend/webv2/scripts/browser-test-pointer.ts@@ -0,0 +1,12 @@+import { beforeEach } from 'vitest';+import { server } from 'vitest/browser';++declare module 'vitest/browser' {+ interface BrowserCommands {+ resetBrowserPointer: () => Promise<void>;+ }+}++beforeEach(async () => {+ await server.commands.resetBrowserPointer();+});diff --git a/invokeai/frontend/webv2/scripts/browser-test-viewport.ts b/invokeai/frontend/webv2/scripts/browser-test-viewport.tsdeleted file mode 100644index 5fe892373a..0000000000--- a/invokeai/frontend/webv2/scripts/browser-test-viewport.ts+++ /dev/null@@ -1,33 +0,0 @@-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.- *- * The runner's outer page is a few pixels taller than its viewport, so a `scrollIntoView` or `focus()` inside a- * test scrolls it too, and that offset outlives the test file. Playwright judges hover and click targets against the- * top-level viewport, so a later file's elements at the iframe's top edge then sit outside it and every pointer- * 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(async () => {- await server.commands.resetBrowserPointer();- let frame: Window = window;-- while (frame.parent !== frame) {- frame = frame.parent;-- try {- frame.scrollTo(0, 0);- } catch {- // A cross-origin ancestor cannot be scrolled from here, and nothing inside it can leak into this one.- return;- }- }-});diff --git a/invokeai/frontend/webv2/src/architecture/browserTestViewport.browser.test.ts b/invokeai/frontend/webv2/src/architecture/browserTestViewport.browser.test.tsindex b2f2c4bc00..fc6e26862c 100644--- a/invokeai/frontend/webv2/src/architecture/browserTestViewport.browser.test.ts+++ b/invokeai/frontend/webv2/src/architecture/browserTestViewport.browser.test.ts@@ -1,33 +1,25 @@import { expect, it } from 'vitest';-import { userEvent } from 'vitest/browser';/*- * Guards scripts/browser-test-viewport.ts. The two tests run in order: the first leaves the runner's outer page- * scrolled, as any scrollIntoView or focus() in a test can, and the second needs the reset before it to reach an- * element at the iframe's top edge. Without the reset the hover times out, as FeatureHint's suite did on CI.+ * Playwright judges hover and click targets against the runner's outer page. If that page can scroll, a+ * scrollIntoView or focus() in one test leaves it offset for later files, and their pointer actions on elements at+ * the iframe's top edge time out (FeatureHint's suite fails this way). The runner keeps that page unscrollable by+ * laying the test iframe out as a block exactly filling it; an inline iframe leaves a few pixels of overflow below.*/-it('scrolls the outer page from inside the test iframe', () => {- const below = document.createElement('div');+it('keeps the outer page unscrolled when the test iframe scrolls', () => {+ const below = document.createElement('input');- below.style.cssText = 'position:absolute;left:0;top:1200px;width:10px;height:10px';+ below.style.cssText = 'position:absolute;left:0;top:5000px';document.body.append(below);- below.scrollIntoView();- below.remove();- window.scrollTo(0, 0);-- expect(window.parent.scrollY).toBeGreaterThan(0);-});--it('starts the next test with an element at the iframe corner reachable', async () => {- const corner = document.createElement('div');-- corner.style.cssText = 'position:fixed;left:0;top:0;width:2px;height:2px;z-index:2147483647';- document.body.append(corner);try {- await userEvent.hover(corner, { timeout: 2000 });+ below.scrollIntoView();+ below.focus();+ expect(window.scrollY).toBeGreaterThan(0);+ expect(window.parent.scrollY).toBe(0);} finally {- corner.remove();+ below.remove();+ window.scrollTo(0, 0);}});diff --git a/invokeai/frontend/webv2/vitest.browser.config.mts b/invokeai/frontend/webv2/vitest.browser.config.mtsindex ade9c52e5a..7e23c86e28 100644--- a/invokeai/frontend/webv2/vitest.browser.config.mts+++ b/invokeai/frontend/webv2/vitest.browser.config.mts@@ -129,7 +129,7 @@ export default mergeConfig(provider: playwright(),},include: ['src/**/*.browser.test.{ts,tsx}'],- setupFiles: ['./scripts/browser-test-console.ts', './scripts/browser-test-viewport.ts'],+ setupFiles: ['./scripts/browser-test-console.ts', './scripts/browser-test-pointer.ts'],},}));