Skip to content

Commit e6c6e27

Browse files
Update core/src/components/app/test/safe-area/app.e2e.ts
Co-authored-by: Brandy Smith <[email protected]>
1 parent a01ab8b commit e6c6e27

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

core/src/components/app/test/safe-area/app.e2e.ts

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,40 @@ configs({ directions: ['ltr'] }).forEach(({ config, title, screenshot }) => {
4646
});
4747

4848
test.describe(title('Capacitor safe area variables'), () => {
49-
test.beforeEach(async ({ page }) => {
50-
const toggleButton = page.locator('#toggle-safe-area');
51-
await toggleButton.click();
49+
test('should use safe-area-inset vars when safe-area class is defined', async ({ page }) => {
50+
await page.evaluate(() => {
51+
const html = document.documentElement;
5252

53-
const htmlTag = page.locator('html');
54-
const hasSafeAreaClass = await htmlTag.evaluate((el) => el.classList.contains('safe-area-capacitor'));
53+
// Remove the safe area class
54+
html.classList.remove('safe-area');
5555

56-
expect(hasSafeAreaClass).toBe(true);
57-
});
56+
// Set the safe area inset variables
57+
html.style.setProperty('--safe-area-inset-top', '10px');
58+
html.style.setProperty('--safe-area-inset-bottom', '20px');
59+
html.style.setProperty('--safe-area-inset-left', '30px');
60+
html.style.setProperty('--safe-area-inset-right', '40px');
61+
});
5862

59-
test('should not have visual regressions with action sheet', async ({ page }) => {
60-
await testOverlay(page, '#show-action-sheet', 'ionActionSheetDidPresent', 'capacitor-action-sheet');
61-
});
62-
test('should not have visual regressions with menu', async ({ page }) => {
63-
await testOverlay(page, '#show-menu', 'ionDidOpen', 'capacitor-menu');
64-
});
65-
test('should not have visual regressions with picker', async ({ page }) => {
66-
await testOverlay(page, '#show-picker', 'ionPickerDidPresent', 'capacitor-picker');
67-
});
68-
test('should not have visual regressions with toast', async ({ page }) => {
69-
await testOverlay(page, '#show-toast', 'ionToastDidPresent', 'capacitor-toast');
63+
const top = await page.evaluate(() =>
64+
getComputedStyle(document.documentElement).getPropertyValue('--ion-safe-area-top').trim()
65+
);
66+
const bottom = await page.evaluate(() =>
67+
getComputedStyle(document.documentElement).getPropertyValue('--ion-safe-area-bottom').trim()
68+
);
69+
const left = await page.evaluate(() =>
70+
getComputedStyle(document.documentElement).getPropertyValue('--ion-safe-area-left').trim()
71+
);
72+
const right = await page.evaluate(() =>
73+
getComputedStyle(document.documentElement).getPropertyValue('--ion-safe-area-right').trim()
74+
);
75+
76+
expect(top).toBe('10px');
77+
expect(bottom).toBe('20px');
78+
expect(left).toBe('30px');
79+
expect(right).toBe('40px');
7080
});
7181
});
7282
});
83+
});
84+
});
7385
});

0 commit comments

Comments
 (0)