Allow post-preview scroll tests to observe embed height growth

Permalink embeds can grow after first paint while remaining pinned to
the bottom. Assert distanceFromBottom stays 0 instead of requiring a
single observation.

Co-authored-by: mattermost-code <matty-code@mattermost.com>
This commit is contained in:
Cursor Agentandmattermost-code committed 2026-09-28 10:02:09 +00:00
1 parent 918aeb20fe
commit f44f7f3941
1 file changed
+20 -4
@@ -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<ReturnType<PostListScrollWatcher['waitForObservations']>>,
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);
}
});