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
425490c2
Unverified
Commit
425490c2
authored
Oct 09, 2022
by
Tim Neutkens
Committed by
GitHub
Oct 09, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for link to catchall route in new router (#41289)
parent
f7a7c3fa
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
3 deletions
+43
-3
page.js
test/e2e/app-dir/app/app/catch-all-link/page.js
+18
-0
page.js
...2e/app-dir/app/app/catch-all-optional/[[...slug]]/page.js
+1
-1
index.test.ts
test/e2e/app-dir/index.test.ts
+24
-2
No files found.
test/e2e/app-dir/app/app/catch-all-link/page.js
0 → 100644
View file @
425490c2
import
Link
from
'next/link'
export
default
function
Page
()
{
return
(
<>
<
div
>
<
Link
href
=
"/catch-all/this/is/a/test"
>
<
a
id
=
"to-catch-all"
>
To
catch
-
all
<
/a
>
<
/Link
>
<
/div
>
<
div
>
<
Link
href
=
"/catch-all-optional/this/is/a/test"
>
<
a
id
=
"to-catch-all-optional"
>
To
optional
catch
-
all
<
/a
>
<
/Link
>
<
/div
>
<
/
>
)
}
test/e2e/app-dir/app/app/
optional-catch-al
l/[[...slug]]/page.js
→
test/e2e/app-dir/app/app/
catch-all-optiona
l/[[...slug]]/page.js
View file @
425490c2
export
default
function
Page
({
params
})
{
return
(
<
h1
id
=
"text"
data
-
params
=
{
params
.
slug
?.
join
(
'/'
)
??
''
}
>
hello
from
/
optional-catch-al
l/
{
params
.
slug
?.
join
(
'/'
)}
hello
from
/
catch-all-optiona
l/
{
params
.
slug
?.
join
(
'/'
)}
<
/h1
>
)
}
test/e2e/app-dir/index.test.ts
View file @
425490c2
...
...
@@ -639,18 +639,29 @@ describe('app dir', () => {
const
route
=
params
.
join
(
'/'
)
const
html
=
await
renderViaHTTP
(
next
.
url
,
`/
optional-catch-al
l/
${
route
}
`
`/
catch-all-optiona
l/
${
route
}
`
)
const
$
=
cheerio
.
load
(
html
)
expect
(
$
(
'#text'
).
attr
(
'data-params'
)).
toBe
(
route
)
})
it
(
'should handle optional segments root'
,
async
()
=>
{
const
html
=
await
renderViaHTTP
(
next
.
url
,
`/
optional-catch-al
l`
)
const
html
=
await
renderViaHTTP
(
next
.
url
,
`/
catch-all-optiona
l`
)
const
$
=
cheerio
.
load
(
html
)
expect
(
$
(
'#text'
).
attr
(
'data-params'
)).
toBe
(
''
)
})
it
(
'should handle optional catch-all segments link'
,
async
()
=>
{
const
browser
=
await
webdriver
(
next
.
url
,
'/catch-all-link'
)
expect
(
await
browser
.
elementByCss
(
'#to-catch-all-optional'
)
.
click
()
.
waitForElementByCss
(
'#text'
)
.
text
()
).
toBe
(
`hello from /catch-all-optional/this/is/a/test`
)
})
it
(
'should handle required segments'
,
async
()
=>
{
const
params
=
[
'this'
,
'is'
,
'a'
,
'test'
]
const
route
=
params
.
join
(
'/'
)
...
...
@@ -668,6 +679,17 @@ describe('app dir', () => {
expect
(
res
.
status
).
toBe
(
404
)
expect
(
await
res
.
text
()).
toContain
(
'This page could not be found'
)
})
it
(
'should handle catch-all segments link'
,
async
()
=>
{
const
browser
=
await
webdriver
(
next
.
url
,
'/catch-all-link'
)
expect
(
await
browser
.
elementByCss
(
'#to-catch-all'
)
.
click
()
.
waitForElementByCss
(
'#text'
)
.
text
()
).
toBe
(
`hello from /catch-all/this/is/a/test`
)
})
})
describe
(
'should serve client component'
,
()
=>
{
...
...
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