From fa8e25ba1835faec9c99374278b6f4fb477f324a Mon Sep 17 00:00:00 2001 From: Tanay Parikh Date: Fri, 12 Nov 2021 12:49:21 -0800 Subject: [PATCH] Remove Blazor Playwright Component E2E Tests in E2ETestMigration Fixes #37929 --- AspNetCore.sln | 34 +- src/Components/Components.slnf | 1 - src/Components/ComponentsNoDeps.slnf | 3 +- .../Infrastructure/ComponentTestBase.cs | 83 - .../ServerFixtures/AspNetEnvironment.cs | 10 - .../ServerFixtures/AspNetSiteServerFixture.cs | 46 - .../BasicTestAppServerSiteFixture.cs | 12 - .../BlazorWasmTestAppFixture.cs | 107 -- .../ServerFixtures/ServerFixture.cs | 83 - .../ServerFixtures/StaticSiteServerFixture.cs | 48 - .../ToggleExecutionModeServerFixture.cs | 70 - .../ServerFixtures/WebHostServerFixture.cs | 35 - .../Infrastructure/ServerTestBase.cs | 42 - ...tCore.Components.Migration.E2ETests.csproj | 106 -- .../Properties/AssemblyInfo.cs | 6 - .../TestJsonSerializerOptionsProvider.cs | 15 - .../Tests/BinaryHttpClientTest.cs | 66 - .../test/E2ETestMigration/Tests/BindTest.cs | 1359 ----------------- .../Tests/DownloadAnchorTest.cs | 60 - .../E2ETestMigration/Tests/InputFileTest.cs | 301 ---- .../playwrightSettings.ci.json | 7 - .../playwrightSettings.ci.linux.json | 10 - .../playwrightSettings.ci.osx.json | 7 - .../playwrightSettings.ci.win.json | 2 - .../playwrightSettings.debug.json | 7 - .../E2ETestMigration/playwrightSettings.json | 38 - .../playwrightSettings.linux.json | 8 - .../playwrightSettings.osx.json | 2 - .../playwrightSettings.win.json | 8 - .../test/E2ETestMigration/xunit.runner.json | 7 - 30 files changed, 5 insertions(+), 2578 deletions(-) delete mode 100644 src/Components/test/E2ETestMigration/Infrastructure/ComponentTestBase.cs delete mode 100644 src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/AspNetEnvironment.cs delete mode 100644 src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/AspNetSiteServerFixture.cs delete mode 100644 src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/BasicTestAppServerSiteFixture.cs delete mode 100644 src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/BlazorWasmTestAppFixture.cs delete mode 100644 src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/ServerFixture.cs delete mode 100644 src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/StaticSiteServerFixture.cs delete mode 100644 src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/ToggleExecutionModeServerFixture.cs delete mode 100644 src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/WebHostServerFixture.cs delete mode 100644 src/Components/test/E2ETestMigration/Infrastructure/ServerTestBase.cs delete mode 100644 src/Components/test/E2ETestMigration/Microsoft.AspNetCore.Components.Migration.E2ETests.csproj delete mode 100644 src/Components/test/E2ETestMigration/Properties/AssemblyInfo.cs delete mode 100644 src/Components/test/E2ETestMigration/TestJsonSerializerOptionsProvider.cs delete mode 100644 src/Components/test/E2ETestMigration/Tests/BinaryHttpClientTest.cs delete mode 100644 src/Components/test/E2ETestMigration/Tests/BindTest.cs delete mode 100644 src/Components/test/E2ETestMigration/Tests/DownloadAnchorTest.cs delete mode 100644 src/Components/test/E2ETestMigration/Tests/InputFileTest.cs delete mode 100644 src/Components/test/E2ETestMigration/playwrightSettings.ci.json delete mode 100644 src/Components/test/E2ETestMigration/playwrightSettings.ci.linux.json delete mode 100644 src/Components/test/E2ETestMigration/playwrightSettings.ci.osx.json delete mode 100644 src/Components/test/E2ETestMigration/playwrightSettings.ci.win.json delete mode 100644 src/Components/test/E2ETestMigration/playwrightSettings.debug.json delete mode 100644 src/Components/test/E2ETestMigration/playwrightSettings.json delete mode 100644 src/Components/test/E2ETestMigration/playwrightSettings.linux.json delete mode 100644 src/Components/test/E2ETestMigration/playwrightSettings.osx.json delete mode 100644 src/Components/test/E2ETestMigration/playwrightSettings.win.json delete mode 100644 src/Components/test/E2ETestMigration/xunit.runner.json diff --git a/AspNetCore.sln b/AspNetCore.sln index ad4064e3ebde..931eeedc5266 100644 --- a/AspNetCore.sln +++ b/AspNetCore.sln @@ -1596,8 +1596,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Featur EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Features.Tests", "src\Extensions\Features\test\Microsoft.Extensions.Features.Tests.csproj", "{09FFBC53-3EFF-45C4-9822-5D66089CD6AD}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.Migration.E2ETests", "src\Components\test\E2ETestMigration\Microsoft.AspNetCore.Components.Migration.E2ETests.csproj", "{A1D02CE6-1077-410A-81CB-D4BD500FD765}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.WebView", "src\Components\WebView\WebView\src\Microsoft.AspNetCore.Components.WebView.csproj", "{3044DFA5-DE4F-44D8-8DD8-EDF547BE513E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Components.WebView.Test", "src\Components\WebView\WebView\test\Microsoft.AspNetCore.Components.WebView.Test.csproj", "{4BD6F0DB-BE9C-4C54-B52A-D20B88855ED5}" @@ -1626,7 +1624,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Logging.W3C.Sample", "src\M EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Client.SourceGenerator", "Client.SourceGenerator", "{4FC50620-4C8B-495F-859C-BFACAD158033}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.SignalR.Client.SourceGenerator", "src\SignalR\clients\csharp\Client.SourceGenerator\src\Microsoft.AspNetCore.SignalR.Client.SourceGenerator.csproj", "{E090F82D-8345-477E-92E8-F724F08ADC56}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SignalR.Client.SourceGenerator", "src\SignalR\clients\csharp\Client.SourceGenerator\src\Microsoft.AspNetCore.SignalR.Client.SourceGenerator.csproj", "{E090F82D-8345-477E-92E8-F724F08ADC56}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Internal.SourceGenerator.Transport", "src\Razor\Microsoft.AspNetCore.Razor.Internal.SourceGenerator.Transport\Microsoft.AspNetCore.Razor.Internal.SourceGenerator.Transport.csproj", "{247E7B6F-FBA2-41A9-BA03-C7C4DF28091C}" EndProject @@ -1644,11 +1642,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AspNetCoreAnalyzers", "AspN EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B5D98AEB-9409-4280-8225-9C1EC6A791B2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.App.Analyzers", "src\Framework\AspNetCoreAnalyzers\src\Analyzers\Microsoft.AspNetCore.App.Analyzers.csproj", "{2A150BE3-D7DC-4E2A-8399-6EBAB77DEF00}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.App.Analyzers", "src\Framework\AspNetCoreAnalyzers\src\Analyzers\Microsoft.AspNetCore.App.Analyzers.csproj", "{2A150BE3-D7DC-4E2A-8399-6EBAB77DEF00}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.App.CodeFixes", "src\Framework\AspNetCoreAnalyzers\src\CodeFixes\Microsoft.AspNetCore.App.CodeFixes.csproj", "{D5F4D764-887D-4EB3-8D00-FCBE23FFDBBC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.App.CodeFixes", "src\Framework\AspNetCoreAnalyzers\src\CodeFixes\Microsoft.AspNetCore.App.CodeFixes.csproj", "{D5F4D764-887D-4EB3-8D00-FCBE23FFDBBC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.App.Analyzers.Test", "src\Framework\AspNetCoreAnalyzers\test\Microsoft.AspNetCore.App.Analyzers.Test.csproj", "{40F493E2-FE59-4787-BE44-3AED39D585BF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.App.Analyzers.Test", "src\Framework\AspNetCoreAnalyzers\test\Microsoft.AspNetCore.App.Analyzers.Test.csproj", "{40F493E2-FE59-4787-BE44-3AED39D585BF}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testassets", "testassets", "{5420BABA-BDC5-4FBF-81B4-6D7C02C4814D}" EndProject @@ -9682,22 +9680,6 @@ Global {09FFBC53-3EFF-45C4-9822-5D66089CD6AD}.Release|x64.Build.0 = Release|Any CPU {09FFBC53-3EFF-45C4-9822-5D66089CD6AD}.Release|x86.ActiveCfg = Release|Any CPU {09FFBC53-3EFF-45C4-9822-5D66089CD6AD}.Release|x86.Build.0 = Release|Any CPU - {A1D02CE6-1077-410A-81CB-D4BD500FD765}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A1D02CE6-1077-410A-81CB-D4BD500FD765}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A1D02CE6-1077-410A-81CB-D4BD500FD765}.Debug|arm64.ActiveCfg = Debug|Any CPU - {A1D02CE6-1077-410A-81CB-D4BD500FD765}.Debug|arm64.Build.0 = Debug|Any CPU - {A1D02CE6-1077-410A-81CB-D4BD500FD765}.Debug|x64.ActiveCfg = Debug|Any CPU - {A1D02CE6-1077-410A-81CB-D4BD500FD765}.Debug|x64.Build.0 = Debug|Any CPU - {A1D02CE6-1077-410A-81CB-D4BD500FD765}.Debug|x86.ActiveCfg = Debug|Any CPU - {A1D02CE6-1077-410A-81CB-D4BD500FD765}.Debug|x86.Build.0 = Debug|Any CPU - {A1D02CE6-1077-410A-81CB-D4BD500FD765}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A1D02CE6-1077-410A-81CB-D4BD500FD765}.Release|Any CPU.Build.0 = Release|Any CPU - {A1D02CE6-1077-410A-81CB-D4BD500FD765}.Release|arm64.ActiveCfg = Release|Any CPU - {A1D02CE6-1077-410A-81CB-D4BD500FD765}.Release|arm64.Build.0 = Release|Any CPU - {A1D02CE6-1077-410A-81CB-D4BD500FD765}.Release|x64.ActiveCfg = Release|Any CPU - {A1D02CE6-1077-410A-81CB-D4BD500FD765}.Release|x64.Build.0 = Release|Any CPU - {A1D02CE6-1077-410A-81CB-D4BD500FD765}.Release|x86.ActiveCfg = Release|Any CPU - {A1D02CE6-1077-410A-81CB-D4BD500FD765}.Release|x86.Build.0 = Release|Any CPU {3044DFA5-DE4F-44D8-8DD8-EDF547BE513E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3044DFA5-DE4F-44D8-8DD8-EDF547BE513E}.Debug|Any CPU.Build.0 = Debug|Any CPU {3044DFA5-DE4F-44D8-8DD8-EDF547BE513E}.Debug|arm64.ActiveCfg = Debug|Any CPU @@ -9978,12 +9960,6 @@ Global {40F493E2-FE59-4787-BE44-3AED39D585BF}.Release|x64.Build.0 = Release|Any CPU {40F493E2-FE59-4787-BE44-3AED39D585BF}.Release|x86.ActiveCfg = Release|Any CPU {40F493E2-FE59-4787-BE44-3AED39D585BF}.Release|x86.Build.0 = Release|Any CPU - {37BDB2D5-EEEC-48C9-A7AD-5A2A73BD31B1}.Debug|arm64.ActiveCfg = Debug|Any CPU - {37BDB2D5-EEEC-48C9-A7AD-5A2A73BD31B1}.Release|arm64.ActiveCfg = Release|Any CPU - {14217994-9F24-4E14-87B6-58367ED0413B}.Debug|arm64.ActiveCfg = Debug|Any CPU - {14217994-9F24-4E14-87B6-58367ED0413B}.Release|arm64.ActiveCfg = Release|Any CPU - {40F493E2-FE59-4787-BE44-3AED39D585BF}.Debug|arm64.ActiveCfg = Debug|Any CPU - {40F493E2-FE59-4787-BE44-3AED39D585BF}.Release|arm64.ActiveCfg = Release|Any CPU {05F4BC5A-060D-49B2-9069-95088402F99B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {05F4BC5A-060D-49B2-9069-95088402F99B}.Debug|Any CPU.Build.0 = Debug|Any CPU {05F4BC5A-060D-49B2-9069-95088402F99B}.Debug|arm64.ActiveCfg = Debug|Any CPU @@ -11121,7 +11097,6 @@ Global {17F28812-983E-4415-A55D-842DD7EC6887} = {627BE8B3-59E6-4F1D-8C9C-76B804D41724} {A07D3B13-388B-444F-9E37-DDC0787C4690} = {17F28812-983E-4415-A55D-842DD7EC6887} {09FFBC53-3EFF-45C4-9822-5D66089CD6AD} = {17F28812-983E-4415-A55D-842DD7EC6887} - {A1D02CE6-1077-410A-81CB-D4BD500FD765} = {0508E463-0269-40C9-B5C2-3B600FB2A28B} {3044DFA5-DE4F-44D8-8DD8-EDF547BE513E} = {C445B129-0A4D-41F5-8347-6534B6B12303} {4BD6F0DB-BE9C-4C54-B52A-D20B88855ED5} = {C445B129-0A4D-41F5-8347-6534B6B12303} {6CCCF618-2E70-4870-B39F-32C016FE08F0} = {088C37A5-30D2-40FB-B031-D163CFBED006} @@ -11148,7 +11123,6 @@ Global {2A150BE3-D7DC-4E2A-8399-6EBAB77DEF00} = {B5D98AEB-9409-4280-8225-9C1EC6A791B2} {D5F4D764-887D-4EB3-8D00-FCBE23FFDBBC} = {B5D98AEB-9409-4280-8225-9C1EC6A791B2} {40F493E2-FE59-4787-BE44-3AED39D585BF} = {4DA84F2B-1948-439B-85AB-E99E31331A9C} - {14217994-9F24-4E14-87B6-58367ED0413B} = {C3722C5D-E159-4AB3-AF60-769185B31B47} {5420BABA-BDC5-4FBF-81B4-6D7C02C4814D} = {16653D2A-AC79-44ED-B908-2EEB58684C50} {05F4BC5A-060D-49B2-9069-95088402F99B} = {5420BABA-BDC5-4FBF-81B4-6D7C02C4814D} {97F9F7E9-56DA-49FE-B672-499E68EBB9DA} = {41B519F7-CF19-4FB4-B96C-E38A7EF45F70} diff --git a/src/Components/Components.slnf b/src/Components/Components.slnf index c6d021df5de0..f2da642c3112 100644 --- a/src/Components/Components.slnf +++ b/src/Components/Components.slnf @@ -45,7 +45,6 @@ "src\\Components\\Web\\test\\Microsoft.AspNetCore.Components.Web.Tests.csproj", "src\\Components\\benchmarkapps\\Wasm.Performance\\Driver\\Wasm.Performance.Driver.csproj", "src\\Components\\benchmarkapps\\Wasm.Performance\\TestApp\\Wasm.Performance.TestApp.csproj", - "src\\Components\\test\\E2ETestMigration\\Microsoft.AspNetCore.Components.Migration.E2ETests.csproj", "src\\Components\\test\\E2ETest\\Microsoft.AspNetCore.Components.E2ETests.csproj", "src\\Components\\test\\testassets\\BasicTestApp\\BasicTestApp.csproj", "src\\Components\\test\\testassets\\ComponentsApp.App\\ComponentsApp.App.csproj", diff --git a/src/Components/ComponentsNoDeps.slnf b/src/Components/ComponentsNoDeps.slnf index fc900b80a57b..9218ed501d67 100644 --- a/src/Components/ComponentsNoDeps.slnf +++ b/src/Components/ComponentsNoDeps.slnf @@ -48,7 +48,6 @@ "src\\Components\\benchmarkapps\\Wasm.Performance\\ConsoleHost\\Wasm.Performance.ConsoleHost.csproj", "src\\Components\\benchmarkapps\\Wasm.Performance\\Driver\\Wasm.Performance.Driver.csproj", "src\\Components\\benchmarkapps\\Wasm.Performance\\TestApp\\Wasm.Performance.TestApp.csproj", - "src\\Components\\test\\E2ETestMigration\\Microsoft.AspNetCore.Components.Migration.E2ETests.csproj", "src\\Components\\test\\E2ETest\\Microsoft.AspNetCore.Components.E2ETests.csproj", "src\\Components\\test\\testassets\\BasicTestApp\\BasicTestApp.csproj", "src\\Components\\test\\testassets\\ComponentsApp.Server\\ComponentsApp.Server.csproj", @@ -57,4 +56,4 @@ "src\\Components\\test\\testassets\\TestServer\\Components.TestServer.csproj" ] } -} \ No newline at end of file +} diff --git a/src/Components/test/E2ETestMigration/Infrastructure/ComponentTestBase.cs b/src/Components/test/E2ETestMigration/Infrastructure/ComponentTestBase.cs deleted file mode 100644 index 3bcd89b93ee0..000000000000 --- a/src/Components/test/E2ETestMigration/Infrastructure/ComponentTestBase.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.BrowserTesting; -using Microsoft.AspNetCore.Testing; -using PlaywrightSharp; -using Xunit; -using Xunit.Abstractions; - -namespace Microsoft.AspNetCore.Components.E2ETest.Infrastructure; - -public abstract class ComponentBrowserTestBase : BrowserTestBase -{ - public ComponentBrowserTestBase(ITestOutputHelper output = null) : base(output) { } - - protected abstract Type TestComponent { get; } - protected string MountUri { get; set; } - protected IPage TestPage { get; set; } - protected IBrowserContext TestBrowser { get; set; } - protected BrowserKind BrowserKind { get; set; } - - protected async Task MountTestComponentAsync(IPage page) - { - var componentTypeName = TestComponent.Assembly == typeof(BasicTestApp.Program).Assembly ? - TestComponent.FullName : - TestComponent.AssemblyQualifiedName; - var testSelector = await page.WaitForSelectorAsync("#test-selector > select"); - Assert.NotNull(testSelector); - - Output.WriteLine("Selecting test: " + componentTypeName); - - var selected = await page.SelectOptionAsync("#test-selector > select", componentTypeName); - Assert.True(selected.Length == 1); - Assert.Equal(componentTypeName, selected.First()); - } - - public bool ShouldSkip(BrowserKind browserKind) => !BrowserManager.IsAvailable(browserKind); - - protected override async Task InitializeCoreAsync(TestContext context) - { - await base.InitializeCoreAsync(context); - - // Default to Chrome - var browserKind = BrowserKind.Chromium; - - // Check if a different browser is requested - var browserKindArgument = context.MethodArguments.FirstOrDefault(); - if (browserKindArgument != null && - browserKindArgument.GetType() == typeof(BrowserKind)) - { - browserKind = (BrowserKind)browserKindArgument; - } - - if (ShouldSkip(browserKind)) - { - var avail = String.Join(",", BrowserManager.GetAvailableBrowsers()); - var error = $"Skipping browser: {browserKind}: Available: {avail}"; - Output.WriteLine(error); - return; - } - - TestBrowser = await BrowserManager.GetBrowserInstance(browserKind, BrowserContextInfo); - TestPage = await TestBrowser.NewPageAsync(); - var response = await TestPage.GoToAsync(MountUri); - - Assert.True(response.Ok, $"Got: {response.StatusText} from: {MountUri}"); - Output.WriteLine($"Loaded MountUri: {MountUri}"); - - await MountTestComponentAsync(TestPage); - } - - public override async Task DisposeAsync() - { - if (TestPage != null) - { - await TestPage.CloseAsync(); - } - await base.DisposeAsync(); - } -} diff --git a/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/AspNetEnvironment.cs b/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/AspNetEnvironment.cs deleted file mode 100644 index 0478d5918f0c..000000000000 --- a/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/AspNetEnvironment.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; - -public enum AspNetEnvironment -{ - Development, - Production -} diff --git a/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/AspNetSiteServerFixture.cs b/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/AspNetSiteServerFixture.cs deleted file mode 100644 index b35b839e7d0c..000000000000 --- a/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/AspNetSiteServerFixture.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - -namespace Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; - -public class AspNetSiteServerFixture : WebHostServerFixture -{ - public delegate IHost BuildWebHost(string[] args); - - public Assembly ApplicationAssembly { get; set; } - - public BuildWebHost BuildWebHostMethod { get; set; } - - public AspNetEnvironment Environment { get; set; } = AspNetEnvironment.Production; - - public List AdditionalArguments { get; set; } = new List { "--test-execution-mode", "server" }; - - protected override IHost CreateWebHost() - { - if (BuildWebHostMethod == null) - { - throw new InvalidOperationException( - $"No value was provided for {nameof(BuildWebHostMethod)}"); - } - - var assembly = ApplicationAssembly ?? BuildWebHostMethod.Method.DeclaringType.Assembly; - var sampleSitePath = FindSampleOrTestSitePath(assembly.FullName); - - var host = "127.0.0.1"; - - return BuildWebHostMethod(new[] - { - "--urls", $"http://{host}:0", - "--contentroot", sampleSitePath, - "--environment", Environment.ToString(), - }.Concat(AdditionalArguments).ToArray()); - } -} diff --git a/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/BasicTestAppServerSiteFixture.cs b/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/BasicTestAppServerSiteFixture.cs deleted file mode 100644 index e828bf69dfe6..000000000000 --- a/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/BasicTestAppServerSiteFixture.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; - -public class BasicTestAppServerSiteFixture : AspNetSiteServerFixture where TStartup : class -{ - public BasicTestAppServerSiteFixture() - { - BuildWebHostMethod = TestServer.Program.BuildWebHost; - } -} diff --git a/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/BlazorWasmTestAppFixture.cs b/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/BlazorWasmTestAppFixture.cs deleted file mode 100644 index 746556ceafb1..000000000000 --- a/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/BlazorWasmTestAppFixture.cs +++ /dev/null @@ -1,107 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using DevHostServerProgram = Microsoft.AspNetCore.Components.WebAssembly.DevServer.Server.Program; - -namespace Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; - -public class BlazorWasmTestAppFixture : WebHostServerFixture -{ - public readonly bool TestTrimmedApps = false; - //typeof(ToggleExecutionModeServerFixture<>).Assembly - // .GetCustomAttributes() - // .First(m => m.Key == "Microsoft.AspNetCore.E2ETesting.TestTrimmedApps") - // .Value == "true"; - - public string Environment { get; set; } - public string PathBase { get; set; } - public string ContentRoot { get; private set; } - - protected override IHost CreateWebHost() - { - if (TestTrimmedApps) - { - var staticFilePath = Path.Combine(AppContext.BaseDirectory, "trimmed", typeof(TProgram).Assembly.GetName().Name); - if (!Directory.Exists(staticFilePath)) - { - throw new DirectoryNotFoundException($"Test is configured to use trimmed outputs, but trimmed outputs were not found in {staticFilePath}."); - } - - return CreateStaticWebHost(staticFilePath); - } - - ContentRoot = FindSampleOrTestSitePath( - typeof(TProgram).Assembly.FullName); - - var host = "127.0.0.1"; - - var args = new List - { - "--urls", $"http://{host}:0", - "--contentroot", ContentRoot, - "--pathbase", PathBase, - "--applicationpath", typeof(TProgram).Assembly.Location, - }; - - if (!string.IsNullOrEmpty(Environment)) - { - args.Add("--environment"); - args.Add(Environment); - } - - return DevHostServerProgram.BuildWebHost(args.ToArray()); - } - - private IHost CreateStaticWebHost(string contentRoot) - { - var host = "127.0.0.1"; - return new HostBuilder() - .ConfigureWebHost(webHostBuilder => webHostBuilder - .UseKestrel() - .UseContentRoot(contentRoot) - .UseStartup(_ => new StaticSiteStartup { PathBase = PathBase }) - .UseUrls($"http://{host}:0")) - .Build(); - } - - private class StaticSiteStartup - { - public string PathBase { get; init; } - - public void ConfigureServices(IServiceCollection serviceCollection) - { - serviceCollection.AddRouting(); - } - - public void Configure(IApplicationBuilder app) - { - app.UseBlazorFrameworkFiles(); - app.UseStaticFiles(new StaticFileOptions - { - ServeUnknownFileTypes = true, - }); - - app.UseRouting(); - - app.UseEndpoints(endpoints => - { - var fallback = "index.html"; - if (!string.IsNullOrEmpty(PathBase)) - { - fallback = PathBase + '/' + fallback; - } - - endpoints.MapFallbackToFile(fallback); - }); - } - } -} diff --git a/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/ServerFixture.cs b/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/ServerFixture.cs deleted file mode 100644 index 2d6bc541d3fb..000000000000 --- a/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/ServerFixture.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.ExceptionServices; -using System.Threading; - -namespace Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; - -public abstract class ServerFixture : IDisposable -{ - public Uri RootUri => _rootUriInitializer.Value; - - private readonly Lazy _rootUriInitializer; - - public ServerFixture() - { - _rootUriInitializer = new Lazy(() => - { - var uri = new Uri(StartAndGetRootUri()); - - return uri; - }); - } - - public abstract void Dispose(); - - protected abstract string StartAndGetRootUri(); - - public static string FindSampleOrTestSitePath(string projectName) - { - var comma = projectName.IndexOf(",", StringComparison.Ordinal); - if (comma != -1) - { - projectName = projectName.Substring(0, comma); - } - - if (string.Equals(projectName, "Components.TestServer", StringComparison.Ordinal)) - { - projectName = "TestServer"; // This testasset doesn't match the folder name for some reason - } - var path = Path.Combine(AppContext.BaseDirectory, "testassets", projectName); - if (!Directory.Exists(path)) - { - throw new ArgumentException($"Cannot find a sample or test site directory: '{path}'."); - } - return path; - } - - protected static void RunInBackgroundThread(Action action) - { - var isDone = new ManualResetEvent(false); - - ExceptionDispatchInfo edi = null; - new Thread(() => - { - try - { - action(); - } - catch (Exception ex) - { - edi = ExceptionDispatchInfo.Capture(ex); - } - - isDone.Set(); - }).Start(); - - if (!isDone.WaitOne(TimeSpan.FromSeconds(10))) - { - throw new TimeoutException("Timed out waiting for: " + action); - } - - if (edi != null) - { - throw edi.SourceException; - } - } -} diff --git a/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/StaticSiteServerFixture.cs b/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/StaticSiteServerFixture.cs deleted file mode 100644 index 34e5c9cb639a..000000000000 --- a/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/StaticSiteServerFixture.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.IO; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - -namespace Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; - -// Although this is not used for anything meaningful related to Blazor yet, it -// will be used later when there's a mechanism for publishing standalone Blazor -// apps as a set of purely static files and we need E2E testing on the result. - -public class StaticSiteServerFixture : WebHostServerFixture -{ - public string SampleSiteName { get; set; } - - protected override IHost CreateWebHost() - { - if (string.IsNullOrEmpty(SampleSiteName)) - { - throw new InvalidOperationException($"No value was provided for {nameof(SampleSiteName)}"); - } - - var sampleSitePath = FindSampleOrTestSitePath(SampleSiteName); - - var host = "127.0.0.1"; - - return new HostBuilder() - .ConfigureWebHost(webHostBuilder => webHostBuilder - .UseKestrel() - .UseContentRoot(sampleSitePath) - .UseWebRoot(string.Empty) - .UseStartup() - .UseUrls($"http://{host}:0")) - .Build(); - } - - private class StaticSiteStartup - { - public void Configure(IApplicationBuilder app) - { - app.UseFileServer(); - } - } -} diff --git a/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/ToggleExecutionModeServerFixture.cs b/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/ToggleExecutionModeServerFixture.cs deleted file mode 100644 index 9921c47dd5cc..000000000000 --- a/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/ToggleExecutionModeServerFixture.cs +++ /dev/null @@ -1,70 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using Microsoft.Extensions.Hosting; - -namespace Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; - -public class ToggleExecutionModeServerFixture - : ServerFixture -{ - public string PathBase { get; set; } - - public IHost Host { get; set; } - - public ExecutionMode ExecutionMode { get; set; } = ExecutionMode.Client; - - private AspNetSiteServerFixture.BuildWebHost _buildWebHostMethod; - private IDisposable _serverToDispose; - - public List AspNetFixtureAdditionalArguments { get; set; } = new List(); - - public void UseAspNetHost(AspNetSiteServerFixture.BuildWebHost buildWebHostMethod) - { - _buildWebHostMethod = buildWebHostMethod - ?? throw new ArgumentNullException(nameof(buildWebHostMethod)); - } - - protected override string StartAndGetRootUri() - { - if (_buildWebHostMethod == null) - { - var underlying = new BlazorWasmTestAppFixture(); - underlying.PathBase = "/subdir"; - _serverToDispose = underlying; - var uri = underlying.RootUri.AbsoluteUri; // As a side-effect, this starts the server - - Host = underlying.Host; - - return uri; - } - else - { - // Use specified ASP.NET host server - var underlying = new AspNetSiteServerFixture(); - underlying.AdditionalArguments.AddRange(AspNetFixtureAdditionalArguments); - underlying.BuildWebHostMethod = _buildWebHostMethod; - _serverToDispose = underlying; - var uri = underlying.RootUri.AbsoluteUri; // As a side-effect, this starts the server - - Host = underlying.Host; - - return uri; - } - } - - public override void Dispose() - { - _serverToDispose?.Dispose(); - } - - internal ToggleExecutionModeServerFixture WithAdditionalArguments(string[] additionalArguments) - { - AspNetFixtureAdditionalArguments.AddRange(additionalArguments); - return this; - } -} - -public enum ExecutionMode { Client, Server } diff --git a/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/WebHostServerFixture.cs b/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/WebHostServerFixture.cs deleted file mode 100644 index ea700c7d1816..000000000000 --- a/src/Components/test/E2ETestMigration/Infrastructure/ServerFixtures/WebHostServerFixture.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Linq; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Hosting.Server; -using Microsoft.AspNetCore.Hosting.Server.Features; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; - -namespace Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; - -public abstract class WebHostServerFixture : ServerFixture -{ - protected override string StartAndGetRootUri() - { - Host = CreateWebHost(); - RunInBackgroundThread(Host.Start); - return Host.Services.GetRequiredService().Features - .Get() - .Addresses.Single(); - } - - public IHost Host { get; set; } - - public override void Dispose() - { - // This can be null if creating the webhost throws, we don't want to throw here and hide - // the original exception. - Host?.Dispose(); - Host?.StopAsync(); - } - - protected abstract IHost CreateWebHost(); -} diff --git a/src/Components/test/E2ETestMigration/Infrastructure/ServerTestBase.cs b/src/Components/test/E2ETestMigration/Infrastructure/ServerTestBase.cs deleted file mode 100644 index 95d3e1dd4625..000000000000 --- a/src/Components/test/E2ETestMigration/Infrastructure/ServerTestBase.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Threading.Tasks; -using Microsoft.AspNetCore.BrowserTesting; -using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; -using Microsoft.AspNetCore.Testing; -using Xunit; -using Xunit.Abstractions; - -namespace Microsoft.AspNetCore.Components.E2ETest.Infrastructure; - -public abstract class ServerTestBase - : ComponentBrowserTestBase, - IClassFixture - where TServerFixture : ServerFixture -{ - public string ServerPathBase => "/subdir"; - - protected readonly TServerFixture _serverFixture; - - public ServerTestBase( - TServerFixture serverFixture, - ITestOutputHelper output) - : base(output) - { - _serverFixture = serverFixture; - MountUri = _serverFixture.RootUri + "subdir"; - } - - protected override async Task InitializeCoreAsync(TestContext context) - { - await base.InitializeCoreAsync(context); - - if (TestPage != null) - { - // Clear logs - we check these during tests in some cases. - // Make sure each test starts clean. - await TestPage.EvaluateAsync("console.clear()"); - } - } -} diff --git a/src/Components/test/E2ETestMigration/Microsoft.AspNetCore.Components.Migration.E2ETests.csproj b/src/Components/test/E2ETestMigration/Microsoft.AspNetCore.Components.Migration.E2ETests.csproj deleted file mode 100644 index 0963d9615efc..000000000000 --- a/src/Components/test/E2ETestMigration/Microsoft.AspNetCore.Components.Migration.E2ETests.csproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - $(DefaultNetCoreTargetFramework) - Components.Migration.E2ETests - - true - - - false - - - true - false - - false - - - - - - - - - - - - - - - - - - - - - - - - - PreserveNewest - playwrightSettings.json - - - PreserveNewest - - - - - - - - - - - - - - - - - - <_DefaultProjectRoot>$([System.IO.Path]::GetFullPath($(_DefaultProjectFilter))) - - - <_ContentRootProjectReferences - Include="@(ReferencePath)" - Condition="'%(ReferencePath.ReferenceSourceTarget)' == 'ProjectReference' AND $([System.String]::Copy(%(ReferencePath.MSBuildSourceProjectFile)).StartsWith('$(_DefaultProjectRoot)'))" /> - - - - - - PreserveNewest - - - - - - - - - - <_PublishBasicFiles Include="$(OutputPath)helixcontent\BasicTestApp\**\*.*" /> - - - - - - - - <_PublishFiles Include="$(OutputPath).playwright\**\*.*" /> - <_PublishBasicFiles Include="$(OutputPath)helixcontent\BasicTestApp\**\*.*" /> - - - - - - diff --git a/src/Components/test/E2ETestMigration/Properties/AssemblyInfo.cs b/src/Components/test/E2ETestMigration/Properties/AssemblyInfo.cs deleted file mode 100644 index 92234b218205..000000000000 --- a/src/Components/test/E2ETestMigration/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Xunit; - -[assembly: CollectionBehavior(DisableTestParallelization = true)] diff --git a/src/Components/test/E2ETestMigration/TestJsonSerializerOptionsProvider.cs b/src/Components/test/E2ETestMigration/TestJsonSerializerOptionsProvider.cs deleted file mode 100644 index 28285c229b81..000000000000 --- a/src/Components/test/E2ETestMigration/TestJsonSerializerOptionsProvider.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Text.Json; - -namespace Microsoft.AspNetCore.Components.E2ETest; - -internal static class TestJsonSerializerOptionsProvider -{ - public static JsonSerializerOptions Options { get; } = new JsonSerializerOptions - { - PropertyNamingPolicy = JsonNamingPolicy.CamelCase, - PropertyNameCaseInsensitive = true, - }; -} diff --git a/src/Components/test/E2ETestMigration/Tests/BinaryHttpClientTest.cs b/src/Components/test/E2ETestMigration/Tests/BinaryHttpClientTest.cs deleted file mode 100644 index afdaa01b62cf..000000000000 --- a/src/Components/test/E2ETestMigration/Tests/BinaryHttpClientTest.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using BasicTestApp.HttpClientTest; -using Microsoft.AspNetCore.BrowserTesting; -using Microsoft.AspNetCore.Components.E2ETest.Infrastructure; -using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; -using Microsoft.AspNetCore.Testing; -using PlaywrightSharp; -using TestServer; -using Xunit; -using Xunit.Abstractions; - -namespace Microsoft.AspNetCore.Components.E2ETest.Tests; - -public class BinaryHttpClientTest : ComponentBrowserTestBase, - IClassFixture>, - IClassFixture> -{ - private readonly BlazorWasmTestAppFixture _devHostServerFixture; - readonly ServerFixture _apiServerFixture; - - protected override Type TestComponent { get; } = typeof(BinaryHttpRequestsComponent); - - public BinaryHttpClientTest( - BlazorWasmTestAppFixture devHostServerFixture, - BasicTestAppServerSiteFixture apiServerFixture, - ITestOutputHelper output) - : base(output) - { - _devHostServerFixture = devHostServerFixture; - _devHostServerFixture.PathBase = "/subdir"; - _apiServerFixture = apiServerFixture; - MountUri = _devHostServerFixture.RootUri + "subdir"; - } - - [QuarantinedTest("New experimental test that need bake time.")] - [ConditionalTheory] - [InlineData(BrowserKind.Chromium)] - [InlineData(BrowserKind.Firefox)] - [InlineData(BrowserKind.Webkit)] - // NOTE: BrowserKind argument must be first - public async Task CanSendAndReceiveBytes(BrowserKind browserKind) - { - if (ShouldSkip(browserKind)) - { - return; - } - - var targetUri = new Uri(_apiServerFixture.RootUri, "/subdir/api/data"); - await TestPage.TypeAsync("#request-uri", targetUri.AbsoluteUri); - await TestPage.ClickAsync("#send-request"); - - var status = await TestPage.GetTextContentAsync("#response-status"); - var statusText = await TestPage.GetTextContentAsync("#response-status-text"); - var testOutcome = await TestPage.GetTextContentAsync("#test-outcome"); - - Assert.Equal("OK", status); - Assert.Equal("OK", statusText); - Assert.Equal("", testOutcome); - } -} diff --git a/src/Components/test/E2ETestMigration/Tests/BindTest.cs b/src/Components/test/E2ETestMigration/Tests/BindTest.cs deleted file mode 100644 index ffde77dc031b..000000000000 --- a/src/Components/test/E2ETestMigration/Tests/BindTest.cs +++ /dev/null @@ -1,1359 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Threading.Tasks; -using BasicTestApp; -using Microsoft.AspNetCore.BrowserTesting; -using Microsoft.AspNetCore.Components.E2ETest.Infrastructure; -using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; -using Microsoft.AspNetCore.Testing; -using PlaywrightSharp; -using Xunit; -using Xunit.Abstractions; - -namespace Microsoft.AspNetCore.Components.E2ETest.Tests; - -public class BindTest : ServerTestBase> -{ - public BindTest( - ToggleExecutionModeServerFixture serverFixture, - ITestOutputHelper output) - : base(serverFixture, output) - { - } - - protected override Type TestComponent { get; } = typeof(BindCasesComponent); - - protected async Task GetInputValue(string selector) - => await TestPage.EvalOnSelectorAsync(selector, "e => e.value"); - - [QuarantinedTest("New experimental test that need bake time.")] - [ConditionalTheory] - [InlineData(BrowserKind.Chromium)] - [InlineData(BrowserKind.Firefox)] - [InlineData(BrowserKind.Webkit)] - // NOTE: BrowserKind argument must be first - public async Task CanBindTextbox_InitiallyBlank(BrowserKind browserKind) - { - if (ShouldSkip(browserKind)) - { - return; - } - - var target = await TestPage.QuerySelectorAsync("#textbox-initially-blank"); - Assert.Equal(string.Empty, await GetInputValue("#textbox-initially-blank")); - Assert.Equal(string.Empty, await TestPage.GetInnerTextAsync("#textbox-initially-blank-value")); - Assert.Equal(string.Empty, await GetInputValue("#textbox-initially-blank-mirror")); - - // Modify target; verify value is updated and that textboxes linked to the same data are updated - await target.TypeAsync("Changed value"); - // Doesn't update until change event - Assert.Equal(string.Empty, await TestPage.GetInnerTextAsync("#textbox-initially-blank-value")); - Assert.Equal(string.Empty, await GetInputValue("#textbox-initially-blank-mirror")); - await target.PressAsync("Tab"); - Assert.Equal("Changed value", await TestPage.GetInnerTextAsync("#textbox-initially-blank-value")); - Assert.Equal("Changed value", await GetInputValue("#textbox-initially-blank-mirror")); - - // Remove the value altogether - await TestPage.ClickAsync("#textbox-initially-blank-setnull"); - Assert.Equal(string.Empty, await GetInputValue("#textbox-initially-blank")); - Assert.Equal(string.Empty, await TestPage.GetInnerTextAsync("#textbox-initially-blank-value")); - Assert.Equal(string.Empty, await GetInputValue("#textbox-initially-blank-mirror")); - } - - //[Fact] - //public void CanBindTextbox_InitiallyPopulated() - //{ - // var target = Browser.Exists(By.Id("textbox-initially-populated")); - // var boundValue = Browser.Exists(By.Id("textbox-initially-populated-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-initially-populated-mirror")); - // var setNullButton = Browser.Exists(By.Id("textbox-initially-populated-setnull")); - // Assert.Equal("Hello", target.GetAttribute("value")); - // Assert.Equal("Hello", boundValue.Text); - // Assert.Equal("Hello", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("Changed value\t"); - // Browser.Equal("Changed value", () => boundValue.Text); - // Assert.Equal("Changed value", mirrorValue.GetAttribute("value")); - - // // Remove the value altogether - // setNullButton.Click(); - // Browser.Equal(string.Empty, () => target.GetAttribute("value")); - // Assert.Equal(string.Empty, boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - //} - - //[Fact] - //public void CanBindTextbox_WithBindSuffixInitiallyPopulated() - //{ - // var target = Browser.Exists(By.Id("bind-with-suffix-textbox-initially-populated")); - // var boundValue = Browser.Exists(By.Id("bind-with-suffix-textbox-initially-populated-value")); - // var mirrorValue = Browser.Exists(By.Id("bind-with-suffix-textbox-initially-populated-mirror")); - // var setNullButton = Browser.Exists(By.Id("bind-with-suffix-textbox-initially-populated-setnull")); - // Assert.Equal("Hello", target.GetAttribute("value")); - // Assert.Equal("Hello", boundValue.Text); - // Assert.Equal("Hello", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("Changed value\t"); - // Browser.Equal("Changed value", () => boundValue.Text); - // Assert.Equal("Changed value", mirrorValue.GetAttribute("value")); - - // // Remove the value altogether - // setNullButton.Click(); - // Browser.Equal(string.Empty, () => target.GetAttribute("value")); - // Assert.Equal(string.Empty, boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - //} - - //[Fact] - //public void CanBindTextArea_InitiallyBlank() - //{ - // var target = Browser.Exists(By.Id("textarea-initially-blank")); - // var boundValue = Browser.Exists(By.Id("textarea-initially-blank-value")); - // Assert.Equal(string.Empty, target.GetAttribute("value")); - // Assert.Equal(string.Empty, boundValue.Text); - - // // Modify target; verify value is updated - // target.SendKeys("Changed value"); - // Assert.Equal(string.Empty, boundValue.Text); // Don't update as there's no change event fired yet. - // target.SendKeys("\t"); - // Browser.Equal("Changed value", () => boundValue.Text); - //} - - //[Fact] - //public void CanBindTextArea_InitiallyPopulated() - //{ - // var target = Browser.Exists(By.Id("textarea-initially-populated")); - // var boundValue = Browser.Exists(By.Id("textarea-initially-populated-value")); - // Assert.Equal("Hello", target.GetAttribute("value")); - // Assert.Equal("Hello", boundValue.Text); - - // // Modify target; verify value is updated - // target.Clear(); - // target.SendKeys("Changed value\t"); - // Browser.Equal("Changed value", () => boundValue.Text); - //} - - //[Fact] - //public void CanBindCheckbox_InitiallyNull() - //{ - // var target = Browser.Exists(By.Id("checkbox-initially-null")); - // var boundValue = Browser.Exists(By.Id("checkbox-initially-null-value")); - // var invertButton = Browser.Exists(By.Id("checkbox-initially-null-invert")); - // Assert.False(target.Selected); - // Assert.Equal(string.Empty, boundValue.Text); - - // // Modify target; verify value is updated - // target.Click(); - // Browser.True(() => target.Selected); - // Browser.Equal("True", () => boundValue.Text); - - // // Modify data; verify checkbox is updated - // invertButton.Click(); - // Browser.False(() => target.Selected); - // Browser.Equal("False", () => boundValue.Text); - //} - - //[Fact] - //public void CanBindCheckbox_InitiallyUnchecked() - //{ - // var target = Browser.Exists(By.Id("checkbox-initially-unchecked")); - // var boundValue = Browser.Exists(By.Id("checkbox-initially-unchecked-value")); - // var invertButton = Browser.Exists(By.Id("checkbox-initially-unchecked-invert")); - // Assert.False(target.Selected); - // Assert.Equal("False", boundValue.Text); - - // // Modify target; verify value is updated - // target.Click(); - // Browser.True(() => target.Selected); - // Browser.Equal("True", () => boundValue.Text); - - // // Modify data; verify checkbox is updated - // invertButton.Click(); - // Browser.False(() => target.Selected); - // Browser.Equal("False", () => boundValue.Text); - //} - - //[Fact] - //public void CanBindCheckbox_InitiallyChecked() - //{ - // var target = Browser.Exists(By.Id("checkbox-initially-checked")); - // var boundValue = Browser.Exists(By.Id("checkbox-initially-checked-value")); - // var invertButton = Browser.Exists(By.Id("checkbox-initially-checked-invert")); - // Assert.True(target.Selected); - // Assert.Equal("True", boundValue.Text); - - // // Modify target; verify value is updated - // target.Click(); - // Browser.False(() => target.Selected); - // Browser.Equal("False", () => boundValue.Text); - - // // Modify data; verify checkbox is updated - // invertButton.Click(); - // Browser.True(() => target.Selected); - // Browser.Equal("True", () => boundValue.Text); - //} - - //[Fact] - //public void CanBindSelect() - //{ - // var target = new SelectElement(Browser.Exists(By.Id("select-box"))); - // var boundValue = Browser.Exists(By.Id("select-box-value")); - // Assert.Equal("Second choice", target.SelectedOption.Text); - // Assert.Equal("Second", boundValue.Text); - - // // Modify target; verify value is updated - // target.SelectByText("Third choice"); - // Browser.Equal("Third", () => boundValue.Text); - - // // Also verify we can add and select new options atomically - // // Don't move this into a separate test, because then the previous assertions - // // would be dependent on test execution order (or would require a full page reload) - // Browser.Exists(By.Id("select-box-add-option")).Click(); - // Browser.Equal("Fourth", () => boundValue.Text); - // Assert.Equal("Fourth choice", target.SelectedOption.Text); - - // // verify that changing an option value and selected value at the same time works. - // Browser.Exists(By.Id("change-variable-value")).Click(); - // Browser.Equal("Sixth", () => boundValue.Text); - - // // Verify we can select options whose value is empty - // // https://github.com/dotnet/aspnetcore/issues/17735 - // target.SelectByText("Empty value"); - // Browser.Equal(string.Empty, () => boundValue.Text); - // Browser.Equal("Empty value", () => target.SelectedOption.Text); - //} - - //[Fact] - //public void CanBindSelectToMarkup() - //{ - // var target = new SelectElement(Browser.Exists(By.Id("select-markup-box"))); - // var boundValue = Browser.Exists(By.Id("select-markup-box-value")); - // Assert.Equal("Second choice", target.SelectedOption.Text); - // Assert.Equal("Second", boundValue.Text); - - // // Modify target; verify value is updated - // target.SelectByText("Third choice"); - // Browser.Equal("Third", () => boundValue.Text); - - // // Verify we can select options whose value is empty - // // https://github.com/dotnet/aspnetcore/issues/17735 - // target.SelectByText("Empty value"); - // Browser.Equal(string.Empty, () => boundValue.Text); - // Browser.Equal("Empty value", () => target.SelectedOption.Text); - //} - - //[Fact] - //public void CanBindTextboxInt() - //{ - // var target = Browser.Exists(By.Id("textbox-int")); - // var boundValue = Browser.Exists(By.Id("textbox-int-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-int-mirror")); - // Assert.Equal("-42", target.GetAttribute("value")); - // Assert.Equal("-42", boundValue.Text); - // Assert.Equal("-42", mirrorValue.GetAttribute("value")); - - // // Clear target; value resets to zero - // target.Clear(); - // Browser.Equal("0", () => target.GetAttribute("value")); - // Assert.Equal("0", boundValue.Text); - // Assert.Equal("0", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // // Leading zeros are not preserved - // target.SendKeys("42"); - // Browser.Equal("042", () => target.GetAttribute("value")); - // target.SendKeys("\t"); - // Browser.Equal("42", () => target.GetAttribute("value")); - // Assert.Equal("42", boundValue.Text); - // Assert.Equal("42", mirrorValue.GetAttribute("value")); - //} - - //[Fact] - //public void CanBindTextboxNullableInt() - //{ - // var target = Browser.Exists(By.Id("textbox-nullable-int")); - // var boundValue = Browser.Exists(By.Id("textbox-nullable-int-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-nullable-int-mirror")); - // Assert.Equal(string.Empty, target.GetAttribute("value")); - // Assert.Equal(string.Empty, boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // Browser.Equal("", () => boundValue.Text); - // Assert.Equal("", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.SendKeys("-42\t"); - // Browser.Equal("-42", () => boundValue.Text); - // Assert.Equal("-42", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("42\t"); - // Browser.Equal("42", () => boundValue.Text); - // Assert.Equal("42", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("\t"); - // Browser.Equal(string.Empty, () => boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - //} - - //[Fact] - //public void CanBindTextboxLong() - //{ - // var target = Browser.Exists(By.Id("textbox-long")); - // var boundValue = Browser.Exists(By.Id("textbox-long-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-long-mirror")); - // Assert.Equal("3000000000", target.GetAttribute("value")); - // Assert.Equal("3000000000", boundValue.Text); - // Assert.Equal("3000000000", mirrorValue.GetAttribute("value")); - - // // Clear target; value resets to zero - // target.Clear(); - // Browser.Equal("0", () => target.GetAttribute("value")); - // Assert.Equal("0", boundValue.Text); - // Assert.Equal("0", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.SendKeys(Keys.Backspace); - // target.SendKeys("-3000000000\t"); - // Browser.Equal("-3000000000", () => target.GetAttribute("value")); - // Assert.Equal("-3000000000", boundValue.Text); - // Assert.Equal("-3000000000", mirrorValue.GetAttribute("value")); - //} - - //[Fact] - //public void CanBindTextboxNullableLong() - //{ - // var target = Browser.Exists(By.Id("textbox-nullable-long")); - // var boundValue = Browser.Exists(By.Id("textbox-nullable-long-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-nullable-long-mirror")); - // Assert.Equal(string.Empty, target.GetAttribute("value")); - // Assert.Equal(string.Empty, boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // Browser.Equal("", () => boundValue.Text); - // Assert.Equal("", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.SendKeys("3000000000\t"); - // Browser.Equal("3000000000", () => boundValue.Text); - // Assert.Equal("3000000000", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("-3000000000\t"); - // Browser.Equal("-3000000000", () => boundValue.Text); - // Assert.Equal("-3000000000", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("\t"); - // Browser.Equal(string.Empty, () => boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - //} - - //[Fact] - //public void CanBindTextboxShort() - //{ - // var target = Browser.Exists(By.Id("textbox-short")); - // var boundValue = Browser.Exists(By.Id("textbox-short-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-short-mirror")); - // Assert.Equal("-42", target.GetAttribute("value")); - // Assert.Equal("-42", boundValue.Text); - // Assert.Equal("-42", mirrorValue.GetAttribute("value")); - - // // Clear target; value resets to zero - // target.Clear(); - // Browser.Equal("0", () => target.GetAttribute("value")); - // Assert.Equal("0", boundValue.Text); - // Assert.Equal("0", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // // Leading zeros are not preserved - // target.SendKeys("42"); - // Browser.Equal("042", () => target.GetAttribute("value")); - // target.SendKeys("\t"); - // Browser.Equal("42", () => target.GetAttribute("value")); - // Assert.Equal("42", boundValue.Text); - // Assert.Equal("42", mirrorValue.GetAttribute("value")); - //} - - //[Fact] - //public void CanBindTextboxNullableShort() - //{ - // var target = Browser.Exists(By.Id("textbox-nullable-short")); - // var boundValue = Browser.Exists(By.Id("textbox-nullable-short-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-nullable-short-mirror")); - // Assert.Equal(string.Empty, target.GetAttribute("value")); - // Assert.Equal(string.Empty, boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // Browser.Equal("", () => boundValue.Text); - // Assert.Equal("", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.SendKeys("-42\t"); - // Browser.Equal("-42", () => boundValue.Text); - // Browser.Equal("-42", () => mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("42\t"); - // Browser.Equal("42", () => boundValue.Text); - // Browser.Equal("42", () => mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("\t"); - // Browser.Equal(string.Empty, () => boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - //} - - //[Fact] - //public void CanBindTextboxFloat() - //{ - // var target = Browser.Exists(By.Id("textbox-float")); - // var boundValue = Browser.Exists(By.Id("textbox-float-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-float-mirror")); - // Assert.Equal("3.141", target.GetAttribute("value")); - // Assert.Equal("3.141", boundValue.Text); - // Assert.Equal("3.141", mirrorValue.GetAttribute("value")); - - // // Clear target; value resets to zero - // target.Clear(); - // Browser.Equal("0", () => target.GetAttribute("value")); - // Assert.Equal("0", boundValue.Text); - // Assert.Equal("0", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.SendKeys(Keys.Backspace); - // target.SendKeys("-3.141\t"); - // Browser.Equal("-3.141", () => target.GetAttribute("value")); - // Browser.Equal("-3.141", () => boundValue.Text); - // Browser.Equal("-3.141", () => mirrorValue.GetAttribute("value")); - //} - - //[Fact] - //public void CanBindTextboxNullableFloat() - //{ - // var target = Browser.Exists(By.Id("textbox-nullable-float")); - // var boundValue = Browser.Exists(By.Id("textbox-nullable-float-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-nullable-float-mirror")); - // Assert.Equal(string.Empty, target.GetAttribute("value")); - // Assert.Equal(string.Empty, boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // Browser.Equal("", () => boundValue.Text); - // Assert.Equal("", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.SendKeys("3.141\t"); - // Browser.Equal("3.141", () => boundValue.Text); - // Assert.Equal("3.141", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("-3.141\t"); - // Browser.Equal("-3.141", () => boundValue.Text); - // Assert.Equal("-3.141", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("\t"); - // Browser.Equal(string.Empty, () => boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - //} - - //[Fact] - //public void CanBindTextboxDouble() - //{ - // var target = Browser.Exists(By.Id("textbox-double")); - // var boundValue = Browser.Exists(By.Id("textbox-double-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-double-mirror")); - // Assert.Equal("3.14159265359", target.GetAttribute("value")); - // Assert.Equal("3.14159265359", boundValue.Text); - // Assert.Equal("3.14159265359", mirrorValue.GetAttribute("value")); - - // // Clear target; value resets to default - // target.Clear(); - // Browser.Equal("0", () => target.GetAttribute("value")); - // Assert.Equal("0", boundValue.Text); - // Assert.Equal("0", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.SendKeys(Keys.Backspace); - // target.SendKeys("-3.14159265359\t"); - // Browser.Equal("-3.14159265359", () => boundValue.Text); - // Assert.Equal("-3.14159265359", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // // Double shouldn't preserve trailing zeros - // target.Clear(); - // target.SendKeys(Keys.Backspace); - // target.SendKeys("0.010\t"); - // Browser.Equal("0.01", () => target.GetAttribute("value")); - // Assert.Equal("0.01", boundValue.Text); - // Assert.Equal("0.01", mirrorValue.GetAttribute("value")); - //} - - //[Fact] - //public void CanBindTextboxNullableDouble() - //{ - // var target = Browser.Exists(By.Id("textbox-nullable-double")); - // var boundValue = Browser.Exists(By.Id("textbox-nullable-double-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-nullable-double-mirror")); - // Assert.Equal(string.Empty, target.GetAttribute("value")); - // Assert.Equal(string.Empty, boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // Browser.Equal("", () => boundValue.Text); - // Assert.Equal("", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.SendKeys("3.14159265359\t"); - // Browser.Equal("3.14159265359", () => boundValue.Text); - // Assert.Equal("3.14159265359", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("-3.14159265359\t"); - // Browser.Equal("-3.14159265359", () => boundValue.Text); - // Assert.Equal("-3.14159265359", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // // Double shouldn't preserve trailing zeros - // target.Clear(); - // target.SendKeys("0.010\t"); - // Browser.Equal("0.01", () => boundValue.Text); - // Assert.Equal("0.01", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("\t"); - // Browser.Equal(string.Empty, () => boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - //} - - //[Fact] - //public void CanBindTextboxDecimal() - //{ - // var target = Browser.Exists(By.Id("textbox-decimal")); - // var boundValue = Browser.Exists(By.Id("textbox-decimal-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-decimal-mirror")); - // Assert.Equal("0.0000000000000000000000000001", target.GetAttribute("value")); - // Assert.Equal("0.0000000000000000000000000001", boundValue.Text); - // Assert.Equal("0.0000000000000000000000000001", mirrorValue.GetAttribute("value")); - - // // Clear textbox; value updates to zero because that's the default - // target.Clear(); - // Browser.Equal("0", () => target.GetAttribute("value")); - // Assert.Equal("0", boundValue.Text); - // Assert.Equal("0", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // // Decimal should preserve trailing zeros - // target.SendKeys("0.010\t"); - // Browser.Equal("0.010", () => boundValue.Text); - // Assert.Equal("0.010", mirrorValue.GetAttribute("value")); - //} - - //[Fact] - //public void CanBindTextboxNullableDecimal() - //{ - // var target = Browser.Exists(By.Id("textbox-nullable-decimal")); - // var boundValue = Browser.Exists(By.Id("textbox-nullable-decimal-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-nullable-decimal-mirror")); - // Assert.Equal(string.Empty, target.GetAttribute("value")); - // Assert.Equal(string.Empty, boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // Browser.Equal("", () => boundValue.Text); - // Assert.Equal("", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.SendKeys("0.0000000000000000000000000001\t"); - // Browser.Equal("0.0000000000000000000000000001", () => boundValue.Text); - // Assert.Equal("0.0000000000000000000000000001", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // // Decimal should preserve trailing zeros - // target.Clear(); - // target.SendKeys("0.010\t"); - // Browser.Equal("0.010", () => boundValue.Text); - // Browser.Equal("0.010", () => mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("\t"); - // Browser.Equal(string.Empty, () => boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - //} - - //// This tests what happens you put invalid (unconvertable) input in. This is separate from the - //// other tests because it requires type="text" - the other tests use type="number" - //[Fact] - //public void CanBindTextbox_Decimal_InvalidInput() - //{ - // var target = Browser.Exists(By.Id("textbox-decimal-invalid")); - // var boundValue = Browser.Exists(By.Id("textbox-decimal-invalid-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-decimal-invalid-mirror")); - // Assert.Equal("0.0000000000000000000000000001", target.GetAttribute("value")); - // Assert.Equal("0.0000000000000000000000000001", boundValue.Text); - // Assert.Equal("0.0000000000000000000000000001", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("0.01\t"); - // Browser.Equal("0.01", () => boundValue.Text); - // Assert.Equal("0.01", mirrorValue.GetAttribute("value")); - - // // Modify target to something invalid - the invalid change is reverted - // // back to the last valid value - // target.SendKeys("2A"); - // Assert.Equal("0.012A", target.GetAttribute("value")); - // target.SendKeys("\t"); - // Browser.Equal("0.01", () => boundValue.Text); - // Browser.Equal("0.01", () => mirrorValue.GetAttribute("value")); - // Browser.Equal("0.01", () => target.GetAttribute("value")); - - // // Continue editing with valid inputs - // target.SendKeys(Keys.Backspace); - // target.SendKeys("2\t"); - // Browser.Equal("0.02", () => boundValue.Text); - // Browser.Equal("0.02", () => mirrorValue.GetAttribute("value")); - //} - - //// This tests what happens you put invalid (unconvertable) input in. This is separate from the - //// other tests because it requires type="text" - the other tests use type="number" - //[Fact] - //public void CanBindTextbox_NullableDecimal_InvalidInput() - //{ - // var target = Browser.Exists(By.Id("textbox-nullable-decimal-invalid")); - // var boundValue = Browser.Exists(By.Id("textbox-nullable-decimal-invalid-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-nullable-decimal-invalid-mirror")); - // Assert.Equal(string.Empty, target.GetAttribute("value")); - // Assert.Equal(string.Empty, boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("0.01\t"); - // Browser.Equal("0.01", () => boundValue.Text); - // Assert.Equal("0.01", mirrorValue.GetAttribute("value")); - - // // Modify target to something invalid - the invalid change is reverted - // // back to the last valid value - // target.SendKeys("2A"); - // Assert.Equal("0.012A", target.GetAttribute("value")); - // target.SendKeys("\t"); - // Browser.Equal("0.01", () => boundValue.Text); - // Assert.Equal("0.01", mirrorValue.GetAttribute("value")); - // Assert.Equal("0.01", target.GetAttribute("value")); - - // // Continue editing with valid inputs - // target.SendKeys(Keys.Backspace); - // target.SendKeys("2\t"); - // Browser.Equal("0.02", () => boundValue.Text); - // Assert.Equal("0.02", mirrorValue.GetAttribute("value")); - //} - - //[Fact] - //public void CanBindTextboxGenericInt() - //{ - // var target = Browser.Exists(By.Id("textbox-generic-int")); - // var boundValue = Browser.Exists(By.Id("textbox-generic-int-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-generic-int-mirror")); - // Assert.Equal("-42", target.GetAttribute("value")); - // Assert.Equal("-42", boundValue.Text); - // Assert.Equal("-42", mirrorValue.GetAttribute("value")); - - // // Clear target; value resets to zero - // target.Clear(); - // Browser.Equal("0", () => target.GetAttribute("value")); - // Assert.Equal("0", boundValue.Text); - // Assert.Equal("0", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.SendKeys("42\t"); - // Browser.Equal("42", () => boundValue.Text); - // Assert.Equal("42", mirrorValue.GetAttribute("value")); - //} - - //[Fact] - //public void CanBindTextboxGenericGuid() - //{ - // var target = Browser.Exists(By.Id("textbox-generic-guid")); - // var boundValue = Browser.Exists(By.Id("textbox-generic-guid-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-generic-guid-mirror")); - // Assert.Equal("00000000-0000-0000-0000-000000000000", target.GetAttribute("value")); - // Assert.Equal("00000000-0000-0000-0000-000000000000", boundValue.Text); - // Assert.Equal("00000000-0000-0000-0000-000000000000", mirrorValue.GetAttribute("value")); - - // // Modify target; value is not updated because it's not convertable. - // target.Clear(); - // Browser.Equal("00000000-0000-0000-0000-000000000000", () => boundValue.Text); - // Assert.Equal("00000000-0000-0000-0000-000000000000", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // var newValue = Guid.NewGuid().ToString(); - // target.SendKeys(newValue + "\t"); - // Browser.Equal(newValue, () => boundValue.Text); - // Assert.Equal(newValue, mirrorValue.GetAttribute("value")); - //} - - //// For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side - //// Blazor have different formatting behaviour by default. - //[Fact] - //public void CanBindTextboxDateTime() - //{ - // var target = Browser.Exists(By.Id("textbox-datetime")); - // var boundValue = Browser.Exists(By.Id("textbox-datetime-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-datetime-mirror")); - // var expected = new DateTime(1985, 3, 4); - // Assert.Equal(expected, DateTime.Parse(target.GetAttribute("value"), CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Clear textbox; value updates to 01/01/0001 because that's the default - // target.Clear(); - // expected = default; - // Browser.Equal(expected, () => DateTime.Parse(target.GetAttribute("value"), CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.SendKeys(Keys.Control + "a"); // select all - // target.SendKeys("01/02/2000 00:00:00\t"); - // expected = new DateTime(2000, 1, 2); - // Browser.Equal(expected, () => DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - //} - - //// For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side - //// Blazor have different formatting behaviour by default. - //[Fact] - //public void CanBindTextboxNullableDateTime() - //{ - // var target = Browser.Exists(By.Id("textbox-nullable-datetime")); - // var boundValue = Browser.Exists(By.Id("textbox-nullable-datetime-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-nullable-datetime-mirror")); - // Assert.Equal(string.Empty, target.GetAttribute("value")); - // Assert.Equal(string.Empty, boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // Browser.Equal("", () => boundValue.Text); - // Assert.Equal("", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // var expected = new DateTime(2000, 1, 2); - // target.SendKeys("01/02/2000 00:00:00\t"); - // Browser.Equal(expected, () => DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("\t"); - // Browser.Equal(string.Empty, () => boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - //} - - //// For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side - //// Blazor have different formatting behaviour by default. - //[Fact] - //public void CanBindTextboxDateTimeOffset() - //{ - // var target = Browser.Exists(By.Id("textbox-datetimeoffset")); - // var boundValue = Browser.Exists(By.Id("textbox-datetimeoffset-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-datetimeoffset-mirror")); - // var expected = new DateTimeOffset(new DateTime(1985, 3, 4), TimeSpan.FromHours(8)); - // Assert.Equal(expected, DateTimeOffset.Parse(target.GetAttribute("value"), CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTimeOffset.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTimeOffset.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Clear textbox; value updates to 01/01/0001 because that's the default - // target.Clear(); - // expected = default; - // Browser.Equal(expected, () => DateTimeOffset.Parse(target.GetAttribute("value"), CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTimeOffset.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTimeOffset.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.SendKeys(Keys.Control + "a"); // select all - // target.SendKeys("01/02/2000 00:00:00 +08:00\t"); - // expected = new DateTimeOffset(new DateTime(2000, 1, 2), TimeSpan.FromHours(8)); - // Browser.Equal(expected, () => DateTimeOffset.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTimeOffset.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - //} - - //// For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side - //// Blazor have different formatting behaviour by default. - //[Fact] - //public void CanBindTextboxNullableDateTimeOffset() - //{ - // var target = Browser.Exists(By.Id("textbox-nullable-datetimeoffset")); - // var boundValue = Browser.Exists(By.Id("textbox-nullable-datetimeoffset-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-nullable-datetimeoffset-mirror")); - // Assert.Equal(string.Empty, target.GetAttribute("value")); - // Assert.Equal(string.Empty, boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // Browser.Equal("", () => boundValue.Text); - // Assert.Equal("", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.SendKeys("01/02/2000 00:00:00 +08:00" + "\t"); - // var expected = new DateTimeOffset(new DateTime(2000, 1, 2), TimeSpan.FromHours(8)); - // Browser.Equal(expected, () => DateTimeOffset.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTimeOffset.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("\t"); - // Browser.Equal(string.Empty, () => boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - //} - - //// For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side - //// Blazor have different formatting behaviour by default. - //[Fact] - //public void CanBindTextboxDateTimeWithFormat() - //{ - // var target = Browser.Exists(By.Id("textbox-datetime-format")); - // var boundValue = Browser.Exists(By.Id("textbox-datetime-format-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-datetime-format-mirror")); - // var expected = new DateTime(1985, 3, 4); - // Assert.Equal("03-04", target.GetAttribute("value")); - // Assert.Equal(expected, DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Clear textbox; value updates to the default - // target.Clear(); - // target.SendKeys("\t"); - // expected = default; - // Browser.Equal("01-01", () => target.GetAttribute("value")); - // Assert.Equal(expected, DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.SendKeys(Keys.Control + "a"); // select all - // target.SendKeys("01-02\t"); - // expected = new DateTime(DateTime.Now.Year, 1, 2); - // Browser.Equal(expected, () => DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - //} - - //// For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side - //// Blazor have different formatting behaviour by default. - //[Fact] - //public void CanBindTextboxNullableDateTimeWithFormat() - //{ - // var target = Browser.Exists(By.Id("textbox-nullable-datetime-format")); - // var boundValue = Browser.Exists(By.Id("textbox-nullable-datetime-format-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-nullable-datetime-format-mirror")); - // Assert.Equal(string.Empty, target.GetAttribute("value")); - // Assert.Equal(string.Empty, boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // Browser.Equal("", () => boundValue.Text); - // Assert.Equal("", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.SendKeys("01-02\t"); - // var expected = new DateTime(DateTime.Now.Year, 1, 2); - // Browser.Equal(expected, () => DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("\t"); - // Browser.Equal(string.Empty, () => boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - //} - - //// For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side - //// Blazor have different formatting behaviour by default. - //[Fact] - //public void CanBindTextboxDateTimeOffsetWithFormat() - //{ - // var target = Browser.Exists(By.Id("textbox-datetimeoffset-format")); - // var boundValue = Browser.Exists(By.Id("textbox-datetimeoffset-format-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-datetimeoffset-format-mirror")); - // var expected = new DateTimeOffset(new DateTime(1985, 3, 4), TimeSpan.FromHours(8)); - // Assert.Equal("03-04", target.GetAttribute("value")); - // Assert.Equal(expected, DateTimeOffset.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTimeOffset.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Clear textbox; value updates to the default - // target.Clear(); - // expected = default; - // Browser.Equal("01-01", () => target.GetAttribute("value")); - // Assert.Equal(expected, DateTimeOffset.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTimeOffset.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.SendKeys(Keys.Control + "a"); // select all - // target.SendKeys("01-02\t"); - // expected = new DateTimeOffset(new DateTime(DateTime.Now.Year, 1, 2), TimeSpan.FromHours(0)); - // Browser.Equal(expected.DateTime, () => DateTimeOffset.Parse(boundValue.Text, CultureInfo.InvariantCulture).DateTime); - // Assert.Equal(expected.DateTime, DateTimeOffset.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture).DateTime); - //} - - //// For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side - //// Blazor have different formatting behaviour by default. - //// - //// Guess what! Client-side and server-side also understand timezones differently. So for now we're comparing - //// the parsed output without consideration for the timezone - //[Fact] - //public void CanBindTextboxNullableDateTimeOffsetWithFormat() - //{ - // var target = Browser.Exists(By.Id("textbox-nullable-datetimeoffset")); - // var boundValue = Browser.Exists(By.Id("textbox-nullable-datetimeoffset-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-nullable-datetimeoffset-mirror")); - // Assert.Equal(string.Empty, target.GetAttribute("value")); - // Assert.Equal(string.Empty, boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // Browser.Equal("", () => boundValue.Text); - // Assert.Equal("", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.SendKeys("01-02" + "\t"); - // var expected = new DateTimeOffset(new DateTime(DateTime.Now.Year, 1, 2), TimeSpan.FromHours(0)); - // Browser.Equal(expected.DateTime, () => DateTimeOffset.Parse(boundValue.Text, CultureInfo.InvariantCulture).DateTime); - // Assert.Equal(expected.DateTime, DateTimeOffset.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture).DateTime); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("\t"); - // Browser.Equal(string.Empty, () => boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - //} - - //// For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side - //// Blazor have different formatting behaviour by default. - //[Fact] - //public void CanBindTextboxNullableDateTime_InvalidValue() - //{ - // var target = Browser.Exists(By.Id("textbox-nullable-datetime-invalid")); - // var boundValue = Browser.Exists(By.Id("textbox-nullable-datetime-invalid-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-nullable-datetime-invalid-mirror")); - // Assert.Equal(string.Empty, target.GetAttribute("value")); - // Assert.Equal(string.Empty, boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // var expected = new DateTime(2000, 1, 2); - // target.SendKeys("01/02/2000 00:00:00\t"); - // Browser.Equal(expected, () => DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Modify target to something invalid - the invalid change is reverted - // // back to the last valid value - // target.SendKeys(Keys.Control + "a"); // select all - // target.SendKeys("05/06X"); - // Browser.Equal("05/06X", () => target.GetAttribute("value")); - // target.SendKeys("\t"); - // Browser.Equal(expected, () => DateTime.Parse(target.GetAttribute("value"), CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Now change it to something valid - // target.SendKeys(Keys.Control + "a"); // select all - // target.SendKeys("05/06\t"); - // expected = new DateTime(DateTime.Now.Year, 5, 6); - // Browser.Equal(expected, () => DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - //} - - //// For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side - //// Blazor have different formatting behaviour by default. - //[Fact] - //public void CanBindTextboxDateTimeOffset_InvalidValue() - //{ - // var target = Browser.Exists(By.Id("textbox-datetimeoffset-invalid")); - // var boundValue = Browser.Exists(By.Id("textbox-datetimeoffset-invalid-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-datetimeoffset-invalid-mirror")); - // var expected = new DateTimeOffset(new DateTime(1985, 3, 4), TimeSpan.FromHours(8)); - // Assert.Equal(expected, DateTimeOffset.Parse(target.GetAttribute("value"), CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTimeOffset.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTimeOffset.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // expected = new DateTime(2000, 1, 2); - // target.SendKeys(Keys.Control + "a"); // select all - // target.SendKeys("01/02/2000 00:00:00\t"); - // Browser.Equal(expected.DateTime, () => DateTimeOffset.Parse(boundValue.Text, CultureInfo.InvariantCulture).DateTime); - // Assert.Equal(expected.DateTime, DateTimeOffset.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture).DateTime); - - // // Modify target to something invalid - the invalid change is reverted - // // back to the last valid value - // target.SendKeys(Keys.Control + "a"); // select all - // target.SendKeys("05/06X"); - // Browser.Equal("05/06X", () => target.GetAttribute("value")); - // target.SendKeys("\t"); - // Browser.Equal(expected.DateTime, () => DateTimeOffset.Parse(target.GetAttribute("value"), CultureInfo.InvariantCulture).DateTime); - // Assert.Equal(expected.DateTime, DateTimeOffset.Parse(boundValue.Text, CultureInfo.InvariantCulture).DateTime); - // Assert.Equal(expected.DateTime, DateTimeOffset.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture).DateTime); - - // // Now change it to something valid - // target.SendKeys(Keys.Control + "a"); // select all - // target.SendKeys("05/06\t"); - // expected = new DateTime(DateTime.Now.Year, 5, 6); - // Browser.Equal(expected.DateTime, () => DateTimeOffset.Parse(boundValue.Text, CultureInfo.InvariantCulture).DateTime); - // Assert.Equal(expected.DateTime, DateTimeOffset.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture).DateTime); - //} - - //// For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side - //// Blazor have different formatting behaviour by default. - //[Fact] - //public void CanBindTextboxDateTimeWithFormat_InvalidValue() - //{ - // var target = Browser.Exists(By.Id("textbox-datetime-format-invalid")); - // var boundValue = Browser.Exists(By.Id("textbox-datetime-format-invalid-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-datetime-format-invalid-mirror")); - // var expected = new DateTime(1985, 3, 4); - // Assert.Equal("03-04", target.GetAttribute("value")); - // Assert.Equal(expected, DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Modify target to something invalid - the invalid change is reverted - // // back to the last valid value - // target.SendKeys(Keys.Control + "a"); // select all - // target.SendKeys("05/06"); - // Browser.Equal("05/06", () => target.GetAttribute("value")); - // target.SendKeys("\t"); - // Browser.Equal("03-04", () => target.GetAttribute("value")); - // Assert.Equal(expected, DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Now change it to something valid - // target.SendKeys(Keys.Control + "a"); // select all - // target.SendKeys("05-06\t"); - // expected = new DateTime(DateTime.Now.Year, 5, 6); - // Browser.Equal(expected, () => DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - //} - - //// For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side - //// Blazor have different formatting behaviour by default. - //[Fact] - //public void CanBindTextboxNullableDateTimeOffsetWithFormat_InvalidValue() - //{ - // var target = Browser.Exists(By.Id("textbox-nullable-datetimeoffset-format-invalid")); - // var boundValue = Browser.Exists(By.Id("textbox-nullable-datetimeoffset-format-invalid-value")); - // var mirrorValue = Browser.Exists(By.Id("textbox-nullable-datetimeoffset-format-invalid-mirror")); - // Assert.Equal(string.Empty, target.GetAttribute("value")); - // Assert.Equal(string.Empty, boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // var expected = new DateTimeOffset(new DateTime(DateTime.Now.Year, 1, 2)); - // target.SendKeys(Keys.Control + "a"); // select all - // target.SendKeys("01-02\t"); - // Browser.Equal(expected.DateTime, () => DateTimeOffset.Parse(boundValue.Text, CultureInfo.InvariantCulture).DateTime); - // Assert.Equal(expected.DateTime, DateTimeOffset.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture).DateTime); - - // // Modify target to something invalid - the invalid change is reverted - // // back to the last valid value - // target.SendKeys(Keys.Control + "a"); // select all - // target.SendKeys("05/06"); - // Browser.Equal("05/06", () => target.GetAttribute("value")); - // target.SendKeys("\t"); - // Browser.Equal(expected.DateTime, () => DateTimeOffset.Parse(target.GetAttribute("value"), CultureInfo.InvariantCulture).DateTime); - // Assert.Equal(expected.DateTime, DateTimeOffset.Parse(boundValue.Text, CultureInfo.InvariantCulture).DateTime); - // Assert.Equal(expected.DateTime, DateTimeOffset.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture).DateTime); - - // // Now change it to something valid - // target.SendKeys(Keys.Control + "a"); // select all - // target.SendKeys("05-06\t"); - // expected = new DateTime(DateTime.Now.Year, 5, 6); - // Browser.Equal(expected.DateTime, () => DateTimeOffset.Parse(boundValue.Text, CultureInfo.InvariantCulture).DateTime); - // Assert.Equal(expected.DateTime, DateTimeOffset.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture).DateTime); - //} - - //// For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side - //// Blazor have different formatting behaviour by default. - //[Fact] - //public void CanBindDateTimeLocalTextboxDateTime() - //{ - // var target = Browser.Exists(By.Id("datetime-local-textbox-datetime")); - // var boundValue = Browser.Exists(By.Id("datetime-local-textbox-datetime-value")); - // var mirrorValue = Browser.Exists(By.Id("datetime-local-textbox-datetime-mirror")); - // var expected = new DateTime(1985, 3, 4); - // Assert.Equal(expected, DateTime.Parse(target.GetAttribute("value"), CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Clear textbox; value updates to 01/01/0001 because that's the default - // target.Clear(); - // expected = default; - // Browser.Equal(expected, () => DateTime.Parse(target.GetAttribute("value"), CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // We have to do it this way because the browser gets in the way when sending keys to the input - // // element directly. - // ApplyInputValue("#datetime-local-textbox-datetime", "2000-01-02T04:05:06"); - // expected = new DateTime(2000, 1, 2, 04, 05, 06); - // Browser.Equal(expected, () => DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - //} - - //// For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side - //// Blazor have different formatting behaviour by default. - //[Fact] - //public void CanBindDateTimeLocalTextboxNullableDateTime() - //{ - // var target = Browser.Exists(By.Id("datetime-local-textbox-nullable-datetime")); - // var boundValue = Browser.Exists(By.Id("datetime-local-textbox-nullable-datetime-value")); - // var mirrorValue = Browser.Exists(By.Id("datetime-local-textbox-nullable-datetime-mirror")); - // Assert.Equal(string.Empty, target.GetAttribute("value")); - // Assert.Equal(string.Empty, boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // Browser.Equal("", () => boundValue.Text); - // Assert.Equal("", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // // We have to do it this way because the browser gets in the way when sending keys to the input - // // element directly. - // ApplyInputValue("#datetime-local-textbox-nullable-datetime", "2000-01-02T04:05:06"); - // var expected = new DateTime(2000, 1, 2, 04, 05, 06); - // Browser.Equal(expected, () => DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("\t"); - // Browser.Equal(string.Empty, () => boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - //} - - //// For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side - //// Blazor have different formatting behaviour by default. - //[Fact] - //public void CanBindMonthTextboxDateTime() - //{ - // var target = Browser.Exists(By.Id("month-textbox-datetime")); - // var boundValue = Browser.Exists(By.Id("month-textbox-datetime-value")); - // var mirrorValue = Browser.Exists(By.Id("month-textbox-datetime-mirror")); - // var expected = new DateTime(1985, 3, 1); - // Assert.Equal(expected, DateTime.Parse(target.GetAttribute("value"), CultureInfo.InvariantCulture)); - // // When the value gets displayed the first time it gets truncated to the 1st day, - // // until there is no change the bound value doesn't get updated. - // Assert.Equal(expected.AddDays(3), DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected.AddDays(3), DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Clear textbox; value updates to 01/01/0001 because that's the default - // target.Clear(); - // expected = default; - // Browser.Equal(expected, () => DateTime.Parse(target.GetAttribute("value"), CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // We have to do it this way because the browser gets in the way when sending keys to the input - // // element directly. - // ApplyInputValue("#month-textbox-datetime", "2000-02"); - // expected = new DateTime(2000, 2, 1); - // Browser.Equal(expected, () => DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - //} - - //// For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side - //// Blazor have different formatting behaviour by default. - //[Fact] - //public void CanBindMonthTextboxNullableDateTime() - //{ - // var target = Browser.Exists(By.Id("month-textbox-nullable-datetime")); - // var boundValue = Browser.Exists(By.Id("month-textbox-nullable-datetime-value")); - // var mirrorValue = Browser.Exists(By.Id("month-textbox-nullable-datetime-mirror")); - // Assert.Equal(string.Empty, target.GetAttribute("value")); - // Assert.Equal(string.Empty, boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // Browser.Equal("", () => boundValue.Text); - // Assert.Equal("", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // // We have to do it this way because the browser gets in the way when sending keys to the input - // // element directly. - // ApplyInputValue("#month-textbox-nullable-datetime", "2000-02"); - // var expected = new DateTime(2000, 2, 1); - // Browser.Equal(expected, () => DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("\t"); - // Browser.Equal(string.Empty, () => boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - //} - - //// For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side - //// Blazor have different formatting behaviour by default. - //[Fact] - //public void CanBindTimeTextboxDateTime() - //{ - // var target = Browser.Exists(By.Id("time-textbox-datetime")); - // var boundValue = Browser.Exists(By.Id("time-textbox-datetime-value")); - // var mirrorValue = Browser.Exists(By.Id("time-textbox-datetime-mirror")); - // var expected = DateTime.Now.Date.AddHours(8).AddMinutes(5); - // Assert.Equal(expected, DateTime.Parse(target.GetAttribute("value"), CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Clear textbox; value updates to 00:00 because that's the default - // target.Clear(); - // expected = default; - // Browser.Equal(DateTime.Now.Date, () => DateTime.Parse(target.GetAttribute("value"), CultureInfo.InvariantCulture)); - // Assert.Equal(default, DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(default, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // We have to do it this way because the browser gets in the way when sending keys to the input - // // element directly. - // ApplyInputValue("#time-textbox-datetime", "04:05"); - // expected = DateTime.Now.Date.Add(new TimeSpan(4, 5, 0)); - // Browser.Equal(expected, () => DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - //} - - //// For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side - //// Blazor have different formatting behaviour by default. - //[Fact] - //public void CanBindTimeTextboxNullableDateTime() - //{ - // var target = Browser.Exists(By.Id("time-textbox-nullable-datetime")); - // var boundValue = Browser.Exists(By.Id("time-textbox-nullable-datetime-value")); - // var mirrorValue = Browser.Exists(By.Id("time-textbox-nullable-datetime-mirror")); - // Assert.Equal(string.Empty, target.GetAttribute("value")); - // Assert.Equal(string.Empty, boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // Browser.Equal("", () => boundValue.Text); - // Assert.Equal("", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // // We have to do it this way because the browser gets in the way when sending keys to the input - // // element directly. - // ApplyInputValue("#time-textbox-nullable-datetime", "05:06"); - // var expected = DateTime.Now.Date.Add(new TimeSpan(05, 06, 0)); - // Browser.Equal(expected, () => DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("\t"); - // Browser.Equal(string.Empty, () => boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - //} - - //// For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side - //// Blazor have different formatting behaviour by default. - //[Fact] - //public void CanBindTimeStepTextboxDateTime() - //{ - // var target = Browser.Exists(By.Id("time-step-textbox-datetime")); - // var boundValue = Browser.Exists(By.Id("time-step-textbox-datetime-value")); - // var mirrorValue = Browser.Exists(By.Id("time-step-textbox-datetime-mirror")); - // var expected = DateTime.Now.Date.Add(new TimeSpan(8, 5, 30)); - // Assert.Equal(expected, DateTime.Parse(target.GetAttribute("value"), CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Clear textbox; value updates to 00:00 because that's the default - // target.Clear(); - // expected = default; - // Browser.Equal(DateTime.Now.Date, () => DateTime.Parse(target.GetAttribute("value"), CultureInfo.InvariantCulture)); - // Assert.Equal(default, DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(default, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // We have to do it this way because the browser gets in the way when sending keys to the input - // // element directly. - // ApplyInputValue("#time-step-textbox-datetime", "04:05:06"); - // expected = DateTime.Now.Date.Add(new TimeSpan(4, 5, 6)); - // Browser.Equal(expected, () => DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - //} - - //// For date comparisons, we parse (non-formatted) values to compare them. Client-side and server-side - //// Blazor have different formatting behaviour by default. - //[Fact] - //public void CanBindTimeStepTextboxNullableDateTime() - //{ - // var target = Browser.Exists(By.Id("time-step-textbox-nullable-datetime")); - // var boundValue = Browser.Exists(By.Id("time-step-textbox-nullable-datetime-value")); - // var mirrorValue = Browser.Exists(By.Id("time-step-textbox-nullable-datetime-mirror")); - // Assert.Equal(string.Empty, target.GetAttribute("value")); - // Assert.Equal(string.Empty, boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // Browser.Equal("", () => boundValue.Text); - // Assert.Equal("", mirrorValue.GetAttribute("value")); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // // We have to do it this way because the browser gets in the way when sending keys to the input - // // element directly. - // ApplyInputValue("#time-step-textbox-nullable-datetime", "05:06"); - // var expected = DateTime.Now.Date.Add(new TimeSpan(05, 06, 0)); - // Browser.Equal(expected, () => DateTime.Parse(boundValue.Text, CultureInfo.InvariantCulture)); - // Assert.Equal(expected, DateTime.Parse(mirrorValue.GetAttribute("value"), CultureInfo.InvariantCulture)); - - // // Modify target; verify value is updated and that textboxes linked to the same data are updated - // target.Clear(); - // target.SendKeys("\t"); - // Browser.Equal(string.Empty, () => boundValue.Text); - // Assert.Equal(string.Empty, mirrorValue.GetAttribute("value")); - //} - - //// Applies an input through javascript to datetime-local/month/time controls. - //private void ApplyInputValue(string cssSelector, string value) - //{ - // // It's very difficult to enter an invalid value into an , because - // // most combinations of keystrokes get normalized to something valid. Additionally, - // // using Selenium's SendKeys interacts unpredictably with this normalization logic, - // // most likely based on timings. As a workaround, use JS to apply the values. This - // // should only be used when strictly necessary, as it doesn't represent actual user - // // interaction as authentically as SendKeys in other cases. - // var javascript = (IJavaScriptExecutor)Browser; - // javascript.ExecuteScript( - // $"var elem = document.querySelector('{cssSelector}');" - // + $"elem.value = '{value}';" - // + "elem.dispatchEvent(new KeyboardEvent('change'));"); - //} -} diff --git a/src/Components/test/E2ETestMigration/Tests/DownloadAnchorTest.cs b/src/Components/test/E2ETestMigration/Tests/DownloadAnchorTest.cs deleted file mode 100644 index 91d1d0fe98e2..000000000000 --- a/src/Components/test/E2ETestMigration/Tests/DownloadAnchorTest.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Threading.Tasks; -using BasicTestApp; -using BasicTestApp.RouterTest; -using Microsoft.AspNetCore.BrowserTesting; -using Microsoft.AspNetCore.Components.E2ETest.Infrastructure; -using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; -using Microsoft.AspNetCore.Testing; -using Moq; -using PlaywrightSharp; -using Xunit; -using Xunit.Abstractions; - -namespace Microsoft.AspNetCore.Components.E2ETest.Tests; - -public class DownloadAnchorTest - : ServerTestBase> -{ - public DownloadAnchorTest( - ToggleExecutionModeServerFixture serverFixture, - ITestOutputHelper output) - : base(serverFixture, output) - { - } - - protected override Type TestComponent { get; } = typeof(TestRouter); - - [QuarantinedTest("New experimental test that need bake time.")] - [ConditionalTheory] - [InlineData(BrowserKind.Chromium)] - [InlineData(BrowserKind.Firefox)] - // NOTE: BrowserKind argument must be first - public async Task DownloadFileFromAnchor(BrowserKind browserKind) - { - if (ShouldSkip(browserKind)) - { - return; - } - - // Arrange - var initialUrl = TestPage.Url; - var downloadTask = TestPage.WaitForEventAsync(PageEvent.Download); - - // Act - await Task.WhenAll( - downloadTask, - TestPage.ClickAsync("a[download]")); - - // Assert URL should still be same as before click - Assert.Equal(initialUrl, TestPage.Url); - - // Assert that the resource was downloaded - var download = downloadTask.Result.Download; - Assert.Equal($"{_serverFixture.RootUri}subdir/images/blazor_logo_1000x.png", download.Url); - Assert.Equal("blazor_logo_1000x.png", download.SuggestedFilename); - } -} diff --git a/src/Components/test/E2ETestMigration/Tests/InputFileTest.cs b/src/Components/test/E2ETestMigration/Tests/InputFileTest.cs deleted file mode 100644 index 21a3aa604332..000000000000 --- a/src/Components/test/E2ETestMigration/Tests/InputFileTest.cs +++ /dev/null @@ -1,301 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using BasicTestApp; -using BasicTestApp.FormsTest; -using Microsoft.AspNetCore.BrowserTesting; -using Microsoft.AspNetCore.Components.E2ETest.Infrastructure; -using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; -using Microsoft.AspNetCore.Testing; -using PlaywrightSharp; -using Xunit; -using Xunit.Abstractions; - -namespace Microsoft.AspNetCore.Components.E2ETest.Tests; - -public class InputFileTest : ServerTestBase> -{ - private string _tempDirectory; - - public InputFileTest( - ToggleExecutionModeServerFixture serverFixture, - ITestOutputHelper output) - : base(serverFixture, output) - { - } - - protected override Type TestComponent { get; } = typeof(InputFileComponent); - - protected override async Task InitializeCoreAsync(TestContext context) - { - await base.InitializeCoreAsync(context); - - _tempDirectory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N")); - Directory.CreateDirectory(_tempDirectory); - } - - private async Task VerifyFile(TempFile file) - { - // Upload the file - await TestPage.SetInputFilesAsync("#input-file", file.Path); - - var fileContainer = await TestPage.WaitForSelectorAsync($"#file-{file.Name}"); - Assert.NotNull(fileContainer); - var fileNameElement = await fileContainer.QuerySelectorAsync("#file-name"); - Assert.NotNull(fileNameElement); - var fileLastModifiedElement = await fileContainer.QuerySelectorAsync("#file-last-modified"); - Assert.NotNull(fileLastModifiedElement); - var fileSizeElement = await fileContainer.QuerySelectorAsync("#file-size"); - Assert.NotNull(fileSizeElement); - var fileContentTypeElement = await fileContainer.QuerySelectorAsync("#file-content-type"); - Assert.NotNull(fileContentTypeElement); - var fileContentElement = await fileContainer.QuerySelectorAsync("#file-content"); - Assert.NotNull(fileContentElement); - - // Validate that the file was uploaded correctly and all fields are present - Assert.False(string.IsNullOrWhiteSpace(await fileNameElement.GetTextContentAsync())); - Assert.NotEqual(default, DateTimeOffset.Parse(await fileLastModifiedElement.GetTextContentAsync(), CultureInfo.InvariantCulture)); - Assert.Equal(file.Contents.Length.ToString(CultureInfo.InvariantCulture), await fileSizeElement.GetTextContentAsync()); - Assert.Equal("application/octet-stream", await fileContentTypeElement.GetTextContentAsync()); - Assert.Equal(file.Text, await fileContentElement.GetTextContentAsync()); - } - - private async Task VerifyFiles(IEnumerable files) - { - // Upload the files - var filePaths = files - .Select(i => i.Path) - .ToArray(); - - await TestPage.SetInputFilesAsync("#input-file", filePaths); - - foreach (var file in files) - { - var fileContainer = await TestPage.WaitForSelectorAsync($"#file-{file.Name}"); - Assert.NotNull(fileContainer); - var fileNameElement = await fileContainer.QuerySelectorAsync("#file-name"); - Assert.NotNull(fileNameElement); - var fileLastModifiedElement = await fileContainer.QuerySelectorAsync("#file-last-modified"); - Assert.NotNull(fileLastModifiedElement); - var fileSizeElement = await fileContainer.QuerySelectorAsync("#file-size"); - Assert.NotNull(fileSizeElement); - var fileContentTypeElement = await fileContainer.QuerySelectorAsync("#file-content-type"); - Assert.NotNull(fileContentTypeElement); - var fileContentElement = await fileContainer.QuerySelectorAsync("#file-content"); - Assert.NotNull(fileContentElement); - - // Validate that the file was uploaded correctly and all fields are present - Assert.False(string.IsNullOrWhiteSpace(await fileNameElement.GetTextContentAsync())); - Assert.NotEqual(default, DateTimeOffset.Parse(await fileLastModifiedElement.GetTextContentAsync(), CultureInfo.InvariantCulture)); - Assert.Equal(file.Contents.Length.ToString(CultureInfo.InvariantCulture), await fileSizeElement.GetTextContentAsync()); - Assert.Equal("application/octet-stream", await fileContentTypeElement.GetTextContentAsync()); - Assert.Equal(file.Text, await fileContentElement.GetTextContentAsync()); - } - } - - [QuarantinedTest("New experimental test that need bake time.")] - [ConditionalTheory] - [InlineData(BrowserKind.Chromium)] - [InlineData(BrowserKind.Firefox)] - // NOTE: BrowserKind argument must be first - public async Task CanUploadSingleSmallFile(BrowserKind browserKind) - { - if (ShouldSkip(browserKind)) - { - return; - } - - // Create a temporary text file - var file = TempFile.Create(_tempDirectory, "txt", "This file was uploaded to the browser and read from .NET."); - await VerifyFile(file); - } - - [QuarantinedTest("New experimental test that need bake time.")] - [ConditionalTheory] - [InlineData(BrowserKind.Chromium)] - [InlineData(BrowserKind.Firefox)] - // NOTE: BrowserKind argument must be first - public async Task CanUploadSingleLargeFile(BrowserKind browserKind) - { - if (ShouldSkip(browserKind)) - { - return; - } - - // Create a large text file - var fileContentSizeInBytes = 1024 * 1024; - var contentBuilder = new StringBuilder(); - - for (int i = 0; i < fileContentSizeInBytes; i++) - { - contentBuilder.Append((i % 10).ToString(CultureInfo.InvariantCulture)); - } - - var file = TempFile.Create(_tempDirectory, "txt", contentBuilder.ToString()); - - await VerifyFile(file); - } - - [QuarantinedTest("New experimental test that need bake time.")] - [ConditionalTheory] - [InlineData(BrowserKind.Chromium)] - [InlineData(BrowserKind.Firefox)] - // NOTE: BrowserKind argument must be first - public async Task CanUploadMultipleFiles(BrowserKind browserKind) - { - if (ShouldSkip(browserKind)) - { - return; - } - - // Create multiple small text files - var files = Enumerable.Range(1, 3) - .Select(i => TempFile.Create(_tempDirectory, "txt", $"Contents of file {i}.")) - .ToList(); - - await VerifyFiles(files); - } - - [QuarantinedTest("New experimental test that need bake time.")] - [ConditionalTheory] - [InlineData(BrowserKind.Chromium)] - [InlineData(BrowserKind.Firefox)] - // NOTE: BrowserKind argument must be first - public async Task CanUploadAndConvertImageFile(BrowserKind browserKind) - { - if (ShouldSkip(browserKind)) - { - return; - } - - var sourceImageId = "image-source"; - - // Get the source image base64 - var base64 = await TestPage.EvaluateAsync($@" - const canvas = document.createElement('canvas'); - const context = canvas.getContext('2d'); - const image = document.getElementById('{sourceImageId}'); - - canvas.width = image.naturalWidth; - canvas.height = image.naturalHeight; - context.drawImage(image, 0, 0, image.naturalWidth, image.naturalHeight); - - canvas.toDataURL().split(',').pop();"); - - // Save the image file locally - var file = TempFile.Create(_tempDirectory, "png", Convert.FromBase64String(base64)); - - // Re-upload the image file (it will be converted to a JPEG and scaled to fix 640x480) - var inputFile = await TestPage.QuerySelectorAsync("#input-image"); - await inputFile.SetInputFilesAsync(file.Path); - - // Validate that the image was converted without error and is the correct size - var uploadedImage = await TestPage.WaitForSelectorAsync("#image-uploaded"); - Assert.NotNull(uploadedImage); - var box = await uploadedImage.GetBoundingBoxAsync(); - Assert.Equal(480, Math.Round(box.Height)); - Assert.Equal(480, Math.Round(box.Width)); - } - - protected async Task ClearAndType(string selector, string value) - { - await TestPage.EvalOnSelectorAsync(selector, "e => e.value = ''"); - var element = await TestPage.QuerySelectorAsync(selector); - await element.TypeAsync(value); - } - - [QuarantinedTest("New experimental test that need bake time.")] - [ConditionalTheory] - [InlineData(BrowserKind.Chromium)] - [InlineData(BrowserKind.Firefox)] - // NOTE: BrowserKind argument must be first - public async Task ThrowsWhenTooManyFilesAreSelected(BrowserKind browserKind) - { - if (ShouldSkip(browserKind)) - { - return; - } - - await ClearAndType("#max-allowed-files", "1\n"); - - // Save two files locally - var file1 = TempFile.Create(_tempDirectory, "txt", "This is file 1."); - var file2 = TempFile.Create(_tempDirectory, "txt", "This is file 2."); - - // Select both files - await TestPage.SetInputFilesAsync("#input-file", new string[] { file1.Path, file2.Path }); - - // Validate that the proper exception is thrown - var exceptionMessage = await TestPage.QuerySelectorAsync("#exception-message"); - Assert.Equal("The maximum number of files accepted is 1, but 2 were supplied.", await exceptionMessage.GetTextContentAsync()); - } - - [QuarantinedTest("New experimental test that need bake time.")] - [ConditionalTheory] - [InlineData(BrowserKind.Chromium)] - [InlineData(BrowserKind.Firefox)] - // NOTE: BrowserKind argument must be first - public async Task ThrowsWhenOversizedFileIsSelected(BrowserKind browserKind) - { - if (ShouldSkip(browserKind)) - { - return; - } - - await ClearAndType("#max-file-size", "10\n"); - - // Save a file that exceeds the specified file size limit - var file = TempFile.Create(_tempDirectory, "txt", "This file is over 10 bytes long."); - - // Select the file - await TestPage.SetInputFilesAsync("#input-file", file.Path); - - // Validate that the proper exception is thrown - var exceptionMessage = await TestPage.QuerySelectorAsync("#exception-message"); - Assert.Equal("Supplied file with size 32 bytes exceeds the maximum of 10 bytes.", await exceptionMessage.GetTextContentAsync()); - } - - public override void Dispose() - { - base.Dispose(); - if (!String.IsNullOrEmpty(_tempDirectory)) - { - Directory.Delete(_tempDirectory, recursive: true); - } - } - - private struct TempFile - { - public string Name { get; } - public string Path { get; } - public byte[] Contents { get; } - - public string Text => Encoding.ASCII.GetString(Contents); - - private TempFile(string tempDirectory, string extension, byte[] contents) - { - Name = $"{Guid.NewGuid():N}-{extension}"; - Path = System.IO.Path.Combine(tempDirectory, Name); - Contents = contents; - } - - public static TempFile Create(string tempDirectory, string extension, byte[] contents) - { - var file = new TempFile(tempDirectory, extension, contents); - - File.WriteAllBytes(file.Path, contents); - - return file; - } - - public static TempFile Create(string tempDirectory, string extension, string text) - => Create(tempDirectory, extension, Encoding.ASCII.GetBytes(text)); - } -} diff --git a/src/Components/test/E2ETestMigration/playwrightSettings.ci.json b/src/Components/test/E2ETestMigration/playwrightSettings.ci.json deleted file mode 100644 index ad285bd810d6..000000000000 --- a/src/Components/test/E2ETestMigration/playwrightSettings.ci.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "TimeoutInMilliseconds": 120000, - "TimeoutAfterFirstFailureInMilliseconds": 20000, - "GlobalBrowserOptions": { - "Headless": true - } -} diff --git a/src/Components/test/E2ETestMigration/playwrightSettings.ci.linux.json b/src/Components/test/E2ETestMigration/playwrightSettings.ci.linux.json deleted file mode 100644 index 5e2a2e7c629b..000000000000 --- a/src/Components/test/E2ETestMigration/playwrightSettings.ci.linux.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "BrowserOptions": { - "Chromium": { - "IsEnabled": false - }, - "Firefox": { - "IsEnabled": false - } - } -} diff --git a/src/Components/test/E2ETestMigration/playwrightSettings.ci.osx.json b/src/Components/test/E2ETestMigration/playwrightSettings.ci.osx.json deleted file mode 100644 index 137e7e958118..000000000000 --- a/src/Components/test/E2ETestMigration/playwrightSettings.ci.osx.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "BrowserOptions": { - "Chromium": { - "IsEnabled": false - } - } -} diff --git a/src/Components/test/E2ETestMigration/playwrightSettings.ci.win.json b/src/Components/test/E2ETestMigration/playwrightSettings.ci.win.json deleted file mode 100644 index 2c63c0851048..000000000000 --- a/src/Components/test/E2ETestMigration/playwrightSettings.ci.win.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -} diff --git a/src/Components/test/E2ETestMigration/playwrightSettings.debug.json b/src/Components/test/E2ETestMigration/playwrightSettings.debug.json deleted file mode 100644 index 6899a11ae8f8..000000000000 --- a/src/Components/test/E2ETestMigration/playwrightSettings.debug.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "TimeoutInMilliseconds": 120000000, - "TimeoutAfterFirstFailureInMilliseconds": 20000000, - "GlobalBrowserOptions": { - "Headless": false - } -} diff --git a/src/Components/test/E2ETestMigration/playwrightSettings.json b/src/Components/test/E2ETestMigration/playwrightSettings.json deleted file mode 100644 index d5e34b4795f4..000000000000 --- a/src/Components/test/E2ETestMigration/playwrightSettings.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "TimeoutInMilliseconds": 30000, - "TimeoutAfterFirstFailureInMilliseconds": 10000, - "BaseArtifactsFolder": ".", - "GlobalBrowserOptions": { - "ChromiumSandbox": true, - "DumpIO": true, - "IgnoreHTTPSErrors": true, - "Headless": true, - "Timeout": 30000 - }, - "GlobalContextOptions": { - "RecordVideo": { - "Dir": "videos" - }, - "RecordHar": { - "Path": "har" - }, - "IgnoreHTTPSErrors": true - }, - "BrowserOptions": { - "Chromium": { - "BrowserKind": "Chromium", - "IsEnabled": true, - "Args": { - "--ignore-certificate-errors": true - } - }, - "Firefox": { - "BrowserKind": "Firefox", - "IsEnabled": true - }, - "Webkit": { - "BrowserKind": "Webkit", - "IsEnabled": true - } - } -} diff --git a/src/Components/test/E2ETestMigration/playwrightSettings.linux.json b/src/Components/test/E2ETestMigration/playwrightSettings.linux.json deleted file mode 100644 index 98c2893fe01e..000000000000 --- a/src/Components/test/E2ETestMigration/playwrightSettings.linux.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "BrowserOptions": { - "Firefox": { - "BrowserKind": "Firefox", - "IsEnabled": false - } - } -} diff --git a/src/Components/test/E2ETestMigration/playwrightSettings.osx.json b/src/Components/test/E2ETestMigration/playwrightSettings.osx.json deleted file mode 100644 index 2c63c0851048..000000000000 --- a/src/Components/test/E2ETestMigration/playwrightSettings.osx.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -} diff --git a/src/Components/test/E2ETestMigration/playwrightSettings.win.json b/src/Components/test/E2ETestMigration/playwrightSettings.win.json deleted file mode 100644 index 8ea04ee84c8d..000000000000 --- a/src/Components/test/E2ETestMigration/playwrightSettings.win.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "BrowserOptions": { - "Webkit": { - "BrowserKind": "Webkit", - "IsEnabled": false - } - } -} diff --git a/src/Components/test/E2ETestMigration/xunit.runner.json b/src/Components/test/E2ETestMigration/xunit.runner.json deleted file mode 100644 index baa05fb93d2a..000000000000 --- a/src/Components/test/E2ETestMigration/xunit.runner.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - // This is set to -1 to allow the usage of an - // unlimited ammount of threads. - "maxParallelThreads": -1, - "diagnosticMessages": true, - "longRunningTestSeconds": 30 -}