From 7d017fce95a78220c02c53434f8a7d7eecfaee27 Mon Sep 17 00:00:00 2001 From: Emil Kowalski <36730035+emilkowalski@users.noreply.github.com> Date: Wed, 15 Jan 2025 13:29:10 +0100 Subject: [PATCH] fix: swipe test (#545) * fix test * fix trest * remove only * update * Remove only --- test/tests/basic.spec.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/test/tests/basic.spec.ts b/test/tests/basic.spec.ts index 019f400..4c9a2ab 100644 --- a/test/tests/basic.spec.ts +++ b/test/tests/basic.spec.ts @@ -109,19 +109,23 @@ test.describe('Basic functionality', () => { test("toast's dismiss callback gets executed correctly", async ({ page }) => { await page.getByTestId('dismiss-toast-callback').click(); const toast = page.locator('[data-sonner-toast]'); - const dragBoundingBox = await toast.boundingBox(); - if (!dragBoundingBox) return; + await toast.waitFor({ state: 'visible' }); - // Initial touch point - await page.mouse.move(dragBoundingBox.x + dragBoundingBox.width / 2, dragBoundingBox.y); + const box = await toast.boundingBox(); + if (!box) return; + + const startX = box.x + box.width / 2; + const startY = box.y + box.height / 2; + + await page.mouse.move(startX, startY); await page.mouse.down(); - // Move mouse slightly to determine swipe direction - await page.mouse.move(dragBoundingBox.x + dragBoundingBox.width / 2, dragBoundingBox.y + 10); + // Small initial movement to trigger drag + await page.mouse.move(startX, startY + 20, { steps: 5 }); - // Complete the swipe - await page.mouse.move(0, dragBoundingBox.y + 300); + // Main swipe movement + await page.mouse.move(startX, startY + 300, { steps: 10 }); await page.mouse.up(); await expect(page.getByTestId('dismiss-el')).toHaveCount(1);