From f869f6123845bc1552774cac98cdc1f10f159d13 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Mon, 2 Dec 2024 21:56:39 +0800 Subject: [PATCH] =?UTF-8?q?feat(dialogPage):=20=E8=A1=A5=E5=85=85=20trigge?= =?UTF-8?q?rParentHide=20=E5=8F=82=E6=95=B0=E7=A4=BA=E4=BE=8B=E5=8F=8A?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.json | 10 +- pages/API/dialog-page/dialog-4.uvue | 89 +++++++++++++++++ pages/API/dialog-page/dialog-page.test.js | 115 ++++++++++++++++++++-- pages/API/dialog-page/dialog-page.uvue | 32 +++++- 4 files changed, 237 insertions(+), 9 deletions(-) create mode 100644 pages/API/dialog-page/dialog-4.uvue diff --git a/pages.json b/pages.json index 28a69e80..8a650de7 100644 --- a/pages.json +++ b/pages.json @@ -1508,6 +1508,14 @@ } }, // #endif + // #ifdef APP-ANDROID || APP-IOS || WEB + { + "path": "pages/API/dialog-page/dialog-4", + "style": { + "navigationBarTitleText": "dialogPage4" + } + }, + // #endif // #ifdef APP-ANDROID || APP-IOS || MP-WEIXIN { "path": "pages/API/create-interstitial-ad/create-interstitial-ad", @@ -3354,4 +3362,4 @@ ] } ] -} +} diff --git a/pages/API/dialog-page/dialog-4.uvue b/pages/API/dialog-page/dialog-4.uvue new file mode 100644 index 00000000..f1f42924 --- /dev/null +++ b/pages/API/dialog-page/dialog-4.uvue @@ -0,0 +1,89 @@ + + + + + diff --git a/pages/API/dialog-page/dialog-page.test.js b/pages/API/dialog-page/dialog-page.test.js index ccdb05a1..c73baa44 100644 --- a/pages/API/dialog-page/dialog-page.test.js +++ b/pages/API/dialog-page/dialog-page.test.js @@ -1,4 +1,4 @@ -jest.setTimeout(20000) +jest.setTimeout(50000) const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() const isWeb = platformInfo.startsWith('web') @@ -201,7 +201,8 @@ describe('dialog page', () => { await page.callMethod('setLifeCycleNum', 0) }) - it('openDialogPage to home page', async () => { + it('openDialogPage to home page', async () => { + // 本测试例中是在 FIRST_PAGE_PATH 中打开 await page.callMethod('openDialogPage1ToHomePage') await page.waitFor(1000) if (isWeb) { @@ -215,7 +216,6 @@ describe('dialog page', () => { it('dialog2 navigateBack', async () => { await program.navigateBack() page = await program.currentPage() - // dialogPage onBackPress 返回 true, 应可以拦截 navigateBack expect(page.path).toBe(FIRST_PAGE_PATH.substring(1)) const image = await program.screenshot({ deviceShot: true, @@ -226,8 +226,8 @@ describe('dialog page', () => { }); expect(image).toSaveImageSnapshot(); lifecycleNum = await page.callMethod('getLifeCycleNum') - // onBackPress 生命周期应该被触发 - expect(lifecycleNum).toBe(2) + // dialogPage2 onBackPress +1 dialogPage1 show +1 dialogPage unload -5*2 firstPage show +10 + expect(lifecycleNum).toBe(2) await page.callMethod('setLifeCycleNum', 0) }) @@ -298,10 +298,111 @@ describe('dialog page', () => { }); expect(image5).toSaveImageSnapshot(); lifecycleNum = await page.callMethod('getLifeCycleNum') - expect(lifecycleNum).toBe(2) + expect(lifecycleNum).toBe(2) + await page.callMethod('setLifeCycleNum', 0) + }) + + it('check triggerParentHide', async () => { + // no triggerParentHide should not trigger parent hide + await page.callMethod('openDialog4') + await page.waitFor(1000) + if (isWeb) { + await page.waitFor(2000) + } + // dialog4 show +1 + expect(await page.callMethod('getLifeCycleNum')).toBe(1) + await page.callMethod('closeDialog') + await page.waitFor(200) + // dialog4 unload -5 closeDialog callback +2 + expect(await page.callMethod('getLifeCycleNum')).toBe(-2) + + + // triggerParentHide should trigger parent hide + await page.callMethod('openDialogWithTriggerParentHide') + await page.waitFor(1000) + if (isWeb) { + await page.waitFor(2000) + } + // openDialog callback +2 dialog4 show +1 parent hide -10 + expect(await page.callMethod('getLifeCycleNum')).toBe(-9) + await page.callMethod('closeDialog') + await page.waitFor(200) + // dialog4 unload -5 parent show +10 closeDialog callback +2 + expect(await page.callMethod('getLifeCycleNum')).toBe(-2) + + + // triggerParentHide should trigger parent hide + await page.callMethod('openDialogWithTriggerParentHide') + await page.waitFor(1000) + if (isWeb) { + await page.waitFor(2000) + } + // openDialog callback +2 dialog4 show +1 parent hide -10 + expect(await page.callMethod('getLifeCycleNum')).toBe(-9) + + // second triggerParentHide should not trigger parent hide + await page.callMethod('openDialogWithTriggerParentHide') + await page.waitFor(1000) + if (isWeb) { + await page.waitFor(2000) + } + // openDialog callback +2 dialog4 show +1 + expect(await page.callMethod('getLifeCycleNum')).toBe(-6) + + await page.callMethod('closeSpecifiedDialog', 1) + await page.waitFor(200) + // close not last triggerParentHide should not trigger parent show + // close callback +2 dialog4 unload -5 dialog4 show +1 + expect(await page.callMethod('getLifeCycleNum')).toBe(-8) + + await page.callMethod('closeSpecifiedDialog', 0) + await page.waitFor(200) + // close last triggerParentHide should trigger parent show + // close callback +2 dialog4 unload -5 parent show +10 + expect(await page.callMethod('getLifeCycleNum')).toBe(-1) + + + // no triggerParentHide should not trigger parent hide + await page.callMethod('openDialog4') + await page.waitFor(1000) + if (isWeb) { + await page.waitFor(2000) + } + // dialog4 show +1 + expect(await page.callMethod('getLifeCycleNum')).toBe(0) + // triggerParentHide should trigger parent hide + await page.callMethod('openDialogWithTriggerParentHide') + await page.waitFor(1000) + if (isWeb) { + await page.waitFor(2000) + } + // openDialog callback +2 dialog4 show +1 parent hide -10 + expect(await page.callMethod('getLifeCycleNum')).toBe(-7) + + // second triggerParentHide should not trigger parent hide + await page.callMethod('openDialogWithTriggerParentHide') + await page.waitFor(1000) + if (isWeb) { + await page.waitFor(2000) + } + // openDialog callback +2 dialog4 show +1 + expect(await page.callMethod('getLifeCycleNum')).toBe(-4) + // close middle triggerParentHide dialogPage + await page.callMethod('closeSpecifiedDialog', 1) + await page.waitFor(200) + // close callback +2 dialog4 unload -5 + expect(await page.callMethod('getLifeCycleNum')).toBe(-7) + // close last triggerParentHide dialogPage shoud trigger parent show + await page.callMethod('closeSpecifiedDialog', 1) + await page.waitFor(200) + // close callback +2 dialog4 unload -5 dialog4 show +1 parent show +10 + expect(await page.callMethod('getLifeCycleNum')).toBe(1) + await page.callMethod('closeDialog') + await page.waitFor(200) + // close callback +2 dialog4 unload -5 + expect(await page.callMethod('getLifeCycleNum')).toBe(-2) }) - it('input-hold-keyboard in dialog', async () => { await page.callMethod('jest_OpenDialog1') await page.waitFor(2000); diff --git a/pages/API/dialog-page/dialog-page.uvue b/pages/API/dialog-page/dialog-page.uvue index 34b4a747..e90a6de8 100644 --- a/pages/API/dialog-page/dialog-page.uvue +++ b/pages/API/dialog-page/dialog-page.uvue @@ -15,6 +15,9 @@ + choose open dialogPage animationType +style> -- GitLab