|
1 | 1 | import { expect } from '@playwright/test'; |
2 | | -import { configs, test } from '@utils/test/playwright'; |
| 2 | +import { configs, dragElementBy, test } from '@utils/test/playwright'; |
3 | 3 |
|
4 | 4 | import { CardModalPage } from '../fixtures'; |
5 | 5 |
|
@@ -95,4 +95,39 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, screenshot, c |
95 | 95 | }); |
96 | 96 | }); |
97 | 97 | }); |
| 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 | + }); |
98 | 133 | }); |
0 commit comments