mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-24 22:55:13 +00:00
test: use retryable assertion for scrollY
(#26298)
This commit is contained in:
parent
20079904c0
commit
c7d0567da1
@ -717,61 +717,53 @@ describe('nuxt links', () => {
|
|||||||
await page.close()
|
await page.close()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('expect scroll to top on routes with same component',
|
it('expect scroll to top on routes with same component', async () => {
|
||||||
async () => {
|
// #22402
|
||||||
// #22402
|
const page = await createPage('/big-page-1', {
|
||||||
const page = await createPage('/big-page-1', {
|
viewport: {
|
||||||
viewport: {
|
width: 1000,
|
||||||
width: 1000,
|
height: 1000
|
||||||
height: 1000
|
}
|
||||||
}
|
})
|
||||||
})
|
await page.waitForFunction(() => window.useNuxtApp?.()._route.fullPath === '/big-page-1')
|
||||||
await page.waitForFunction(() => window.useNuxtApp?.()._route.fullPath === '/big-page-1')
|
|
||||||
|
|
||||||
await page.locator('#big-page-2').scrollIntoViewIfNeeded()
|
await page.locator('#big-page-2').scrollIntoViewIfNeeded()
|
||||||
expect(await page.evaluate(() => window.scrollY)).toBeGreaterThan(0)
|
await page.waitForFunction(() => window.scrollY > 0)
|
||||||
await page.locator('#big-page-2').click()
|
await page.locator('#big-page-2').click()
|
||||||
await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, '/big-page-2')
|
await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, '/big-page-2')
|
||||||
expect(await page.evaluate(() => window.scrollY)).toBe(0)
|
await page.waitForFunction(() => window.scrollY === 0)
|
||||||
|
|
||||||
await page.locator('#big-page-1').scrollIntoViewIfNeeded()
|
await page.locator('#big-page-1').scrollIntoViewIfNeeded()
|
||||||
expect(await page.evaluate(() => window.scrollY)).toBeGreaterThan(0)
|
await page.waitForFunction(() => window.scrollY > 0)
|
||||||
await page.locator('#big-page-1').click()
|
await page.locator('#big-page-1').click()
|
||||||
await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, '/big-page-1')
|
await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, '/big-page-1')
|
||||||
expect(await page.evaluate(() => window.scrollY)).toBe(0)
|
await page.waitForFunction(() => window.scrollY === 0)
|
||||||
await page.close()
|
await page.close()
|
||||||
},
|
})
|
||||||
// Flaky behavior when using Webpack
|
|
||||||
{ retry: isWebpack ? 10 : 0 }
|
|
||||||
)
|
|
||||||
|
|
||||||
it('expect scroll to top on nested pages',
|
it('expect scroll to top on nested pages', async () => {
|
||||||
async () => {
|
// #20523
|
||||||
// #20523
|
const page = await createPage('/nested/foo/test', {
|
||||||
const page = await createPage('/nested/foo/test', {
|
viewport: {
|
||||||
viewport: {
|
width: 1000,
|
||||||
width: 1000,
|
height: 1000
|
||||||
height: 1000
|
}
|
||||||
}
|
})
|
||||||
})
|
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)
|
expect(await page.evaluate(() => window.scrollY)).toBeGreaterThan(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)
|
expect(await page.evaluate(() => window.scrollY)).toBe(0)
|
||||||
|
|
||||||
await page.locator('#test').scrollIntoViewIfNeeded()
|
await page.locator('#test').scrollIntoViewIfNeeded()
|
||||||
expect(await page.evaluate(() => window.scrollY)).toBeGreaterThan(0)
|
expect(await page.evaluate(() => window.scrollY)).toBeGreaterThan(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)
|
expect(await page.evaluate(() => window.scrollY)).toBe(0)
|
||||||
await page.close()
|
await page.close()
|
||||||
},
|
})
|
||||||
// Flaky behavior when using Webpack
|
|
||||||
{ retry: isWebpack ? 10 : 0 }
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('head tags', () => {
|
describe('head tags', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user