Skip to content

Improve flaky tests, move tests blockade. #60930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 19, 2025
Merged
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 @@ -668,11 +668,10 @@ public void CanUpdateHrefOnLinkTagWithIntegrity()
}

[Theory]
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/60875")]
[InlineData(false, false, false)]
// [InlineData(false, false, false)] // https://github.com/dotnet/aspnetcore/issues/60875
[InlineData(false, true, false)]
[InlineData(true, true, false)]
[InlineData(true, false, false)]
// [InlineData(true, false, false)] // https://github.com/dotnet/aspnetcore/issues/60875
// [InlineData(false, false, true)] programmatic navigation doesn't work without enhanced navigation
[InlineData(false, true, true)]
[InlineData(true, true, true)]
Expand Down Expand Up @@ -723,9 +722,9 @@ public void EnhancedNavigationScrollBehavesSameAsBrowserOnNavigation(bool enable
}

[Theory]
[InlineData(false, false, false)]
[InlineData(false, false, false)] // https://github.com/dotnet/aspnetcore/issues/60875
[InlineData(false, true, false)]
[InlineData(true, true, false)]
[InlineData(true, true, false)] // https://github.com/dotnet/aspnetcore/issues/60875
[InlineData(true, false, false)]
// [InlineData(false, false, true)] programmatic navigation doesn't work without enhanced navigation
[InlineData(false, true, true)]
Expand Down Expand Up @@ -819,7 +818,7 @@ private void AssertScrollPositionCorrect(bool useEnhancedNavigation, long previo
Assert.True(success, $"The expected scroll position was {messagePart}, but it was found at {currentScrollPosition}.");
}

private void AssertEnhancedNavigation(bool useEnhancedNavigation, IWebElement elementForStalenessCheck, int retryCount = 3, int delayBetweenRetriesMs = 100)
private void AssertEnhancedNavigation(bool useEnhancedNavigation, IWebElement elementForStalenessCheck, int retryCount = 3, int delayBetweenRetriesMs = 1000)
{
bool enhancedNavigationDetected = false;
for (int i = 0; i < retryCount; i++)
Expand Down
69 changes: 33 additions & 36 deletions src/Components/test/E2ETest/Tests/RoutingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -571,16 +571,13 @@ public void NavigationToSamePathDoesNotScrollToTheTop()
BrowserScrollY = maxScrollPosition;

app.FindElement(By.Id("do-self-navigate")).Click();
var scrollPosition = BrowserScrollY;
Assert.True(scrollPosition == maxScrollPosition, "Expected to stay scrolled down.");
WaitAssert.True(Browser, () => maxScrollPosition == BrowserScrollY, default, $"Expected to stay scrolled down in {maxScrollPosition} but the scroll is in position {BrowserScrollY}.");

app.FindElement(By.Id("do-self-navigate-with-query")).Click();
scrollPosition = BrowserScrollY;
Assert.True(scrollPosition == maxScrollPosition, "Expected to stay scrolled down.");
WaitAssert.True(Browser, () => maxScrollPosition == BrowserScrollY, default, $"Expected to stay scrolled down in {maxScrollPosition} but the scroll is in position {BrowserScrollY}.");

app.FindElement(By.Id("do-self-navigate-to-fragment")).Click();
scrollPosition = BrowserScrollY;
Assert.True(scrollPosition == fragmentScrollPosition, "Expected to scroll to the fragment.");
WaitAssert.True(Browser, () => fragmentScrollPosition == BrowserScrollY, default, $"Expected to scroll to the fragment in position {fragmentScrollPosition} but the scroll is in position {BrowserScrollY}.");
}

[Fact]
Expand Down Expand Up @@ -1696,11 +1693,11 @@ public void AnchorWithHrefContainingHashSamePage_ScrollsToElementOnTheSamePage()

app.FindElement(By.Id("anchor-test1")).Click();

var currentWindowScrollY = BrowserScrollY;
var test1VerticalLocation = app.FindElement(By.Id("test1")).Location.Y;
var currentRelativeUrl = _serverFixture.RootUri.MakeRelativeUri(new Uri(Browser.Url)).ToString();
Assert.Equal("subdir/LongPageWithHash#test1", currentRelativeUrl);
Assert.Equal(test1VerticalLocation, currentWindowScrollY);
string expectedUrl = "subdir/LongPageWithHash#test1";
WaitAssert.True(Browser, () => expectedUrl == currentRelativeUrl, default, $"Expected {expectedUrl} but got {currentRelativeUrl}");
WaitAssert.True(Browser, () => BrowserScrollY == test1VerticalLocation, default, $"Expected {test1VerticalLocation} but got {BrowserScrollY}");
}

[Fact]
Expand All @@ -1712,11 +1709,11 @@ public void AnchorWithHrefToSameUrlWithQueryAndHash_ScrollsToElementOnTheSamePag

