From a7b964279bd232ca9bb0c0f3710c6e2be5a55c11 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Tue, 8 Oct 2019 10:41:52 -0400 Subject: [PATCH] fix(overlay): ensure lifecycles fire properly (#19579) --- core/src/components/modal/test/test.utils.ts | 12 ++++++++++++ core/src/utils/overlays.ts | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/core/src/components/modal/test/test.utils.ts b/core/src/components/modal/test/test.utils.ts index ab2d346c95..b336afc5c9 100644 --- a/core/src/components/modal/test/test.utils.ts +++ b/core/src/components/modal/test/test.utils.ts @@ -14,8 +14,16 @@ export const testModal = async ( }); const screenshotCompares = []; + const ionModalWillPresent = await page.spyOnEvent('ionModalWillPresent'); + const ionModalDidPresent = await page.spyOnEvent('ionModalDidPresent'); + const ionModalWillDismiss = await page.spyOnEvent('ionModalWillDismiss'); + const ionModalDidDismiss = await page.spyOnEvent('ionModalDidDismiss'); await page.click(selector); + + await ionModalWillPresent.next(); + await ionModalDidPresent.next(); + await page.waitForSelector(selector); let modal = await page.find('ion-modal'); @@ -25,6 +33,10 @@ export const testModal = async ( screenshotCompares.push(await page.compareScreenshot()); await modal.callMethod('dismiss'); + + await ionModalWillDismiss.next(); + await ionModalDidDismiss.next(); + await modal.waitForNotVisible(); screenshotCompares.push(await page.compareScreenshot('dismiss')); diff --git a/core/src/utils/overlays.ts b/core/src/utils/overlays.ts index 079e0c1686..b5d52d2cc6 100644 --- a/core/src/utils/overlays.ts +++ b/core/src/utils/overlays.ts @@ -221,7 +221,7 @@ const overlayAnimation = async ( /** * TODO: Remove AnimationBuilder */ - const hasCompleted = (typeof animationResult as any === 'boolean') ? animationResult : (animation as any).hasCompleted; + const hasCompleted = (typeof animationResult as any === 'undefined') ? true : (animation as any).hasCompleted; if (isAnimationBuilder) { animation.destroy(); }