@@ -127,16 +127,11 @@ private void AssertNotFoundPageRendered()
127127 private void AssertUrlNotChanged ( string expectedUrl ) =>
128128 Browser . True ( ( ) => Browser . Url . Contains ( expectedUrl ) , $ "Expected URL to contain '{ expectedUrl } ', but found '{ Browser . Url } '") ;
129129
130- private void AssertUrlChanged ( string urlPart ) =>
131- Browser . False ( ( ) => Browser . Url . Contains ( urlPart ) , $ "Expected URL not to contain '{ urlPart } ', but found '{ Browser . Url } '") ;
132-
133130 [ Theory ]
134131 [ InlineData ( true , true ) ]
135132 [ InlineData ( true , false ) ]
136133 [ InlineData ( false , true ) ]
137134 [ InlineData ( false , false ) ]
138- // When response has not started, it does not matter how we arrive the the page setting the not found status code.
139- // We can navigate straight to the testing page, skipping the index page.
140135 public void NotFoundSetOnInitialization_ResponseNotStarted_SSR ( bool hasReExecutionMiddleware , bool hasCustomNotFoundPageSet )
141136 {
142137 string reexecution = hasReExecutionMiddleware ? "/reexecution" : "" ;
@@ -154,32 +149,18 @@ public void NotFoundSetOnInitialization_ResponseNotStarted_SSR(bool hasReExecuti
154149 AssertUrlNotChanged ( testUrl ) ;
155150 }
156151
157- // If the response has started, it matters how we arrive the the page setting the not found status code
158- // because we are rendering client-side. In browser-initiated navigation and form submissions, the headers
159- // don't contain enhanced-nav and we redirect to the not found page. In link clicking navigation,
160- // the headers contain enhanced-nav, redirection is not needed and the original url is preserved.
161-
162152 [ Theory ]
163153 [ InlineData ( true , true ) ]
164154 [ InlineData ( true , false ) ]
165155 [ InlineData ( false , true ) ]
166156 [ InlineData ( false , false ) ]
167- // enhanced navigation is switched off for browser navigation
168157 public void NotFoundSetOnInitialization_ResponseStarted_BrowserNavigation_SSR ( bool hasReExecutionMiddleware , bool hasCustomNotFoundPageSet )
169158 {
170159 string reexecution = hasReExecutionMiddleware ? "/reexecution" : "" ;
171160 string testUrl = $ "{ ServerPathBase } { reexecution } /set-not-found-ssr-streaming?useCustomNotFoundPage={ hasCustomNotFoundPageSet } ";
172161 Navigate ( testUrl ) ;
173162 AssertNotFoundRendered_ResponseStarted_Or_POST ( hasReExecutionMiddleware , hasCustomNotFoundPageSet , testUrl ) ;
174- bool throwsException = ! hasCustomNotFoundPageSet && ! hasReExecutionMiddleware ;
175- if ( throwsException )
176- {
177- AssertUrlNotChanged ( testUrl ) ;
178- }
179- else
180- {
181- AssertUrlChanged ( testUrl ) ;
182- }
163+ AssertUrlNotChanged ( testUrl ) ;
183164 }
184165
185166 private void AssertNotFoundRendered_ResponseStarted_Or_POST ( bool hasReExecutionMiddleware , bool hasCustomNotFoundPageSet , string testUrl )
@@ -204,7 +185,6 @@ private void AssertNotFoundRendered_ResponseStarted_Or_POST(bool hasReExecutionM
204185 [ InlineData ( true , false ) ]
205186 [ InlineData ( false , true ) ]
206187 [ InlineData ( false , false ) ]
207- // enhanced navigation is switched on for link navigation
208188 public void NotFoundSetOnInitialization_ResponseStarted_LinkNavigation_SSR ( bool hasReExecutionMiddleware , bool hasCustomNotFoundPageSet )
209189 {
210190 string testUrl = NavigateByLinkToPageTestingNotFound ( "Sets" , hasReExecutionMiddleware , hasCustomNotFoundPageSet ) ;
@@ -229,8 +209,6 @@ private string NavigateByLinkToPageTestingNotFound(string action, bool hasReExec
229209 [ InlineData ( true , false ) ]
230210 [ InlineData ( false , true ) ]
231211 [ InlineData ( false , false ) ]
232- // NotFound triggered by POST cannot get rendered in the same batch and we rely on the client to render it
233- // However, because it is triggered by form POST, it won't have enhanced-nav headers
234212 public void NotFoundSetOnFormSubmit_ResponseNotStarted_SSR ( bool hasReExecutionMiddleware , bool hasCustomNotFoundPageSet )
235213 {
236214 string reexecution = hasReExecutionMiddleware ? "/reexecution" : "" ;
@@ -239,15 +217,7 @@ public void NotFoundSetOnFormSubmit_ResponseNotStarted_SSR(bool hasReExecutionMi
239217 Browser . FindElement ( By . Id ( "not-found-form" ) ) . FindElement ( By . TagName ( "button" ) ) . Click ( ) ;
240218
241219 AssertNotFoundRendered_ResponseStarted_Or_POST ( hasReExecutionMiddleware , hasCustomNotFoundPageSet , testUrl ) ;
242- bool throwsException = ! hasCustomNotFoundPageSet && ! hasReExecutionMiddleware ;
243- if ( throwsException )
244- {
245- AssertUrlNotChanged ( testUrl ) ;
246- }
247- else
248- {
249- AssertUrlChanged ( testUrl ) ;
250- }
220+ AssertUrlNotChanged ( testUrl ) ;
251221 }
252222
253223 [ Theory ]
@@ -263,15 +233,7 @@ public void NotFoundSetOnFormSubmit_ResponseStarted_SSR(bool hasReExecutionMiddl
263233 Browser . FindElement ( By . Id ( "not-found-form" ) ) . FindElement ( By . TagName ( "button" ) ) . Click ( ) ;
264234
265235 AssertNotFoundRendered_ResponseStarted_Or_POST ( hasReExecutionMiddleware , hasCustomNotFoundPageSet , testUrl ) ;
266- bool throwsException = ! hasCustomNotFoundPageSet && ! hasReExecutionMiddleware ;
267- if ( throwsException )
268- {
269- AssertUrlNotChanged ( testUrl ) ;
270- }
271- else
272- {
273- AssertUrlChanged ( testUrl ) ;
274- }
236+ AssertUrlNotChanged ( testUrl ) ;
275237 }
276238
277239 private void AssertNotFoundFragmentRendered ( ) =>
0 commit comments