@@ -151,21 +151,29 @@ public void NotFoundSetOnInitialization_ResponseNotStarted_SSR(bool hasReExecuti
151151 string testUrl = $ "{ ServerPathBase } { reexecution } /set-not-found-ssr?useCustomNotFoundPage={ hasCustomNotFoundPageSet } ";
152152 Navigate ( testUrl ) ;
153153
154- if ( hasCustomNotFoundPageSet )
155- {
156- AssertNotFoundPageRendered ( ) ;
157- }
158- else
159- {
160- AssertNotFoundFragmentRendered ( ) ;
161- }
154+ AssertNotFoundRendered_ResponseNotStarted ( hasCustomNotFoundPageSet ) ;
155+ AssertUrlNotChanged ( testUrl ) ;
156+ }
157+
158+ [ Theory ]
159+ [ InlineData ( true , true ) ]
160+ [ InlineData ( true , false ) ]
161+ [ InlineData ( false , true ) ]
162+ [ InlineData ( false , false ) ]
163+ public void NotFoundSetOnInitialization_AfterAsyncOperation_ResponseNotStarted_SSR ( bool hasReExecutionMiddleware , bool hasCustomNotFoundPageSet )
164+ {
165+ string reexecution = hasReExecutionMiddleware ? "/reexecution" : "" ;
166+ string testUrl = $ "{ ServerPathBase } { reexecution } /set-not-found-ssr?doAsync=true&useCustomNotFoundPage={ hasCustomNotFoundPageSet } ";
167+ Navigate ( testUrl ) ;
168+
169+ AssertNotFoundRendered_ResponseNotStarted ( hasCustomNotFoundPageSet ) ;
162170 AssertUrlNotChanged ( testUrl ) ;
163171 }
164172
165173 [ Theory ]
166174 [ InlineData ( true ) ]
167175 [ InlineData ( false ) ]
168- // our custom router does not support NotFoundPage nor NotFound fragment to simulate most probable custom router behavior
176+ // our custom router does not support NotFoundPage to simulate the most probable custom router behavior
169177 public void NotFoundSetOnInitialization_ResponseNotStarted_CustomRouter_SSR ( bool hasReExecutionMiddleware )
170178 {
171179 string reexecution = hasReExecutionMiddleware ? "/reexecution" : "" ;
@@ -196,7 +204,7 @@ public void NotFoundSetOnInitialization_ResponseStarted_SSR(bool hasReExecutionM
196204 string reexecution = hasReExecutionMiddleware ? "/reexecution" : "" ;
197205 string testUrl = $ "{ ServerPathBase } { reexecution } /set-not-found-ssr-streaming?useCustomNotFoundPage={ hasCustomNotFoundPageSet } ";
198206 Navigate ( testUrl ) ;
199- AssertNotFoundRendered_ResponseStarted_Or_POST ( hasReExecutionMiddleware , hasCustomNotFoundPageSet , testUrl ) ;
207+ AssertNotFoundRendered_ResponseStarted ( hasReExecutionMiddleware , hasCustomNotFoundPageSet , testUrl ) ;
200208 AssertUrlNotChanged ( testUrl ) ;
201209 }
202210
@@ -210,11 +218,47 @@ public void NotFoundSetOnInitialization_ResponseStarted_EnhancedNavigationDisabl
210218 string reexecution = hasReExecutionMiddleware ? "/reexecution" : "" ;
211219 string testUrl = $ "{ ServerPathBase } { reexecution } /set-not-found-ssr-streaming?useCustomNotFoundPage={ hasCustomNotFoundPageSet } ";
212220 Navigate ( testUrl ) ;
213- AssertNotFoundRendered_ResponseStarted_Or_POST ( hasReExecutionMiddleware , hasCustomNotFoundPageSet , testUrl ) ;
221+ AssertNotFoundRendered_ResponseStarted ( hasReExecutionMiddleware , hasCustomNotFoundPageSet , testUrl ) ;
214222 AssertUrlChanged ( testUrl ) ;
215223 }
216224
217- private void AssertNotFoundRendered_ResponseStarted_Or_POST ( bool hasReExecutionMiddleware , bool hasCustomNotFoundPageSet , string testUrl )
225+ [ Theory ]
226+ [ InlineData ( true ) ]
227+ [ InlineData ( false ) ]
228+ // our custom router does not support NotFoundPage to simulate the most probable custom router behavior
229+ public void NotFoundSetOnInitialization_ResponseStarted_CustomRouter_SSR ( bool hasReExecutionMiddleware )
230+ {
231+ string reexecution = hasReExecutionMiddleware ? "/reexecution" : "" ;
232+ string testUrl = $ "{ ServerPathBase } { reexecution } /set-not-found-ssr-streaming?useCustomRouter=true";
233+ Navigate ( testUrl ) ;
234+
235+ if ( hasReExecutionMiddleware )
236+ {
237+ AssertReExecutionPageRendered ( ) ;
238+ }
239+ else
240+ {
241+ // Apps that don't support re-execution and don't have blazor's router,
242+ // cannot render custom NotFound contents.
243+ // The browser will display default 404 page.
244+ AssertBrowserDefaultNotFoundViewRendered ( ) ;
245+ }
246+ AssertUrlNotChanged ( testUrl ) ;
247+ }
248+
249+ private void AssertNotFoundRendered_ResponseNotStarted ( bool hasCustomNotFoundPageSet )
250+ {
251+ if ( hasCustomNotFoundPageSet )
252+ {
253+ AssertNotFoundPageRendered ( ) ;
254+ }
255+ else
256+ {
257+ AssertNotFoundContentNotRendered ( ) ;
258+ }
259+ }
260+
261+ private void AssertNotFoundRendered_ResponseStarted ( bool hasReExecutionMiddleware , bool hasCustomNotFoundPageSet , string testUrl )
218262 {
219263 if ( hasCustomNotFoundPageSet )
220264 {
@@ -243,7 +287,33 @@ public void NotFoundSetOnFormSubmit_ResponseNotStarted_SSR(bool hasReExecutionMi
243287 Navigate ( testUrl ) ;
244288 Browser . FindElement ( By . Id ( "not-found-form" ) ) . FindElement ( By . TagName ( "button" ) ) . Click ( ) ;
245289
246- AssertNotFoundRendered_ResponseStarted_Or_POST ( hasReExecutionMiddleware , hasCustomNotFoundPageSet , testUrl ) ;
290+ AssertNotFoundRendered_ResponseNotStarted ( hasCustomNotFoundPageSet ) ;
291+ AssertUrlNotChanged ( testUrl ) ;
292+ }
293+
294+ [ Theory ]
295+ [ InlineData ( true , true ) ]
296+ [ InlineData ( true , false ) ]
297+ [ InlineData ( false , true ) ]
298+ [ InlineData ( false , false ) ]
299+ public void NotFoundSetOnFormSubmit_AfterAsyncOperation_ResponseNotStarted_SSR ( bool hasReExecutionMiddleware , bool hasCustomNotFoundPageSet )
300+ {
301+ string reexecution = hasReExecutionMiddleware ? "/reexecution" : "" ;
302+ string testUrl = $ "{ ServerPathBase } { reexecution } /post-not-found-ssr?doAsync=true&useCustomNotFoundPage={ hasCustomNotFoundPageSet } ";
303+ Navigate ( testUrl ) ;
304+ Browser . FindElement ( By . Id ( "not-found-form" ) ) . FindElement ( By . TagName ( "button" ) ) . Click ( ) ;
305+
306+ AssertNotFoundRendered_ResponseNotStarted ( hasCustomNotFoundPageSet ) ;
307+ AssertUrlNotChanged ( testUrl ) ;
308+ }
309+
310+ [ Fact ]
311+ public void NotFoundSetOnFormSubmit_ResponseNotStarted_CustomRouter_SSR ( )
312+ {
313+ string testUrl = $ "{ ServerPathBase } /reexecution/post-not-found-ssr?useCustomRouter=true";
314+ Navigate ( testUrl ) ;
315+
316+ AssertReExecutionPageRendered ( ) ;
247317 AssertUrlNotChanged ( testUrl ) ;
248318 }
249319
@@ -259,12 +329,19 @@ public void NotFoundSetOnFormSubmit_ResponseStarted_SSR(bool hasReExecutionMiddl
259329 Navigate ( testUrl ) ;
260330 Browser . FindElement ( By . Id ( "not-found-form" ) ) . FindElement ( By . TagName ( "button" ) ) . Click ( ) ;
261331
262- AssertNotFoundRendered_ResponseStarted_Or_POST ( hasReExecutionMiddleware , hasCustomNotFoundPageSet , testUrl ) ;
332+ AssertNotFoundRendered_ResponseStarted ( hasReExecutionMiddleware , hasCustomNotFoundPageSet , testUrl ) ;
263333 AssertUrlNotChanged ( testUrl ) ;
264334 }
265335
266- private void AssertNotFoundFragmentRendered ( ) =>
267- Browser . Equal ( "There's nothing here" , ( ) => Browser . FindElement ( By . Id ( "not-found-fragment" ) ) . Text ) ;
336+ [ Fact ]
337+ public void NotFoundSetOnFormSubmit_ResponseStarted_CustomRouter_SSR ( )
338+ {
339+ string testUrl = $ "{ ServerPathBase } /reexecution/post-not-found-ssr-streaming?useCustomRouter=true";
340+ Navigate ( testUrl ) ;
341+
342+ AssertReExecutionPageRendered ( ) ;
343+ AssertUrlNotChanged ( testUrl ) ;
344+ }
268345
269346 private void AssertNotFoundContentNotRendered ( ) =>
270347 Browser . Equal ( "Any content" , ( ) => Browser . FindElement ( By . Id ( "test-info" ) ) . Text ) ;
0 commit comments