Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ protected IWebElement MountTestComponent<TComponent>() 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"), timeoutSeconds: 30);

// 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"), timeoutSeconds: 30);
}

protected SelectElement WaitUntilTestSelectorReady()
Expand Down
12 changes: 12 additions & 0 deletions src/Components/test/E2ETest/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you get to diagnose this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posted below

2 changes: 1 addition & 1 deletion src/Components/test/E2ETest/Tests/ClientSideHostingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")));
}
}
}
20 changes: 12 additions & 8 deletions src/Components/test/testassets/BasicTestApp/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,16 @@
<hr />
</div>

<app>
@((RenderFragment)RenderSelectedComponent)
</app>
@if (SelectedComponentType != null)
{
<app>
@((RenderFragment)RenderSelectedComponent)
</app>
}
else
{
<div id="no-test-selected">Select a test case from the dropdown</div>
}

@functions {
string SelectedComponentTypeName { get; set; } = "none";
Expand All @@ -73,10 +80,7 @@

void RenderSelectedComponent(RenderTreeBuilder builder)
{
if (SelectedComponentType != null)
{
builder.OpenComponent(0, SelectedComponentType);
builder.CloseComponent();
}
builder.OpenComponent(0, SelectedComponentType);
builder.CloseComponent();
}
}
2 changes: 1 addition & 1 deletion src/Shared/E2ETesting/WaitAssert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(this IWebDriver driver, T expected, Func<T> actual)
=> WaitAssertCore(driver, () => Assert.Equal(expected, actual()));
Expand Down