diff --git a/src/Components/Web.JS/src/Services/NavigationEnhancement.ts b/src/Components/Web.JS/src/Services/NavigationEnhancement.ts index e029c77178dd..9dcd7540d866 100644 --- a/src/Components/Web.JS/src/Services/NavigationEnhancement.ts +++ b/src/Components/Web.JS/src/Services/NavigationEnhancement.ts @@ -455,6 +455,7 @@ function enhancedNavigationIsEnabledForForm(form: HTMLFormElement): boolean { function retryEnhancedNavAsFullPageLoad(internalDestinationHref: string) { // The ? trick here is the same workaround as described in #10839, and without it, the user // would not be able to use the back button afterwards. + console.warn(`Enhanced navigation failed for destination ${internalDestinationHref}. Falling back to full page load.`); history.replaceState(null, '', internalDestinationHref + '?'); location.replace(internalDestinationHref); } diff --git a/src/Components/test/E2ETest/ServerRenderingTests/EnhancedNavigationTest.cs b/src/Components/test/E2ETest/ServerRenderingTests/EnhancedNavigationTest.cs index 8c1a1717b162..7dfaf3523287 100644 --- a/src/Components/test/E2ETest/ServerRenderingTests/EnhancedNavigationTest.cs +++ b/src/Components/test/E2ETest/ServerRenderingTests/EnhancedNavigationTest.cs @@ -73,6 +73,10 @@ public void CanNavigateToNonHtmlResponse() Navigate($"{ServerPathBase}/nav"); Browser.Exists(By.TagName("nav")).FindElement(By.LinkText("Non-HTML page")).Click(); Browser.Equal("Hello, this is plain text", () => Browser.Exists(By.TagName("html")).Text); + + //Check if the fall back because of the non-html response sends a warning + var logs = Browser.GetBrowserLogs(LogLevel.Warning); + Assert.Contains(logs, log => log.Message.Contains("Enhanced navigation failed for destination") && log.Message.Contains("Falling back to full page load.") && !log.Message.Contains("Error")); } [Fact] @@ -465,6 +469,11 @@ public void EnhancedNavNotUsedForNonBlazorDestinations() Browser.Exists(By.TagName("nav")).FindElement(By.LinkText("Non-Blazor HTML page")).Click(); Browser.Equal("This is a non-Blazor endpoint", () => Browser.Exists(By.TagName("h1")).Text); Assert.Equal("undefined", Browser.ExecuteJavaScript("return typeof Blazor")); // Blazor JS is NOT loaded + + //Check if the fall back because of the non-blazor endpoint navigation sends a warning + var logs = Browser.GetBrowserLogs(LogLevel.Warning); + Assert.Contains(logs, log => log.Message.Contains("Enhanced navigation failed for destination") && log.Message.Contains("Falling back to full page load.") && !log.Message.Contains("Error")); + } [Theory]