app.FindElement(By.Id("anchor-test1-with-query")).Click();

var currentWindowScrollY = BrowserScrollY;
var test1VerticalLocation = app.FindElement(By.Id("test1")).Location.Y;
var currentRelativeUrl = _serverFixture.RootUri.MakeRelativeUri(new Uri(Browser.Url)).ToString();
Assert.Equal("subdir/LongPageWithHash?color=green&number=123#test1", currentRelativeUrl);
Assert.Equal(test1VerticalLocation, currentWindowScrollY);
string expectedUrl = "subdir/LongPageWithHash?color=green&number=123#test1";
WaitAssert.True(Browser, () => expectedUrl == currentRelativeUrl, default, $"Expected {expectedUrl} but got {currentRelativeUrl}");
WaitAssert.True(Browser, () => BrowserScrollY == test1VerticalLocation, default, $"Expected {test1VerticalLocation} but got {BrowserScrollY}");
}

[Fact]
Expand All @@ -1728,11 +1725,11 @@ public void AnchorWithHrefToSameUrlWithParamAndHash_ScrollsToElementOnTheSamePag

app.FindElement(By.Id("anchor-test1-with-param")).Click();

var currentWindowScrollY = BrowserScrollY;
var test1VerticalLocation = app.FindElement(By.Id("test1")).Location.Y;
var currentRelativeUrl = _serverFixture.RootUri.MakeRelativeUri(new Uri(Browser.Url)).ToString();
Assert.Equal("subdir/LongPageWithHash/11#test1", currentRelativeUrl);
Assert.Equal(test1VerticalLocation, currentWindowScrollY);
string expectedUrl = "subdir/LongPageWithHash/11#test1";
WaitAssert.True(Browser, () => expectedUrl == currentRelativeUrl, default, $"Expected {expectedUrl} but got {currentRelativeUrl}");
WaitAssert.True(Browser, () => BrowserScrollY == test1VerticalLocation, default, $"Expected {test1VerticalLocation} but got {BrowserScrollY}");
}

[Fact]
Expand All @@ -1744,11 +1741,11 @@ public void AnchorWithHrefToSameUrlWithParamQueryAndHash_ScrollsToElementOnTheSa

app.FindElement(By.Id("anchor-test1-with-param-and-query")).Click();

var currentWindowScrollY = BrowserScrollY;
var test1VerticalLocation = app.FindElement(By.Id("test1")).Location.Y;
var currentRelativeUrl = _serverFixture.RootUri.MakeRelativeUri(new Uri(Browser.Url)).ToString();
Assert.Equal("subdir/LongPageWithHash/11?color=green&number=123#test1", currentRelativeUrl);
Assert.Equal(test1VerticalLocation, currentWindowScrollY);
string expectedUrl = "subdir/LongPageWithHash/11?color=green&number=123#test1";
WaitAssert.True(Browser, () => expectedUrl == currentRelativeUrl, default, $"Expected {expectedUrl} but got {currentRelativeUrl}");
WaitAssert.True(Browser, () => BrowserScrollY == test1VerticalLocation, default, $"Expected {test1VerticalLocation} but got {BrowserScrollY}");
}

[Fact]
Expand All @@ -1760,11 +1757,11 @@ public void AnchorWithHrefContainingHashAnotherPage_NavigatesToPageAndScrollsToE

app.FindElement(By.Id("anchor-test2")).Click();

var currentWindowScrollY = BrowserScrollY;
var test2VerticalLocation = app.FindElement(By.Id("test2")).Location.Y;
var currentRelativeUrl = _serverFixture.RootUri.MakeRelativeUri(new Uri(Browser.Url)).ToString();
Assert.Equal("subdir/LongPageWithHash2#test2", currentRelativeUrl);
Assert.Equal(test2VerticalLocation, currentWindowScrollY);
string expectedUrl = "subdir/LongPageWithHash2#test2";
WaitAssert.True(Browser, () => expectedUrl == currentRelativeUrl, default, $"Expected {expectedUrl} but got {currentRelativeUrl}");
WaitAssert.True(Browser, () => BrowserScrollY == test2VerticalLocation, default, $"Expected {test2VerticalLocation} but got {BrowserScrollY}");
}

[Fact]
Expand All @@ -1776,11 +1773,11 @@ public void NavigationManagerNavigateToAnotherUrlWithHash_NavigatesToPageAndScro

app.FindElement(By.Id("navigate-test2")).Click();

