Skip to content

Commit 21d33fe

Browse files
committed
make scroll restore test pass
1 parent d33d1c1 commit 21d33fe

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

test/e2e/scroll-restore.e2e.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
import { expect, test } from '@playwright/test'
99

10-
import { expectScrollTop, scrollTo } from './utils'
10+
import { expectScrollTop, scrollTo, sleep } from './utils'
1111

1212
test('scroll restore', async ({ page }) => {
1313
// open small window to make scrolling easier
@@ -26,14 +26,24 @@ test('scroll restore', async ({ page }) => {
2626
await page.goBack()
2727
await expect(page).toHaveURL('/projects/mock-project/disks')
2828
await expectScrollTop(page, 143)
29+
30+
// sleep required to get the scroll position to stick
31+
await sleep(1000)
2932
await scrollTo(page, 190)
33+
await sleep(1000)
3034

3135
// go forward to snapshots, now scroll it
3236
await page.goForward()
3337
await expect(page).toHaveURL('/projects/mock-project/snapshots')
3438
await expectScrollTop(page, 0)
3539
await scrollTo(page, 30)
3640

41+
// Oddly, this is required here in order for the page to have time to
42+
// catch the 30 scroll position. This became necessary with RR v7's use of
43+
// startTransition. Extra oddly, with a value of 500 it passes rarely, but
44+
// with 1000 it passes every time.
45+
await sleep(1000)
46+
3747
// new nav to disks
3848
await page.getByRole('link', { name: 'Disks' }).click()
3949
await expectScrollTop(page, 0)
@@ -53,6 +63,7 @@ test('scroll restore', async ({ page }) => {
5363
// back again to disks, newer scroll value is restored
5464
await page.goBack()
5565
await expect(page).toHaveURL('/projects/mock-project/disks')
66+
await sleep(1000)
5667
await expectScrollTop(page, 190)
5768

5869
// forward again to newest disks history entry, scroll remains 0

0 commit comments

Comments
 (0)