test(cua): await responsive layout before measuring overflow
This commit is contained in:
1 parent
b0e4907b10
commit
1aabce5547
1 file changed
+5
-2
@@ -97,13 +97,16 @@ it.skipIf(process.platform !== 'darwin')('keeps system requests pending until fr
|
||||
for (const colorScheme of ['light', 'dark'] as const) {
|
||||
await page.emulateMedia({ colorScheme })
|
||||
await expect.poll(() => page.evaluate(() => document.body.hasAttribute('data-ds-dark-theme'))).toBe(colorScheme === 'dark')
|
||||
const layout = await panel.evaluate(element => ({
|
||||
const measure = () => panel.evaluate(element => ({
|
||||
clientWidth: element.clientWidth, scrollWidth: element.scrollWidth,
|
||||
overflowing: [...element.querySelectorAll('*')].filter(child =>
|
||||
child.getBoundingClientRect().right > element.getBoundingClientRect().right + 1,
|
||||
).map(child => ({ tag: child.tagName, className: child.className, text: child.textContent?.slice(0, 80) })),
|
||||
}))
|
||||
expect(layout.scrollWidth, JSON.stringify({ width, colorScheme, ...layout })).toBeLessThanOrEqual(layout.clientWidth)
|
||||
await expect.poll(async () => {
|
||||
const layout = await measure()
|
||||
return layout.scrollWidth <= layout.clientWidth ? true : { width, colorScheme, ...layout }
|
||||
}).toBe(true)
|
||||
if (webSnapshotMode() === 'refresh') {
|
||||
const directory = fileURLToPath(new URL('../../../.artifacts', import.meta.url))
|
||||
await mkdir(directory, { recursive: true })
|
||||
|
||||
Reference in new issue
Block a user