Skip to content

Commit 7b9e6c9

Browse files
committed
Add tests for forms under a route with re-execution middleware.
1 parent 6a96694 commit 7b9e6c9

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

src/Components/test/E2ETest/ServerRenderingTests/FormHandlingTests/FormWithParentBindingContextTest.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ public void CanDispatchToTheDefaultForm(bool suppressEnhancedNavigation)
4949
DispatchToFormCore(dispatchToForm);
5050
}
5151

52+
[Theory]
53+
[InlineData(true)]
54+
[InlineData(false)]
55+
public void CanDispatchToTheDefaultFormWithReExecutionMiddleware(bool suppressEnhancedNavigation)
56+
{
57+
var dispatchToForm = new DispatchToForm(this)
58+
{
59+
Url = "reexecution/forms/default-form",
60+
FormCssSelector = "form",
61+
SuppressEnhancedNavigation = suppressEnhancedNavigation,
62+
};
63+
DispatchToFormCore(dispatchToForm);
64+
}
65+
5266
[Fact]
5367
public void PlainFormIsNotEnhancedByDefault()
5468
{
@@ -891,6 +905,21 @@ public async Task CanModifyTheHttpResponseDuringEventHandling()
891905
Assert.Equal("ModifyHttpContext", cookie.Value);
892906
}
893907

908+
[Theory]
909+
[InlineData(true)]
910+
[InlineData(false)]
911+
public void FormNoAntiforgeryReturnBadRequestWithReExecutionMiddleware(bool suppressEnhancedNavigation)
912+
{
913+
var dispatchToForm = new DispatchToForm(this)
914+
{
915+
Url = "reexecution/forms/no-antiforgery",
916+
FormCssSelector = "form",
917+
ShouldCauseBadRequest = true,
918+
SuppressEnhancedNavigation = suppressEnhancedNavigation,
919+
};
920+
DispatchToFormCore(dispatchToForm);
921+
}
922+
894923
[Theory]
895924
[InlineData(true)]
896925
[InlineData(false)]
@@ -973,6 +1002,21 @@ public void FormNoHandlerReturnBadRequest(bool suppressEnhancedNavigation)
9731002
DispatchToFormCore(dispatchToForm);
9741003
}
9751004

1005+
[Theory]
1006+
[InlineData(true)]
1007+
[InlineData(false)]
1008+
public void FormNoHandlerReturnBadRequestWithReExecutionMiddleware(bool suppressEnhancedNavigation)
1009+
{
1010+
var dispatchToForm = new DispatchToForm(this)
1011+
{
1012+
Url = "reexecution/forms/no-handler",
1013+
FormCssSelector = "form",
1014+
ShouldCauseBadRequest = true,
1015+
SuppressEnhancedNavigation = suppressEnhancedNavigation,
1016+
};
1017+
DispatchToFormCore(dispatchToForm);
1018+
}
1019+
9761020
[Theory]
9771021
[InlineData(true)]
9781022
[InlineData(false)]

src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/Forms/DefaultForm.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@page "/forms/default-form"
2+
@page "/reexecution/forms/default-form"
23
@using Microsoft.AspNetCore.Components.Forms
34

45
<h2>Default form</h2>

src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/Forms/FormNoAntiforgery.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@page "/forms/no-antiforgery"
2+
@page "/reexecution/forms/no-antiforgery"
23
@using Microsoft.AspNetCore.Components.Forms
34

45
<h2>Default form</h2>

src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/Forms/FormNoHandler.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@page "/forms/no-handler"
2+
@page "/reexecution/forms/no-handler"
23
@using Microsoft.AspNetCore.Components.Forms
34

45
<h2>Form with no handler</h2>

0 commit comments

Comments
 (0)