@@ -214,5 +214,78 @@ describe(`app-dir-hmr`, () => {
214
214
it ( 'should have no unexpected action error for hmr' , async ( ) => {
215
215
expect ( next . cliOutput ) . not . toContain ( 'Unexpected action' )
216
216
} )
217
+
218
+ it ( 'can navigate cleanly to a page that requires a change in the Webpack runtime' , async ( ) => {
219
+ // This isn't a very accurate test since the Webpack runtime is somewhat an implementation detail.
220
+ // To ensure this is still valid, check the `*/webpack.*.hot-update.js` network response content when the navigation is triggered.
221
+ // If there is new functionality added, the test is still valid.
222
+ // If not, the test doesn't cover anything new.
223
+ // TODO: Enforce console.error assertions or MPA navigation assertions in all tests instead.
224
+ const browser = await next . browser ( '/bundler-runtime-changes' )
225
+ await browser . eval ( 'window.__TEST_NO_RELOAD = true' )
226
+
227
+ await browser
228
+ . elementByCss ( 'a' )
229
+ . click ( )
230
+ . waitForElementByCss ( '[data-testid="new-runtime-functionality-page"]' )
231
+
232
+ const logs = await browser . log ( )
233
+ if ( process . env . TURBOPACK ) {
234
+ // FIXME: logging "rebuilding" multiple times instead of closing it of with "done in"
235
+ // Should just not branch here and have the same logs as Webpack.
236
+ expect ( logs ) . toEqual (
237
+ expect . arrayContaining ( [
238
+ {
239
+ message : '[Fast Refresh] rebuilding' ,
240
+ source : 'log' ,
241
+ } ,
242
+ {
243
+ message : '[Fast Refresh] rebuilding' ,
244
+ source : 'log' ,
245
+ } ,
246
+ {
247
+ message : '[Fast Refresh] rebuilding' ,
248
+ source : 'log' ,
249
+ } ,
250
+ ] )
251
+ )
252
+ expect ( logs ) . not . toEqual (
253
+ expect . arrayContaining ( [
254
+ {
255
+ message : expect . stringContaining ( '[Fast Refresh] done in' ) ,
256
+ source : 'log' ,
257
+ } ,
258
+ ] )
259
+ )
260
+ } else {
261
+ // TODO: Should assert on all logs but these are cluttered with logs from our test utils (e.g. playwright tracing or webdriver)
262
+ expect ( logs ) . toEqual (
263
+ expect . arrayContaining ( [
264
+ {
265
+ message : '[Fast Refresh] rebuilding' ,
266
+ source : 'log' ,
267
+ } ,
268
+ {
269
+ message : expect . stringContaining ( '[Fast Refresh] done in' ) ,
270
+ source : 'log' ,
271
+ } ,
272
+ ] )
273
+ )
274
+ expect ( logs ) . toEqual (
275
+ expect . arrayContaining ( [
276
+ expect . objectContaining ( {
277
+ source : 'error' ,
278
+ } ) ,
279
+ ] )
280
+ )
281
+ }
282
+ if ( process . env . TURBOPACK ) {
283
+ // No MPA navigation triggered
284
+ expect ( await browser . eval ( 'window.__TEST_NO_RELOAD' ) ) . toEqual ( true )
285
+ } else {
286
+ // MPA navigation triggered
287
+ expect ( await browser . eval ( 'window.__TEST_NO_RELOAD' ) ) . toEqual ( undefined )
288
+ }
289
+ } )
217
290
} )
218
291
} )
0 commit comments