From f40458ce8e31ac468f3f343cca59e05f3e51432b Mon Sep 17 00:00:00 2001 From: Daria Tiurina Date: Tue, 8 Jul 2025 11:25:24 +0200 Subject: [PATCH] Added warning when enhanced navigation falls back to full page reload + test --- src/Components/Web.JS/src/Services/NavigationEnhancement.ts | 1 + .../E2ETest/ServerRenderingTests/EnhancedNavigationTest.cs | 4 ++++ 2 files changed, 5 insertions(+) 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..1bac70132ffd 100644 --- a/src/Components/test/E2ETest/ServerRenderingTests/EnhancedNavigationTest.cs +++ b/src/Components/test/E2ETest/ServerRenderingTests/EnhancedNavigationTest.cs @@ -324,6 +324,10 @@ public void RefreshCanFallBackOnFullPageReload(string renderMode) Browser.Exists(By.Id("refresh-with-refresh")).Click(); Browser.True(() => IsElementStale(initialRenderIdElement)); + //Check if the warning about the fail were logged. + var logs = Browser.GetBrowserLogs(LogLevel.Warning); + Assert.Contains(logs, log => log.Message.Contains("Enhanced navigation failed for destination") && !log.Message.Contains("Error")); + var finalRenderIdElement = Browser.Exists(By.Id("render-id")); var finalRenderId = -1; Browser.True(() => int.TryParse(finalRenderIdElement.Text, out finalRenderId));