diff --git a/src/Components/test/E2ETest/Tests/FormsInputDateTest.cs b/src/Components/test/E2ETest/Tests/FormsInputDateTest.cs index 9a0cc0077c03..19147f73427c 100644 --- a/src/Components/test/E2ETest/Tests/FormsInputDateTest.cs +++ b/src/Components/test/E2ETest/Tests/FormsInputDateTest.cs @@ -6,7 +6,6 @@ using Microsoft.AspNetCore.Components.E2ETest.Infrastructure; using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; using Microsoft.AspNetCore.E2ETesting; -using Microsoft.AspNetCore.InternalTesting; using OpenQA.Selenium; using Xunit.Abstractions; @@ -34,7 +33,6 @@ protected override void InitializeAsyncCore() } [Fact] - [QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/67650")] public void InputDateInteractsWithEditContext_NonNullableDateTime() { var appElement = Browser.MountTestComponent(); @@ -46,28 +44,27 @@ public void InputDateInteractsWithEditContext_NonNullableDateTime() // Validates on edit Browser.Equal("valid", () => renewalDateInput.GetDomAttribute("class")); - renewalDateInput.SendKeys($"{Keys.Backspace}\t{Keys.Backspace}\t{Keys.Backspace}\t"); - renewalDateInput.SendKeys("01/01/2000\t"); + ClearDate(renewalDateInput); + SetDate(renewalDateInput, "01/01/2000\t"); Browser.Equal("modified valid", () => renewalDateInput.GetDomAttribute("class")); // Can become invalid - renewalDateInput.SendKeys("11-11-11111\t"); + SetDate(renewalDateInput, "11-11-11111\t"); Browser.Equal("modified invalid", () => renewalDateInput.GetDomAttribute("class")); Browser.Equal(new[] { "The RenewalDate field must be a date." }, messagesAccessor); // Empty is invalid, because it's not nullable - renewalDateInput.SendKeys($"{Keys.Backspace}\t{Keys.Backspace}\t{Keys.Backspace}\t"); + ClearDate(renewalDateInput); Browser.Equal("modified invalid", () => renewalDateInput.GetDomAttribute("class")); Browser.Equal(new[] { "The RenewalDate field must be a date." }, messagesAccessor); // Can become valid - renewalDateInput.SendKeys("01/01/01\t"); + SetDate(renewalDateInput, "01/01/01\t"); Browser.Equal("modified valid", () => renewalDateInput.GetDomAttribute("class")); Browser.Empty(messagesAccessor); } [Fact] - [QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/67650")] public void InputDateInteractsWithEditContext_NullableDateTimeOffset() { var appElement = Browser.MountTestComponent(); @@ -76,22 +73,21 @@ public void InputDateInteractsWithEditContext_NullableDateTimeOffset() // Validates on edit Browser.Equal("valid", () => expiryDateInput.GetDomAttribute("class")); - expiryDateInput.SendKeys("01-01-2000\t"); + SetDate(expiryDateInput, "01-01-2000\t"); Browser.Equal("modified valid", () => expiryDateInput.GetDomAttribute("class")); // Can become invalid - expiryDateInput.SendKeys("11-11-11111\t"); + SetDate(expiryDateInput, "11-11-11111\t"); Browser.Equal("modified invalid", () => expiryDateInput.GetDomAttribute("class")); Browser.Equal(new[] { "The OptionalExpiryDate field must be a date." }, messagesAccessor); // Empty is valid, because it's nullable - expiryDateInput.SendKeys($"{Keys.Backspace}\t{Keys.Backspace}\t{Keys.Backspace}\t"); + ClearDate(expiryDateInput); Browser.Equal("modified valid", () => expiryDateInput.GetDomAttribute("class")); Browser.Empty(messagesAccessor); } [Fact] - [QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/67650")] public void InputDateInteractsWithEditContext_TimeInput() { var appElement = Browser.MountTestComponent(); @@ -111,9 +107,9 @@ public void InputDateInteractsWithEditContext_TimeInput() Browser.Equal("modified valid", () => departureTimeInput.GetDomAttribute("class")); // Can become invalid - // Stricly speaking the following is equivalent to the empty state, because that's how incomplete input is represented + // Strictly speaking the following is equivalent to the empty state, because that's how incomplete input is represented // We don't know of any way to produce a different (non-empty-equivalent) state using UI gestures, so there's nothing else to test - departureTimeInput.SendKeys($"20{Keys.Backspace}\t"); + SetDate(departureTimeInput, $"20{Keys.Backspace}\t"); Browser.Equal("modified invalid", () => departureTimeInput.GetDomAttribute("class")); Browser.Equal(new[] { "The DepartureTime field must be a time." }, messagesAccessor); } @@ -237,6 +233,21 @@ public void InputDateInteractsWithEditContext_DateTimeLocalInput_Step() Browser.Equal("1970-10-10T10:53:21", () => appointmentInput.GetDomProperty("value")); } + private static void SetDate(IWebElement input, string keys) + { + input.Click(); + input.SendKeys(Keys.ArrowLeft + Keys.ArrowLeft + Keys.ArrowLeft); + input.SendKeys(keys); + } + + private static void ClearDate(IWebElement input) + { + input.Click(); + input.SendKeys(Keys.Control + "a"); + input.SendKeys(Keys.Delete); + input.SendKeys(Keys.Tab); + } + private Func CreateValidationMessagesAccessor(IWebElement appElement) { return () => appElement.FindElements(By.ClassName("validation-message"))