Files
GSMTandGitHub 0c1c1c1da3 feat: drawer handle component (#182)
* feat: drawer handle

* fix: readme

* fix type

* fix test

* feat: expand handle hit area & cancel on long press

* extract magic number

* fix: reversed styles

* feat: handle drag

* remove margin

* fix tests

* fix conflicts

* revert

This reverts commit 6692eeb81b6ac7ee524730fa0ec351aa2f4f91ab.

* improve undefined checks

* add small click delay to more reliably detect double taps
2024-05-07 12:13:12 +02:00

33 lines
1.1 KiB
TypeScript

import { test, expect } from '@playwright/test';
import { ANIMATION_DURATION } from './constants';
test.beforeEach(async ({ page }) => {
await page.goto('/with-handle');
});
test.describe('With handle', () => {
test('click should cycle to the next snap point', async ({ page }) => {
await page.waitForTimeout(ANIMATION_DURATION);
await expect(page.getByTestId('content')).toBeVisible();
await expect(page.getByTestId('active-snap-index')).toHaveText('0');
await page.getByTestId('handle').click();
await expect(page.getByTestId('active-snap-index')).toHaveText('1');
await page.getByTestId('handle').click();
await expect(page.getByTestId('content')).not.toBeVisible();
});
test('double click should close the drawer', async ({ page }) => {
await page.waitForTimeout(ANIMATION_DURATION);
await expect(page.getByTestId('content')).toBeVisible();
await expect(page.getByTestId('active-snap-index')).toHaveText('0');
await page.getByTestId('handle').dispatchEvent("dblclick");
await page.waitForTimeout(ANIMATION_DURATION);
await expect(page.getByTestId('content')).not.toBeVisible();
});
});