7
7
*/
8
8
import { expect , test } from '@playwright/test'
9
9
10
- import { expectScrollTop , scrollTo } from './utils'
10
+ import { expectScrollTop , scrollTo , sleep } from './utils'
11
11
12
12
test ( 'scroll restore' , async ( { page } ) => {
13
13
// open small window to make scrolling easier
@@ -26,14 +26,24 @@ test('scroll restore', async ({ page }) => {
26
26
await page . goBack ( )
27
27
await expect ( page ) . toHaveURL ( '/projects/mock-project/disks' )
28
28
await expectScrollTop ( page , 143 )
29
+
30
+ // sleep required to get the scroll position to stick
31
+ await sleep ( 1000 )
29
32
await scrollTo ( page , 190 )
33
+ await sleep ( 1000 )
30
34
31
35
// go forward to snapshots, now scroll it
32
36
await page . goForward ( )
33
37
await expect ( page ) . toHaveURL ( '/projects/mock-project/snapshots' )
34
38
await expectScrollTop ( page , 0 )
35
39
await scrollTo ( page , 30 )
36
40
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
+
37
47
// new nav to disks
38
48
await page . getByRole ( 'link' , { name : 'Disks' } ) . click ( )
39
49
await expectScrollTop ( page , 0 )
@@ -53,6 +63,7 @@ test('scroll restore', async ({ page }) => {
53
63
// back again to disks, newer scroll value is restored
54
64
await page . goBack ( )
55
65
await expect ( page ) . toHaveURL ( '/projects/mock-project/disks' )
66
+ await sleep ( 1000 )
56
67
await expectScrollTop ( page , 190 )
57
68
58
69
// forward again to newest disks history entry, scroll remains 0
0 commit comments