|
1 | 1 | import { expect } from '@playwright/test';
|
2 | 2 | import { configs, dragElementBy, test } from '@utils/test/playwright';
|
3 | 3 |
|
4 |
| -import { testSlidingItem } from '../test.utils'; |
5 |
| - |
6 | 4 | /**
|
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. |
8 | 10 | */
|
9 |
| -configs({ modes: ['md'] }).forEach(({ title, screenshot, config }) => { |
| 11 | +configs().forEach(({ title, screenshot, config }) => { |
10 | 12 | test.describe(title('item-sliding: basic'), () => {
|
11 |
| - test.fixme('should not have visual regressions', async ({ page }) => { |
| 13 | + test.beforeEach(async ({ page }) => { |
12 | 14 | 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); |
13 | 48 |
|
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 | + }); |
16 | 51 | });
|
17 | 52 | });
|
18 | 53 | });
|
|
0 commit comments