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
17716d14
Unverified
Commit
17716d14
authored
Aug 05, 2020
by
Jan Potoms
Committed by
GitHub
Aug 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for querystring-relative urls (#15911)
parent
5dbe0d02
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
0 deletions
+59
-0
query-only.js
test/integration/client-navigation/pages/nav/query-only.js
+24
-0
index.test.js
test/integration/client-navigation/test/index.test.js
+35
-0
No files found.
test/integration/client-navigation/pages/nav/query-only.js
0 → 100644
View file @
17716d14
import
Link
from
'next/link'
import
{
useRouter
}
from
'next/router'
export
async
function
getServerSideProps
({
query
:
{
prop
=
''
}
})
{
return
{
props
:
{
prop
}
}
}
export
default
function
Page
({
prop
})
{
const
router
=
useRouter
()
return
(
<>
<
div
id
=
"prop"
>
{
prop
}
<
/div
>
<
Link
href
=
"?prop=foo"
>
<
a
id
=
"link"
>
Click
me
<
/a
>
<
/Link
>
<
button
id
=
"router-push"
onClick
=
{()
=>
router
.
push
(
'?prop=bar'
)}
>
Push
me
<
/button
>
<
button
id
=
"router-replace"
onClick
=
{()
=>
router
.
replace
(
'?prop=baz'
)}
>
Push
me
<
/button
>
<
/
>
)
}
test/integration/client-navigation/test/index.test.js
View file @
17716d14
...
...
@@ -789,6 +789,41 @@ describe('Client Navigation', () => {
})
})
describe
(
'with querystring relative urls'
,
()
=>
{
it
(
'should work with Link'
,
async
()
=>
{
const
browser
=
await
webdriver
(
context
.
appPort
,
'/nav/query-only'
)
try
{
await
browser
.
elementByCss
(
'#link'
).
click
()
await
check
(()
=>
browser
.
waitForElementByCss
(
'#prop'
).
text
(),
'foo'
)
}
finally
{
await
browser
.
close
()
}
})
it
(
'should work with router.push'
,
async
()
=>
{
const
browser
=
await
webdriver
(
context
.
appPort
,
'/nav/query-only'
)
try
{
await
browser
.
elementByCss
(
'#router-push'
).
click
()
await
check
(()
=>
browser
.
waitForElementByCss
(
'#prop'
).
text
(),
'bar'
)
}
finally
{
await
browser
.
close
()
}
})
it
(
'should work with router.replace'
,
async
()
=>
{
const
browser
=
await
webdriver
(
context
.
appPort
,
'/nav/query-only'
)
try
{
await
browser
.
elementByCss
(
'#router-replace'
).
click
()
await
check
(()
=>
browser
.
waitForElementByCss
(
'#prop'
).
text
(),
'baz'
)
}
finally
{
await
browser
.
close
()
}
})
})
describe
(
'with getInitialProp redirect'
,
()
=>
{
it
(
'should redirect the page via client side'
,
async
()
=>
{
const
browser
=
await
webdriver
(
context
.
appPort
,
'/nav'
)
...
...
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