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
5ff48177
Unverified
Commit
5ff48177
authored
Jun 30, 2023
by
Leah
Committed by
GitHub
Jun 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix app-hmr-changes.test.ts by updating next-tweet (#52046)
parent
9f6cf08f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
29 deletions
+35
-29
app-hmr-changes.test.ts
test/development/acceptance-app/app-hmr-changes.test.ts
+22
-23
tweet.tsx
.../fixtures/app-hmr-changes/app/(post)/components/tweet.tsx
+10
-3
development-sandbox.ts
test/lib/development-sandbox.ts
+3
-3
No files found.
test/development/acceptance-app/app-hmr-changes.test.ts
View file @
5ff48177
import
{
FileRef
,
nextTestSetup
}
from
'e2e-utils'
import
{
FileRef
,
nextTestSetup
}
from
'e2e-utils'
import
{
check
,
hasRedbox
,
waitFor
,
retry
}
from
'next-test-utils
'
import
{
sandbox
}
from
'development-sandbox
'
import
path
from
'path'
import
path
from
'path'
describe
(
'Error overlay - RSC build errors'
,
()
=>
{
describe
(
'Error overlay - RSC build errors'
,
()
=>
{
...
@@ -8,7 +8,7 @@ describe('Error overlay - RSC build errors', () => {
...
@@ -8,7 +8,7 @@ describe('Error overlay - RSC build errors', () => {
dependencies
:
{
dependencies
:
{
'@next/mdx'
:
'canary'
,
'@next/mdx'
:
'canary'
,
'react-wrap-balancer'
:
'^0.2.4'
,
'react-wrap-balancer'
:
'^0.2.4'
,
'
next-tweet'
:
'^0.6.0
'
,
'
react-tweet'
:
'^2.0.2
'
,
'@mdx-js/react'
:
'^2.3.0'
,
'@mdx-js/react'
:
'^2.3.0'
,
tailwindcss
:
'^3.2.6'
,
tailwindcss
:
'^3.2.6'
,
typescript
:
'latest'
,
typescript
:
'latest'
,
...
@@ -20,44 +20,43 @@ describe('Error overlay - RSC build errors', () => {
...
@@ -20,44 +20,43 @@ describe('Error overlay - RSC build errors', () => {
})
})
it
(
'should handle successive HMR changes with errors correctly'
,
async
()
=>
{
it
(
'should handle successive HMR changes with errors correctly'
,
async
()
=>
{
const
browser
=
await
retry
(
const
{
session
,
cleanup
}
=
await
sandbox
(
()
=>
next
.
browser
(
'/2020/develop-preview-test'
)
,
next
,
1000
,
undefined
,
500
'/2020/develop-preview-test'
)
)
await
check
(
expect
(
()
=>
browser
.
eval
(
'document.documentElement.innerHTML'
),
await
session
.
evaluate
(
'document.documentElement.innerHTML'
)
/A few years ago I tweeted/
).
toContain
(
'A few years ago I tweeted'
)
)
const
pagePath
=
'app/(post)/2020/develop-preview-test/page.mdx'
const
pagePath
=
'app/(post)/2020/develop-preview-test/page.mdx'
const
originalPage
=
await
next
.
readFile
(
pagePath
)
const
originalPage
=
await
next
.
readFile
(
pagePath
)
const
break1
=
originalPage
.
replace
(
'break 1'
,
'<Figure>'
)
const
break1
=
originalPage
.
replace
(
'break 1'
,
'<Figure>'
)
await
next
.
patchFile
(
pagePath
,
break1
)
await
session
.
patch
(
pagePath
,
break1
)
const
break2
=
break1
.
replace
(
'{/* break point 2 */}'
,
'<Figure />'
)
const
break2
=
break1
.
replace
(
'{/* break point 2 */}'
,
'<Figure />'
)
await
next
.
patchFile
(
pagePath
,
break2
)
await
session
.
patch
(
pagePath
,
break2
)
for
(
let
i
=
0
;
i
<
5
;
i
++
)
{
for
(
let
i
=
0
;
i
<
5
;
i
++
)
{
await
next
.
patchFile
(
pagePath
,
break2
.
replace
(
'break 3'
,
'<Hello />'
))
await
session
.
patch
(
pagePath
,
break2
.
replace
(
'break 3'
,
'<Hello />'
))
await
next
.
patchFile
(
pagePath
,
break2
)
await
session
.
patch
(
pagePath
,
break2
)
expect
(
await
hasRedbox
(
browser
,
true
)).
toBe
(
true
)
expect
(
await
session
.
hasRedbox
(
true
)).
toBe
(
true
)
await
next
.
patchFile
(
pagePath
,
break1
)
await
session
.
patch
(
pagePath
,
break1
)
await
waitFor
(
100
)
await
next
.
patchFile
(
pagePath
,
originalPage
)
await
session
.
patch
(
pagePath
,
originalPage
)
expect
(
await
hasRedbox
(
browser
,
false
)).
toBe
(
false
)
expect
(
await
session
.
hasRedbox
(
false
)).
toBe
(
false
)
}
}
await
check
(
expect
(
()
=>
browser
.
eval
(
'document.documentElement.innerHTML'
),
await
session
.
evaluate
(
'document.documentElement.innerHTML'
)
/A few years ago I tweeted/
).
toContain
(
'A few years ago I tweeted'
)
)
await
cleanup
()
})
})
})
})
test/development/acceptance-app/fixtures/app-hmr-changes/app/(post)/components/tweet.tsx
View file @
5ff48177
import
{
NextTweet
}
from
'next-tweet'
import
{
Caption
}
from
'./caption'
import
type
{
ReactNode
}
from
'react'
import
type
{
ReactNode
}
from
'react'
import
{
Tweet
as
ReactTweet
,
TweetComponents
}
from
'react-tweet'
import
Image
from
'next/image'
import
{
Caption
}
from
'./caption'
const
components
:
TweetComponents
=
{
AvatarImg
:
(
props
)
=>
<
Image
{
...
props
}
/>,
MediaImg
:
(
props
)
=>
<
Image
{
...
props
}
fill
unoptimized
/>,
}
// we import this globally in the top-most layout.tsx file
// we import this globally in the top-most layout.tsx file
// until Next.js lands suspense-y CSS support
// until Next.js lands suspense-y CSS support
...
@@ -16,7 +23,7 @@ export async function Tweet({ id, caption }: TweetArgs) {
...
@@ -16,7 +23,7 @@ export async function Tweet({ id, caption }: TweetArgs) {
<
div
className=
"my-6"
>
<
div
className=
"my-6"
>
<
div
className=
"flex justify-center"
>
<
div
className=
"flex justify-center"
>
{
/* @ts-ignore */
}
{
/* @ts-ignore */
}
<
NextTweet
id=
{
id
}
/>
<
ReactTweet
id=
{
id
}
components=
{
components
}
/>
</
div
>
</
div
>
{
caption
&&
<
Caption
>
{
caption
}
</
Caption
>
}
{
caption
&&
<
Caption
>
{
caption
}
</
Caption
>
}
</
div
>
</
div
>
...
...
test/lib/development-sandbox.ts
View file @
5ff48177
...
@@ -95,14 +95,14 @@ export async function sandbox(
...
@@ -95,14 +95,14 @@ export async function sandbox(
async
remove
(
filename
)
{
async
remove
(
filename
)
{
await
next
.
deleteFile
(
filename
)
await
next
.
deleteFile
(
filename
)
},
},
async
evaluate
(
snippet
:
()
=>
any
)
{
async
evaluate
(
snippet
:
string
|
Function
)
{
if
(
typeof
snippet
===
'function'
)
{
if
(
typeof
snippet
===
'function'
||
typeof
snippet
===
'string'
)
{
const
result
=
await
browser
.
eval
(
snippet
)
const
result
=
await
browser
.
eval
(
snippet
)
await
waitFor
(
30
)
await
waitFor
(
30
)
return
result
return
result
}
else
{
}
else
{
throw
new
Error
(
throw
new
Error
(
`You must pass a function to be evaluated in the browser.`
`You must pass a
string or
function to be evaluated in the browser.`
)
)
}
}
},
},
...
...
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