@@ -106,6 +106,16 @@ function runTests(isDev) {
106
106
initialRevalidateSeconds : false ,
107
107
srcRoute : '/gsp/no-fallback/[slug]' ,
108
108
} ,
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
+ } ,
109
119
'/en-US/not-found/fallback/first' : {
110
120
dataRoute : `/_next/data/${ buildId } /en-US/not-found/fallback/first.json` ,
111
121
initialRevalidateSeconds : false ,
@@ -157,6 +167,18 @@ function runTests(isDev) {
157
167
) } /gsp/no\\-fallback/([^/]+?)\\.json$`
158
168
) ,
159
169
} ,
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
+ } ,
160
182
'/not-found/fallback/[slug]' : {
161
183
dataRoute : `/_next/data/${ buildId } /not-found/fallback/[slug].json` ,
162
184
dataRouteRegex : normalizeRegEx (
@@ -957,6 +979,70 @@ function runTests(isDev) {
957
979
expect ( await browser . eval ( 'window.beforeNav' ) ) . toBe ( 1 )
958
980
} )
959
981
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
+
960
1046
it ( 'should not remove locale prefix for default locale' , async ( ) => {
961
1047
const res = await fetchViaHTTP ( appPort , '/en-US' , undefined , {
962
1048
redirect : 'manual' ,
0 commit comments