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
f01deeed
Unverified
Commit
f01deeed
authored
Oct 16, 2020
by
JJ Kasper
Committed by
GitHub
Oct 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stabilize i18n fallback test (#17957)
* Stabilize i18n fallback test * Handle reload during hydration check
parent
ba83d865
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
16 deletions
+44
-16
index.test.js
test/integration/i18n-support/test/index.test.js
+6
-1
next-webdriver.d.ts
test/lib/next-webdriver.d.ts
+2
-1
next-webdriver.js
test/lib/next-webdriver.js
+36
-14
No files found.
test/integration/i18n-support/test/index.test.js
View file @
f01deeed
...
@@ -672,7 +672,12 @@ function runTests(isDev) {
...
@@ -672,7 +672,12 @@ function runTests(isDev) {
})
})
it
(
'should render 404 for fallback page that returned 404'
,
async
()
=>
{
it
(
'should render 404 for fallback page that returned 404'
,
async
()
=>
{
const
browser
=
await
webdriver
(
appPort
,
'/en/not-found/fallback/first'
)
const
browser
=
await
webdriver
(
appPort
,
'/en/not-found/fallback/first'
,
true
,
true
)
await
browser
.
waitForElementByCss
(
'h1'
)
await
browser
.
waitForElementByCss
(
'h1'
)
await
browser
.
eval
(
'window.beforeNav = 1'
)
await
browser
.
eval
(
'window.beforeNav = 1'
)
...
...
test/lib/next-webdriver.d.ts
View file @
f01deeed
...
@@ -24,5 +24,6 @@ interface Chain {
...
@@ -24,5 +24,6 @@ interface Chain {
export
default
function
(
export
default
function
(
appPort
:
number
,
appPort
:
number
,
path
:
string
,
path
:
string
,
waitHydration
?:
boolean
waitHydration
?:
boolean
,
allowHydrationRetry
?:
boolean
):
Promise
<
Chain
>
):
Promise
<
Chain
>
test/lib/next-webdriver.js
View file @
f01deeed
...
@@ -152,7 +152,12 @@ const freshWindow = async () => {
...
@@ -152,7 +152,12 @@ const freshWindow = async () => {
await
browser
.
switchTo
().
window
(
newWindow
)
await
browser
.
switchTo
().
window
(
newWindow
)
}
}
export
default
async
(
appPort
,
path
,
waitHydration
=
true
)
=>
{
export
default
async
(
appPort
,
path
,
waitHydration
=
true
,
allowHydrationRetry
=
false
)
=>
{
if
(
!
initialWindow
)
{
if
(
!
initialWindow
)
{
initialWindow
=
await
browser
.
getWindowHandle
()
initialWindow
=
await
browser
.
getWindowHandle
()
}
}
...
@@ -176,11 +181,15 @@ export default async (appPort, path, waitHydration = true) => {
...
@@ -176,11 +181,15 @@ export default async (appPort, path, waitHydration = true) => {
// Wait for application to hydrate
// Wait for application to hydrate
if
(
waitHydration
)
{
if
(
waitHydration
)
{
console
.
log
(
`\n> Waiting hydration for
${
url
}
\n`
)
console
.
log
(
`\n> Waiting hydration for
${
url
}
\n`
)
const
checkHydrated
=
async
()
=>
{
await
browser
.
executeAsyncScript
(
function
()
{
await
browser
.
executeAsyncScript
(
function
()
{
var
callback
=
arguments
[
arguments
.
length
-
1
]
var
callback
=
arguments
[
arguments
.
length
-
1
]
// if it's not a Next.js app return
// if it's not a Next.js app return
if
(
document
.
documentElement
.
innerHTML
.
indexOf
(
'__NEXT_DATA__'
)
===
-
1
)
{
if
(
document
.
documentElement
.
innerHTML
.
indexOf
(
'__NEXT_DATA__'
)
===
-
1
)
{
callback
()
callback
()
}
}
...
@@ -194,6 +203,19 @@ export default async (appPort, path, waitHydration = true) => {
...
@@ -194,6 +203,19 @@ export default async (appPort, path, waitHydration = true) => {
}
}
}
}
})
})
}
try
{
await
checkHydrated
()
}
catch
(
err
)
{
if
(
allowHydrationRetry
)
{
// re-try in case the page reloaded during check
await
checkHydrated
()
}
else
{
throw
err
}
}
console
.
log
(
`\n> Hydration complete for
${
url
}
\n`
)
console
.
log
(
`\n> Hydration complete for
${
url
}
\n`
)
}
}
...
...
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