-
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?
Change priority of re-execution handling and allow router to stream NotFound
contents
#62178
Conversation
…o shared project + redefine test cases.
@@ -127,36 +120,35 @@ private void Assert404ReExecuted() => | |||
[Theory] | |||
[InlineData(true)] | |||
[InlineData(false)] | |||
public void CanRenderNotFoundPageNoStreaming(bool useCustomNotFoundPage) | |||
public void CanRenderNotFoundPage(bool streamingStarted) |
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.
[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 comment
The reason will be displayed to describe this comment to others. Learn more.
DoesNotReExecuteIf404WasHandled(streamingStarted: true)
covers same content as CanRenderNotFoundPageWithStreaming(useCustomNotFoundPage: false)
.
DoesNotReExecuteIf404WasHandled(streamingStarted: false)
covers same content as CanRenderNotFoundPageNoStreaming(useCustomNotFoundPage: false)
.
[InlineData(false, false)] | ||
[InlineData(true, false)] | ||
[InlineData(true, true)] | ||
public void StatusCodePagesWithReExecution(bool streaming, bool responseStarted) |
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 test does not make sense now, as long as we have the default Router
in blazor app, we won't re-execute. And that is the case of all the current test setups in E2E tests. To at least check if re-execution still gets rendered properly if a 404 was set externally (not by a NavigatorManager.NotFound
call), StatusCodePagesWithReExecution
tests were added.
The custom Router
testing and handling will be a subject of the next PR.
Adding |
Contributes to #62153.
Description
Router
, then in all the cases we should renderNotFound
fragment orNotFoundPage
contents.We used to detect the status code in the rendering method to avoid flushing the response and hand-over the processing to re-execution middleware. We no longer do that and we removed nulling-out the response content type because it was done only to force re-execution middleware to process the request further.
Router
to stream-in theNotFound
contents.We used to inject JS-redirection into the page, which changed the url and introduced inconsistent behavior in comparison to non-streaming scenarios. If we avoid doing so and we ensure
Router
can stream, we are able to change the body of the page by streaming theNotFound
fragment/page contents. We cannot change the DOM that is non-body, e.g.PageTitle
because streaming cannot change the<head>
section. Even ifPageTitle.cs
has[StreamRendering]
attribute. From this reason, we are checking for DOM body contents in the streaming-related cases.Components.Shared.csproj
was needed because we want the same components to be tested in global interactivity application (InteractivityTests.cs
that is runningComponents.WasmMinimal.csproj
) and per-component interactivity application (NoInteractivityTests.cs
that is runningComponents.TestServer.csproj
that is not loadingWasmMinimal
assembly). The neatest solution was to put the common components is an external razor library. We could also start loadingWasmMinimal
in non-interactive tests but I decided it makes it too messy.PageThatSetsNotFound
andStreamingSetNotFound
components were doing the same job as newPageThatSetsNotFound-non-streaming
andPageThatSetsNotFound-streaming
but the new version is doing it in a more unified way (both use the same child component that is also used in interactive version of that test).