Skip to content

Commit

Permalink
fix: swipe test (#545)
Browse files Browse the repository at this point in the history
* fix test

* fix trest

* remove only

* update

* Remove only
  • Loading branch information
emilkowalski authored Jan 15, 2025
1 parent 4c06956 commit 7d017fc
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions test/tests/basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7d017fc

Please sign in to comment.