Skip to content

Commit

Permalink
Fixed flaky redirect test in SPA
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasherceg committed Aug 12, 2023
1 parent c333717 commit 21d62d2
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Samples/Tests/Tests/Feature/PostbackConcurrencyTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Threading;
using DotVVM.Samples.Tests.Base;
using DotVVM.Testing.Abstractions;
using OpenQA.Selenium;
using Riganti.Selenium.Core;
using Riganti.Selenium.Core.Abstractions.Attributes;
using Riganti.Selenium.DotVVM;
Expand Down Expand Up @@ -256,11 +257,27 @@ public void Feature_PostbackConcurrency_RedirectPostbackQueueSpa_PostbackFromPre
browser.ElementAt("input[type=button]", 0).Click();
browser.ElementAt("input[type=button]", 2).Click();

var attempt = 0;
while (!browser.CurrentUrl.Contains("?time"))
{
attempt++;
if (attempt > 50)
{
Assert.Fail("The redirect didn't happen.");
}

Thread.Sleep(100);
AssertUI.TextNotEquals(browser.Single(".result"), "1");
try
{
AssertUI.TextNotEquals(browser.Single(".result"), "1", waitForOptions: WaitForOptions.Disabled);
}
catch (StaleElementReferenceException)
{
// ignore
break;
}
}
AssertUI.Url(browser, u => u.Contains("?time"));

for (int i = 0; i < 8; i++)
{
Expand Down

0 comments on commit 21d62d2

Please sign in to comment.