|
1 | 1 | import { expect } from '@playwright/test';
|
2 |
| -import { configs, test } from '@utils/test/playwright'; |
| 2 | +import { configs, test, dragElementBy } from '@utils/test/playwright'; |
3 | 3 |
|
4 | 4 | /**
|
5 | 5 | * This behavior does not vary across modes/directions.
|
@@ -105,8 +105,7 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) =>
|
105 | 105 | });
|
106 | 106 | });
|
107 | 107 |
|
108 |
| - // TODO FW-3021 |
109 |
| - test.describe.skip('when the pointer is released', () => { |
| 108 | + test.describe('when the pointer is released', () => { |
110 | 109 | test('should emit if the value has changed', async ({ page }) => {
|
111 | 110 | test.info().annotations.push({
|
112 | 111 | type: 'issue',
|
@@ -136,14 +135,22 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) =>
|
136 | 135 |
|
137 | 136 | const ionChangeSpy = await page.spyOnEvent('ionChange');
|
138 | 137 |
|
| 138 | + const segment = page.locator('ion-segment'); |
139 | 139 | const firstButton = page.locator('ion-segment-button[value="1"]');
|
140 | 140 | const lastButton = page.locator('ion-segment-button[value="3"]');
|
141 | 141 |
|
142 |
| - await firstButton.hover(); |
143 |
| - await page.mouse.down(); |
144 |
| - |
145 |
| - await lastButton.hover(); |
146 |
| - await page.mouse.up(); |
| 142 | + /* |
| 143 | + * `dragByX` should represent the total width of all segment buttons, |
| 144 | + * excluding the first half of the first button and the second half |
| 145 | + * of the last button. This calculation accounts for dragging from |
| 146 | + * the center of the first button to the center of the last button. |
| 147 | + */ |
| 148 | + const segmentWidth = await segment.boundingBox().then((box) => (box ? box.width : 0)); |
| 149 | + const firstButtonWidth = await firstButton.boundingBox().then((box) => (box ? box.width : 0)); |
| 150 | + const lastButtonWidth = await lastButton.boundingBox().then((box) => (box ? box.width : 0)); |
| 151 | + const dragByX = segmentWidth - firstButtonWidth / 2 - lastButtonWidth / 2; |
| 152 | + |
| 153 | + await dragElementBy(firstButton, page, dragByX); |
147 | 154 |
|
148 | 155 | expect(ionChangeSpy).toHaveReceivedEventDetail({ value: '3' });
|
149 | 156 | expect(ionChangeSpy).toHaveReceivedEventTimes(1);
|
|
0 commit comments