var currentWindowScrollY = BrowserScrollY;
var test2VerticalLocation = app.FindElement(By.Id("test2")).Location.Y;
var currentRelativeUrl = _serverFixture.RootUri.MakeRelativeUri(new Uri(Browser.Url)).ToString();
Assert.Equal("subdir/LongPageWithHash2#test2", currentRelativeUrl);
Assert.Equal(test2VerticalLocation, currentWindowScrollY);
string expectedUrl = "subdir/LongPageWithHash2#test2";
WaitAssert.True(Browser, () => expectedUrl == currentRelativeUrl, default, $"Expected {expectedUrl} but got {currentRelativeUrl}");
WaitAssert.True(Browser, () => BrowserScrollY == test2VerticalLocation, default, $"Expected {test2VerticalLocation} but got {BrowserScrollY}");
}

[Fact]
Expand All @@ -1792,11 +1789,11 @@ public void NavigationManagerNavigateToSameUrlWithHash_ScrollsToElementOnTheSame

app.FindElement(By.Id("navigate-test1")).Click();

var currentWindowScrollY = BrowserScrollY;
var test1VerticalLocation = app.FindElement(By.Id("test1")).Location.Y;
var currentRelativeUrl = _serverFixture.RootUri.MakeRelativeUri(new Uri(Browser.Url)).ToString();
Assert.Equal("subdir/LongPageWithHash#test1", currentRelativeUrl);
Assert.Equal(test1VerticalLocation, currentWindowScrollY);
string expectedUrl = "subdir/LongPageWithHash#test1";
WaitAssert.True(Browser, () => expectedUrl == currentRelativeUrl, default, $"Expected {expectedUrl} but got {currentRelativeUrl}");
WaitAssert.True(Browser, () => BrowserScrollY == test1VerticalLocation, default, $"Expected {test1VerticalLocation} but got {BrowserScrollY}");
}

[Fact]
Expand All @@ -1808,11 +1805,11 @@ public void NavigationManagerNavigateToSameUrlWithQueryAndHash_ScrollsToElementO

app.FindElement(By.Id("navigate-test1-with-query")).Click();

var currentWindowScrollY = BrowserScrollY;
var test1VerticalLocation = app.FindElement(By.Id("test1")).Location.Y;
var currentRelativeUrl = _serverFixture.RootUri.MakeRelativeUri(new Uri(Browser.Url)).ToString();
Assert.Equal("subdir/LongPageWithHash?color=green&number=123#test1", currentRelativeUrl);
Assert.Equal(test1VerticalLocation, currentWindowScrollY);
string expectedUrl = "subdir/LongPageWithHash?color=green&number=123#test1";
WaitAssert.True(Browser, () => expectedUrl == currentRelativeUrl, default, $"Expected {expectedUrl} but got {currentRelativeUrl}");
WaitAssert.True(Browser, () => BrowserScrollY == test1VerticalLocation, default, $"Expected {test1VerticalLocation} but got {BrowserScrollY}");
}

[Fact]
Expand All @@ -1824,11 +1821,11 @@ public void NavigationManagerNavigateToSameUrlWithParamAndHash_ScrollsToElementO

app.FindElement(By.Id("navigate-test1-with-param")).Click();

var currentWindowScrollY = BrowserScrollY;
var test1VerticalLocation = app.FindElement(By.Id("test1")).Location.Y;
var currentRelativeUrl = _serverFixture.RootUri.MakeRelativeUri(new Uri(Browser.Url)).ToString();
Assert.Equal("subdir/LongPageWithHash/22#test1", currentRelativeUrl);
Assert.Equal(test1VerticalLocation, currentWindowScrollY);
string expectedUrl = "subdir/LongPageWithHash/22#test1";
WaitAssert.True(Browser, () => expectedUrl == currentRelativeUrl, default, $"Expected {expectedUrl} but got {currentRelativeUrl}");
WaitAssert.True(Browser, () => BrowserScrollY == test1VerticalLocation, default, $"Expected {test1VerticalLocation} but got {BrowserScrollY}");
}

[Fact]
Expand All @@ -1840,11 +1837,11 @@ public void NavigationManagerNavigateToSameUrlWithParamQueryAndHash_ScrollsToEle

app.FindElement(By.Id("navigate-test1-with-param-and-query")).Click();

var currentWindowScrollY = BrowserScrollY;
var test1VerticalLocation = app.FindElement(By.Id("test1")).Location.Y;
var currentRelativeUrl = _serverFixture.RootUri.MakeRelativeUri(new Uri(Browser.Url)).ToString();
Assert.Equal("subdir/LongPageWithHash/22?color=green&number=123#test1", currentRelativeUrl);
Assert.Equal(test1VerticalLocation, currentWindowScrollY);
string expectedUrl = "subdir/LongPageWithHash/22?color=green&number=123#test1";
WaitAssert.True(Browser, () => expectedUrl == currentRelativeUrl, default, $"Expected {expectedUrl} but got {currentRelativeUrl}");
WaitAssert.True(Browser, () => BrowserScrollY == test1VerticalLocation, default, $"Expected {test1VerticalLocation} but got {BrowserScrollY}");
}

private long BrowserScrollY
Expand Down
Loading