🐛 fix(tests): wait for navigation during suite setup

This commit is contained in:
Saafo committed 2026-10-20 17:13:25 +08:00
1 parent c6fa12c447
commit 2c3e85fd44
2 files changed
+5 -3

No files matched your search

+3 -1
View File
@@ -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)
+2 -2
View File
@@ -193,13 +193,13 @@ export function probeFreePort(): Promise<number> {
async function revealNavigationDrawer(page: Page, locale: 'en' | 'zh'): Promise<void> {
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' })
}
/**