Skip to content

Commit 5e016a6

Browse files
thetaPCIonitronbrandyscarney
authored
test(item-sliding): re-enable flaky tests (#28192)
Issue number: internal --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> Some of the tests for `item-sliding` were being skipped due to flakiness. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Updated the tests to use the stable function, `dragElementBy` to handle gestures, removing the gesture flakiness. - Separated the basic test to lessen the gesture complexity else it becomes flaky since it can't handle opening and closing and opening in the same test. - Tests are now checking all modes and all directions. - Updated a utils function with a warning regarding an open issue with RTL. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> N/A --------- Co-authored-by: ionitron <[email protected]> Co-authored-by: Brandy Carney <[email protected]>
1 parent 0edcb2c commit 5e016a6

File tree

86 files changed

+78
-25
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+78
-25
lines changed

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

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

4-
import { testSlidingItem } from '../test.utils';
5-
64
/**
7-
* item-sliding doesn't have mode-specific styling
5+
* item-sliding doesn't have mode-specific styling,
6+
* but the child components, item-options and item-option, do.
7+
*
8+
* It is important to test all modes to ensure that the
9+
* child components are being rendered correctly.
810
*/
9-
configs({ modes: ['md'] }).forEach(({ title, screenshot, config }) => {
11+
configs().forEach(({ title, screenshot, config }) => {
1012
test.describe(title('item-sliding: basic'), () => {
11-
test.fixme('should not have visual regressions', async ({ page }) => {
13+
test.beforeEach(async ({ page }) => {
1214
await page.goto(`/src/components/item-sliding/test/basic`, config);
15+
});
16+
test.describe('start options', () => {
17+
test('should not have visual regressions', async ({ page }) => {
18+
const item = page.locator('#item2');
19+
20+
/**
21+
* Negative dragByX value to drag element from the right to the left
22+
* to reveal the options on the right side.
23+
* Positive dragByX value to drag element from the left to the right
24+
* to reveal the options on the left side.
25+
*/
26+
const dragByX = config.direction === 'rtl' ? -150 : 150;
27+
28+
await dragElementBy(item, page, dragByX);
29+
await page.waitForChanges();
30+
31+
await expect(item).toHaveScreenshot(screenshot('item-sliding-start'));
32+
});
33+
});
34+
35+
test.describe('end options', () => {
36+
test('should not have visual regressions', async ({ page }) => {
37+
const item = page.locator('#item2');
38+
39+
/**
40+
* Negative dragByX value to drag element from the right to the left
41+
* to reveal the options on the right side.
42+
* Positive dragByX value to drag element from the left to the right
43+
* to reveal the options on the left side.
44+
*/
45+
const dragByX = config.direction === 'rtl' ? 150 : -150;
46+
47+
await dragElementBy(item, page, dragByX);
1348

14-
await testSlidingItem(page, 'item2', 'start', screenshot, true);
15-
await testSlidingItem(page, 'item2', 'end', screenshot);
49+
await expect(item).toHaveScreenshot(screenshot('item-sliding-end'));
50+
});
1651
});
1752
});
1853
});

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

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,36 @@
1-
import { configs, test } from '@utils/test/playwright';
1+
import { expect } from '@playwright/test';
2+
import { configs, test, dragElementBy } from '@utils/test/playwright';
23

3-
import { testSlidingItem } from '../test.utils';
4-
5-
// TODO FW-3006
64
/**
7-
* item-sliding doesn't have mode-specific styling
5+
* item-sliding doesn't have mode-specific styling,
6+
* but the child components, item-options and item-option, do.
7+
*
8+
* It is important to test all modes to ensure that the
9+
* child components are being rendered correctly.
810
*/
9-
configs({ modes: ['md'] }).forEach(({ title, screenshot, config }) => {
10-
test.describe.skip(title('item-sliding: icons'), () => {
11+
configs().forEach(({ title, screenshot, config }) => {
12+
test.describe(title('item-sliding: icons'), () => {
1113
test('should not have visual regressions', async ({ page }) => {
1214
await page.goto(`/src/components/item-sliding/test/icons`, config);
1315

1416
const itemIDs = ['iconsOnly', 'iconsStart', 'iconsEnd', 'iconsTop', 'iconsBottom'];
1517
for (const itemID of itemIDs) {
16-
await testSlidingItem(page, itemID, itemID, screenshot);
18+
const item = page.locator(`#${itemID}`);
19+
20+
/**
21+
* Negative dragByX value to drag element from the right to the left
22+
* to reveal the options on the right side.
23+
* Positive dragByX value to drag element from the left to the right
24+
* to reveal the options on the left side.
25+
*/
26+
const dragByX = config.direction === 'rtl' ? 150 : -150;
27+
28+
await dragElementBy(item, page, dragByX);
29+
await page.waitForChanges();
30+
31+
// Convert camelCase ids to kebab-case for screenshot file names
32+
const itemIDKebab = itemID.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
33+
await expect(item).toHaveScreenshot(screenshot(`item-sliding-${itemIDKebab}`));
1734
}
1835
});
1936
});

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { expect } from '@playwright/test';
2-
import { configs, test } from '@utils/test/playwright';
2+
import { configs, test, dragElementBy } from '@utils/test/playwright';
33
/**
44
* This behavior does not vary across modes/directions
55
*/
66
configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) => {
77
test.describe(title('item-sliding: scroll-target'), () => {
8-
// TODO FW-3006
9-
test.skip('should not scroll when the item-sliding is swiped in custom scroll target', async ({ page, skip }) => {
8+
test('should not scroll when the item-sliding is swiped in custom scroll target', async ({ page, skip }) => {
109
skip.browser('webkit', 'mouse.wheel is not available in WebKit');
1110

1211
await page.goto(`/src/components/item-sliding/test/scroll-target`, config);
@@ -16,13 +15,7 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) =>
1615

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

19-
const box = (await itemSlidingEl.boundingBox())!;
20-
const centerX = box.x + box.width / 2;
21-
const centerY = box.y + box.height / 2;
22-
23-
await page.mouse.move(centerX, centerY);
24-
await page.mouse.down();
25-
await page.mouse.move(centerX - 30, centerY);
18+
await dragElementBy(itemSlidingEl, page, -150, 0, undefined, undefined, false);
2619

2720
/**
2821
* Do not use scrollToBottom() or other scrolling methods

core/src/components/item-sliding/test/test.utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { expect } from '@playwright/test';
22
import type { E2EPage, ScreenshotFn } from '@utils/test/playwright';
33

4+
/**
5+
* Warning: This function will fail when in RTL mode.
6+
* TODO(FW-3711): Remove the `directions` config when this issue preventing
7+
* tests from passing in RTL mode is resolved.
8+
*/
49
export const testSlidingItem = async (
510
page: E2EPage,
611
itemID: string,
@@ -23,6 +28,9 @@ export const testSlidingItem = async (
2328
}
2429

2530
// opening animation takes longer than waitForChanges accounts for
31+
// especially if another item sliding is already open,
32+
// so we wait to ensure the opened item is closed before
33+
// opening another
2634
await page.waitForTimeout(500);
2735

2836
await expect(item).toHaveScreenshot(screenshot(`item-sliding-${screenshotNameSuffix}`));

0 commit comments

Comments
 (0)