diff --git a/e2e/specs/mock/scenarios/pinned.helpers.ts b/e2e/specs/mock/scenarios/pinned.helpers.ts index d87a18584b..1c351732a1 100644 --- a/e2e/specs/mock/scenarios/pinned.helpers.ts +++ b/e2e/specs/mock/scenarios/pinned.helpers.ts @@ -105,6 +105,10 @@ export async function removePins(pins: SeededPin[]): Promise { await deleteConversations(pins.map((pin) => pin.conversationId)); } +/** Resolves once the page has run the animation frame after this call. */ +const nextAnimationFrame = (page: Page): Promise => + page.evaluate(() => new Promise((resolve) => requestAnimationFrame(() => resolve()))); + /** * Drags one row onto a point inside another and releases there. * @@ -151,9 +155,16 @@ export async function dragRowOnto( * decides a swap reads the offset at the moment it fires. A pointer that * arrived in one last jump gets a single reading, taken while React may still * be rendering the previous one; a real hand keeps sending events. These - * repeats are that, bounded. */ + * repeats are that, bounded. + * + * react-dnd delivers hover once per animation frame, and judges the release + * against the offset the last delivered hover recorded. Every move here can + * land inside a single frame, which leaves the release judged against where + * the pointer was a frame earlier: short of the row's midpoint, and so no + * swap. Each repeat therefore waits for the frame that delivers it. */ for (let settle = 0; settle < 3; settle += 1) { await page.mouse.move(endX, endY + settle - 1, { steps: 2 }); + await nextAnimationFrame(page); } await page.mouse.up(); } diff --git a/e2e/specs/mock/scenarios/tool-timer.spec.ts b/e2e/specs/mock/scenarios/tool-timer.spec.ts index 2a931815fc..0316e1af0d 100644 --- a/e2e/specs/mock/scenarios/tool-timer.spec.ts +++ b/e2e/specs/mock/scenarios/tool-timer.spec.ts @@ -20,6 +20,12 @@ test('a running tool includes hidden time before and after expansion @scenario:r .getByRole('button', { name: /^E2E Memory\b/ }) .click(); await page.keyboard.press('Escape'); + /** `setFixedTime` hands every timer the page starts from then on to Playwright's clock, which + * runs one per task and falls seconds behind once the stream's cache notifications queue up. + * The palette is still closing here; a leave timer started after the install waits behind + * them, and the invisible popover covers the transcript and takes the click meant for the + * tool row. It unmounts when the leave ends, so wait for that on the page's own clock. */ + await expect(page.getByRole('dialog', { name: 'Attach and tools' })).toHaveCount(0); const start = await page.evaluate(() => Date.now()); await page.clock.setFixedTime(start); await sendMessage(page, `E2E_INTERRUPT_TOOL_REPLY:${label}`);