Update reconnection E2E tests
This commit is contained in:
parent
a77738e52f
commit
e6a4d9f19e
|
|
@ -142,21 +142,17 @@ namespace Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests
|
||||||
public void ReconnectUI()
|
public void ReconnectUI()
|
||||||
{
|
{
|
||||||
Browser.FindElement(By.LinkText("Counter")).Click();
|
Browser.FindElement(By.LinkText("Counter")).Click();
|
||||||
|
|
||||||
var javascript = (IJavaScriptExecutor)Browser;
|
var javascript = (IJavaScriptExecutor)Browser;
|
||||||
javascript.ExecuteScript(@"
|
javascript.ExecuteScript("Blazor._internal.forceCloseConnection()");
|
||||||
window.modalDisplayState = [];
|
|
||||||
window.Blazor.circuitHandlers.push({
|
|
||||||
onConnectionUp: () => window.modalDisplayState.push(document.getElementById('components-reconnect-modal').style.display),
|
|
||||||
onConnectionDown: () => window.modalDisplayState.push(document.getElementById('components-reconnect-modal').style.display)
|
|
||||||
});
|
|
||||||
window.Blazor._internal.forceCloseConnection();");
|
|
||||||
|
|
||||||
new WebDriverWait(Browser, TimeSpan.FromSeconds(10)).Until(
|
// We should see the 'reconnecting' UI appear
|
||||||
driver => (long)javascript.ExecuteScript("console.log(window.modalDisplayState); return window.modalDisplayState.length") == 2);
|
var reconnectionDialog = WaitUntilReconnectionDialogExists();
|
||||||
|
Browser.True(() => reconnectionDialog.GetCssValue("display") == "block");
|
||||||
|
|
||||||
var states = (string)javascript.ExecuteScript("return window.modalDisplayState.join(',')");
|
// Then it should disappear
|
||||||
|
new WebDriverWait(Browser, TimeSpan.FromSeconds(10))
|
||||||
Assert.Equal("block,none", states);
|
.Until(driver => reconnectionDialog.GetCssValue("display") == "none");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -169,16 +165,17 @@ window.Blazor._internal.forceCloseConnection();");
|
||||||
var initialValue = element.Text;
|
var initialValue = element.Text;
|
||||||
|
|
||||||
var javascript = (IJavaScriptExecutor)Browser;
|
var javascript = (IJavaScriptExecutor)Browser;
|
||||||
javascript.ExecuteScript(@"
|
javascript.ExecuteScript("Blazor._internal.forceCloseConnection()");
|
||||||
window.connectionUp = false;
|
|
||||||
window.Blazor.circuitHandlers.push({
|
|
||||||
onConnectionUp: () => window.connectionUp = true
|
|
||||||
});
|
|
||||||
window.Blazor._internal.forceCloseConnection();");
|
|
||||||
|
|
||||||
new WebDriverWait(Browser, TimeSpan.FromSeconds(10)).Until(
|
// We should see the 'reconnecting' UI appear
|
||||||
driver => (bool)javascript.ExecuteScript("return window.connectionUp"));
|
var reconnectionDialog = WaitUntilReconnectionDialogExists();
|
||||||
|
Browser.True(() => reconnectionDialog.GetCssValue("display") == "block");
|
||||||
|
|
||||||
|
// Then it should disappear
|
||||||
|
new WebDriverWait(Browser, TimeSpan.FromSeconds(10))
|
||||||
|
.Until(driver => reconnectionDialog.GetCssValue("display") == "none");
|
||||||
|
|
||||||
|
// We should receive a render that occurred while disconnected
|
||||||
var currentValue = element.Text;
|
var currentValue = element.Text;
|
||||||
Assert.NotEqual(initialValue, currentValue);
|
Assert.NotEqual(initialValue, currentValue);
|
||||||
|
|
||||||
|
|
@ -204,5 +201,13 @@ window.Blazor._internal.forceCloseConnection();");
|
||||||
Browser.True(() => Browser.Manage().Logs.GetLog(LogType.Browser)
|
Browser.True(() => Browser.Manage().Logs.GetLog(LogType.Browser)
|
||||||
.Any(l => l.Level == LogLevel.Info && l.Message.Contains("Connection disconnected.")));
|
.Any(l => l.Level == LogLevel.Info && l.Message.Contains("Connection disconnected.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IWebElement WaitUntilReconnectionDialogExists()
|
||||||
|
{
|
||||||
|
IWebElement reconnectionDialog = null;
|
||||||
|
new WebDriverWait(Browser, TimeSpan.FromSeconds(10))
|
||||||
|
.Until(driver => (reconnectionDialog = driver.FindElement(By.Id("components-reconnect-modal"))) != null);
|
||||||
|
return reconnectionDialog;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue