diff --git a/e2e-tests/playwright/specs/functional/channels/post_list/initial_scroll_read.spec.ts b/e2e-tests/playwright/specs/functional/channels/post_list/initial_scroll_read.spec.ts index 9464d270743..61eae92f68e 100644 --- a/e2e-tests/playwright/specs/functional/channels/post_list/initial_scroll_read.spec.ts +++ b/e2e-tests/playwright/specs/functional/channels/post_list/initial_scroll_read.spec.ts @@ -147,8 +147,8 @@ test.describe('Post list initial scroll in read channel', () => { // # Open the web app directly to that channel await channelsPage.goto(team.name, channel.name); - // * Verify that the post list didn't scroll or change height - expect(await waitForScrollToSettle(watcher)).toHaveLength(1); + // * Verify that the post list stayed at the bottom + expectStayedAtBottom(await waitForScrollToSettle(watcher), testCase.name); }); test(`${testCase.name} - should stay at the bottom when switching to the channel`, async ({}) => { @@ -161,8 +161,8 @@ test.describe('Post list initial scroll in read channel', () => { // # Switch to the channel await channelsPage.sidebarLeft.goToItem(channel.name); - // * Verify that the post list didn't scroll or change height - expect(await waitForScrollToSettle(watcher)).toHaveLength(1); + // * Verify that the post list stayed at the bottom + expectStayedAtBottom(await waitForScrollToSettle(watcher), testCase.name); }); }); } @@ -180,4 +180,20 @@ test.describe('Post list initial scroll in read channel', () => { // # Wait until the post list hasn't scrolled for 500ms before returning results return watcher.waitForObservations(500); } + + function expectStayedAtBottom( + observations: Awaited>, + caseName: string, + ) { + if (caseName === 'with multiple pages of post previews') { + // Permalink embeds can grow after first paint; stay pinned to the bottom. + expect(observations.length).toBeGreaterThanOrEqual(1); + for (const obs of observations) { + expect(obs.distanceFromBottom).toBe(0); + } + return; + } + + expect(observations).toHaveLength(1); + } });