From 2c3e85fd44e81853cdebba8ddc4e0c3e387f666b Mon Sep 17 00:00:00 2001 From: Saafo <46736350+Saafo@users.noreply.github.com> Date: Tue, 20 Oct 2026 17:13:25 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(tests):=20wait=20for=20navig?= =?UTF-8?q?ation=20during=20suite=20setup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/tests/caption-overlays.e2e.ts | 4 +++- apps/web/tests/support.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/web/tests/caption-overlays.e2e.ts b/apps/web/tests/caption-overlays.e2e.ts index c1fe2de9a7..35b203436a 100644 --- a/apps/web/tests/caption-overlays.e2e.ts +++ b/apps/web/tests/caption-overlays.e2e.ts @@ -21,6 +21,8 @@ it('keeps settings and expanded plugin dialogs clear of the Windows caption acro document.documentElement.setAttribute('data-windows-titlebar', '') document.documentElement.style.setProperty('--dsh-windows-titlebar-height', '40px') }) + await page.setViewportSize({ width: 521, height: 600 }) + await page.locator('[data-sidebar-drawer]').waitFor({ state: 'detached' }) const reopenSidebar = page.locator('[data-shell-leading]').getByRole('button', { name: '打开侧边栏', exact: true }) await openSettings(page, 'zh') const settings = page.getByRole('dialog', { name: '设置', exact: true }) @@ -84,7 +86,7 @@ it('keeps settings and expanded plugin dialogs clear of the Windows caption acro else document.documentElement.removeAttribute('data-platform') }, platform) // Publish the synthetic platform change through the frame's size observer. - await page.setViewportSize({ width: platform === 'darwin' ? 521 : 520, height: 600 }) + await page.setViewportSize({ width: platform === 'darwin' ? 520 : 521, height: 600 }) await page.locator('[data-sidebar-drawer]').waitFor() await openSettings(page, 'zh') await expect.poll(async () => (await settings.boundingBox())?.y).toBe(platform === 'darwin' ? 68 : 24) diff --git a/apps/web/tests/support.ts b/apps/web/tests/support.ts index 03fd4999d6..b11ab62f17 100644 --- a/apps/web/tests/support.ts +++ b/apps/web/tests/support.ts @@ -193,13 +193,13 @@ export function probeFreePort(): Promise { async function revealNavigationDrawer(page: Page, locale: 'en' | 'zh'): Promise { const drawer = await page.evaluate(() => window.innerWidth < 768 && !document.documentElement.hasAttribute('data-windows-titlebar')) - await expect.poll(() => page.locator('[data-sidebar-drawer]').count()).toBe(drawer ? 1 : 0) + await page.waitForFunction(expected => Boolean(document.querySelector('[data-sidebar-drawer]')) === expected, drawer) const closed = page.locator('[data-sidebar-drawer][data-sidebar-collapsed]') if (await closed.count() === 0) return await page.locator('[data-shell-leading]').getByRole('button', { name: locale === 'zh' ? '打开侧边栏' : 'Open sidebar', exact: true, }).click() - await expect.poll(() => closed.count()).toBe(0) + await closed.waitFor({ state: 'detached' }) } /**