From 3e5fdd0dabc07e2e502bd71685c4348cb3c6432c Mon Sep 17 00:00:00 2001 From: Lotus CI Date: Mon, 28 Sep 2026 22:08:13 -0400 Subject: [PATCH] test(e2e): clock-ahead warning needs a minute of samples (#158) "Ahead" is now reported only once it has held for a minute of fresh samples (a stalled server delivers late and reads as ahead). The test sends its ticks, checks nothing is shown yet, fast-forwards the page clock past a minute and sends two more. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA --- e2e/local-homeserver.spec.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/e2e/local-homeserver.spec.ts b/e2e/local-homeserver.spec.ts index 62e41769e..0df5c0d1a 100644 --- a/e2e/local-homeserver.spec.ts +++ b/e2e/local-homeserver.spec.ts @@ -257,12 +257,21 @@ test.describe('local homeserver regression', () => { await page.clock.install({ time: Date.now() + 14 * 60 * 1000 }); await loginUI(page, alice); await openRoom(page, room); - for (let i = 0; i < 4; i += 1) { - // eslint-disable-next-line no-await-in-loop - await sendText(bob, room, `tick ${i}`); - // eslint-disable-next-line no-await-in-loop - await page.waitForTimeout(500); - } + const ticks = async (from: number, n: number) => { + for (let i = from; i < from + n; i += 1) { + // eslint-disable-next-line no-await-in-loop + await sendText(bob, room, `tick ${i}`); + // eslint-disable-next-line no-await-in-loop + await page.waitForTimeout(500); + } + }; + await ticks(0, 4); + // "Ahead" could be a late delivery (a stalled server), so it is only + // reported once it has held for a minute of fresh samples. + await page.waitForTimeout(2000); + await expect(page.getByText(/clock is .*ahead of the server/)).toHaveCount(0); + await page.clock.fastForward('01:05'); + await ticks(4, 2); await expect(page.getByText(/clock is .*14 minutes ahead of the server/)).toBeVisible(); await page.getByRole('button', { name: 'Dismiss for 24 h' }).click(); await expect(page.getByText(/clock is .*ahead of the server/)).toHaveCount(0);