1212
1313namespace Microsoft . AspNetCore . Components . E2ETests . ServerRenderingTests ;
1414
15- public class RedirectionTest : ServerTestBase < BasicTestAppServerSiteFixture < RazorComponentEndpointsStartup < App > > >
15+ public class RedirectionTest :
16+ ServerTestBase < BasicTestAppServerSiteFixture < RazorComponentEndpointsStartup < App > > > ,
17+ IClassFixture < BasicTestAppServerSiteFixture < ExternalNavigationStartup > >
1618{
19+ private readonly Uri _externalNavigationTargetUri ;
20+ private readonly Uri _externalNavigationTargetUriWithQuery ;
1721 private IWebElement _originalH1Element ;
1822
1923 public RedirectionTest (
2024 BrowserFixture browserFixture ,
2125 BasicTestAppServerSiteFixture < RazorComponentEndpointsStartup < App > > serverFixture ,
26+ BasicTestAppServerSiteFixture < ExternalNavigationStartup > externalNavigationFixture ,
2227 ITestOutputHelper output )
2328 : base ( browserFixture , serverFixture , output )
2429 {
30+ _externalNavigationTargetUri = new Uri ( externalNavigationFixture . RootUri , "/external-navigation-target" ) ;
31+ _externalNavigationTargetUriWithQuery = new Uri ( $ "{ _externalNavigationTargetUri } ?foo=🙂") ;
32+ serverFixture . AdditionalArguments . Add ( $ "--ExternalNavigationTargetUri={ _externalNavigationTargetUri . AbsoluteUri } ") ;
2533 }
2634
2735 public override async Task InitializeAsync ( )
@@ -55,12 +63,11 @@ public void RedirectStreamingGetToInternal(bool disableThrowNavigationException)
5563 [ Theory ]
5664 [ InlineData ( true ) ]
5765 [ InlineData ( false ) ]
58- [ QuarantinedTest ( "https://github.com/dotnet/aspnetcore/issues/66969" ) ]
5966 public void RedirectStreamingGetToExternal ( bool disableThrowNavigationException )
6067 {
6168 AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
6269 Browser . Exists ( By . LinkText ( "Streaming GET with external redirection" ) ) . Click ( ) ;
63- Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
70+ AssertExternalNavigationCompleted ( ) ;
6471 }
6572
6673 [ Theory ]
@@ -85,12 +92,11 @@ public void RedirectStreamingPostToInternal(bool disableThrowNavigationException
8592 [ Theory ]
8693 [ InlineData ( true ) ]
8794 [ InlineData ( false ) ]
88- [ QuarantinedTest ( "https://github.com/dotnet/aspnetcore/issues/67342" ) ]
8995 public void RedirectStreamingPostToExternal ( bool disableThrowNavigationException )
9096 {
9197 AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
9298 Browser . Exists ( By . CssSelector ( "#form-streaming-external button" ) ) . Click ( ) ;
93- Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
99+ AssertExternalNavigationCompleted ( ) ;
94100 }
95101
96102 [ Theory ]
@@ -119,12 +125,11 @@ public void RedirectEnhancedGetToInternal(bool disableThrowNavigationException)
119125 [ Theory ]
120126 [ InlineData ( true ) ]
121127 [ InlineData ( false ) ]
122- [ QuarantinedTest ( "https://github.com/dotnet/aspnetcore/issues/67738" ) ]
123128 public void RedirectEnhancedGetToExternal ( bool disableThrowNavigationException )
124129 {
125130 AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
126131 Browser . Exists ( By . LinkText ( "Enhanced GET with external redirection" ) ) . Click ( ) ;
127- Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
132+ AssertExternalNavigationCompleted ( ) ;
128133 }
129134
130135 [ Theory ]
@@ -148,12 +153,11 @@ public void RedirectEnhancedPostToInternal(bool disableThrowNavigationException)
148153 [ Theory ]
149154 [ InlineData ( true ) ]
150155 [ InlineData ( false ) ]
151- [ QuarantinedTest ( "https://github.com/dotnet/aspnetcore/issues/67444" ) ]
152156 public void RedirectEnhancedPostToExternal ( bool disableThrowNavigationException )
153157 {
154158 AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
155159 Browser . Exists ( By . CssSelector ( "#form-enhanced-external button" ) ) . Click ( ) ;
156- Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
160+ AssertExternalNavigationCompleted ( ) ;
157161 }
158162
159163 [ Theory ]
@@ -177,13 +181,12 @@ public void RedirectStreamingEnhancedGetToInternal(bool disableThrowNavigationEx
177181 [ Theory ]
178182 [ InlineData ( true ) ]
179183 [ InlineData ( false ) ]
180- [ QuarantinedTest ( "https://github.com/dotnet/aspnetcore/issues/66969" ) ]
181184 public void RedirectStreamingEnhancedGetToExternal ( bool disableThrowNavigationException )
182185 {
183186 AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
184187
185188 Browser . Exists ( By . LinkText ( "Streaming enhanced GET with external redirection" ) ) . Click ( ) ;
186- Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
189+ AssertExternalNavigationCompleted ( ) ;
187190 }
188191
189192 [ Theory ]
@@ -207,13 +210,12 @@ public void RedirectStreamingEnhancedPostToInternal(bool disableThrowNavigationE
207210 [ Theory ]
208211 [ InlineData ( true ) ]
209212 [ InlineData ( false ) ]
210- [ QuarantinedTest ( "https://github.com/dotnet/aspnetcore/issues/66869" ) ]
211213 public void RedirectStreamingEnhancedPostToExternal ( bool disableThrowNavigationException )
212214 {
213215 AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
214216
215217 Browser . Exists ( By . CssSelector ( "#form-streaming-enhanced-external button" ) ) . Click ( ) ;
216- Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
218+ AssertExternalNavigationCompleted ( ) ;
217219 }
218220
219221 [ Theory ]
@@ -238,13 +240,12 @@ public void RedirectEnhancedNonBlazorGetToInternal(bool disableThrowNavigationEx
238240 [ Theory ]
239241 [ InlineData ( true ) ]
240242 [ InlineData ( false ) ]
241- [ QuarantinedTest ( "https://github.com/dotnet/aspnetcore/issues/67342" ) ]
242243 public void RedirectEnhancedNonBlazorGetToExternal ( bool disableThrowNavigationException )
243244 {
244245 AppContext . SetSwitch ( "Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException" , disableThrowNavigationException ) ;
245246
246247 Browser . Exists ( By . LinkText ( "Enhanced GET to non-Blazor endpoint with external redirection" ) ) . Click ( ) ;
247- Browser . Contains ( "microsoft.com" , ( ) => Browser . Url ) ;
248+ AssertExternalNavigationCompleted ( hasQuery : false ) ;
248249 }
249250
250251 [ Theory ]
@@ -322,4 +323,11 @@ private void AssertElementRemoved(IWebElement element)
322323 return false ;
323324 } ) ;
324325 }
326+
327+ private void AssertExternalNavigationCompleted ( bool hasQuery = true )
328+ {
329+ var expectedUri = hasQuery ? _externalNavigationTargetUriWithQuery : _externalNavigationTargetUri ;
330+ Browser . Equal ( expectedUri , ( ) => new Uri ( Browser . Url ) ) ;
331+ Browser . Exists ( By . Id ( "external-navigation-target" ) ) ;
332+ }
325333}
0 commit comments