Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
f7fecf00
Unverified
Commit
f7fecf00
authored
Oct 20, 2022
by
Tim Neutkens
Committed by
GitHub
Oct 20, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add back/forward test for new router (#41590)
parent
d7348c4e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
0 deletions
+60
-0
page.js
test/e2e/app-dir/app/app/back-forward/[id]/page.js
+24
-0
index.test.ts
test/e2e/app-dir/index.test.ts
+36
-0
No files found.
test/e2e/app-dir/app/app/back-forward/[id]/page.js
0 → 100644
View file @
f7fecf00
'use client'
import
Link
from
'next/link'
import
{
useRouter
}
from
'next/navigation'
export
default
function
Page
({
params
})
{
const
router
=
useRouter
()
return
(
<>
<
h1
id
=
{
`message-
${
params
.
id
}
`
}
>
Hello
from
{
params
.
id
}
<
/h1
>
<
Link
href
=
{
params
.
id
===
'1'
?
'/back-forward/2'
:
'/back-forward/1'
}
id
=
"to-other-page"
>
Go
to
{
params
.
id
===
'1'
?
'2'
:
'1'
}
<
/Link
>
<
button
onClick
=
{()
=>
router
.
back
()}
id
=
"back-button"
>
Back
<
/button
>
<
button
onClick
=
{()
=>
router
.
forward
()}
id
=
"forward-button"
>
Forward
<
/button
>
<
/
>
)
}
test/e2e/app-dir/index.test.ts
View file @
f7fecf00
...
...
@@ -913,6 +913,42 @@ describe('app dir', () => {
await
browser
.
close
()
}
})
it
(
'should support router.back and router.forward'
,
async
()
=>
{
const
browser
=
await
webdriver
(
next
.
url
,
'/back-forward/1'
)
const
firstMessage
=
'Hello from 1'
const
secondMessage
=
'Hello from 2'
expect
(
await
browser
.
elementByCss
(
'#message-1'
).
text
()).
toBe
(
firstMessage
)
try
{
const
message2
=
await
browser
.
waitForElementByCss
(
'#to-other-page'
)
.
click
()
.
waitForElementByCss
(
'#message-2'
)
.
text
()
expect
(
message2
).
toBe
(
secondMessage
)
const
message1
=
await
browser
.
waitForElementByCss
(
'#back-button'
)
.
click
()
.
waitForElementByCss
(
'#message-1'
)
.
text
()
expect
(
message1
).
toBe
(
firstMessage
)
const
message2Again
=
await
browser
.
waitForElementByCss
(
'#forward-button'
)
.
click
()
.
waitForElementByCss
(
'#message-2'
)
.
text
()
expect
(
message2Again
).
toBe
(
secondMessage
)
}
finally
{
await
browser
.
close
()
}
})
})
describe
(
'hooks'
,
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment