import { run } from "./run.mts" await run("modal", async ({ browser, expect, failures, url }) => { const page = await browser.newPage({ viewport: { width: 1200, height: 800 } }) page.on("pageerror", (error) => failures.push("page error " + String(error))) await page.goto(url + "modal.html") await page.waitForSelector("body[data-ready]", { state: "attached" }) await page.waitForSelector("[data-dialog-portal]:popover-open", { state: "attached" }) // Another popover shown above the modal is inert, unlike the inspector. await page.evaluate(() => document.getElementById("other").showPopover()) const action = page.getByRole("button", { name: "Background action", includeHidden: true }) const actionBox = await action.boundingBox() await page.mouse.click( actionBox.x + actionBox.width / 2, actionBox.y + actionBox.height / 2 ) const clicked = await action.evaluate((button) => button.hasAttribute("data-clicked") ) expect( !clicked, "an unrelated popover above the modal takes no click", clicked ) await page.getByRole("button", { name: "Menu" }).click() await page.waitForSelector("#menu:popover-open", { state: "attached" }) // A real mouse click, so a backdrop covering the launcher would take it. const frame = page.frameLocator("iframe[data-effect-ui-devtools]").last() const launcher = frame.getByRole("button", { name: "Open the Effect UI inspector" }) const box = await launcher.boundingBox() await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2) await frame.getByRole("dialog", { name: "Effect UI inspector" }) .waitFor({ timeout: 5_000 }) const dialogOpen = await page.evaluate(() => document.querySelector("[data-dialog-portal]")?.matches(":popover-open") ?? false ) expect( dialogOpen, "pressing the launcher doesn't close the kit dialog", dialogOpen ) })