@@ -62,7 +62,7 @@ test.describe("actions", () => {
6262 // Without this, sometimes the URL is #hash-1
6363 await page . waitForTimeout ( 100 ) ;
6464
65- expect ( page ) . toHaveURL (
65+ await expect ( page ) . toHaveURL (
6666 "/qwikcity-test/scroll-restoration/hash/#hash-2" ,
6767 ) ;
6868 let scrollY1 ;
@@ -77,20 +77,29 @@ test.describe("actions", () => {
7777 await scrollTo ( page , 0 , 1000 ) ;
7878 await link2 . click ( ) ;
7979
80- expect ( page ) . toHaveURL (
80+ await expect ( page ) . toHaveURL (
8181 "/qwikcity-test/scroll-restoration/hash/#hash-1" ,
8282 ) ;
8383 await page . waitForTimeout ( 50 ) ;
84- const scrollY2 = ( await getWindowScrollXY ( page ) ) [ 1 ] ;
84+ let scrollY2 ;
85+ do {
86+ await page . waitForTimeout ( 10 ) ;
87+ scrollY2 = ( await getWindowScrollXY ( page ) ) [ 1 ] ;
88+ } while ( scrollY2 > 500 ) ;
8589 expect ( scrollY2 ) . toBeGreaterThan ( 70 ) ;
8690 expect ( scrollY2 ) . toBeLessThan ( 90 ) ;
8791
8892 const link3 = page . locator ( "#no-hash" ) ;
8993 await scrollTo ( page , 0 , 2000 ) ;
9094 await link3 . click ( ) ;
9195
92- expect ( page ) . toHaveURL ( "/qwikcity-test/scroll-restoration/hash/" ) ;
96+ await expect ( page ) . toHaveURL ( "/qwikcity-test/scroll-restoration/hash/" ) ;
9397 await page . waitForTimeout ( 50 ) ;
98+ let scrollY3 ;
99+ do {
100+ await page . waitForTimeout ( 10 ) ;
101+ scrollY3 = ( await getWindowScrollXY ( page ) ) [ 1 ] ;
102+ } while ( scrollY3 > 1000 ) ;
94103 expect ( await getWindowScrollXY ( page ) ) . toStrictEqual ( [ 0 , 0 ] ) ;
95104 } ) ;
96105 test ( "should restore scroll on back and forward navigations" , async ( {
0 commit comments