Skip to content

Commit 8e9b223

Browse files
committed
Add E2E test
1 parent 7f63036 commit 8e9b223

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

src/Components/test/E2ETest/Tests/FormsTest.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,25 @@ public void InputRadioGroupWorksWithMutatingSetter()
844844
Browser.Equal("False", () => tuesday.GetDomProperty("checked"));
845845
}
846846

847+
[Theory]
848+
[InlineData(0)]
849+
[InlineData(2)]
850+
public void InputRadioGroupWorksWithParentImplementingIHandleEvent(int n)
851+
{
852+
Browser.Url = new UriBuilder(Browser.Url) { Query = ($"?n={n}") }.ToString();
853+
var appElement = Browser.MountTestComponent<InputRadioParentImplementsIHandleEvent>();
854+
var zero = appElement.FindElement(By.Id("inputradiogroup-parent-ihandle-event-0"));
855+
var one = appElement.FindElement(By.Id("inputradiogroup-parent-ihandle-event-1"));
856+
857+
Browser.Equal(n == 0 ? "True" : "False", () => zero.GetDomProperty("checked"));
858+
Browser.Equal("False", () => one.GetDomProperty("checked"));
859+
860+
// Observe that the value can be mutated by the setter, and this shows up in the DOM
861+
one.Click();
862+
Browser.Equal("False", () => zero.GetDomProperty("checked"));
863+
Browser.Equal("True", () => one.GetDomProperty("checked"));
864+
}
865+
847866
[Fact]
848867
public void InputSelectWorksWithMutatingSetter()
849868
{
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@using Microsoft.AspNetCore.Components.Forms
2+
@implements IHandleEvent
3+
4+
<InputRadioGroup @bind-Value="N">
5+
<InputRadio id="inputradiogroup-parent-ihandle-event-0" Value="0" />
6+
<InputRadio id="inputradiogroup-parent-ihandle-event-1" Value="1" />
7+
</InputRadioGroup>
8+
9+
@code {
10+
11+
[SupplyParameterFromQuery(Name = "n")] int? N { get; set; }
12+
13+
Task IHandleEvent.HandleEventAsync(EventCallbackWorkItem callback, object arg) => callback.InvokeAsync(arg);
14+
}

src/Components/test/testassets/BasicTestApp/Index.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<option value="BasicTestApp.FormsTest.InputRangeComponent">Input range</option>
5050
<option value="BasicTestApp.FormsTest.InputsWithoutEditForm">Inputs without EditForm</option>
5151
<option value="BasicTestApp.FormsTest.InputsWithMutatingSetters">Inputs with mutating setters</option>
52+
<option value="BasicTestApp.FormsTest.InputRadioParentImplementsIHandleEvent">Input Radio Parent Implements IHandleEvent</option>
5253
<option value="BasicTestApp.NavigateOnSubmit">Navigate to submit</option>
5354
<option value="BasicTestApp.GlobalizationBindCases">Globalization Bind Cases</option>
5455
<option value="BasicTestApp.GracefulTermination">Graceful Termination</option>

0 commit comments

Comments
 (0)