test: use function assertion for second scrollY test

This commit is contained in:
Daniel Roe 2024-03-16 13:58:22 -07:00
parent 3d77e267d8
commit d981c056d1
No known key found for this signature in database
GPG Key ID: CBC814C393D93268

View File

@ -759,16 +759,16 @@ describe('nuxt links', () => {
await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, '/nested/foo/test') await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, '/nested/foo/test')
await page.locator('#user-test').scrollIntoViewIfNeeded() await page.locator('#user-test').scrollIntoViewIfNeeded()
expect(await page.evaluate(() => window.scrollY)).toBeGreaterThan(0) await page.waitForFunction(() => window.scrollY > 0)
await page.locator('#user-test').click() await page.locator('#user-test').click()
await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, '/nested/foo/user-test') await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, '/nested/foo/user-test')
expect(await page.evaluate(() => window.scrollY)).toBe(0) await page.waitForFunction(() => window.scrollY === 0)
await page.locator('#test').scrollIntoViewIfNeeded() await page.locator('#test').scrollIntoViewIfNeeded()
expect(await page.evaluate(() => window.scrollY)).toBeGreaterThan(0) await page.waitForFunction(() => window.scrollY > 0)
await page.locator('#test').click() await page.locator('#test').click()
await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, '/nested/foo/test') await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, '/nested/foo/test')
expect(await page.evaluate(() => window.scrollY)).toBe(0) await page.waitForFunction(() => window.scrollY === 0)
await page.close() await page.close()
}) })
}) })