Skip to content

Commit 3b89c4b

Browse files
committed
Clean up tests and make them work.
1 parent 8907524 commit 3b89c4b

File tree

12 files changed

+51
-46
lines changed

12 files changed

+51
-46
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,7 @@ public void NavigatesWithInteractivityByRequestRedirection(bool controlFlowByExc
14181418
[InlineData("WebAssemblyNonPrerendered")]
14191419
public void ProgrammaticNavigationToNotExistingPathReExecutesTo404(string renderMode)
14201420
{
1421-
Navigate($"{ServerPathBase}/reexecution/redirection-not-found?render-mode={renderMode}&navigate-programmatically=true");
1421+
Navigate($"{ServerPathBase}/reexecution/redirection-not-found?renderMode={renderMode}&navigate-programmatically=true");
14221422
Assert404ReExecuted();
14231423
}
14241424

@@ -1428,7 +1428,7 @@ public void ProgrammaticNavigationToNotExistingPathReExecutesTo404(string render
14281428
[InlineData("WebAssemblyNonPrerendered")]
14291429
public void LinkNavigationToNotExistingPathReExecutesTo404(string renderMode)
14301430
{
1431-
Navigate($"{ServerPathBase}/reexecution/redirection-not-found?render-mode={renderMode}");
1431+
Navigate($"{ServerPathBase}/reexecution/redirection-not-found?renderMode={renderMode}");
14321432
Browser.Click(By.Id("link-to-not-existing-page"));
14331433
Assert404ReExecuted();
14341434
}
@@ -1442,7 +1442,7 @@ public void BrowserNavigationToNotExistingPathReExecutesTo404(string renderMode)
14421442
// non-existing path has to have re-execution middleware set up
14431443
// so it has to have "reexecution" prefix. Otherwise middleware mapping
14441444
// will not be activated, see configuration in Startup
1445-
Navigate($"{ServerPathBase}/reexecution/not-existing-page?render-mode={renderMode}");
1445+
Navigate($"{ServerPathBase}/reexecution/not-existing-page?renderMode={renderMode}");
14461446
Assert404ReExecuted();
14471447
}
14481448

src/Components/test/testassets/Components.TestServer/RazorComponentEndpointsNoInteractivityStartup.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,15 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
5050
{
5151
app.Map("/reexecution", reexecutionApp =>
5252
{
53+
reexecutionApp.UseStaticFiles();
54+
reexecutionApp.UseRouting();
5355
reexecutionApp.UseStatusCodePagesWithReExecute("/not-found-reexecute", createScopeForErrors: true);
54-
ConfigureSubdirPipeline(reexecutionApp, env);
56+
reexecutionApp.UseRouting();
57+
reexecutionApp.UseAntiforgery();
58+
reexecutionApp.UseEndpoints(endpoints =>
59+
{
60+
endpoints.MapRazorComponents<TRootComponent>();
61+
});
5562
});
5663

5764
ConfigureSubdirPipeline(app, env);

src/Components/test/testassets/Components.TestServer/RazorComponentEndpointsStartup.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,12 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
7575
{
7676
app.Map("/reexecution", reexecutionApp =>
7777
{
78+
reexecutionApp.UseRouting();
7879
reexecutionApp.UseStatusCodePagesWithReExecute("/not-found-reexecute", createScopeForErrors: true);
79-
8080
reexecutionApp.UseRouting();
81+
8182
reexecutionApp.UseAntiforgery();
82-
reexecutionApp.UseEndpoints(endpoints =>
83-
{
84-
endpoints.MapRazorComponents<TRootComponent>();
85-
});
83+
ConfigureEndpoints(reexecutionApp, env);
8684
});
8785

8886
ConfigureSubdirPipeline(app, env);
@@ -106,11 +104,15 @@ private void ConfigureSubdirPipeline(IApplicationBuilder app, IWebHostEnvironmen
106104
{
107105
if (ctx.Request.Query.ContainsKey("add-csp"))
108106
{
109-
ctx.Response.Headers.Add("Content-Security-Policy", "script-src 'self' 'unsafe-inline'");
107+
ctx.Response.Headers.Add("Content-Security-Policy", "script-src 'self' 'unsafe-inline'");
110108
}
111109
return nxt();
112110
});
111+
ConfigureEndpoints(app, env);
112+
}
113113

114+
private void ConfigureEndpoints(IApplicationBuilder app, IWebHostEnvironment env)
115+
{
114116
_ = app.UseEndpoints(endpoints =>
115117
{
116118
var contentRootStaticAssetsPath = Path.Combine(env.ContentRootPath, "Components.TestServer.staticwebassets.endpoints.json");

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

Lines changed: 0 additions & 32 deletions
This file was deleted.

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-
<RedirectionNotFoundComponent />
5+
<Components.WasmMinimal.Pages.NotFound.RedirectionNotFoundComponent />

src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/NotFound/RedirectionNotFound-SSR.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"
33
@attribute [StreamRendering(false)]
44

5-
<RedirectionNotFoundComponent />
5+
<Components.WasmMinimal.Pages.NotFound.RedirectionNotFoundComponent />
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@page "/render-not-found-ssr"
2+
@inject NavigationManager NavigationManager
3+
4+
<p id="test-info">Any content</p>
5+
6+
@code{
7+
protected override void OnInitialized()
8+
{
9+
NavigationManager.NotFound();
10+
}
11+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@page "/redirection-not-found"
2+
@page "/reexecution/redirection-not-found"
3+
4+
<RedirectionNotFoundComponent @rendermode="@RenderModeHelper.GetRenderMode(_renderMode)" />
5+
6+
@code{
7+
[Parameter, SupplyParameterFromQuery(Name = "renderMode")]
8+
public string? RenderModeStr { get; set; }
9+
10+
private RenderModeId _renderMode;
11+
12+
protected override void OnInitialized()
13+
{
14+
if (!string.IsNullOrEmpty(RenderModeStr))
15+
{
16+
_renderMode = RenderModeHelper.ParseRenderMode(RenderModeStr);
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)