Skip to content

Commit 7b597ba

Browse files
committed
test(modal): add drag events tests
1 parent 962ba1c commit 7b597ba

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

core/src/components/modal/test/card/modal-card.e2e.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from '@playwright/test';
2-
import { configs, test } from '@utils/test/playwright';
2+
import { configs, dragElementBy, test } from '@utils/test/playwright';
33

44
import { CardModalPage } from '../fixtures';
55

@@ -95,4 +95,39 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, screenshot, c
9595
});
9696
});
9797
});
98+
99+
test.describe(title('card modal: drag events'), () => {
100+
test('should emit ionDragStart, ionDragMove, and ionDragEnd events', async ({ page }, testInfo) => {
101+
testInfo.annotations.push({
102+
type: 'issue',
103+
description: 'https://github.com/ionic-team/ionic-framework/issues/23955',
104+
});
105+
106+
await page.goto('/src/components/modal/test/card', config);
107+
108+
const ionModalDidPresent = await page.spyOnEvent('ionModalDidPresent');
109+
110+
await page.click('#drag-events');
111+
await ionModalDidPresent.next();
112+
113+
const ionDragStart = await page.spyOnEvent('ionDragStart');
114+
const ionDragMove = await page.spyOnEvent('ionDragMove');
115+
const ionDragEnd = await page.spyOnEvent('ionDragEnd');
116+
117+
const header = page.locator('.modal-card ion-header');
118+
await dragElementBy(header, page, 0, 100);
119+
120+
await ionDragStart.next();
121+
const dragMoveEvent = await ionDragMove.next();
122+
const dragEndEvent = await ionDragEnd.next();
123+
124+
expect(ionDragStart.length).toBe(1);
125+
126+
expect(ionDragMove.length).toBeGreaterThan(0);
127+
expect(Object.keys(dragMoveEvent.detail).length).toBe(4);
128+
129+
expect(ionDragEnd.length).toBe(1);
130+
expect(Object.keys(dragEndEvent.detail).length).toBe(4);
131+
});
132+
});
98133
});

core/src/components/modal/test/sheet/modal.e2e.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,4 +353,39 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) =>
353353
await expect(dragHandle).toBeFocused();
354354
});
355355
});
356+
357+
test.describe(title('sheet modal: drag events'), () => {
358+
test('should emit ionDragStart, ionDragMove, and ionDragEnd events', async ({ page }, testInfo) => {
359+
testInfo.annotations.push({
360+
type: 'issue',
361+
description: 'https://github.com/ionic-team/ionic-framework/issues/23955',
362+
});
363+
364+
await page.goto('/src/components/modal/test/sheet', config);
365+
366+
const ionModalDidPresent = await page.spyOnEvent('ionModalDidPresent');
367+
368+
await page.click('#drag-events');
369+
await ionModalDidPresent.next();
370+
371+
const ionDragStart = await page.spyOnEvent('ionDragStart');
372+
const ionDragMove = await page.spyOnEvent('ionDragMove');
373+
const ionDragEnd = await page.spyOnEvent('ionDragEnd');
374+
375+
const header = page.locator('.modal-sheet ion-header');
376+
await dragElementBy(header, page, 0, 100);
377+
378+
await ionDragStart.next();
379+
const dragMoveEvent = await ionDragMove.next();
380+
const dragEndEvent = await ionDragEnd.next();
381+
382+
expect(ionDragStart.length).toBe(1);
383+
384+
expect(ionDragMove.length).toBeGreaterThan(0);
385+
expect(Object.keys(dragMoveEvent.detail).length).toBe(5);
386+
387+
expect(ionDragEnd.length).toBe(1);
388+
expect(Object.keys(dragEndEvent.detail).length).toBe(5);
389+
});
390+
});
356391
});

0 commit comments

Comments
 (0)