Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: swipe test #545

Merged
merged 5 commits into from
Jan 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading