|
2 | 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
3 | 3 |
|
4 | 4 | using System.Linq;
|
| 5 | +using System.Threading.Tasks; |
5 | 6 | using BasicTestApp;
|
6 | 7 | using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
|
7 | 8 | using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
|
@@ -211,6 +212,33 @@ public void CanUseViewportAsContainer()
|
211 | 212 | Browser.NotEqual(expectedInitialSpacerStyle, () => topSpacer.GetAttribute("style"));
|
212 | 213 | }
|
213 | 214 |
|
| 215 | + [Fact] |
| 216 | + public async Task ToleratesIncorrectItemSize() |
| 217 | + { |
| 218 | + Browser.MountTestComponent<VirtualizationComponent>(); |
| 219 | + var topSpacer = Browser.Exists(By.Id("incorrect-size-container")).FindElement(By.TagName("div")); |
| 220 | + var expectedInitialSpacerStyle = "height: 0px;"; |
| 221 | + |
| 222 | + // Wait until items have been rendered. |
| 223 | + Browser.True(() => GetItemCount() > 0); |
| 224 | + Browser.Equal(expectedInitialSpacerStyle, () => topSpacer.GetAttribute("style")); |
| 225 | + |
| 226 | + // Scroll slowly, in increments of 50px at a time. At one point this would trigger a bug |
| 227 | + // due to the incorrect item size, whereby it would not realise it's necessary to show more |
| 228 | + // items because the first time the spacer became visible, the size calculation said that |
| 229 | + // we're already showing all the items we need to show. |
| 230 | + for (var pos = 0; pos < 1000; pos += 50) |
| 231 | + { |
| 232 | + Browser.ExecuteJavaScript($"document.getElementById('incorrect-size-container').scrollTop = {pos};"); |
| 233 | + await Task.Delay(200); |
| 234 | + } |
| 235 | + |
| 236 | + // Validate that the top spacer did change |
| 237 | + Browser.NotEqual(expectedInitialSpacerStyle, () => topSpacer.GetAttribute("style")); |
| 238 | + |
| 239 | + int GetItemCount() => Browser.FindElements(By.ClassName("incorrect-size-item")).Count; |
| 240 | + } |
| 241 | + |
214 | 242 | [Fact]
|
215 | 243 | public void CanMutateDataInPlace_Sync()
|
216 | 244 | {
|
|
0 commit comments