Skip to content

Commit

Permalink
make scroll restore test pass
Browse files Browse the repository at this point in the history
  • Loading branch information
david-crespo committed Dec 17, 2024
1 parent d33d1c1 commit e5c2740
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/e2e/scroll-restore.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import { expect, test } from '@playwright/test'

import { expectScrollTop, scrollTo } from './utils'
import { expectScrollTop, scrollTo, sleep } from './utils'

test('scroll restore', async ({ page }) => {
// open small window to make scrolling easier
Expand All @@ -26,14 +26,24 @@ test('scroll restore', async ({ page }) => {
await page.goBack()
await expect(page).toHaveURL('/projects/mock-project/disks')
await expectScrollTop(page, 143)

// sleep required to get the scroll position to stick
await sleep(1000)
await scrollTo(page, 190)
await sleep(1000)

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

// Oddly, this is required here in order for the page to have time to
// catch the 30 scroll position. This became necessary with RR v7's use of
// startTransition. Extra oddly, with a value of 500 it passes rarely, but
// with 1000 it passes every time.
await sleep(1000)

// new nav to disks
await page.getByRole('link', { name: 'Disks' }).click()
await expectScrollTop(page, 0)
Expand All @@ -53,6 +63,7 @@ test('scroll restore', async ({ page }) => {
// back again to disks, newer scroll value is restored
await page.goBack()
await expect(page).toHaveURL('/projects/mock-project/disks')
await sleep(1000)
await expectScrollTop(page, 190)

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

0 comments on commit e5c2740

Please sign in to comment.