|
1 | 1 | import { mkdir, readFile } from "node:fs/promises"; |
2 | 2 | import path from "node:path"; |
3 | | -import { chromium, type Browser, type BrowserContext } from "playwright"; |
| 3 | +import { chromium, type Browser, type BrowserContext, type Page } from "playwright"; |
4 | 4 | import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest"; |
5 | 5 | import { |
6 | 6 | canRunPlaywrightChromium, |
@@ -33,6 +33,15 @@ async function closeContext(context: BrowserContext) { |
33 | 33 | await context.close().catch(() => {}); |
34 | 34 | } |
35 | 35 |
|
| 36 | +async function waitForLightboxAnimations(page: Page): Promise<void> { |
| 37 | + await page.locator("openclaw-image-lightbox wa-dialog").evaluate(async (dialogAdapter) => { |
| 38 | + const nativeDialog = dialogAdapter.shadowRoot?.querySelector("dialog"); |
| 39 | + await Promise.all( |
| 40 | + (nativeDialog?.getAnimations({ subtree: true }) ?? []).map((animation) => animation.finished), |
| 41 | + ); |
| 42 | + }); |
| 43 | +} |
| 44 | + |
36 | 45 | describeControlUiE2e("Control UI image lightbox", () => { |
37 | 46 | beforeAll(async () => { |
38 | 47 | if (!chromiumAvailable) { |
@@ -156,6 +165,7 @@ describeControlUiE2e("Control UI image lightbox", () => { |
156 | 165 | ), |
157 | 166 | ) |
158 | 167 | .toBeGreaterThan(0); |
| 168 | + await waitForLightboxAnimations(page); |
159 | 169 | const desktopBox = await page.locator("openclaw-image-lightbox .lightbox").boundingBox(); |
160 | 170 | expect(desktopBox?.width ?? 0).toBeGreaterThan(1000); |
161 | 171 | expect(desktopBox?.height ?? 0).toBeGreaterThan(700); |
@@ -213,14 +223,7 @@ describeControlUiE2e("Control UI image lightbox", () => { |
213 | 223 | await page.setViewportSize({ height: 844, width: 390 }); |
214 | 224 | await sidebarTrigger.click(); |
215 | 225 | await sidebarDialog.waitFor({ state: "visible" }); |
216 | | - await page.locator("openclaw-image-lightbox wa-dialog").evaluate(async (dialogAdapter) => { |
217 | | - const nativeDialog = dialogAdapter.shadowRoot?.querySelector("dialog"); |
218 | | - await Promise.all( |
219 | | - (nativeDialog?.getAnimations({ subtree: true }) ?? []).map( |
220 | | - (animation) => animation.finished, |
221 | | - ), |
222 | | - ); |
223 | | - }); |
| 226 | + await waitForLightboxAnimations(page); |
224 | 227 | const mobileBox = await page.locator("openclaw-image-lightbox .lightbox").boundingBox(); |
225 | 228 | const mobileImageLayout = await page |
226 | 229 | .locator("openclaw-image-lightbox .stage") |
|
0 commit comments