|
| 1 | +import { expect } from '@playwright/test'; |
| 2 | +import { configs, test } from '@utils/test/playwright'; |
| 3 | + |
| 4 | +configs({ modes: ['md'] }).forEach(({ title, screenshot, config }) => { |
| 5 | + test.describe(title('fab: safe area'), () => { |
| 6 | + test('should ignore document direction in safe area positioning for start-positioned fab', async ({ page }) => { |
| 7 | + await page.setContent( |
| 8 | + ` |
| 9 | + <style> |
| 10 | + :root { |
| 11 | + --ion-safe-area-left: 40px; |
| 12 | + --ion-safe-area-right: 20px; |
| 13 | + } |
| 14 | + </style> |
| 15 | +
|
| 16 | + <ion-content> |
| 17 | + <ion-fab vertical="center" horizontal="start"> |
| 18 | + <ion-fab-button> |
| 19 | + <ion-icon name="add"></ion-icon> |
| 20 | + </ion-fab-button> |
| 21 | + </ion-fab> |
| 22 | + </ion-content> |
| 23 | + `, |
| 24 | + config |
| 25 | + ); |
| 26 | + |
| 27 | + /** |
| 28 | + * We need to capture the entire page to check the fab's position, |
| 29 | + * but we don't need much extra white space. |
| 30 | + */ |
| 31 | + await page.setViewportSize({ |
| 32 | + width: 200, |
| 33 | + height: 200, |
| 34 | + }); |
| 35 | + |
| 36 | + await expect(page).toHaveScreenshot(screenshot('fab-safe-area-horizontal-start')); |
| 37 | + }); |
| 38 | + |
| 39 | + test('should ignore document direction in safe area positioning for end-positioned fab', async ({ page }) => { |
| 40 | + await page.setContent( |
| 41 | + ` |
| 42 | + <style> |
| 43 | + :root { |
| 44 | + --ion-safe-area-left: 40px; |
| 45 | + --ion-safe-area-right: 20px; |
| 46 | + } |
| 47 | + </style> |
| 48 | +
|
| 49 | + <ion-content> |
| 50 | + <ion-fab vertical="center" horizontal="end"> |
| 51 | + <ion-fab-button> |
| 52 | + <ion-icon name="add"></ion-icon> |
| 53 | + </ion-fab-button> |
| 54 | + </ion-fab> |
| 55 | + </ion-content> |
| 56 | + `, |
| 57 | + config |
| 58 | + ); |
| 59 | + |
| 60 | + /** |
| 61 | + * We need to capture the entire page to check the fab's position, |
| 62 | + * but we don't need much extra white space. |
| 63 | + */ |
| 64 | + await page.setViewportSize({ |
| 65 | + width: 200, |
| 66 | + height: 200, |
| 67 | + }); |
| 68 | + |
| 69 | + await expect(page).toHaveScreenshot(screenshot('fab-safe-area-horizontal-end')); |
| 70 | + }); |
| 71 | + }); |
| 72 | +}); |
0 commit comments