You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: Infinite scroll - scrolling to the top test is flaky on CI with Safari #30423
This issue has been labeled as help wanted. This label is added to issues that we believe would be good for contributors.
If you'd like to work on this issue, please comment here letting us know that you would like to submit a pull request for it. This helps us to keep track of the pull request and make sure there isn't duplicated effort.
For a guide on how to create a pull request and test this project locally to see your changes, see our contributing documentation.
I investigated this and found the top-positioned infinite scroll test starts with scrollTop = 0, so the previous assertion path was depending on a racy initial scroll state. I’ve prepared a test fix that first scrolls down, waits until the content is actually offset, and then scrolls back to the top before waiting for ionInfiniteComplete. It passes locally for me in both Chrome and Safari.
I took a look at the flaky Safari CI test (core/src/components/infinite-scroll/test/top/infinite-scroll.e2e.ts).
Hypothesis
On Safari CI the page can start the test already at (or extremely near) scrollTop=0. In that case scrollToTop(0) becomes a no-op and may never trigger ionInfiniteComplete, so the test can hang/fail.
Proposed fix
Force a small non-zero scroll offset first, wait until it’s observed, then scroll back to top and wait for ionInfiniteComplete. This avoids fixed timeouts.
Patch (unified diff):
diff --git a/core/src/components/infinite-scroll/test/top/infinite-scroll.e2e.ts b/core/src/components/infinite-scroll/test/top/infinite-scroll.e2e.ts
index 4ca25b7e8d..9f1c0bb111 100644
--- a/core/src/components/infinite-scroll/test/top/infinite-scroll.e2e.ts+++ b/core/src/components/infinite-scroll/test/top/infinite-scroll.e2e.ts@@ -1,16 +1,40 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
test.describe(title('infinite-scroll: top'), () => {
test('should load more items when scrolled to the top', async ({ page }) => {
await page.goto('/src/components/infinite-scroll/test/top', config);
const ionInfiniteComplete = await page.spyOnEvent('ionInfiniteComplete');
const content = page.locator('ion-content');
const items = page.locator('ion-item');
expect(await items.count()).toBe(30);
+ // Safari CI can start this test already at the top (or too close to it),+ // making scrollToTop a no-op that never triggers ion-infinite.+ // Force a non-zero scroll offset first, then scroll back to top.+ await content.evaluate(async (el: HTMLIonContentElement) => {+ const scrollEl = await el.getScrollElement();+ scrollEl.scrollTop = 100;+ });++ await expect+ .poll(async () => {+ return await content.evaluate(async (el: HTMLIonContentElement) => {+ const scrollEl = await el.getScrollElement();+ return scrollEl.scrollTop;+ });+ })+ .toBeGreaterThan(0);+
await content.evaluate((el: HTMLIonContentElement) => el.scrollToTop(0));
await ionInfiniteComplete.next();
expect(await items.count()).toBe(60);
});
});
});
Hi! I drafted a small patch to stabilize the Safari CI flake described in #30423.
Hypothesis: On Safari CI the test can start already at (or extremely near) scrollTop=0, so scrollToTop(0) becomes a no-op and never triggers ionInfiniteComplete.
Fix: force a small non-zero scroll offset first (and verify it), then scroll back to top and wait for ionInfiniteComplete.
Patch (unified diff):
diff --git a/core/src/components/infinite-scroll/test/top/infinite-scroll.e2e.ts b/core/src/components/infinite-scroll/test/top/infinite-scroll.e2e.ts
index 4ca25b7e8d..9f1c0bb111 100644
--- a/core/src/components/infinite-scroll/test/top/infinite-scroll.e2e.ts+++ b/core/src/components/infinite-scroll/test/top/infinite-scroll.e2e.ts@@ -1,16 +1,40 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
test.describe(title('infinite-scroll: top'), () => {
test('should load more items when scrolled to the top', async ({ page }) => {
await page.goto('/src/components/infinite-scroll/test/top', config);
const ionInfiniteComplete = await page.spyOnEvent('ionInfiniteComplete');
const content = page.locator('ion-content');
const items = page.locator('ion-item');
expect(await items.count()).toBe(30);
++ // Safari CI can start this test already at the top (or too close to it),+ // making scrollToTop a no-op that never triggers ion-infinite.+ // Force a non-zero scroll offset first, then scroll back to top.+ await content.evaluate(async (el: HTMLIonContentElement) => {+ const scrollEl = await el.getScrollElement();+ scrollEl.scrollTop = 100;+ });++ await expect+ .poll(async () => {+ return await content.evaluate(async (el: HTMLIonContentElement) => {+ const scrollEl = await el.getScrollElement();+ return scrollEl.scrollTop;+ });+ })+ .toBeGreaterThan(0);
await content.evaluate((el: HTMLIonContentElement) => el.scrollToTop(0));
await ionInfiniteComplete.next();
expect(await items.count()).toBe(60);
});
});
});
I think this Safari CI flake can happen when the test starts already at (or extremely near) scrollTop=0, so scrollToTop(0) becomes a no-op and never triggers ionInfiniteComplete.
Proposed fix: force a small non-zero scroll offset first (and poll until it’s observed), then scroll back to top and await ionInfiniteComplete.
I took a pass at stabilizing the Safari CI flake described here.
Hypothesis:
On Safari CI, the test can start already at (or extremely near) scrollTop=0. In that case scrollToTop(0) becomes a no-op and doesn’t trigger the ionInfiniteComplete event, causing a hang/failure.
Proposed fix:
Before calling scrollToTop(0), force a small non-zero scroll offset, wait until that offset is observed, then scroll to top and wait for ionInfiniteComplete. This avoids adding fixed timeouts.
Patch (unified diff):
diff --git a/core/src/components/infinite-scroll/test/top/infinite-scroll.e2e.ts b/core/src/components/infinite-scroll/test/top/infinite-scroll.e2e.ts
index 4ca25b7e8d..9f1c0bb111 100644
--- a/core/src/components/infinite-scroll/test/top/infinite-scroll.e2e.ts+++ b/core/src/components/infinite-scroll/test/top/infinite-scroll.e2e.ts@@ -1,16 +1,40 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
test.describe(title('infinite-scroll: top'), () => {
test('should load more items when scrolled to the top', async ({ page }) => {
await page.goto('/src/components/infinite-scroll/test/top', config);
const ionInfiniteComplete = await page.spyOnEvent('ionInfiniteComplete');
const content = page.locator('ion-content');
const items = page.locator('ion-item');
expect(await items.count()).toBe(30);
++ // Safari CI can start this test already at the top (or too close to it),+ // making scrollToTop a no-op that never triggers ion-infinite.+ // Force a non-zero scroll offset first, then scroll back to top.+ await content.evaluate(async (el: HTMLIonContentElement) => {+ const scrollEl = await el.getScrollElement();+ scrollEl.scrollTop = 100;+ });++ await expect+ .poll(async () => {+ return await content.evaluate(async (el: HTMLIonContentElement) => {+ const scrollEl = await el.getScrollElement();+ return scrollEl.scrollTop;+ });+ })+ .toBeGreaterThan(0);
await content.evaluate((el: HTMLIonContentElement) => el.scrollToTop(0));
await ionInfiniteComplete.next();
expect(await items.count()).toBe(60);
});
});
});
Activity
ionitron-bot commentedon May 25, 2025
This issue has been labeled as
help wanted. This label is added to issues that we believe would be good for contributors.If you'd like to work on this issue, please comment here letting us know that you would like to submit a pull request for it. This helps us to keep track of the pull request and make sure there isn't duplicated effort.
For a guide on how to create a pull request and test this project locally to see your changes, see our contributing documentation.
Thank you!
ManthanBhatt commentedon Mar 30, 2026
I investigated this and found the top-positioned infinite scroll test starts with scrollTop = 0, so the previous assertion path was depending on a racy initial scroll state. I’ve prepared a test fix that first scrolls down, waits until the content is actually offset, and then scrolls back to the top before waiting for ionInfiniteComplete. It passes locally for me in both Chrome and Safari.
TheDerbiedOne commentedon May 27, 2026
I took a look at the flaky Safari CI test (
core/src/components/infinite-scroll/test/top/infinite-scroll.e2e.ts).Hypothesis
On Safari CI the page can start the test already at (or extremely near)
scrollTop=0. In that casescrollToTop(0)becomes a no-op and may never triggerionInfiniteComplete, so the test can hang/fail.Proposed fix
Force a small non-zero scroll offset first, wait until it’s observed, then scroll back to top and wait for
ionInfiniteComplete. This avoids fixed timeouts.Patch (unified diff):
TheDerbiedOne commentedon May 27, 2026
Hi! I drafted a small patch to stabilize the Safari CI flake described in #30423.
Hypothesis: On Safari CI the test can start already at (or extremely near) scrollTop=0, so
scrollToTop(0)becomes a no-op and never triggersionInfiniteComplete.Fix: force a small non-zero scroll offset first (and verify it), then scroll back to top and wait for
ionInfiniteComplete.Patch (unified diff):
TheDerbiedOne commentedon May 27, 2026
I think this Safari CI flake can happen when the test starts already at (or extremely near) scrollTop=0, so scrollToTop(0) becomes a no-op and never triggers ionInfiniteComplete.
Proposed fix: force a small non-zero scroll offset first (and poll until it’s observed), then scroll back to top and await ionInfiniteComplete.
Patch (unified diff):
diff --git a/core/src/components/infinite-scroll/test/top/infinite-scroll.e2e.ts b/core/src/components/infinite-scroll/test/top/infinite-scroll.e2e.ts
index 4ca25b7e8d..9f1c0bb111 100644
--- a/core/src/components/infinite-scroll/test/top/infinite-scroll.e2e.ts
+++ b/core/src/components/infinite-scroll/test/top/infinite-scroll.e2e.ts
@@ -1,16 +1,40 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
test.describe(title('infinite-scroll: top'), () => {
test('should load more items when scrolled to the top', async ({ page }) => {
await page.goto('/src/components/infinite-scroll/test/top', config);
});
});
TheDerbiedOne commentedon May 27, 2026
I took a pass at stabilizing the Safari CI flake described here.
Hypothesis:
On Safari CI, the test can start already at (or extremely near) scrollTop=0. In that case
scrollToTop(0)becomes a no-op and doesn’t trigger theionInfiniteCompleteevent, causing a hang/failure.Proposed fix:
Before calling
scrollToTop(0), force a small non-zero scroll offset, wait until that offset is observed, then scroll to top and wait forionInfiniteComplete. This avoids adding fixed timeouts.Patch (unified diff):
test(infinite-scroll): fix flaky top test in Safari (ionic-team#31198)