Skip to content

Commit

Permalink
Add more tests. test "scroll:false" behaviour.
Browse files Browse the repository at this point in the history
  • Loading branch information
l-you committed Jun 8, 2024
1 parent 78f754d commit 0c48ee3
Show file tree
Hide file tree
Showing 6 changed files with 2,539 additions and 2,055 deletions.
8 changes: 8 additions & 0 deletions __tests__/ScrollRestorer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ test('End to end testing of scroll restorer', async ({page, browserName}) => {
await resolveTimeout(1000)//Sometimes browsers struggle to restore the same millisecond
await expectScrollToBe(page, mainPage)



await page.getByText('Lets-go without scroll').scrollIntoViewIfNeeded()
await expectScrollToBe(page, mainPage)
await page.getByText('Lets-go without scroll').click()
await page.waitForURL('/?fff=fff')
await expectScrollToBe(page, mainPage)

})

test('Safari scroll reset bug simulation', async ({page}) => {
Expand Down
5 changes: 2 additions & 3 deletions next-app-mock/src/ClientSideScrollRestorer.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

import {Suspense} from "react"
'use client'
import {ScrollRestorer} from "../../src"

const ClientSideScrollRestorer = () => {
return <Suspense><ScrollRestorer /></Suspense>
return <ScrollRestorer />
}
export default ClientSideScrollRestorer
6 changes: 4 additions & 2 deletions next-app-mock/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ClientSideScrollRestorer from "@/ClientSideScrollRestorer"
import type {Metadata} from 'next'
import {Inter} from 'next/font/google'
import './globals.css'
import {FunctionComponent, ReactNode} from "react"
import {FunctionComponent, ReactNode, Suspense} from "react"

const inter = Inter({subsets: ['latin']})

Expand All @@ -16,7 +16,9 @@ const RootLayout: FunctionComponent<{
return (
<html lang="en">
<body className={inter.className}>
<ClientSideScrollRestorer/>
<Suspense>
<ClientSideScrollRestorer/>
</Suspense>
{children}
</body>
</html>
Expand Down
3 changes: 3 additions & 0 deletions next-app-mock/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const Page = ()=>{
<Link href="/low-page">
Lets-go to low-page
</Link>
<Link href="/?fff=fff" scroll={false}>
Lets-go without scroll
</Link>
</div>
}
export default Page
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@
"changeset": "^0.2.6",
"eslint-config-grisaia-react": "^0.6.15",
"eslint-config-grisaia-typescript": "^0.6.14",
"grisaia-package-builder": "^0.1.16"
"grisaia-package-builder": "^0.1.16",
"typescript": "^5.4.5"
},
"peerDependencies": {
"next": "^13.0 || ^14.0",
"react": "^17.0 || ^18.0"
},
"packageManager": "pnpm@8.7.5",
"packageManager": "pnpm@9.1.2",
"dependencies": {
"@bladl/react-hooks": "^1.5.2"
}
Expand Down
Loading

0 comments on commit 0c48ee3

Please sign in to comment.