|
| 1 | +import { expect } from '@playwright/test'; |
| 2 | +import { configs, test } from '@utils/test/playwright'; |
| 3 | + |
| 4 | +/** |
| 5 | + * Safe-area tests verify that ion-content correctly applies safe-area classes |
| 6 | + * based on the presence/absence of sibling ion-header and ion-footer elements. |
| 7 | + * |
| 8 | + * These tests verify the FW-6830 feature: automatic safe-area handling for content. |
| 9 | + */ |
| 10 | + |
| 11 | +configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => { |
| 12 | + test.describe(title('content: safe-area'), () => { |
| 13 | + test.beforeEach(async ({ page }) => { |
| 14 | + await page.goto('/src/components/content/test/safe-area', config); |
| 15 | + }); |
| 16 | + |
| 17 | + test('content without header should have safe-area-top class', async ({ page }, testInfo) => { |
| 18 | + testInfo.annotations.push({ |
| 19 | + type: 'issue', |
| 20 | + description: 'https://outsystemsrd.atlassian.net/browse/FW-6830', |
| 21 | + }); |
| 22 | + |
| 23 | + const content = page.locator('#content-no-header'); |
| 24 | + await expect(content).toHaveClass(/safe-area-top/); |
| 25 | + await expect(content).not.toHaveClass(/safe-area-bottom/); |
| 26 | + }); |
| 27 | + |
| 28 | + test('content without footer should have safe-area-bottom class', async ({ page }, testInfo) => { |
| 29 | + testInfo.annotations.push({ |
| 30 | + type: 'issue', |
| 31 | + description: 'https://outsystemsrd.atlassian.net/browse/FW-6830', |
| 32 | + }); |
| 33 | + |
| 34 | + const content = page.locator('#content-no-footer'); |
| 35 | + await expect(content).not.toHaveClass(/safe-area-top/); |
| 36 | + await expect(content).toHaveClass(/safe-area-bottom/); |
| 37 | + }); |
| 38 | + |
| 39 | + test('content with both header and footer should not have safe-area classes', async ({ page }, testInfo) => { |
| 40 | + testInfo.annotations.push({ |
| 41 | + type: 'issue', |
| 42 | + description: 'https://outsystemsrd.atlassian.net/browse/FW-6830', |
| 43 | + }); |
| 44 | + |
| 45 | + const content = page.locator('#content-with-both'); |
| 46 | + await expect(content).not.toHaveClass(/safe-area-top/); |
| 47 | + await expect(content).not.toHaveClass(/safe-area-bottom/); |
| 48 | + }); |
| 49 | + |
| 50 | + test('content without header or footer should have both safe-area classes', async ({ page }, testInfo) => { |
| 51 | + testInfo.annotations.push({ |
| 52 | + type: 'issue', |
| 53 | + description: 'https://outsystemsrd.atlassian.net/browse/FW-6830', |
| 54 | + }); |
| 55 | + |
| 56 | + const content = page.locator('#content-no-both'); |
| 57 | + await expect(content).toHaveClass(/safe-area-top/); |
| 58 | + await expect(content).toHaveClass(/safe-area-bottom/); |
| 59 | + }); |
| 60 | + |
| 61 | + test('content with wrapped header should not have safe-area-top class', async ({ page }, testInfo) => { |
| 62 | + testInfo.annotations.push({ |
| 63 | + type: 'issue', |
| 64 | + description: 'https://outsystemsrd.atlassian.net/browse/FW-6830', |
| 65 | + }); |
| 66 | + |
| 67 | + const content = page.locator('#content-wrapped-header'); |
| 68 | + // Wrapped header detection should find the ion-header inside my-header |
| 69 | + await expect(content).not.toHaveClass(/safe-area-top/); |
| 70 | + }); |
| 71 | + |
| 72 | + test('content with wrapped footer should not have safe-area-bottom class', async ({ page }, testInfo) => { |
| 73 | + testInfo.annotations.push({ |
| 74 | + type: 'issue', |
| 75 | + description: 'https://outsystemsrd.atlassian.net/browse/FW-6830', |
| 76 | + }); |
| 77 | + |
| 78 | + const content = page.locator('#content-wrapped-footer'); |
| 79 | + // Wrapped footer detection should find the ion-footer inside my-footer |
| 80 | + await expect(content).not.toHaveClass(/safe-area-bottom/); |
| 81 | + }); |
| 82 | + |
| 83 | + test('nested content should not have safe-area classes', async ({ page }, testInfo) => { |
| 84 | + testInfo.annotations.push({ |
| 85 | + type: 'issue', |
| 86 | + description: 'https://outsystemsrd.atlassian.net/browse/FW-6830', |
| 87 | + }); |
| 88 | + |
| 89 | + const nestedContent = page.locator('#content-nested'); |
| 90 | + // Nested content should not be treated as main content |
| 91 | + await expect(nestedContent).not.toHaveClass(/safe-area-top/); |
| 92 | + await expect(nestedContent).not.toHaveClass(/safe-area-bottom/); |
| 93 | + }); |
| 94 | + |
| 95 | + test('outer content should still have safe-area classes', async ({ page }, testInfo) => { |
| 96 | + testInfo.annotations.push({ |
| 97 | + type: 'issue', |
| 98 | + description: 'https://outsystemsrd.atlassian.net/browse/FW-6830', |
| 99 | + }); |
| 100 | + |
| 101 | + const outerContent = page.locator('#content-outer'); |
| 102 | + // Outer content has no sibling header/footer, so it should have safe-area classes |
| 103 | + await expect(outerContent).toHaveClass(/safe-area-top/); |
| 104 | + await expect(outerContent).toHaveClass(/safe-area-bottom/); |
| 105 | + }); |
| 106 | + |
| 107 | + test('content inside modal should not have safe-area classes', async ({ page }, testInfo) => { |
| 108 | + testInfo.annotations.push({ |
| 109 | + type: 'issue', |
| 110 | + description: 'https://outsystemsrd.atlassian.net/browse/FW-6830', |
| 111 | + }); |
| 112 | + |
| 113 | + // Open the modal |
| 114 | + await page.evaluate(() => { |
| 115 | + const modal = document.getElementById('test-modal') as HTMLIonModalElement; |
| 116 | + modal.isOpen = true; |
| 117 | + }); |
| 118 | + |
| 119 | + // Wait for modal to be presented |
| 120 | + const ionModalDidPresent = await page.spyOnEvent('ionModalDidPresent'); |
| 121 | + await ionModalDidPresent.next(); |
| 122 | + |
| 123 | + const modalContent = page.locator('#content-in-modal'); |
| 124 | + // Content inside modal should not be treated as main content |
| 125 | + await expect(modalContent).not.toHaveClass(/safe-area-top/); |
| 126 | + await expect(modalContent).not.toHaveClass(/safe-area-bottom/); |
| 127 | + }); |
| 128 | + |
| 129 | + test('dynamic header addition should update safe-area classes', async ({ page }, testInfo) => { |
| 130 | + testInfo.annotations.push({ |
| 131 | + type: 'issue', |
| 132 | + description: 'https://outsystemsrd.atlassian.net/browse/FW-6830', |
| 133 | + }); |
| 134 | + |
| 135 | + const content = page.locator('#content-dynamic'); |
| 136 | + |
| 137 | + // Initially should have safe-area-top (no header) |
| 138 | + await expect(content).toHaveClass(/safe-area-top/); |
| 139 | + |
| 140 | + // Add header dynamically |
| 141 | + await page.click('#add-header-btn'); |
| 142 | + |
| 143 | + // Wait for mutation observer to trigger and component to update |
| 144 | + // Using expect with timeout instead of waitForTimeout for reliability |
| 145 | + await expect(content).not.toHaveClass(/safe-area-top/, { timeout: 1000 }); |
| 146 | + }); |
| 147 | + |
| 148 | + test('dynamic header removal should update safe-area classes', async ({ page }, testInfo) => { |
| 149 | + testInfo.annotations.push({ |
| 150 | + type: 'issue', |
| 151 | + description: 'https://outsystemsrd.atlassian.net/browse/FW-6830', |
| 152 | + }); |
| 153 | + |
| 154 | + const content = page.locator('#content-dynamic'); |
| 155 | + |
| 156 | + // Add header first |
| 157 | + await page.click('#add-header-btn'); |
| 158 | + await expect(content).not.toHaveClass(/safe-area-top/, { timeout: 1000 }); |
| 159 | + |
| 160 | + // Remove header |
| 161 | + await page.click('#remove-header-btn'); |
| 162 | + |
| 163 | + // Should have safe-area-top again |
| 164 | + await expect(content).toHaveClass(/safe-area-top/, { timeout: 1000 }); |
| 165 | + }); |
| 166 | + }); |
| 167 | +}); |
0 commit comments