From 1f8acec6baed95921aaea5afceb5887e22516007 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Wed, 8 May 2019 17:33:51 +0100 Subject: [PATCH 1/4] In components E2E tests, always wait for initial render after each MountTestComponent call --- .../Infrastructure/BasicTestAppTestBase.cs | 7 ++++++- .../test/testassets/BasicTestApp/Index.razor | 20 +++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/Components/test/E2ETest/Infrastructure/BasicTestAppTestBase.cs b/src/Components/test/E2ETest/Infrastructure/BasicTestAppTestBase.cs index d4933b858edb..a4b7777db59d 100644 --- a/src/Components/test/E2ETest/Infrastructure/BasicTestAppTestBase.cs +++ b/src/Components/test/E2ETest/Infrastructure/BasicTestAppTestBase.cs @@ -30,9 +30,14 @@ protected IWebElement MountTestComponent() where TComponent : ICompo { var componentTypeName = typeof(TComponent).FullName; var testSelector = WaitUntilTestSelectorReady(); + + // Wait until we've torn down any earlier component testSelector.SelectByValue("none"); + WaitUntilExists(By.Id("no-test-selected")); + + // Wait until we've done the initial render for the new component testSelector.SelectByValue(componentTypeName); - return Browser.FindElement(By.TagName("app")); + return WaitUntilExists(By.TagName("app")); } protected SelectElement WaitUntilTestSelectorReady() diff --git a/src/Components/test/testassets/BasicTestApp/Index.razor b/src/Components/test/testassets/BasicTestApp/Index.razor index 92f8d65b94d7..e4ecaf6c9868 100644 --- a/src/Components/test/testassets/BasicTestApp/Index.razor +++ b/src/Components/test/testassets/BasicTestApp/Index.razor @@ -61,9 +61,16 @@
- - @((RenderFragment)RenderSelectedComponent) - +@if (SelectedComponentType != null) +{ + + @((RenderFragment)RenderSelectedComponent) + +} +else +{ +
Select a test case from the dropdown
+} @functions { string SelectedComponentTypeName { get; set; } = "none"; @@ -73,10 +80,7 @@ void RenderSelectedComponent(RenderTreeBuilder builder) { - if (SelectedComponentType != null) - { - builder.OpenComponent(0, SelectedComponentType); - builder.CloseComponent(); - } + builder.OpenComponent(0, SelectedComponentType); + builder.CloseComponent(); } } From c66c7b1eec8ea7e7a2a93e8295f7a1adb8c07c4d Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Wed, 8 May 2019 19:02:26 +0100 Subject: [PATCH 2/4] Update ClientSideHostingTest to match updated doc shape --- src/Components/test/E2ETest/Tests/ClientSideHostingTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/test/E2ETest/Tests/ClientSideHostingTest.cs b/src/Components/test/E2ETest/Tests/ClientSideHostingTest.cs index 3097d06dca80..2c6a3ac0772f 100644 --- a/src/Components/test/E2ETest/Tests/ClientSideHostingTest.cs +++ b/src/Components/test/E2ETest/Tests/ClientSideHostingTest.cs @@ -71,7 +71,7 @@ public void MapFallbackToClientSideBlazor_AssemblyPath_Pattern_FilePath() private void WaitUntilLoaded() { new WebDriverWait(Browser, TimeSpan.FromSeconds(30)).Until( - driver => driver.FindElement(By.TagName("app")).Text != "Loading..."); + driver => driver.FindElement(By.Id("no-test-selected"))); } } } From 534a4fcab3a2976fae3b16d6afc845ba6b10450b Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Wed, 8 May 2019 22:26:31 +0100 Subject: [PATCH 3/4] Extend timeouts --- .../test/E2ETest/Infrastructure/BasicTestAppTestBase.cs | 4 ++-- src/Shared/E2ETesting/WaitAssert.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Components/test/E2ETest/Infrastructure/BasicTestAppTestBase.cs b/src/Components/test/E2ETest/Infrastructure/BasicTestAppTestBase.cs index a4b7777db59d..5f95bc66d207 100644 --- a/src/Components/test/E2ETest/Infrastructure/BasicTestAppTestBase.cs +++ b/src/Components/test/E2ETest/Infrastructure/BasicTestAppTestBase.cs @@ -33,11 +33,11 @@ protected IWebElement MountTestComponent() where TComponent : ICompo // Wait until we've torn down any earlier component testSelector.SelectByValue("none"); - WaitUntilExists(By.Id("no-test-selected")); + WaitUntilExists(By.Id("no-test-selected"), timeoutSeconds: 30); // Wait until we've done the initial render for the new component testSelector.SelectByValue(componentTypeName); - return WaitUntilExists(By.TagName("app")); + return WaitUntilExists(By.TagName("app"), timeoutSeconds: 30); } protected SelectElement WaitUntilTestSelectorReady() diff --git a/src/Shared/E2ETesting/WaitAssert.cs b/src/Shared/E2ETesting/WaitAssert.cs index ded27f289f30..952f57ff94a9 100644 --- a/src/Shared/E2ETesting/WaitAssert.cs +++ b/src/Shared/E2ETesting/WaitAssert.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.E2ETesting public static class WaitAssert { - public static TimeSpan DefaultTimeout = TimeSpan.FromSeconds(3); + public static TimeSpan DefaultTimeout = TimeSpan.FromSeconds(10); public static void Equal(this IWebDriver driver, T expected, Func actual) => WaitAssertCore(driver, () => Assert.Equal(expected, actual())); From c5f22e6b0112cbdfde6c8dfc187afa3a5b800e63 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Thu, 9 May 2019 12:33:25 +0100 Subject: [PATCH 4/4] Disable E2E test parallelism --- .../test/E2ETest/Properties/AssemblyInfo.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/Components/test/E2ETest/Properties/AssemblyInfo.cs diff --git a/src/Components/test/E2ETest/Properties/AssemblyInfo.cs b/src/Components/test/E2ETest/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..f6e1962dd810 --- /dev/null +++ b/src/Components/test/E2ETest/Properties/AssemblyInfo.cs @@ -0,0 +1,12 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Xunit; + +// Parallelism causes issues with the server-side execution tests. It's not clear why, since +// we have separate browser and server instances for different test collections (i.e., classes) +// so they should be entirely isolated anyway. When parallelism is on, we can observe intermittent +// interference between test classes, for example test A observing the UI state of test B, which +// suggests that either Selenium has thread-safety issues that direct commands to the wrong +// browser instance, or something in our tracking of browser instances goes wrong. +[assembly: CollectionBehavior(DisableTestParallelization = true)]