test: add network idle test

This commit is contained in:
Michael Brevard 2024-06-03 00:04:43 +03:00 committed by GitHub
parent f4f8ca08dc
commit 9746137b28
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 3 deletions

View File

@ -2638,10 +2638,15 @@ describe('lazy import components', () => {
it('lazy load delayed hydration comps at the right time', async () => {
expect(html).not.toContain('This shouldn\'t be visible at first!')
const { page } = await renderPage('/lazy-import-components')
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight))
expect(await page.locator('body').getByText('This should be visible at first!').all()).toHaveLength(1)
expect(await page.locator('body').getByText('This should be visible at first with network!').all()).toHaveLength(1)
expect(await page.locator('body').getByText('This shouldn\'t be visible at first with network!').all()).toHaveLength(0)
await page.waitForLoadState('networkidle')
expect(await page.locator('body').getByText('This shouldn\'t be visible at first!').all()).toHaveLength(1)
expect(await page.locator('body').getByText('This should be visible at first with network!').all()).toHaveLength(0)
expect(await page.locator('body').getByText('This shouldn\'t be visible at first with network!').all()).toHaveLength(1)
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight))
expect(await page.locator('body').getByText('This should be visible at first with viewport!').all()).toHaveLength(1)
await page.waitForLoadState('networkidle')
expect(await page.locator('body').getByText('This shouldn\'t be visible at first with viewport!').all()).toHaveLength(1)
})
})