-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Change priority of re-execution handling and allow router to stream NotFound
contents
#62178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
599f846
842941e
079b66f
301efac
e7ce5ba
a2bfccf
526dbb1
b166369
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,13 +80,6 @@ public void NavigatesWithoutInteractivityByRequestRedirection(bool controlFlowBy | |
Browser.Equal("Routing test cases", () => Browser.Exists(By.Id("test-info")).Text); | ||
} | ||
|
||
[Fact] | ||
public void CanRenderNotFoundPageAfterStreamingStarted() | ||
{ | ||
Navigate($"{ServerPathBase}/streaming-set-not-found"); | ||
Browser.Equal("Default Not Found Page", () => Browser.Title); | ||
} | ||
|
||
[Theory] | ||
[InlineData(true)] | ||
[InlineData(false)] | ||
|
@@ -127,36 +120,35 @@ private void Assert404ReExecuted() => | |
[Theory] | ||
[InlineData(true)] | ||
[InlineData(false)] | ||
public void CanRenderNotFoundPageNoStreaming(bool useCustomNotFoundPage) | ||
public void CanRenderNotFoundPage(bool streamingStarted) | ||
{ | ||
string query = useCustomNotFoundPage ? "&useCustomNotFoundPage=true" : ""; | ||
Navigate($"{ServerPathBase}/set-not-found?shouldSet=true{query}"); | ||
|
||
if (useCustomNotFoundPage) | ||
{ | ||
var infoText = Browser.FindElement(By.Id("test-info")).Text; | ||
Assert.Contains("Welcome On Custom Not Found Page", infoText); | ||
// custom page should have a custom layout | ||
var aboutLink = Browser.FindElement(By.Id("about-link")).Text; | ||
Assert.Contains("About", aboutLink); | ||
} | ||
else | ||
{ | ||
var bodyText = Browser.FindElement(By.TagName("body")).Text; | ||
Assert.Contains("There's nothing here", bodyText); | ||
} | ||
string streamingPath = streamingStarted ? "-streaming" : ""; | ||
Navigate($"{ServerPathBase}/set-not-found-ssr{streamingPath}?useCustomNotFoundPage=true"); | ||
|
||
var infoText = Browser.FindElement(By.Id("test-info")).Text; | ||
Assert.Contains("Welcome On Custom Not Found Page", infoText); | ||
// custom page should have a custom layout | ||
var aboutLink = Browser.FindElement(By.Id("about-link")).Text; | ||
Assert.Contains("About", aboutLink); | ||
} | ||
|
||
[Theory] | ||
[InlineData(true)] | ||
[InlineData(false)] | ||
public void CanRenderNotFoundPageWithStreaming(bool useCustomNotFoundPage) | ||
[InlineData(true)] | ||
public void DoesNotReExecuteIf404WasHandled(bool streamingStarted) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
{ | ||
// when streaming started, we always render page under "not-found" path | ||
string query = useCustomNotFoundPage ? "?useCustomNotFoundPage=true" : ""; | ||
Navigate($"{ServerPathBase}/streaming-set-not-found{query}"); | ||
string streamingPath = streamingStarted ? "-streaming" : ""; | ||
Navigate($"{ServerPathBase}/reexecution/set-not-found-ssr{streamingPath}"); | ||
AssertNotFoundFragmentRendered(); | ||
} | ||
|
||
private void AssertNotFoundFragmentRendered() => | ||
Browser.Equal("There's nothing here", () => Browser.FindElement(By.Id("not-found-fragment")).Text); | ||
|
||
string expectedTitle = "Default Not Found Page"; | ||
Browser.Equal(expectedTitle, () => Browser.Title); | ||
[Fact] | ||
public void StatusCodePagesWithReExecution() | ||
{ | ||
Navigate($"{ServerPathBase}/reexecution/trigger-404"); | ||
Browser.Equal("Re-executed page", () => Browser.Title); | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@inject NavigationManager NavigationManager | ||
|
||
@if (!WaitForInteractivity || RendererInfo.IsInteractive) | ||
{ | ||
<PageTitle>Original page</PageTitle> | ||
|
||
<p id="test-info">Any content</p> | ||
|
||
} | ||
|
||
@code{ | ||
[Parameter] | ||
public bool StartStreaming { get; set; } = false; | ||
|
||
[Parameter] | ||
public bool WaitForInteractivity { get; set; } = false; | ||
|
||
protected async override Task OnInitializedAsync() | ||
{ | ||
if (StartStreaming) | ||
{ | ||
await Task.Yield(); | ||
} | ||
NavigationManager.NotFound(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Razor"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<SupportedPlatform Include="browser" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="Microsoft.AspNetCore.Components.Web" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@page "/reexecution/set-not-found-ssr" | ||
@page "/set-not-found-ssr" | ||
@attribute [StreamRendering(false)] | ||
|
||
@* | ||
this page is used in global interactivity and no interactivity scenarios | ||
the content is rendered on the server without streaming and might become | ||
interactive later if interactivity was enabled in the app | ||
*@ | ||
|
||
<Components.Shared.ComponentThatSetsNotFound /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@page "/reexecution/set-not-found-ssr-streaming" | ||
@page "/set-not-found-ssr-streaming" | ||
@attribute [StreamRendering(true)] | ||
|
||
@* | ||
this page is used in global interactivity and no interactivity scenarios | ||
the content is rendered on the server with streaming and might become | ||
interactive later if interactivity was enabled in the app | ||
*@ | ||
|
||
<Components.Shared.ComponentThatSetsNotFound StartStreaming="true"/> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@using Microsoft.AspNetCore.Components.Web |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one covers the old:
CanRenderNotFoundPageNoStreaming(useCustomNotFoundPage: true)
,CanRenderNotFoundPageWithStreaming(useCustomNotFoundPage: true)
- we used to redirect to "not-found" route here, now the behavior is same as for no-streaming, so we can consolidate them.