Skip to content

Commit b1df2e2

Browse files
committed
test(item-sliding): use constant
1 parent fbd4983 commit b1df2e2

4 files changed

Lines changed: 29 additions & 4 deletions

File tree

core/src/components/item-sliding/test/icons/item-sliding.e2e.ts

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

4+
/**
5+
* Drag distances that reveal options without crossing the full swipe threshold
6+
* (optsWidth + SWIPE_MARGIN). A narrower options panel requires a shorter drag.
7+
*/
8+
const DRAG_DISTANCE_TWO_OPTIONS = 150;
9+
410
/**
511
* item-sliding doesn't have mode-specific styling,
612
* but the child components, item-options and item-option, do.
@@ -24,7 +30,7 @@ configs({ modes: ['ionic-md', 'ios', 'md'] }).forEach(({ title, screenshot, conf
2430
* Positive dragByX value to drag element from the left to the right
2531
* to reveal the options on the left side.
2632
*/
27-
const dragByX = config.direction === 'rtl' ? 150 : -150;
33+
const dragByX = config.direction === 'rtl' ? DRAG_DISTANCE_TWO_OPTIONS : -DRAG_DISTANCE_TWO_OPTIONS;
2834

2935
await dragElementBy(item, page, dragByX, 0, undefined, undefined, undefined, 15);
3036
await page.waitForChanges();

core/src/components/item-sliding/test/scroll-target/item-sliding.e2e.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import { expect } from '@playwright/test';
22
import { configs, test, dragElementBy } from '@utils/test/playwright';
3+
4+
/**
5+
* Drag distances that reveal options without crossing the full swipe threshold
6+
* (optsWidth + SWIPE_MARGIN). A narrower options panel requires a shorter drag.
7+
*/
8+
const DRAG_DISTANCE_TWO_OPTIONS = 150;
9+
310
/**
411
* This behavior does not vary across modes/directions
512
*/
@@ -15,7 +22,7 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) =>
1522

1623
expect(await scrollEl.evaluate((el: HTMLElement) => el.scrollTop)).toEqual(0);
1724

18-
await dragElementBy(itemSlidingEl, page, -150, 0, undefined, undefined, false);
25+
await dragElementBy(itemSlidingEl, page, -DRAG_DISTANCE_TWO_OPTIONS, 0, undefined, undefined, false);
1926

2027
/**
2128
* Do not use scrollToBottom() or other scrolling methods

core/src/components/item-sliding/test/shapes/item-sliding.e2e.ts

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

4+
/**
5+
* Drag distances that reveal options without crossing the full swipe threshold
6+
* (optsWidth + SWIPE_MARGIN). A narrower options panel requires a shorter drag.
7+
*/
8+
const DRAG_DISTANCE_TWO_OPTIONS = 150;
9+
410
/**
511
* The shapes on the `item-option` do not vary by direction
612
* when they are not being dragged.
@@ -19,7 +25,7 @@ configs({ modes: ['ionic-md'], directions: ['ltr'] }).forEach(({ title, screensh
1925
* Negative dragByX value to drag element from the right to the left
2026
* to reveal the options on the right side.
2127
*/
22-
const dragByX = -150;
28+
const dragByX = -DRAG_DISTANCE_TWO_OPTIONS;
2329

2430
await dragElementBy(item, page, dragByX, 0, undefined, undefined, undefined, 15);
2531
await page.waitForChanges();

core/src/components/item-sliding/test/states/item-sliding.e2e.ts

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

4+
/**
5+
* Drag distances that reveal options without crossing the full swipe threshold
6+
* (optsWidth + SWIPE_MARGIN). A narrower options panel requires a shorter drag.
7+
*/
8+
const DRAG_DISTANCE_TWO_OPTIONS = 150;
9+
410
/**
511
* This behavior does not vary across modes
612
*/
@@ -16,7 +22,7 @@ configs({ modes: ['ionic-md', 'md', 'ios'], directions: ['ltr'] }).forEach(({ ti
1622
* Negative dragByX value to drag element from the right to the left
1723
* to reveal the options on the right side.
1824
*/
19-
const dragByX = -150;
25+
const dragByX = -DRAG_DISTANCE_TWO_OPTIONS;
2026

2127
await dragElementBy(item, page, dragByX);
2228
await page.waitForChanges();

0 commit comments

Comments
 (0)