|
1 | 1 | import { expect, test } from "@playwright/test"; |
2 | 2 | import { Group, Panel, Separator } from "react-resizable-panels"; |
3 | | -import { goToUrl } from "./utils/goToUrl"; |
| 3 | +import { PopupWindow } from "../src/components/PopupWindow"; |
4 | 4 | import { calculateHitArea } from "./utils/calculateHitArea"; |
5 | 5 | import { getCenterCoordinates } from "./utils/getCenterCoordinates"; |
| 6 | +import { goToUrl } from "./utils/goToUrl"; |
6 | 7 |
|
7 | 8 | test.describe("cursor", () => { |
8 | 9 | test("horizontal", async ({ page }) => { |
@@ -201,4 +202,51 @@ test.describe("cursor", () => { |
201 | 202 | await page.evaluate(() => getComputedStyle(document.body).cursor) |
202 | 203 | ).toBe("auto"); |
203 | 204 | }); |
| 205 | + |
| 206 | + test("should target ownerDocument to support popup windows", async ({ |
| 207 | + page: mainPage |
| 208 | + }) => { |
| 209 | + await goToUrl( |
| 210 | + mainPage, |
| 211 | + <PopupWindow className="dark" height={250} width={500}> |
| 212 | + <Group className="h-full w-full" orientation="horizontal"> |
| 213 | + <Panel id="left" minSize="25%" /> |
| 214 | + <Separator /> |
| 215 | + <Panel id="right" minSize="25%" /> |
| 216 | + </Group> |
| 217 | + </PopupWindow> |
| 218 | + ); |
| 219 | + |
| 220 | + const popupPromise = mainPage.waitForEvent("popup"); |
| 221 | + await mainPage.getByRole("button").click(); |
| 222 | + const popupPage = await popupPromise; |
| 223 | + |
| 224 | + const hitAreaBox = await calculateHitArea(popupPage, ["left", "right"]); |
| 225 | + const { x, y } = getCenterCoordinates(hitAreaBox); |
| 226 | + |
| 227 | + expect( |
| 228 | + await popupPage.evaluate(() => getComputedStyle(document.body).cursor) |
| 229 | + ).toBe("auto"); |
| 230 | + |
| 231 | + await popupPage.mouse.move(x, y); |
| 232 | + |
| 233 | + expect( |
| 234 | + await popupPage.evaluate(() => getComputedStyle(document.body).cursor) |
| 235 | + ).toBe("ew-resize"); |
| 236 | + |
| 237 | + await popupPage.mouse.down(); |
| 238 | + await popupPage.mouse.move(50, y); |
| 239 | + await popupPage.mouse.move(25, y); |
| 240 | + |
| 241 | + expect( |
| 242 | + await popupPage.evaluate(() => getComputedStyle(document.body).cursor) |
| 243 | + ).toBe("e-resize"); |
| 244 | + |
| 245 | + await popupPage.mouse.move(950, y); |
| 246 | + await popupPage.mouse.move(975, y); |
| 247 | + |
| 248 | + expect( |
| 249 | + await popupPage.evaluate(() => getComputedStyle(document.body).cursor) |
| 250 | + ).toBe("w-resize"); |
| 251 | + }); |
204 | 252 | }); |
0 commit comments