@@ -106,6 +106,16 @@ function runTests(isDev) {
106106 initialRevalidateSeconds : false ,
107107 srcRoute : '/gsp/no-fallback/[slug]' ,
108108 } ,
109+ '/en-US/not-found/blocking-fallback/first' : {
110+ dataRoute : `/_next/data/${ buildId } /en-US/not-found/blocking-fallback/first.json` ,
111+ initialRevalidateSeconds : false ,
112+ srcRoute : '/not-found/blocking-fallback/[slug]' ,
113+ } ,
114+ '/en-US/not-found/blocking-fallback/second' : {
115+ dataRoute : `/_next/data/${ buildId } /en-US/not-found/blocking-fallback/second.json` ,
116+ initialRevalidateSeconds : false ,
117+ srcRoute : '/not-found/blocking-fallback/[slug]' ,
118+ } ,
109119 '/en-US/not-found/fallback/first' : {
110120 dataRoute : `/_next/data/${ buildId } /en-US/not-found/fallback/first.json` ,
111121 initialRevalidateSeconds : false ,
@@ -157,6 +167,18 @@ function runTests(isDev) {
157167 ) } /gsp/no\\-fallback/([^/]+?)\\.json$`
158168 ) ,
159169 } ,
170+ '/not-found/blocking-fallback/[slug]' : {
171+ dataRoute : `/_next/data/${ buildId } /not-found/blocking-fallback/[slug].json` ,
172+ dataRouteRegex : normalizeRegEx (
173+ `^\\/_next\\/data\\/${ escapeRegex (
174+ buildId
175+ ) } \\/not\\-found\\/blocking\\-fallback\\/([^\\/]+?)\\.json$`
176+ ) ,
177+ fallback : null ,
178+ routeRegex : normalizeRegEx (
179+ `^\\/not\\-found\\/blocking\\-fallback\\/([^\\/]+?)(?:\\/)?$`
180+ ) ,
181+ } ,
160182 '/not-found/fallback/[slug]' : {
161183 dataRoute : `/_next/data/${ buildId } /not-found/fallback/[slug].json` ,
162184 dataRouteRegex : normalizeRegEx (
@@ -957,6 +979,70 @@ function runTests(isDev) {
957979 expect ( await browser . eval ( 'window.beforeNav' ) ) . toBe ( 1 )
958980 } )
959981
982+ it ( 'should render 404 for blocking fallback page that returned 404 on client transition' , async ( ) => {
983+ const browser = await webdriver ( appPort , '/en' , true , true )
984+ await browser . eval ( `(function() {
985+ next.router.push('/not-found/blocking-fallback/first')
986+ })()` )
987+ await browser . waitForElementByCss ( 'h1' )
988+ await browser . eval ( 'window.beforeNav = 1' )
989+
990+ expect ( await browser . elementByCss ( 'html' ) . text ( ) ) . toContain (
991+ 'This page could not be found'
992+ )
993+ const props = JSON . parse ( await browser . elementByCss ( '#props' ) . text ( ) )
994+
995+ expect ( props . is404 ) . toBe ( true )
996+ expect ( props . locale ) . toBe ( 'en' )
997+ expect ( await browser . elementByCss ( 'html' ) . getAttribute ( 'lang' ) ) . toBe ( 'en' )
998+
999+ const parsedUrl = url . parse (
1000+ await browser . eval ( 'window.location.href' ) ,
1001+ true
1002+ )
1003+ expect ( parsedUrl . pathname ) . toBe ( '/en/not-found/blocking-fallback/first' )
1004+ expect ( parsedUrl . query ) . toEqual ( { } )
1005+
1006+ if ( isDev ) {
1007+ // make sure page doesn't reload un-necessarily in development
1008+ await waitFor ( 10 * 1000 )
1009+ }
1010+ expect ( await browser . eval ( 'window.beforeNav' ) ) . toBe ( 1 )
1011+ } )
1012+
1013+ it ( 'should render 404 for blocking fallback page that returned 404' , async ( ) => {
1014+ const browser = await webdriver (
1015+ appPort ,
1016+ '/en/not-found/blocking-fallback/first' ,
1017+ true ,
1018+ true
1019+ )
1020+ await browser . waitForElementByCss ( 'h1' )
1021+ await browser . eval ( 'window.beforeNav = 1' )
1022+
1023+ expect ( await browser . elementByCss ( 'html' ) . text ( ) ) . toContain (
1024+ 'This page could not be found'
1025+ )
1026+ const props = JSON . parse ( await browser . elementByCss ( '#props' ) . text ( ) )
1027+
1028+ expect ( props . is404 ) . toBe ( true )
1029+ expect ( props . locale ) . toBe ( 'en' )
1030+ expect ( await browser . elementByCss ( 'html' ) . getAttribute ( 'lang' ) ) . toBe ( 'en' )
1031+
1032+ const parsedUrl = url . parse (
1033+ await browser . eval ( 'window.location.href' ) ,
1034+ true
1035+ )
1036+ expect ( parsedUrl . pathname ) . toBe ( '/en/not-found/blocking-fallback/first' )
1037+ expect ( parsedUrl . query ) . toEqual ( { } )
1038+
1039+ if ( isDev ) {
1040+ // make sure page doesn't reload un-necessarily in development
1041+ await waitFor ( 10 * 1000 )
1042+ }
1043+ expect ( await browser . eval ( 'window.beforeNav' ) ) . toBe ( 1 )
1044+ } )
1045+
9601046 it ( 'should not remove locale prefix for default locale' , async ( ) => {
9611047 const res = await fetchViaHTTP ( appPort , '/en-US' , undefined , {
9621048 redirect : 'manual' ,
0 commit comments