Skip to content

Commit 84186c4

Browse files
Modify tests to support a quickly reconnecting circuit
1 parent 4eddbef commit 84186c4

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

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

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ public void ReconnectUI()
3636
var javascript = (IJavaScriptExecutor)Browser;
3737
javascript.ExecuteScript("Blazor._internal.forceCloseConnection()");
3838

39-
// We should see the 'reconnecting' UI appear
40-
Browser.Equal("block", () => Browser.Exists(By.Id("components-reconnect-modal")).GetCssValue("display"));
39+
// Circuit should immediately try to reconnect itself
40+
AssertLogContains("Connection disconnected.");
41+
AssertLogContains("WebSocket connected");
4142

42-
// Then it should disappear
43+
// And we should not see a reconnection dialog
4344
Browser.Equal("none", () => Browser.Exists(By.Id("components-reconnect-modal")).GetCssValue("display"));
4445

4546
Browser.Exists(By.Id("increment")).Click();
@@ -59,26 +60,36 @@ public void RendersContinueAfterReconnect()
5960
var javascript = (IJavaScriptExecutor)Browser;
6061
javascript.ExecuteScript("Blazor._internal.forceCloseConnection()");
6162

62-
// We should see the 'reconnecting' UI appear
63-
Browser.Equal("block", () => Browser.Exists(By.Id("components-reconnect-modal")).GetCssValue("display"));
63+
// Circuit should immediately try to reconnect itself
64+
AssertLogContains("Connection disconnected.");
65+
AssertLogContains("WebSocket connected");
6466

65-
// Then it should disappear
67+
// And we should not see a reconnection dialog
6668
Browser.Equal("none", () => Browser.Exists(By.Id("components-reconnect-modal")).GetCssValue("display"));
6769

6870
// We should receive a render that occurred while disconnected
71+
Thread.Sleep(2000);
6972
var currentValue = Browser.Exists(selector).Text;
7073
Assert.NotEqual(initialValue, currentValue);
7174

7275
// Verify it continues to tick
73-
Thread.Sleep(5);
76+
Thread.Sleep(2000);
7477
Browser.False(() => Browser.Exists(selector).Text == currentValue);
7578
}
7679

7780
[Fact]
7881
public void ErrorsStopTheRenderingProcess()
7982
{
8083
Browser.Exists(By.Id("cause-error")).Click();
81-
Browser.True(() => Browser.Manage().Logs.GetLog(LogType.Browser)
82-
.Any(l => l.Level == LogLevel.Info && l.Message.Contains("Connection disconnected.")));
84+
AssertLogContains("Connection disconnected.");
85+
}
86+
87+
void AssertLogContains(params string[] messages)
88+
{
89+
var log = Browser.Manage().Logs.GetLog(LogType.Browser);
90+
foreach (var message in messages)
91+
{
92+
Assert.Contains(log, entry => entry.Message.Contains(message));
93+
}
8394
}
8495
}

0 commit comments

Comments
 (0)