Skip to content

Commit 3b10292

Browse files
matt2eclaude
andcommitted
test(desktop): wait for the Buzz chip to take the pointer before hovering
Follow-up to the 10-30 review of #8743 on 13171fd. "composer Buzz chip labels wrap without orphaning their icons" still failed the PR's Flake Check: run 41051895661, job 124049928438, 1 of 10 repeats. The centre poll in positionOverFragment expected < 1 and received 81.3515625. The caller was :711 of the merge commit, positionOverFragment(0), so this was the first fragment. The current head (832737e, a rebase) has the same positionOverFragment. Evidence: the tooltip is open. data-state matches /open/, and the error context still marks the chip [active]. The screenshot has the tooltip at x 333-621, centre 477. That's the centre of the whole two-line chip, where Radix places the tooltip when focus opens it. The cursor was at 395.6, over the "relay" fragment. In the video the timeline stops moving before the tooltip fades in at that spot, and the tooltip doesn't move for the rest of the run. Cause: useInlineTooltipPosition moves the content only from the trigger's pointermove. Once a pointermove lands, the hook positions the content in that frame or the next, and later Radix placements re-apply the offset. So with the pointer still, the tooltip stays at its focus placement only if the spec's move never reached the chip. Virtua 0.49.3 causes that. While the list is scrolling, its Virtualizer sets pointer-events: none on the item container. A 150 ms timer clears it, and every scroll event restarts the timer. Scrolls Virtua makes itself, like the bottom settle's scrollToIndex, don't set the flag, but other scroll writes can. The artifacts don't show which one set it here. The floor wait only proves scrollTop held for two frames, about 33 ms. A move inside the window hit-tests past the rows. When the rows take pointer events again the pointer hasn't moved, so no pointermove follows, and in this run none did. data-state can't catch this, because focus already opened the tooltip. Fix: positionOverFragment measures the fragment and hit-tests its centre with document.elementFromPoint in one evaluate. It polls until that point lands on the chip, then moves there. elementFromPoint skips pointer-events: none, so the poll waits out Virtua's flag. After the ack and floor waits nothing scrolls, so the move reaches the chip, and the centre poll then proves the reposition landed. This waits on a precondition. It doesn't retry the hover: the move, the open check and the centre poll each still run once per fragment. A fresh hover per fragment wouldn't fix this alone, because a re-entry inside the window misses the chip the same way. Not a product change: a real pointer sends a stream of moves, so the next one after the window positions the tooltip. Verification: pnpm typecheck and pnpm check pass, with biome's 3 existing warnings. An ad hoc tsc over navigation.spec.ts with the desktop tsconfig gives the same 7 pre-existing errors, none in the changed lines. Playwright wasn't run locally. The Flake Check lane will repeat the spec. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Matt Toohey <[email protected]>
1 parent 832737e commit 3b10292

1 file changed

Lines changed: 33 additions & 18 deletions

File tree

‎desktop/tests/e2e/navigation.spec.ts‎

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -672,24 +672,39 @@ test("composer Buzz chip labels wrap without orphaning their icons", async ({
672672
const tooltip = page.getByRole("tooltip");
673673
await sentChip.focus();
674674
const positionOverFragment = async (index: number) => {
675-
const fragment = await sentChip.evaluate((element, fragmentIndex) => {
676-
const container = element.parentElement;
677-
if (container) container.style.width = "220px";
678-
const rects = Array.from(element.getClientRects()).filter(
679-
(rect) => rect.width > 0 && rect.height > 0,
680-
);
681-
const rect = rects.at(fragmentIndex);
682-
if (!rect) return null;
683-
return {
684-
height: rect.height,
685-
left: rect.left,
686-
top: rect.top,
687-
width: rect.width,
688-
};
689-
}, index);
690-
if (!fragment) throw new Error(`Expected chip fragment ${index}`);
691-
const cursorX = fragment.left + fragment.width / 2;
692-
await page.mouse.move(cursorX, fragment.top + fragment.height / 2);
675+
// Virtua sets pointer-events: none on the timeline's rows while the list
676+
// scrolls and clears it 150 ms after the last scroll event, longer than
677+
// the floor wait's two frames. A move in that window misses the chip, and
678+
// nothing sends it a pointermove once the rows take pointer events again,
679+
// so the tooltip stays where focus opened it. Move only once the
680+
// fragment's centre hit-tests to the chip.
681+
let cursorX = Number.NaN;
682+
let cursorY = Number.NaN;
683+
await expect
684+
.poll(async () => {
685+
const fragment = await sentChip.evaluate((element, fragmentIndex) => {
686+
const container = element.parentElement;
687+
if (container) container.style.width = "220px";
688+
const rects = Array.from(element.getClientRects()).filter(
689+
(rect) => rect.width > 0 && rect.height > 0,
690+
);
691+
const rect = rects.at(fragmentIndex);
692+
if (!rect) return null;
693+
const x = rect.left + rect.width / 2;
694+
const y = rect.top + rect.height / 2;
695+
return {
696+
hitsChip: element.contains(document.elementFromPoint(x, y)),
697+
x,
698+
y,
699+
};
700+
}, index);
701+
if (!fragment) throw new Error(`Expected chip fragment ${index}`);
702+
cursorX = fragment.x;
703+
cursorY = fragment.y;
704+
return fragment.hitsChip;
705+
})
706+
.toBe(true);
707+
await page.mouse.move(cursorX, cursorY);
693708
// A closing tooltip stays visible through its exit animation.
694709
await expect(tooltip).toHaveAttribute("data-state", /open/);
695710
let tooltipCenter = Number.NaN;

0 commit comments

Comments
 (0)