From 7ca49ef4ff5052b2224db6435abc080e3c4030b8 Mon Sep 17 00:00:00 2001 From: Zakk Date: Wed, 30 Sep 2026 13:47:39 +1000 Subject: [PATCH] test(e2e): wait for the node menu's virtual list before clicking The latency tile test clicked jp-01 in the faults scenario's 125-node menu, a virtual list. Playwright scrolled the item into view and clicked at once; react-aria's Virtualizer turns pointer events off on its items until 300ms after the last scroll event, so the click could land on the scroll container and the menu stayed open with hk-01 selected. Scroll the item into view with a new scrollIntoList helper that returns once the list takes pointer events again, as scrollTableToEnd already does for virtual grids. Also wait for the tile's value link before the first assertions, which passed vacuously while the tile was still loading. --- e2e/activity.spec.ts | 8 ++++++-- e2e/fixtures.ts | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/e2e/activity.spec.ts b/e2e/activity.spec.ts index 2982fbf0..47d56490 100644 --- a/e2e/activity.spec.ts +++ b/e2e/activity.spec.ts @@ -1,4 +1,4 @@ -import {expect, faults, mockBackend, setAppearance, test} from './fixtures'; +import {expect, faults, mockBackend, scrollIntoList, setAppearance, test} from './fixtures'; import {createMockApi} from '../src/api/mock'; import {test as browserTest, type Page} from '@playwright/test'; import {sha256} from '../src/api/hash'; @@ -167,10 +167,14 @@ test('the latency tile names a node that is unavailable and keeps its size', asy await page.addInitScript(() => localStorage.setItem('doona-mock-scenario', 'faults')); await page.goto('/#/activity'); const tile = page.locator('.rp-card', {hasText: 'Latency'}).first(); + // The value link appears once the nodes have loaded; before that the tile shows its placeholder. + await expect(tile.getByRole('link')).toHaveAccessibleName(/^\S+: \d/); await expect(tile.locator('.rp-light')).toHaveCount(0); const height = (await tile.boundingBox())!.height; await page.getByRole('button', {name: 'Node', exact: true}).click(); - await page.getByRole('menuitemradio').filter({hasText: 'jp-01'}).click(); + const jp = page.getByRole('menuitemradio').filter({hasText: 'jp-01'}); + await scrollIntoList(jp); + await jp.click(); await expect(tile.locator('.rp-light')).toHaveText('Unavailable'); expect((await tile.boundingBox())!.height).toBe(height); }); diff --git a/e2e/fixtures.ts b/e2e/fixtures.ts index f5972899..b543b4b7 100644 --- a/e2e/fixtures.ts +++ b/e2e/fixtures.ts @@ -99,6 +99,22 @@ export const test = base.extend<{storage: Record; signedIn: stri // The default demo has none. export const faults = {'doona-mock-scenario': 'faults'}; +// A long menu is a virtual list, which turns pointer events off on its items until 300ms after its last scroll event. +// Playwright's own scroll into view can land the click in that window, where the list swallows it and the menu stays +// open. This scrolls the item into view and returns once the list takes pointer events again. +export async function scrollIntoList(item: Locator) { + await item.evaluate(async el => { + let scroller = el.parentElement; + while (scroller && !/auto|scroll/.test(getComputedStyle(scroller).overflowY)) scroller = scroller.parentElement; + if (!scroller) return; + const before = scroller.scrollTop; + const scrolled = new Promise(resolve => scroller.addEventListener('scroll', () => resolve(), {once: true})); + el.scrollIntoView({block: 'nearest'}); + if (scroller.scrollTop !== before) await scrolled; + }); + await expect.poll(() => item.evaluate(el => getComputedStyle(el).pointerEvents)).not.toBe('none'); +} + // The selected item's detail: an aside beside the list on wide screens, a drawer below 1200px. // A phone keeps every column and scrolls the table sideways, the container around a native table and the grid itself // once virtualised; this brings the trailing columns into view. A virtualised grid turns pointer events off on its