diff --git a/tests/browser-capabilities/browser-files.spec.ts b/tests/browser-capabilities/browser-files.spec.ts index 14c26786..ab48ffad 100644 --- a/tests/browser-capabilities/browser-files.spec.ts +++ b/tests/browser-capabilities/browser-files.spec.ts @@ -1,10 +1,21 @@ import { expect, test } from "../support/browser/strict-browser-test.ts"; +/** + * 1103/11-10. The controls these tests add sit in a fixed layer above the + * app. The app is still rendering when a test clicks; in the document flow, + * after its root, its content moved the button between mousedown and mouseup. + * The mouseup then landed on the app, the click went to their common ancestor + * and the button's handler never ran: no file chooser, no download, and the + * test waited 30 s for the event. + */ +const FIXED_CONTROLS = + "position: fixed; inset-block-start: 0; inset-inline-start: 0; z-index: 2147483647; background: Canvas;"; + test("selects, inspects, streams, and previews a real browser File", async ({ page, }) => { await page.goto("/"); - await page.evaluate(async () => { + await page.evaluate(async (fixedControls) => { const modulePath = "/src/adapters/browser-files/index.ts"; const { @@ -20,7 +31,10 @@ test("selects, inspects, streams, and previews a real browser File", async ({ const button = document.createElement("button"); button.type = "button"; button.textContent = "Choose test file"; - document.body.append(label, input, button); + const controls = document.createElement("div"); + controls.style.cssText = fixedControls; + controls.append(label, input, button); + document.body.append(controls); const filePolicy = browserFilePolicyReference( "avatar", @@ -166,7 +180,7 @@ test("selects, inspects, streams, and previews a real browser File", async ({ }; })(); }); - }); + }, FIXED_CONTROLS); const chooserPromise = page.waitForEvent("filechooser"); await page.getByRole("button", { name: "Choose test file" }).click(); @@ -212,7 +226,7 @@ test("hands a bounded generated Blob to the real browser download path", async ( page, }) => { await page.goto("/"); - await page.evaluate(async () => { + await page.evaluate(async (fixedControls) => { const modulePath = "/src/adapters/browser-files/index.ts"; const { createBrowserFileRuntime, @@ -228,7 +242,10 @@ test("hands a bounded generated Blob to the real browser download path", async ( const button = document.createElement("button"); button.type = "button"; button.textContent = "Download generated file"; - document.body.append(label, input, button); + const controls = document.createElement("div"); + controls.style.cssText = fixedControls; + controls.append(label, input, button); + document.body.append(controls); const downloadPolicy = browserFilePolicyReference( "generated-export", "bounded-object-url-bin", @@ -301,7 +318,7 @@ test("hands a bounded generated Blob to the real browser download path", async ( }) .finally(() => runtime.dispose()); }); - }); + }, FIXED_CONTROLS); const downloadPromise = page.waitForEvent("download"); await page