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.
This commit is contained in:
Zakk committed 2026-09-30 13:55:32 +10:00
1 parent a939d944d7
commit 7ca49ef4ff
2 files changed
+22 -2

No files matched your search

+6 -2
View File
@@ -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);
});
+16
View File
@@ -99,6 +99,22 @@ export const test = base.extend<{storage: Record<string, string>; 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<void>(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