From 8cf3d13f8fe5d4668c251d57fdd040fcc34f8840 Mon Sep 17 00:00:00 2001 From: Diecodev Date: Thu, 29 Oct 2026 10:27:50 -0500 Subject: [PATCH] =?UTF-8?q?test(e2e):=20=E2=9C=85=20read=20the=20started?= =?UTF-8?q?=20animations=20without=20clearing=20them?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "with several months, every grid animates" failed once in the CI (it passed on the retry): it waited for the ten rows of both grids and got none. Each read of the started animations cleared them, and expect.poll reads again and again: on a slow runner the two grids render apart, so a read between them took the rows of the first grid away, and the poll never saw all ten at once. Reading no longer clears them, and the test that counts two moves starts a new count between them. The test names don't change, so the catalog does neither. --- tests/e2e/animation.spec.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/e2e/animation.spec.ts b/tests/e2e/animation.spec.ts index ba20a47..0b8cc56 100644 --- a/tests/e2e/animation.spec.ts +++ b/tests/e2e/animation.spec.ts @@ -15,8 +15,18 @@ test.beforeEach(async ({ page }) => { await page.goto('/e2e/animation/'); }); -/** The animations started since the last call. */ -const started = (page: Page) => page.evaluate(() => (window as unknown as { started: string[] }).started.splice(0)); +/** + * The animations started since the page loaded, or since the last `forgetStarted`. Reading doesn't clear them: + * `expect.poll` reads again and again, and the grids can render apart, so a read that cleared them could take + * away the rows of one grid and leave the poll waiting for all of them at once. + */ +const started = (page: Page) => page.evaluate(() => [...(window as unknown as { started: string[] }).started]); + +/** Starts a new count of the animations. */ +const forgetStarted = (page: Page) => + page.evaluate(() => { + (window as unknown as { started: string[] }).started.length = 0; + }); test('no direction on load, then next or prev after each move', async ({ page }) => { const calendar = calendarIn(page, 'basic'); @@ -47,6 +57,7 @@ test('the rows of each month are new, so a CSS animation on them plays, in its d await expect.poll(() => before?.evaluate((el) => el.isConnected)).toBe(false); // September 2024 has five rows await expect.poll(() => started(page)).toEqual(Array(5).fill('TR:month-next')); + await forgetStarted(page); await prevButton(calendar).click(); await expect(calendar.locator('[aria-live]')).toHaveText('August 2024'); await expect.poll(() => started(page)).toEqual(Array(5).fill('TR:month-prev'));