@@ -2,6 +2,8 @@ import { NextInstance, nextTestSetup } from 'e2e-utils'
2
2
import { links , locales } from './components/page'
3
3
import glob from 'glob'
4
4
import { promisify } from 'node:util'
5
+ import { waitForHydration } from 'development-sandbox'
6
+ import { setTimeout } from 'node:timers/promises'
5
7
6
8
const globp = promisify ( glob )
7
9
@@ -15,15 +17,22 @@ async function getDotNextFiles(next: NextInstance): Promise<Array<string>> {
15
17
}
16
18
17
19
describe ( 'ppr-navigations incremental' , ( ) => {
18
- const { next, isNextDev, isTurbopack } = nextTestSetup ( {
20
+ const { next, isNextDev, isTurbopack, isNextDeploy } = nextTestSetup ( {
19
21
files : __dirname ,
20
22
} )
21
23
22
24
it ( 'can navigate between all the links and back without writing to disk' , async ( ) => {
23
- const before = ! isNextDev && ! isTurbopack ? await getDotNextFiles ( next ) : [ ]
25
+ const before =
26
+ ! isNextDev && ! isTurbopack && ! isNextDeploy
27
+ ? await getDotNextFiles ( next )
28
+ : [ ]
24
29
25
30
const browser = await next . browser ( '/' )
26
31
32
+ await browser . waitForIdleNetwork ( )
33
+ await waitForHydration ( browser )
34
+ await setTimeout ( 500 )
35
+
27
36
// Add a variable to the window so we can tell if it MPA navigated. If this
28
37
// value is still true at the end of the test, then we know that the page
29
38
// didn't MPA navigate.
@@ -33,14 +42,11 @@ describe('ppr-navigations incremental', () => {
33
42
try {
34
43
for ( const { href } of links ) {
35
44
// Find the link element for the href and click it.
36
- await browser . elementByCss ( `a[href="/api/flow.js?q=https%3A%2F%2Fgithub.com%2Felibobcoder%2Fnext.js%2Fcommit%2F%253Cspan%2520class%3D"pl-s1">${ href } "]`) . click ( )
45
+ await browser . waitForElementByCss ( `a[href="/api/flow.js?q=https%3A%2F%2Fgithub.com%2Felibobcoder%2Fnext.js%2Fcommit%2F%253Cspan%2520class%3D"pl-s1">${ href } "]`) . click ( )
37
46
38
- // Wait for the network to be idle. This seems odd, but this is to help
39
- // catch the condition where a rouge 404 triggers a MPA navigation.
40
47
await browser . waitForIdleNetwork ( )
41
-
42
- // Check if the page navigated.
43
- expect ( await browser . eval ( `window.random` ) ) . toBe ( random )
48
+ await waitForHydration ( browser )
49
+ await setTimeout ( 500 )
44
50
45
51
// Wait for that page to load.
46
52
if ( href === '/' ) {
@@ -50,13 +56,16 @@ describe('ppr-navigations incremental', () => {
50
56
await browser . waitForElementByCss ( `[data-value="${ href } "]` )
51
57
}
52
58
53
- await browser . elementByCss ( '#dynamic' )
59
+ await browser . waitForElementByCss ( '#dynamic' , 1500 )
60
+
61
+ // Check if the page navigated.
62
+ expect ( await browser . eval ( `window.random` ) ) . toBe ( random )
54
63
}
55
64
} finally {
56
65
await browser . close ( )
57
66
}
58
67
59
- if ( ! isNextDev && ! isTurbopack ) {
68
+ if ( ! isNextDev && ! isTurbopack && ! isNextDeploy ) {
60
69
const after = await getDotNextFiles ( next )
61
70
62
71
// Ensure that no new files were written to disk. If this test fails, it's
0 commit comments