|
1 | 1 | import { expect } from '@playwright/test'; |
2 | | -import { configs, test } from '@utils/test/playwright'; |
3 | 2 | import type { E2ELocator } from '@utils/test/playwright'; |
| 3 | +import { configs, test } from '@utils/test/playwright'; |
4 | 4 |
|
5 | 5 | /** |
6 | 6 | * This checks that certain overlays open correctly. While the |
@@ -150,6 +150,41 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) => |
150 | 150 | expect(alerts.length).toBe(1); |
151 | 151 | }); |
152 | 152 | }); |
| 153 | + |
| 154 | + test.describe(title('select: click'), () => { |
| 155 | + test('clicking a select label should only trigger onclick once', async ({ page }) => { |
| 156 | + // Create a spy function in page context |
| 157 | + await page.setContent( |
| 158 | + ` |
| 159 | + <ion-select aria-label="Fruit" interface="alert"> |
| 160 | + <ion-select-option value="apple">Apple</ion-select-option> |
| 161 | + <ion-select-option value="banana">Banana</ion-select-option> |
| 162 | + </ion-select> |
| 163 | + `, |
| 164 | + config |
| 165 | + ); |
| 166 | + |
| 167 | + // Track calls to the exposed function |
| 168 | + const clickEvent = await page.spyOnEvent('click'); |
| 169 | + const input = page.locator('label.select-wrapper'); |
| 170 | + |
| 171 | + // Use position to make sure we click into the label enough to trigger |
| 172 | + // what would be the double click |
| 173 | + await input.click({ |
| 174 | + position: { |
| 175 | + x: 5, |
| 176 | + y: 5, |
| 177 | + }, |
| 178 | + }); |
| 179 | + |
| 180 | + // Verify the click was triggered exactly once |
| 181 | + expect(clickEvent).toHaveReceivedEventTimes(1); |
| 182 | + |
| 183 | + // Verify that the event target is the checkbox and not the item |
| 184 | + const event = clickEvent.events[0]; |
| 185 | + expect((event.target as HTMLElement).tagName.toLowerCase()).toBe('ion-select'); |
| 186 | + }); |
| 187 | + }); |
153 | 188 | }); |
154 | 189 |
|
155 | 190 | /** |
|
0 commit comments