Merge remote-tracking branch 'origin/main' into sync-67-23

This commit is contained in:
Liam DeBeasi
2023-03-23 09:17:19 -04:00
5 changed files with 48 additions and 261 deletions

View File

@@ -19,6 +19,7 @@ test.describe('ripple-effect: basic', () => {
test.describe('ripple effect with nested ion-button', () => {
test('should add .ion-activated when the block is pressed', async ({ page }) => {
await page.goto('/src/components/ripple-effect/test/basic?ionic:_testing=false');
await isIdleCallbackComplete(page);
const el = page.locator('#ripple-with-button');
@@ -45,6 +46,7 @@ test.describe('ripple-effect: basic', () => {
const verifyRippleEffect = async (page: E2EPage, selector: string) => {
await page.goto('/src/components/ripple-effect/test/basic?ionic:_testing=false');
await isIdleCallbackComplete(page);
const el = page.locator(selector);
@@ -61,3 +63,24 @@ const verifyRippleEffect = async (page: E2EPage, selector: string) => {
await expect(el).toHaveClass(/ion-activated/);
};
/**
* This function is used to wait for the idle callback to be called.
* It mirrors the custom implementation in app.tsx for either
* using requestIdleCallback on supported browsers or a setTimeout
* of 32ms (~2 frames) on unsupported browsers (Safari).
*/
const isIdleCallbackComplete = async (page: E2EPage) => {
await page.waitForFunction(
() => {
return new Promise((resolve) => {
if ('requestIdleCallback' in window) {
window.requestIdleCallback(resolve);
} else {
setTimeout(resolve, 32);
}
});
},
{ timeout: 5000 }
);
};