From 2d9faede801eeea5e4edf0be79e7b3f07f165d80 Mon Sep 17 00:00:00 2001 From: Emil Kowalski Date: Wed, 15 Jan 2025 12:54:10 +0100 Subject: [PATCH 1/5] fix test --- test/tests/basic.spec.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/tests/basic.spec.ts b/test/tests/basic.spec.ts index 019f400..e94fba2 100644 --- a/test/tests/basic.spec.ts +++ b/test/tests/basic.spec.ts @@ -117,9 +117,6 @@ test.describe('Basic functionality', () => { await page.mouse.move(dragBoundingBox.x + dragBoundingBox.width / 2, dragBoundingBox.y); await page.mouse.down(); - // Move mouse slightly to determine swipe direction - await page.mouse.move(dragBoundingBox.x + dragBoundingBox.width / 2, dragBoundingBox.y + 10); - // Complete the swipe await page.mouse.move(0, dragBoundingBox.y + 300); await page.mouse.up(); From a1a1751265c20b235fd6f28fd48d8fe1c8ce0a5e Mon Sep 17 00:00:00 2001 From: Emil Kowalski Date: Wed, 15 Jan 2025 13:09:15 +0100 Subject: [PATCH 2/5] fix trest --- test/tests/basic.spec.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/test/tests/basic.spec.ts b/test/tests/basic.spec.ts index e94fba2..bfb9057 100644 --- a/test/tests/basic.spec.ts +++ b/test/tests/basic.spec.ts @@ -106,7 +106,7 @@ test.describe('Basic functionality', () => { await expect(page.getByTestId('auto-close-el')).toHaveCount(1); }); - test("toast's dismiss callback gets executed correctly", async ({ page }) => { + test.only("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(); @@ -114,11 +114,18 @@ test.describe('Basic functionality', () => { if (!dragBoundingBox) return; // Initial touch point - await page.mouse.move(dragBoundingBox.x + dragBoundingBox.width / 2, dragBoundingBox.y); + const startX = dragBoundingBox.x + dragBoundingBox.width / 2; + const startY = dragBoundingBox.y; + + // Initial touch point + await page.mouse.move(startX, startY); await page.mouse.down(); - // Complete the swipe - await page.mouse.move(0, dragBoundingBox.y + 300); + // Move mouse slightly to determine swipe direction + await page.mouse.move(startX, startY + 10); + + // Complete the swipe - using relative position from start + await page.mouse.move(startX, startY + 300); await page.mouse.up(); await expect(page.getByTestId('dismiss-el')).toHaveCount(1); From 2ef21c0e97b4923b4308b21c016e2a3c2d576e88 Mon Sep 17 00:00:00 2001 From: Emil Kowalski Date: Wed, 15 Jan 2025 13:11:49 +0100 Subject: [PATCH 3/5] remove only --- test/tests/basic.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tests/basic.spec.ts b/test/tests/basic.spec.ts index bfb9057..233c07e 100644 --- a/test/tests/basic.spec.ts +++ b/test/tests/basic.spec.ts @@ -106,7 +106,7 @@ test.describe('Basic functionality', () => { await expect(page.getByTestId('auto-close-el')).toHaveCount(1); }); - test.only("toast's dismiss callback gets executed correctly", async ({ page }) => { + 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(); From 1f7cc958ca11a7d02fc8d4a744311eed298cb9cd Mon Sep 17 00:00:00 2001 From: Emil Kowalski Date: Wed, 15 Jan 2025 13:21:15 +0100 Subject: [PATCH 4/5] update --- test/tests/basic.spec.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/tests/basic.spec.ts b/test/tests/basic.spec.ts index 233c07e..152e427 100644 --- a/test/tests/basic.spec.ts +++ b/test/tests/basic.spec.ts @@ -106,26 +106,26 @@ test.describe('Basic functionality', () => { await expect(page.getByTestId('auto-close-el')).toHaveCount(1); }); - test("toast's dismiss callback gets executed correctly", async ({ page }) => { + test.only("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' }); + + const box = await toast.boundingBox(); + if (!box) return; - // Initial touch point - const startX = dragBoundingBox.x + dragBoundingBox.width / 2; - const startY = dragBoundingBox.y; + const startX = box.x + box.width / 2; + const startY = box.y + box.height / 2; - // Initial touch point await page.mouse.move(startX, startY); await page.mouse.down(); - // Move mouse slightly to determine swipe direction - await page.mouse.move(startX, startY + 10); + // Small initial movement to trigger drag + await page.mouse.move(startX, startY + 20, { steps: 5 }); - // Complete the swipe - using relative position from start - await page.mouse.move(startX, startY + 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); From 345892c28d16db30f8331d9a27846747927041d4 Mon Sep 17 00:00:00 2001 From: Emil Kowalski Date: Wed, 15 Jan 2025 13:24:46 +0100 Subject: [PATCH 5/5] Remove only --- test/tests/basic.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tests/basic.spec.ts b/test/tests/basic.spec.ts index 152e427..4c9a2ab 100644 --- a/test/tests/basic.spec.ts +++ b/test/tests/basic.spec.ts @@ -106,7 +106,7 @@ test.describe('Basic functionality', () => { await expect(page.getByTestId('auto-close-el')).toHaveCount(1); }); - test.only("toast's dismiss callback gets executed correctly", async ({ page }) => { + test("toast's dismiss callback gets executed correctly", async ({ page }) => { await page.getByTestId('dismiss-toast-callback').click(); const toast = page.locator('[data-sonner-toast]');