Skip to content

Commit 0a60851

Browse files
committed
Fix the test to pass in all cases.
1 parent fc2e05e commit 0a60851

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/Components/test/E2ETest/ServerRenderingTests/EnhancedNavigationTest.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -664,10 +664,10 @@ public void CanUpdateHrefOnLinkTagWithIntegrity()
664664
}
665665

666666
[Theory]
667-
[InlineData(false, false)] // PASSES
668-
[InlineData(false, true)] // PASSES
669-
[InlineData(true, true)] // line 709 Expected: 1732 Actual: 0
670-
[InlineData(true, false)] // line 709 Expected: 1732 Actual: 0
667+
[InlineData(false, false)]
668+
[InlineData(false, true)]
669+
[InlineData(true, true)]
670+
[InlineData(true, false)]
671671
public async Task EnhancedNavigationScrollBehavesSameAsFullNavigation(bool enableStreaming, bool useEnhancedNavigation)
672672
{
673673
// This test checks if the navigation to other path moves the scroll to the top of the page,
@@ -695,7 +695,7 @@ public async Task EnhancedNavigationScrollBehavesSameAsFullNavigation(bool enabl
695695

696696
if (enableStreaming)
697697
{
698-
// wait for the fragment to be visible
698+
// wait for the fragment to be visible - let the streaming finish
699699
await Task.Delay(TimeSpan.FromSeconds(1));
700700
}
701701
var fragmentScrollPosition = (long)jsExecutor.ExecuteScript("return Math.round(document.getElementById('some-content').getBoundingClientRect().top + window.scrollY);");
@@ -708,13 +708,25 @@ public async Task EnhancedNavigationScrollBehavesSameAsFullNavigation(bool enabl
708708
// parts of page conditioned with showContent are showing with a delay - it affect the scroll position
709709
// from some reason, scroll position differs by 1 pixel between enhanced and browser's navigation
710710
var expectedMaxScrollPositionAfterBackwardsAction = useEnhancedNavigation ? maxScrollPosition: maxScrollPosition - 1;
711+
if (enableStreaming)
712+
{
713+
// let the streaming finish
714+
await Task.Delay(TimeSpan.FromSeconds(1));
715+
expectedMaxScrollPositionAfterBackwardsAction = maxScrollPosition + 127; // why 127 ???
716+
expectedMaxScrollPositionAfterBackwardsAction = useEnhancedNavigation ? expectedMaxScrollPositionAfterBackwardsAction : expectedMaxScrollPositionAfterBackwardsAction - 1;
717+
}
711718
Assert.Equal(expectedMaxScrollPositionAfterBackwardsAction, Browser.GetScrollY());
712719

713720
// navigate to a fragment on another page - we should land at the beginning of the fragment
714721
Browser.Exists(By.Id("do-navigation-with-fragment")).Click();
715722
AssertWeAreOnHashPage();
716723
AssertEnhancedNavigationOnHashPage();
717724
var expectedFragmentScrollPosition = fragmentScrollPosition - 1;
725+
if (enableStreaming)
726+
{
727+
// let the streaming finish
728+
await Task.Delay(TimeSpan.FromSeconds(1));
729+
}
718730
Assert.Equal(expectedFragmentScrollPosition, Browser.GetScrollY());
719731

720732
// go back to be able to go forward and check if the scroll position is preserved

0 commit comments

Comments
 (0)