Skip to content

Commit 280bd4c

Browse files
committed
[Blazor] Reliability improvements for the E2E tests
1 parent 9bb9fc3 commit 280bd4c

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

src/Components/Ignitor/src/BlazorClient.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ public async Task<bool> ConnectAsync(Uri uri, bool connectAutomatically = true)
345345
});
346346

347347
HubConnection = builder.Build();
348-
await HubConnection.StartAsync(CancellationToken);
349348

350349
HubConnection.On<int, string>("JS.AttachComponent", OnAttachComponent);
351350
HubConnection.On<int, string, string>("JS.BeginInvokeJS", OnBeginInvokeJS);
@@ -354,6 +353,8 @@ public async Task<bool> ConnectAsync(Uri uri, bool connectAutomatically = true)
354353
HubConnection.On<string>("JS.Error", OnError);
355354
HubConnection.Closed += OnClosedAsync;
356355

356+
await HubConnection.StartAsync(CancellationToken);
357+
357358
if (CaptureOperations)
358359
{
359360
Operations = new Operations();

src/Components/test/E2ETest/Microsoft.AspNetCore.Components.E2ETests.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,10 @@
5757
<Compile Include="$(RepoRoot)src\Shared\Components\ServerComponentMarker.cs" />
5858
</ItemGroup>
5959

60+
<ItemGroup>
61+
<None Update="xunit.runner.json">
62+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
63+
</None>
64+
</ItemGroup>
65+
6066
</Project>

src/Components/test/E2ETest/ServerExecutionTests/ComponentHubReliabilityTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Microsoft.AspNetCore.Components.RenderTree;
1212
using Microsoft.AspNetCore.Components.Web;
1313
using Microsoft.AspNetCore.SignalR.Client;
14+
using Microsoft.AspNetCore.Testing;
1415
using Microsoft.Extensions.Logging;
1516
using TestServer;
1617
using Xunit;
@@ -119,6 +120,7 @@ await Client.ExpectCircuitErrorAndDisconnect(() => Client.HubConnection.SendAsyn
119120
}
120121

121122
[Fact]
123+
[Repeat(1000)]
122124
public async Task CannotInvokeJSInteropCallbackCompletionsBeforeInitialization()
123125
{
124126
// Arrange

src/Components/test/E2ETest/ServerExecutionTests/IgnitorTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ protected virtual Task InitializeAsync()
8383
return Task.CompletedTask;
8484
}
8585

86-
protected virtual Task DisposeAsync()
86+
protected async virtual Task DisposeAsync()
8787
{
8888
if (TestSink != null)
8989
{
9090
TestSink.MessageLogged -= TestSink_MessageLogged;
9191
}
9292

93-
return Task.CompletedTask;
93+
await Client.DisposeAsync();
9494
}
9595

9696
private void TestSink_MessageLogged(WriteContext context)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
// This is set to -1 to allow the usage of an
3+
// unlimited ammount of threads.
4+
"maxParallelThreads": -1,
5+
"diagnosticMessages": true,
6+
"longRunningTestSeconds": 30
7+
}

0 commit comments

Comments
 (0)