Skip to content

Commit 651a539

Browse files
committed
Make sure switch is in the correct position + add test with async operation before navigation.
1 parent 182e86a commit 651a539

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

src/Components/test/E2ETest/ServerRenderingTests/NoInteractivityTest.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,28 @@ public void NavigatesWithoutInteractivityByRequestRedirection(bool controlFlowBy
8383
[Theory]
8484
[InlineData(true)]
8585
[InlineData(false)]
86-
public void ProgrammaticNavigationToNotExistingPathReExecutesTo404(bool streaming)
86+
public void ProgrammaticNavigationToNotExistingPath_ReExecutesTo404(bool streaming)
8787
{
88+
AppContext.SetSwitch("Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException", isEnabled: true);
8889
string streamingPath = streaming ? "-streaming" : "";
8990
Navigate($"{ServerPathBase}/reexecution/redirection-not-found-ssr{streamingPath}?navigate-programmatically=true");
9091
AssertReExecutionPageRendered();
9192
}
9293

94+
[Fact]
95+
public void ProgrammaticNavigationToNotExistingPath_AfterAsyncOperation_ReExecutesTo404()
96+
{
97+
AppContext.SetSwitch("Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException", isEnabled: true);
98+
Navigate($"{ServerPathBase}/reexecution/redirection-not-found-ssr?doAsync=true&navigate-programmatically=true");
99+
AssertReExecutionPageRendered();
100+
}
101+
93102
[Theory]
94103
[InlineData(true)]
95104
[InlineData(false)]
96-
public void LinkNavigationToNotExistingPathReExecutesTo404(bool streaming)
105+
public void LinkNavigationToNotExistingPath_ReExecutesTo404(bool streaming)
97106
{
107+
AppContext.SetSwitch("Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException", isEnabled: true);
98108
string streamingPath = streaming ? "-streaming" : "";
99109
Navigate($"{ServerPathBase}/reexecution/redirection-not-found-ssr{streamingPath}");
100110
Browser.Click(By.Id("link-to-not-existing-page"));
@@ -104,8 +114,9 @@ public void LinkNavigationToNotExistingPathReExecutesTo404(bool streaming)
104114
[Theory]
105115
[InlineData(true)]
106116
[InlineData(false)]
107-
public void BrowserNavigationToNotExistingPathReExecutesTo404(bool streaming)
117+
public void BrowserNavigationToNotExistingPath_ReExecutesTo404(bool streaming)
108118
{
119+
AppContext.SetSwitch("Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException", isEnabled: true);
109120
// non-existing path has to have re-execution middleware set up
110121
// so it has to have "reexecution" prefix. Otherwise middleware mapping
111122
// will not be activated, see configuration in Startup

src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/NotFound/RedirectionNotFound-SSR-streaming.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
@page "/reexecution/redirection-not-found-ssr-streaming"
33
@attribute [StreamRendering(true)]
44

5-
<Components.WasmMinimal.Pages.NotFound.RedirectionNotFoundComponent StartStreaming="true" />
5+
<Components.WasmMinimal.Pages.NotFound.RedirectionNotFoundComponent DoAsyncOperationBeforeRedirection="true" />

src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/NotFound/RedirectionNotFound-SSR.razor

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@
22
@page "/reexecution/redirection-not-found-ssr"
33
@attribute [StreamRendering(false)]
44

5-
<Components.WasmMinimal.Pages.NotFound.RedirectionNotFoundComponent />
5+
<Components.WasmMinimal.Pages.NotFound.RedirectionNotFoundComponent DoAsyncOperationBeforeRedirection="@DoAsync" />
6+
7+
@code{
8+
[SupplyParameterFromQuery(Name = "doAsync")]
9+
public bool DoAsync { get; set; } = false;
10+
}

src/Components/test/testassets/Components.WasmMinimal/Pages/NotFound/RedirectionNotFoundComponent.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
public bool? NavigateProgrammatically { get; set; }
1717

1818
[Parameter]
19-
public bool StartStreaming { get; set; } = false;
19+
public bool DoAsyncOperationBeforeRedirection { get; set; } = false;
2020

2121
[Parameter]
2222
public bool WaitForInteractivity { get; set; } = false;
@@ -25,7 +25,7 @@
2525

2626
protected override async Task OnInitializedAsync()
2727
{
28-
if (StartStreaming)
28+
if (DoAsyncOperationBeforeRedirection)
2929
{
3030
await Task.Yield();
3131
}

0 commit comments

Comments
 (0)