File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed
E2ETest/ServerRenderingTests
testassets/Components.TestServer Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 8
8
using Xunit . Abstractions ;
9
9
using Components . TestServer . RazorComponents ;
10
10
using OpenQA . Selenium ;
11
+ using OpenQA . Selenium . Support . Extensions ;
11
12
12
13
namespace Microsoft . AspNetCore . Components . E2ETests . ServerRenderingTests ;
13
14
@@ -307,6 +308,18 @@ public void RefreshWithForceReloadDoesFullPageReload(string renderMode)
307
308
Assert . EndsWith ( "/nav" , Browser . Url ) ;
308
309
}
309
310
311
+ [ Fact ]
312
+ public void EnhancedNavNotUsedForNonBlazorDestinations ( )
313
+ {
314
+ Navigate ( $ "{ ServerPathBase } /nav") ;
315
+ Browser . Equal ( "Hello" , ( ) => Browser . Exists ( By . TagName ( "h1" ) ) . Text ) ;
316
+ Assert . Equal ( "object" , Browser . ExecuteJavaScript < string > ( "return typeof Blazor" ) ) ; // Blazor JS is loaded
317
+
318
+ Browser . Exists ( By . TagName ( "nav" ) ) . FindElement ( By . LinkText ( "Non-Blazor HTML page" ) ) . Click ( ) ;
319
+ Browser . Equal ( "This is a non-Blazor endpoint" , ( ) => Browser . Exists ( By . TagName ( "h1" ) ) . Text ) ;
320
+ Assert . Equal ( "undefined" , Browser . ExecuteJavaScript < string > ( "return typeof Blazor" ) ) ; // Blazor JS is NOT loaded
321
+ }
322
+
310
323
private static bool IsElementStale ( IWebElement element )
311
324
{
312
325
try
Original file line number Diff line number Diff line change @@ -145,6 +145,13 @@ private static void MapEnhancedNavigationEndpoints(IEndpointRouteBuilder endpoin
145
145
endpoints . MapGet ( "redirect/nonblazor/get" , PerformRedirection ) ;
146
146
endpoints . MapPost ( "redirect/nonblazor/post" , PerformRedirection ) ;
147
147
148
+ // Used when testing enhanced navigation to non-Blazor endpoints
149
+ endpoints . Map ( "/nav/non-blazor-html-response" , async ( HttpResponse response ) =>
150
+ {
151
+ response . ContentType = "text/html" ;
152
+ await response . WriteAsync ( "<html><body><h1>This is a non-Blazor endpoint</h1><p>That's all</p></body></html>" ) ;
153
+ } ) ;
154
+
148
155
static Task PerformRedirection ( HttpRequest request , HttpResponse response )
149
156
{
150
157
response . Redirect ( request . Query [ "external" ] == "true"
Original file line number Diff line number Diff line change 7
7
<NavLink href =" nav/give-404-with-content" >Error page with 404 content</NavLink > |
8
8
<NavLink href =" nav/nonexistent-page" >Error page with no content</NavLink > |
9
9
<NavLink href =" nav/non-html-response" >Non-HTML page</NavLink > |
10
+ <NavLink href =" nav/non-blazor-html-response" >Non-Blazor HTML page</NavLink > |
10
11
<NavLink href =" nav/scroll-to-hash#some-content" >Scroll to hash</NavLink > |
11
12
<NavLink href =" nav/throw-while-streaming" >Error while streaming</NavLink > |
12
13
<NavLink href =" nav/interactive-component-navigation/server" >Interactive component navigation (server)</NavLink > |
You can’t perform that action at this time.
0 commit comments