diff --git a/pages.json b/pages.json index f48ef91acdb02850c1df0ff76e71a765b7e1a353..2fc32d33258f9f90664cc241d4c268a230c95a6f 100644 --- a/pages.json +++ b/pages.json @@ -257,11 +257,17 @@ "navigationBarTitleText": "页面跳转" } }, - { - "path": "pages/API/set-navigation-bar-color/set-navigation-bar-color", - "style": { - "navigationBarTitleText": "设置导航条颜色" - } + { + "path": "pages/API/set-navigation-bar-color/set-navigation-bar-color", + "style": { + "navigationBarTitleText": "设置导航条颜色" + } + }, + { + "path": "pages/API/set-navigation-bar-title/set-navigation-bar-title", + "style": { + "navigationBarTitleText": "设置导航条标题" + } }, { "path": "pages/API/set-navigation-bar-color/set-custom-navigation-bar-color", @@ -276,13 +282,6 @@ "navigationBarTitleText": "新页面-1" } }, - { - "path": "pages/API/navigator/new-page/new-page-2", - "style": { - "navigationBarTitleText": "新页面-2", - "enablePullDownRefresh": true - } - }, { "path": "pages/API/navigator/new-page/new-page-3", "style": { @@ -1040,6 +1039,14 @@ "navigationBarTitleText" : "transitionend事件", "enablePullDownRefresh" : false } + }, + { + "path" : "pages/API/install-apk/install-apk", + "style" : + { + "navigationBarTitleText" : "install-apk", + "enablePullDownRefresh" : false + } } ], diff --git a/pages/API/event-bus/event-bus.test.js b/pages/API/event-bus/event-bus.test.js index 35d3e36644cf81c5be73373ec095c365021de612..699466dea86f00260d57c933d260540b3d3d09fa 100644 --- a/pages/API/event-bus/event-bus.test.js +++ b/pages/API/event-bus/event-bus.test.js @@ -4,7 +4,7 @@ describe('event-bus', () => { let page beforeAll(async () => { page = await program.reLaunch(PAGE_PATH) - await page.waitFor(500) + await page.waitFor('view') }) it('on', async () => { diff --git a/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js b/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js index c7863eb97bf1e8162ee2e593138ac71e5829a995..7311bbde478ea075d1c187e6742f074fa62607aa 100644 --- a/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js +++ b/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js @@ -5,7 +5,7 @@ let page; describe("getElementByIdForMultipleRootNode", () => { beforeAll(async () => { page = await program.reLaunch(PAGE_PATH); - await page.waitFor(1000); + await page.waitFor('view'); }); it("getElementByNotExistId", async () => { const res = await page.callMethod("getElementByNotExistId"); diff --git a/pages/API/get-element-by-id/get-element-by-id.test.js b/pages/API/get-element-by-id/get-element-by-id.test.js index 00a5f2e78b5a9b162277838a30b2ff502e656ae0..a04f1b1ded90c1768b20e19bb357570782d5d6be 100644 --- a/pages/API/get-element-by-id/get-element-by-id.test.js +++ b/pages/API/get-element-by-id/get-element-by-id.test.js @@ -4,7 +4,7 @@ let page; describe("getElementById", () => { beforeAll(async () => { page = await program.reLaunch(PAGE_PATH); - await page.waitFor(1000); + await page.waitFor('view'); }); it("getElementByNotExistId", async () => { const res = await page.callMethod("getElementByNotExistId"); diff --git a/pages/API/get-launch-options-sync/get-launch-options-sync.test.js b/pages/API/get-launch-options-sync/get-launch-options-sync.test.js index 1c603c6859c06fe41ea1d7ac0716dc18e7c34853..480279377a1a208aa7a9554205ba1505eaa1721b 100644 --- a/pages/API/get-launch-options-sync/get-launch-options-sync.test.js +++ b/pages/API/get-launch-options-sync/get-launch-options-sync.test.js @@ -3,7 +3,7 @@ const PAGE_PATH = '/pages/API/get-launch-options-sync/get-launch-options-sync' describe('getLaunchOptionsSync', () => { it('getLaunchOptionsSync', async () => { const page = await program.navigateTo(PAGE_PATH) - await page.waitFor(1000) + await page.waitFor('view') await page.callMethod('getLaunchOptionsSync') const data = await page.data() expect(data.checked).toBe(true) diff --git a/pages/API/install-apk/install-apk.uvue b/pages/API/install-apk/install-apk.uvue new file mode 100644 index 0000000000000000000000000000000000000000..af849b8debea300eb30ca0bc0cc05a505287de8f --- /dev/null +++ b/pages/API/install-apk/install-apk.uvue @@ -0,0 +1,47 @@ + + + + diff --git a/pages/API/load-font-face/load-font-face-child.test.js b/pages/API/load-font-face/load-font-face-child.test.js deleted file mode 100644 index ad479f5b30c66289750754aacf9f3810799408d3..0000000000000000000000000000000000000000 --- a/pages/API/load-font-face/load-font-face-child.test.js +++ /dev/null @@ -1,12 +0,0 @@ -const PAGE_PATH = '/pages/API/load-font-face/load-font-face-child' - -describe('loadFontFace global', () => { - beforeAll(async () => { - const page = await program.navigateTo(PAGE_PATH) - await page.waitFor(2000) - }) - it('screenshot', async () => { - const image = await program.screenshot() - expect(image).toMatchImageSnapshot() - }) -}) diff --git a/pages/API/load-font-face/load-font-face.test.js b/pages/API/load-font-face/load-font-face.test.js index 548343c03b463c9db70cbc2aca8f1bda91076837..df73df3320f6379f9183248ec5506fe3cf4a0158 100644 --- a/pages/API/load-font-face/load-font-face.test.js +++ b/pages/API/load-font-face/load-font-face.test.js @@ -1,12 +1,19 @@ const PAGE_PATH = '/pages/API/load-font-face/load-font-face' +const CHILD_PAGE_PATH = "/pages/API/load-font-face/load-font-face-child"; -describe('loadFontFace', () => { +describe("loadFontFace", () => { beforeAll(async () => { - const page = await program.navigateTo(PAGE_PATH) - await page.waitFor(4000) - }) - it('screenshot', async () => { - const image = await program.screenshot() - expect(image).toMatchImageSnapshot() - }) -}) + const page = await program.navigateTo(PAGE_PATH); + await page.waitFor(3000); + }); + it("parent screenshot", async () => { + const image = await program.screenshot(); + expect(image).toMatchImageSnapshot(); + }); + it("child screenshot", async () => { + const page = await program.navigateTo(CHILD_PAGE_PATH); + await page.waitFor("view"); + const image = await program.screenshot(); + expect(image).toMatchImageSnapshot(); + }); +}); diff --git a/pages/API/navigator/navigator.test.js b/pages/API/navigator/navigator.test.js deleted file mode 100644 index 45c4efc021bac4de92266b8a4a8a93f744c5bfb9..0000000000000000000000000000000000000000 --- a/pages/API/navigator/navigator.test.js +++ /dev/null @@ -1,199 +0,0 @@ -jest.setTimeout(80000) -const CURRENT_PAGE_PATH = '/pages/API/navigator/navigator' -const CHILD1_PAGE_PATH = '/pages/API/navigator/new-page/new-page-1' -const CHILD2_PAGE_PATH = '/pages/API/navigator/new-page/new-page-2' - -describe('navigator', () => { - let page - let lifeCycleNum - - afterAll(async () => { - page = await program.reLaunch(CURRENT_PAGE_PATH) - const resetLifecycleNum = 1100 - await page.callMethod('setLifeCycleNum', resetLifecycleNum) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(resetLifecycleNum) - }) - - it('reLaunch', async () => { - page = await program.navigateTo(CURRENT_PAGE_PATH) - await page.waitFor(500) - await page.callMethod('setLifeCycleNum', 0) - await page.callMethod('reLaunch') - await page.waitFor(500) - page = await program.navigateTo(CURRENT_PAGE_PATH) - await page.waitFor(500) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(2) - }) - - it('navigateTo', async () => { - await page.callMethod('setLifeCycleNum', 0) - await page.callMethod('navigateTo') - await page.waitFor(500) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(2) - page = await program.navigateBack() - await page.waitFor(500) - }) - - it('navigateTo error page', async () => { - await page.callMethod('setLifeCycleNum', 0) - await page.callMethod('navigateToErrorPage') - await page.waitFor(500) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(2) - }) - - it('navigateTo debounce', async () => { - await page.callMethod('setLifeCycleNum', 0) - await page.callMethod('navigateToDebounce') - await page.waitFor(500) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(4) - page = await program.navigateBack() - await page.waitFor(500) - }) - - it('navigateTo relative path', async () => { - await page.callMethod('setLifeCycleNum', 0) - await page.callMethod('navigateToRelativePath1') - page = await program.navigateBack() - await page.waitFor(500) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(2) - await page.waitFor(500) - }) - - it('navigateTo relative path ./', async () => { - await page.callMethod('setLifeCycleNum', 0) - await page.callMethod('navigateToRelativePath2') - page = await program.navigateBack() - await page.waitFor(500) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(2) - await page.waitFor(500) - }) - - it('navigateTo relative path ../', async () => { - await page.callMethod('setLifeCycleNum', 0) - await page.callMethod('navigateToRelativePath3') - page = await program.navigateBack() - await page.waitFor(500) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(2) - await page.waitFor(500) - }) - - it('navigateBack', async () => { - await page.callMethod('setLifeCycleNum', 0) - await page.callMethod('navigateBack') - await page.waitFor(500) - page = await program.navigateTo(CURRENT_PAGE_PATH) - await page.waitFor(500) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(2) - }) - - it('navigateBackWithDelta1', async () => { - await page.callMethod('setLifeCycleNum', 0) - await page.callMethod('navigateBackWithDelta1') - await page.waitFor(1000) - page = await program.currentPage() - expect(`/${page.path}`).toBe(CURRENT_PAGE_PATH) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(2) - }) - - it('navigateBackWithDelta2', async () => { - await page.callMethod('setLifeCycleNum', 0) - await program.navigateTo(CHILD2_PAGE_PATH) - await page.waitFor(500) - page = await program.navigateTo(CHILD1_PAGE_PATH) - await page.waitFor(500) - await page.callMethod('navigateBackWithDelta2') - await page.waitFor(500) - page = await program.currentPage() - expect(`/${page.path}`).toBe(CURRENT_PAGE_PATH) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(10) - }) - - it('navigateBackWithDelta100', async () => { - page = await program.reLaunch(CURRENT_PAGE_PATH) - await page.callMethod('setLifeCycleNum', 0) - await page.callMethod('navigateBackWithDelta100') - await page.waitFor(1000) - page = await program.currentPage() - expect(`/${page.path}`).toBe(CURRENT_PAGE_PATH) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(2) - }) - - it('redirectTo', async () => { - await page.callMethod('setLifeCycleNum', 0) - await page.callMethod('redirectTo') - await page.waitFor(500) - page = await program.redirectTo(CURRENT_PAGE_PATH) - await page.waitFor(500) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(2) - }) - - it('switchTab', async () => { - page = await program.reLaunch(CURRENT_PAGE_PATH) - await page.callMethod('setLifeCycleNum', 0) - await page.callMethod('switchTab') - await page.waitFor(500) - page = await program.navigateTo(CURRENT_PAGE_PATH) - await page.waitFor(500) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(2) - }) - - it('20 times navigateTo', async () => { - const originPageStack = await program.pageStack() - page = await program.navigateTo(CHILD1_PAGE_PATH) - expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1)) - page = await program.navigateTo(CHILD2_PAGE_PATH) - expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1)) - page = await program.navigateTo(CHILD1_PAGE_PATH) - expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1)) - page = await program.navigateTo(CHILD2_PAGE_PATH) - expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1)) - page = await program.navigateTo(CHILD1_PAGE_PATH) - expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1)) - page = await program.navigateTo(CHILD2_PAGE_PATH) - expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1)) - page = await program.navigateTo(CHILD1_PAGE_PATH) - expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1)) - page = await program.navigateTo(CHILD2_PAGE_PATH) - expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1)) - page = await program.navigateTo(CHILD1_PAGE_PATH) - expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1)) - page = await program.navigateTo(CHILD2_PAGE_PATH) - expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1)) - page = await program.navigateTo(CHILD1_PAGE_PATH) - expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1)) - page = await program.navigateTo(CHILD2_PAGE_PATH) - expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1)) - page = await program.navigateTo(CHILD1_PAGE_PATH) - expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1)) - page = await program.navigateTo(CHILD2_PAGE_PATH) - expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1)) - page = await program.navigateTo(CHILD1_PAGE_PATH) - expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1)) - page = await program.navigateTo(CHILD2_PAGE_PATH) - expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1)) - page = await program.navigateTo(CHILD1_PAGE_PATH) - expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1)) - page = await program.navigateTo(CHILD2_PAGE_PATH) - expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1)) - page = await program.navigateTo(CHILD1_PAGE_PATH) - expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1)) - page = await program.navigateTo(CHILD2_PAGE_PATH) - expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1)) - const newPageStack = await program.pageStack() - expect(newPageStack.length - originPageStack.length).toBe(20) - }) -}) diff --git a/pages/API/navigator/new-page/new-page-2.test.js b/pages/API/navigator/new-page/new-page-2.test.js deleted file mode 100644 index 2ea7cadc05aaa00df4b62bb7280d8ed665b61755..0000000000000000000000000000000000000000 --- a/pages/API/navigator/new-page/new-page-2.test.js +++ /dev/null @@ -1,77 +0,0 @@ -jest.setTimeout(30000) -const PAGE_PATH = '/pages/API/navigator/new-page/new-page-2' -const INTERMEDIATE_PAGE_PATH = '/pages/API/navigator/navigator' -let page -let lifeCycleNum - -describe('app-lifecycle', () => { - it('onLaunch onShow', async () => { - page = await program.reLaunch(INTERMEDIATE_PAGE_PATH) - await page.waitFor(1000) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(1100) - }) - it('onLastPageBackPress', async () => { - page = await program.navigateBack() - await page.waitFor(1000) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(100) - - await page.callMethod('setLifeCycleNum', 0) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(0) - }) -}) - -describe('page-lifecycle', () => { - it('onLoad onShow onReady', async () => { - page = await program.reLaunch(PAGE_PATH) - await page.waitFor(1000) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(120) - await page.callMethod('setLifeCycleNum', 0) - }) - it('onPullDownRefresh', async () => { - await page.callMethod('pullDownRefresh') - await page.waitFor(1500) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(10) - await page.callMethod('setLifeCycleNum', 0) - }) - it('onPageScroll onReachBottom', async () => { - await program.pageScrollTo(2000) - const data = await page.data() - expect(data.isScrolled).toBe(true) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(10) - await page.callMethod('setLifeCycleNum', 0) - }) - it('onHide', async () => { - page = await program.navigateTo(INTERMEDIATE_PAGE_PATH) - await page.waitFor(1000) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(-10) - page = await program.navigateBack() - await page.waitFor(1000) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(0) - }) - it('onUnload', async () => { - page = await program.redirectTo(INTERMEDIATE_PAGE_PATH) - await page.waitFor(1000) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(-100) - await page.callMethod('setLifeCycleNum', 0) - }) - it('onBackPress', async () => { - page = await program.navigateTo(PAGE_PATH) - await page.waitFor(1000) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(120) - page = await program.navigateBack() - await page.waitFor(1000) - lifeCycleNum = await page.callMethod('getLifeCycleNum') - expect(lifeCycleNum).toBe(10) - await page.callMethod('setLifeCycleNum', 0) - }) -}) diff --git a/pages/API/navigator/new-page/new-page-2.uvue b/pages/API/navigator/new-page/new-page-2.uvue deleted file mode 100644 index 661f8bfcbf0d77dafd52163931c3d5e6f100b42f..0000000000000000000000000000000000000000 --- a/pages/API/navigator/new-page/new-page-2.uvue +++ /dev/null @@ -1,91 +0,0 @@ - - - - - diff --git a/pages/API/navigator/new-page/onLoad.test.js b/pages/API/navigator/new-page/onLoad.test.js index 933193ac4e66d8256654faf0f219ef64fbb9dd38..7708452ba04273098bec9bd9bc41a5b0e2c8e4a0 100644 --- a/pages/API/navigator/new-page/onLoad.test.js +++ b/pages/API/navigator/new-page/onLoad.test.js @@ -7,50 +7,50 @@ let page; describe("onLoad", () => { it("adjustData", async () => { page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - await page.waitFor(500); + await page.waitFor('view'); await page.callMethod("navigateToOnLoadWithType", "adjustData"); - await page.waitFor(1000); + await page.waitFor(500); const image = await program.screenshot(); expect(image).toMatchImageSnapshot(); }); it("navigateTo", async () => { page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - await page.waitFor(500); + await page.waitFor('view'); await page.callMethod("navigateToOnLoadWithType", "navigateTo"); - await page.waitFor(1000); + await page.waitFor(500); page = await program.currentPage(); expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); }); it("navigateBack", async () => { page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - await page.waitFor(500); + await page.waitFor('view'); await page.callMethod("navigateToOnLoadWithType", "navigateBack"); - await page.waitFor(1000); page = await program.currentPage(); + await page.waitFor('view'); expect(page.path).toBe(INTERMEDIATE_PAGE_PATH.substring(1)); }); it("redirectTo", async () => { page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - await page.waitFor(500); + await page.waitFor('view'); await page.callMethod("navigateToOnLoadWithType", "redirectTo"); - await page.waitFor(1000); + await page.waitFor(500); page = await program.currentPage(); expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); }); it("reLaunch", async () => { page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - await page.waitFor(500); + await page.waitFor('view'); await page.callMethod("navigateToOnLoadWithType", "reLaunch"); - await page.waitFor(1000); + await page.waitFor(500); page = await program.currentPage(); expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); }); it("switchTab", async () => { page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - await page.waitFor(500); + await page.waitFor('view'); await page.callMethod("navigateToOnLoadWithType", "switchTab"); - await page.waitFor(1000); page = await program.currentPage(); + await page.waitFor('view'); expect(page.path).toBe("pages/tabBar/component"); }); // toast 出现在 INTERMEDIATE_PAGE_PATH 页面(非 onLoad 生命周期所在页面) @@ -66,7 +66,7 @@ describe("onLoad", () => { // 同 toast // it("showLoading", async () => { // page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - // await page.waitFor(500); + // await page.waitFor('view'); // await page.callMethod("navigateToOnLoadWithType", "showLoading"); // await page.waitFor(1000); // const image = await program.screenshot(); @@ -75,7 +75,7 @@ describe("onLoad", () => { // 同 toast // it("showModal", async () => { // page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - // await page.waitFor(500); + // await page.waitFor('view'); // await page.callMethod("navigateToOnLoadWithType", "showModal"); // await page.waitFor(1000); // const image = await program.screenshot(); @@ -84,7 +84,7 @@ describe("onLoad", () => { // 同 toast // it("showActionSheet", async () => { // page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); - // await page.waitFor(500); + // await page.waitFor('view'); // await page.callMethod("navigateToOnLoadWithType", "showActionSheet"); // await page.waitFor(1000); // const image = await program.screenshot(); diff --git a/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js b/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js index 78e2ea174ded707b878bae3f8a9f274f9793587a..54cb43f3fe07110f4b75b8d6b253586bb03bd77a 100644 --- a/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js +++ b/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js @@ -24,6 +24,8 @@ describe("setCustomNavigationBarColor", () => { area: { x: 880, y: 0, width: 100, height: 60 }, }); expect(image).toMatchImageSnapshot(); + const lifeCycleNum = await page.callMethod("getLifeCycleNum"); + expect(lifeCycleNum - originLifeCycleNum).toBe(2); }); it("setNavigationBarColor1", async () => { @@ -34,5 +36,7 @@ describe("setCustomNavigationBarColor", () => { area: { x: 880, y: 0, width: 100, height: 60 }, }); expect(image).toMatchImageSnapshot(); + const lifeCycleNum = await page.callMethod("getLifeCycleNum"); + expect(lifeCycleNum - originLifeCycleNum).toBe(4); }); }); diff --git a/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue b/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue index dac025f6657c59c6d8354594fe969a577324e887..5ba29c1c43c9a2d0394664d6bf2faac1709dc73b 100644 --- a/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue +++ b/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue @@ -50,12 +50,15 @@ export default { success() { this.navigationBarTextColor = '#fff' console.log('setNavigationBarColor success') + this.setLifeCycleNum(state.lifeCycleNum + 1) }, fail() { - console.log('setNavigationBarColor success') + console.log('setNavigationBarColor fail') + this.setLifeCycleNum(state.lifeCycleNum - 1) }, complete() { - console.log('setNavigationBarColor success') + console.log('setNavigationBarColor complete') + this.setLifeCycleNum(state.lifeCycleNum + 1) } }) }, @@ -66,12 +69,15 @@ export default { success() { this.navigationBarTextColor = '#000' console.log('setNavigationBarColor success') + this.setLifeCycleNum(state.lifeCycleNum + 1) }, fail() { - console.log('setNavigationBarColor success') + console.log('setNavigationBarColor fail') + this.setLifeCycleNum(state.lifeCycleNum - 1) }, complete() { - console.log('setNavigationBarColor success') + console.log('setNavigationBarColor complete') + this.setLifeCycleNum(state.lifeCycleNum + 1) } }) }, diff --git a/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js b/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js index a293b96b61498f6afbb943c7b787affcb1313045..455947abd9aad6a7f347f5d7d3ffa0726ecf6aa0 100644 --- a/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js +++ b/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js @@ -16,14 +16,18 @@ describe('setNavigationBarColor', () => { expect(lifeCycleNum).toBe(originLifeCycleNum) }) - it('setNavigationBarColor1', async () => { - await page.callMethod('setNavigationBarColor1') - const image = await program.screenshot() - expect(image).toMatchImageSnapshot() - }) - it('setNavigationBarColor2', async () => { - await page.callMethod('setNavigationBarColor2') - const image = await program.screenshot() - expect(image).toMatchImageSnapshot() - }) + it("setNavigationBarColor1", async () => { + await page.callMethod("setNavigationBarColor1"); + const image = await program.screenshot(); + expect(image).toMatchImageSnapshot(); + const lifeCycleNum = await page.callMethod("getLifeCycleNum"); + expect(lifeCycleNum - originLifeCycleNum).toBe(2); + }); + it("setNavigationBarColor2", async () => { + await page.callMethod("setNavigationBarColor2"); + const image = await program.screenshot(); + expect(image).toMatchImageSnapshot(); + const lifeCycleNum = await page.callMethod("getLifeCycleNum"); + expect(lifeCycleNum - originLifeCycleNum).toBe(4); + }); }) diff --git a/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue b/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue index 913daf0a1c8f9c0d26cbd0c0831207abf84ae9ea..30efdc466659500bd55ac62980043bb890201600 100644 --- a/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue +++ b/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue @@ -26,12 +26,15 @@ export default { backgroundColor: '#00ff00', success() { console.log('setNavigationBarColor success') + this.setLifeCycleNum(state.lifeCycleNum + 1) }, fail() { - console.log('setNavigationBarColor success') + console.log('setNavigationBarColor fail') + this.setLifeCycleNum(state.lifeCycleNum - 1) }, complete() { - console.log('setNavigationBarColor success') + console.log('setNavigationBarColor complete') + this.setLifeCycleNum(state.lifeCycleNum + 1) } }) }, @@ -41,12 +44,15 @@ export default { backgroundColor: '#ff0000', success() { console.log('setNavigationBarColor success') + this.setLifeCycleNum(state.lifeCycleNum + 1) }, fail() { - console.log('setNavigationBarColor success') + console.log('setNavigationBarColor fail') + this.setLifeCycleNum(state.lifeCycleNum - 1) }, complete() { - console.log('setNavigationBarColor success') + console.log('setNavigationBarColor complete') + this.setLifeCycleNum(state.lifeCycleNum + 1) } }) }, @@ -66,12 +72,3 @@ export default { }, } - - diff --git a/pages/API/set-navigation-bar-title/set-navigation-bar-title.test.js b/pages/API/set-navigation-bar-title/set-navigation-bar-title.test.js new file mode 100644 index 0000000000000000000000000000000000000000..d16c75a23fcfb80571a41b5679169b5413977046 --- /dev/null +++ b/pages/API/set-navigation-bar-title/set-navigation-bar-title.test.js @@ -0,0 +1,26 @@ +const CURRENT_PAGE_PATH = + "/pages/API/set-navigation-bar-title/set-navigation-bar-title"; + +describe("setNavigationBarColor", () => { + let page; + let originLifeCycleNum; + beforeAll(async () => { + page = await program.navigateTo(CURRENT_PAGE_PATH); + await page.waitFor(1000); + originLifeCycleNum = await page.callMethod("getLifeCycleNum"); + }); + + afterAll(async () => { + await page.callMethod("setLifeCycleNum", originLifeCycleNum); + const lifeCycleNum = await page.callMethod("getLifeCycleNum"); + expect(lifeCycleNum).toBe(originLifeCycleNum); + }); + + it("setNavigationBarTitle", async () => { + await page.callMethod("setNavigationBarTitle"); + const image = await program.screenshot(); + expect(image).toMatchImageSnapshot(); + const lifeCycleNum = await page.callMethod("getLifeCycleNum"); + expect(lifeCycleNum - originLifeCycleNum).toBe(2); + }); +}); diff --git a/pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue b/pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue new file mode 100644 index 0000000000000000000000000000000000000000..5f917f3190b5911750b37f11499a7ee2b8c3ac69 --- /dev/null +++ b/pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue @@ -0,0 +1,49 @@ + + + diff --git a/pages/component/button/button.test.js b/pages/component/button/button.test.js index 76cb4fcf97225bab7c747ef39e81aa1bb3c21c30..7fb1a9084f0cdff2e33403316f61baa702e69b2e 100644 --- a/pages/component/button/button.test.js +++ b/pages/component/button/button.test.js @@ -4,7 +4,7 @@ describe('Button.uvue', () => { let page beforeAll(async () => { page = await program.reLaunch(PAGE_PATH) - await page.waitFor(500) + await page.waitFor('view') }) it('click', async () => { // TODO 待测试框架支持text的dispatchEvent @@ -41,12 +41,10 @@ describe('Button.uvue', () => { await page.setData({ type_enum_current: 1, }) - await page.waitFor(500) expect(await btn.property('type')).toBe('primary') await page.setData({ type_enum_current: 2, }) - await page.waitFor(500) expect(await btn.property('type')).toBe('warn') }) it('size', async () => { @@ -55,7 +53,6 @@ describe('Button.uvue', () => { await page.setData({ size_enum_current: 1, }) - await page.waitFor(500) expect(await btn.property('size')).toBe('mini') }) it('plain', async () => { @@ -64,7 +61,6 @@ describe('Button.uvue', () => { await page.setData({ plain_boolean: true, }) - await page.waitFor(500) expect(await btn.property('plain')).toBe(true) }) it('disabled', async () => { @@ -73,7 +69,6 @@ describe('Button.uvue', () => { await page.setData({ disabled_boolean: true, }) - await page.waitFor(500) expect(await btn.property('disabled')).toBe(true) }) -}) \ No newline at end of file +}) diff --git a/pages/component/checkbox/checkbox.test.js b/pages/component/checkbox/checkbox.test.js index c3a31094fc9de4ca992c0b4b016e18d83338f226..103e48bd033d0ed9ed308d55af95a62442f65507 100644 --- a/pages/component/checkbox/checkbox.test.js +++ b/pages/component/checkbox/checkbox.test.js @@ -8,7 +8,7 @@ function getData(key = '') { let page beforeAll(async () => { page = await program.reLaunch('/pages/component/checkbox/checkbox') - await page.waitFor(1000) + await page.waitFor('view') }) describe('Checkbox.uvue', () => { @@ -46,7 +46,6 @@ describe('Checkbox.uvue', () => { await page.setData({ checked: false, }) - await page.waitFor(500) expect(await cb.property('checked')).toBe(false) }) it('color', async () => { @@ -55,7 +54,6 @@ describe('Checkbox.uvue', () => { await page.setData({ color: '#63acfc', }) - await page.waitFor(500) expect(await cb.property('color')).toBe('#63acfc') }) it('disabled', async () => { @@ -64,7 +62,6 @@ describe('Checkbox.uvue', () => { await page.setData({ disabled: false, }) - await page.waitFor(500) expect(await cb.property('disabled')).toBe(false) }) }) diff --git a/pages/component/general-attribute/general-attribute.test.js b/pages/component/general-attribute/general-attribute.test.js index 2b3d46985745ce2e4d1aef67e61bc07671bb98f9..290b16a577a9149b69d37540c2f0e5075aeefc5a 100644 --- a/pages/component/general-attribute/general-attribute.test.js +++ b/pages/component/general-attribute/general-attribute.test.js @@ -5,7 +5,7 @@ describe('general attribute', () => { beforeAll(async () => { page = await program.navigateTo(PAGE_PATH) - await page.waitFor(1000) + await page.waitFor('view') }) it("class & style", async () => { const image = await program.screenshot(); @@ -20,7 +20,7 @@ describe('general attribute', () => { it("ref", async () => { const button = await page.$(".btn-ref"); await button.tap(); - await page.waitFor(1000); + await page.waitFor(500); const image = await program.screenshot(); expect(image).toMatchImageSnapshot(); }); diff --git a/pages/component/general-event/general-event.test.js b/pages/component/general-event/general-event.test.js index be05d4892f91fa854c239fd86c192cdf622ecd3f..ded3853e3ade9b306bb989785cc3cd324494c9e9 100644 --- a/pages/component/general-event/general-event.test.js +++ b/pages/component/general-event/general-event.test.js @@ -5,7 +5,7 @@ describe('event trigger sequence', () => { let el beforeAll(async () => { page = await program.navigateTo(PAGE_PATH) - await page.waitFor(1000) + await page.waitFor('view') el = await page.$('.target') }) diff --git a/pages/component/input/input.test.js b/pages/component/input/input.test.js index ab54276ea525e125c9cade9e66af3cab19cf2ee6..d419ddccac41c2ee20159e84c0f624a22ca3d2cc 100644 --- a/pages/component/input/input.test.js +++ b/pages/component/input/input.test.js @@ -73,54 +73,54 @@ describe('component-native-input', () => { // }) // }) // 测试placeholder - it("placeholder", async () => { - const placeholder1 = await page.$('.uni-input-placeholder1'); - expect(await placeholder1.property("placeholder-style")).toMatchObject({ - "color": "red" - }) - expect(await placeholder1.property("placeholder")).toEqual("占位符文字颜色为红色") - await page.setData({ - inputPlaceHolderStyle: "color:#CC00CC", - }) - expect(await placeholder1.property("placeholder-style")).toMatchObject({ - "color": "#CC00CC" - }) + // it("placeholder", async () => { + // const placeholder1 = await page.$('.uni-input-placeholder1'); + // expect(await placeholder1.property("placeholder-style")).toMatchObject({ + // "color": "red" + // }) + // expect(await placeholder1.property("placeholder")).toEqual("占位符文字颜色为红色") + // await page.setData({ + // inputPlaceHolderStyle: "color:#CC00CC", + // }) + // expect(await placeholder1.property("placeholder-style")).toMatchObject({ + // "color": "#CC00CC" + // }) - await page.setData({ - inputPlaceHolderStyle: "color:#CC19CC;background-color:#00b1c0", - }) - expect(await placeholder1.property("placeholder-style")).toMatchObject({ - "color": "#CC19CC", - "backgroundColor": "#00b1c0" - }) + // await page.setData({ + // inputPlaceHolderStyle: "color:#CC19CC;background-color:#00b1c0", + // }) + // expect(await placeholder1.property("placeholder-style")).toMatchObject({ + // "color": "#CC19CC", + // "backgroundColor": "#00b1c0" + // }) - await page.setData({ - inputPlaceHolderStyle: "color:#CC19CC;background-color:#00b1c0;text-align:center;font-size:44px;font-weight:900", - }) - expect(await placeholder1.property("placeholder-style")).toEqual({ - "backgroundColor": "#00b1c0", - "color": "#CC19CC", - "fontSize": "44px", - "fontWeight": "900", - "textAlign": "center" - }) + // await page.setData({ + // inputPlaceHolderStyle: "color:#CC19CC;background-color:#00b1c0;text-align:center;font-size:44px;font-weight:900", + // }) + // expect(await placeholder1.property("placeholder-style")).toEqual({ + // "backgroundColor": "#00b1c0", + // "color": "#CC19CC", + // "fontSize": "44px", + // "fontWeight": "900", + // "textAlign": "center" + // }) - const placeholder2 = await page.$('.uni-input-placeholder2'); - expect(await placeholder2.property("placeholder-class")).toMatchObject({ - "backgroundColor": "#008000" - }) - await page.setData({ - inputPlaceHolderClass: "uni-input-placeholder-class-ts", - }) - expect(await placeholder2.property("placeholder-class")).toMatchObject({ - "backgroundColor": "#FFA500" - }) - expect(await placeholder2.property("placeholder")).toEqual("占位符背景色为绿色") - }) + // const placeholder2 = await page.$('.uni-input-placeholder2'); + // expect(await placeholder2.property("placeholder-class")).toMatchObject({ + // "backgroundColor": "#008000" + // }) + // await page.setData({ + // inputPlaceHolderClass: "uni-input-placeholder-class-ts", + // }) + // expect(await placeholder2.property("placeholder-class")).toMatchObject({ + // "backgroundColor": "#FFA500" + // }) + // expect(await placeholder2.property("placeholder")).toEqual("占位符背景色为绿色") + // }) it("disable", async () => { const input = await page.$('.uni-input-disable'); - expect(await input.property("disabled")).toBe(true) + expect(await input.property("disabled")).toBe("true") }) it("confirm-type", async () => { @@ -139,10 +139,10 @@ describe('component-native-input', () => { // await page.waitFor(500) // }) - // it("afterAllTestScreenshot", async () => { - // const image = await program.screenshot({ - // fullPage: true - // }) - // expect(image).toMatchImageSnapshot() - // }) + it("afterAllTestScreenshot", async () => { + const image = await program.screenshot({ + fullPage: true + }) + expect(image).toMatchImageSnapshot() + }) }); diff --git a/pages/component/picker-view/picker-view.test.js b/pages/component/picker-view/picker-view.test.js index da7cb110b08cc9bd0dfbac50f4e48ba1255f403d..a4e515bf015885788dc6072db790bdb6718290cd 100644 --- a/pages/component/picker-view/picker-view.test.js +++ b/pages/component/picker-view/picker-view.test.js @@ -8,18 +8,18 @@ function getData(key = '') { let page beforeAll(async () => { page = await program.reLaunch('/pages/component/picker-view/picker-view') - await page.waitFor(1000) + await page.waitFor('view') }) describe('PickerView.uvue', () => { it('value', async () => { const el = await page.$('.picker-view') - await page.callMethod('setValue') + await page.callMethod('setValue') await page.waitFor(1000) expect(await el.property('value')).toEqual([0, 0, 0]) expect(await getData('result')).toEqual([0, 0, 0]) - await page.callMethod('setValue1') + await page.callMethod('setValue1') await page.waitFor(1000) expect(await el.property('value')).toEqual([10, 10, 10]) expect(await getData('result')).toEqual([10, 10, 10]) @@ -35,7 +35,7 @@ describe('PickerView.uvue', () => { const el = await page.$('.picker-view') await page.setData({ indicatorStyle: 'height: 100px;', - }) + }) await page.waitFor(500) expect(await el.property('indicatorStyle')).toBe('height: 100px;') }) @@ -44,7 +44,6 @@ describe('PickerView.uvue', () => { await page.setData({ maskTopStyle: 'background: #ffffff;', }) - await page.waitFor(500) expect(await el.property('mask-top-style')).toBe('background: #ffffff;') }) it('mask-bottom-style', async () => { @@ -52,7 +51,6 @@ describe('PickerView.uvue', () => { await page.setData({ maskBottomStyle: 'background: #ffffff;', }) - await page.waitFor(500) expect(await el.property('mask-bottom-style')).toBe('background: #ffffff;') }) }) diff --git a/pages/component/progress/progress.test.js b/pages/component/progress/progress.test.js index de652ae73b3cab09f68bae62d319a6d359bd8da1..66247251350f608ad78412423dc0aa92463cc79b 100644 --- a/pages/component/progress/progress.test.js +++ b/pages/component/progress/progress.test.js @@ -8,7 +8,7 @@ function getData(key = '') { let page beforeAll(async () => { page = await program.reLaunch('/pages/component/progress/progress') - await page.waitFor(1000) + await page.waitFor('view') }) describe('Progress.uvue', () => { @@ -17,14 +17,14 @@ describe('Progress.uvue', () => { const p1 = await page.$('.p1') const p2 = await page.$('.p2') const p3 = await page.$('.p3') - page.callMethod('setProgress') + await page.callMethod('setProgress') await page.waitFor(1000) expect(await p.property('percent')).toEqual(20) expect(await p1.property('percent')).toEqual(40) expect(await p2.property('percent')).toEqual(60) expect(await p3.property('percent')).toEqual(80) expect(await getData('curPercent')).toEqual(20) - page.callMethod('clearProgress') + await page.callMethod('clearProgress') await page.waitFor(1000) expect(await p.property('percent')).toEqual(0) expect(await p1.property('percent')).toEqual(0) @@ -42,7 +42,6 @@ describe('Progress.uvue', () => { await page.setData({ showInfo: false }) - await page.waitFor(500) expect(await el.property('show-info')).toEqual(false) }) it('border-radius', async () => { @@ -51,7 +50,6 @@ describe('Progress.uvue', () => { await page.setData({ borderRadius: 5 }) - await page.waitFor(500) expect(await el.property('border-radius')).toEqual(5) }) it('font-size', async () => { @@ -60,7 +58,6 @@ describe('Progress.uvue', () => { await page.setData({ fontSize: 18 }) - await page.waitFor(500) expect(await el.property('font-size')).toEqual(18) }) it('stroke-width', async () => { @@ -69,7 +66,6 @@ describe('Progress.uvue', () => { await page.setData({ strokeWidth: 6 }) - await page.waitFor(500) expect(await el.property('stroke-width')).toEqual(6) }) it('backgroundColor', async () => { @@ -78,7 +74,6 @@ describe('Progress.uvue', () => { await page.setData({ backgroundColor: "#007aff" }) - await page.waitFor(500) expect(await el.property('background-color')).toEqual('#007aff') }) -}) \ No newline at end of file +}) diff --git a/pages/component/radio/radio.test.js b/pages/component/radio/radio.test.js index e5e175f120bcf0753bc14a5c3f300c5c573ed150..b0642430e5add02f6a5ac0d87ae8708541b5376b 100644 --- a/pages/component/radio/radio.test.js +++ b/pages/component/radio/radio.test.js @@ -8,7 +8,7 @@ function getData(key = '') { let page beforeAll(async () => { page = await program.reLaunch('/pages/component/radio/radio') - await page.waitFor(1000) + await page.waitFor('view') }) describe('Radio.uvue', () => { @@ -44,7 +44,6 @@ describe('Radio.uvue', () => { await page.setData({ checked: false, }) - await page.waitFor(500) expect(await radio.property('checked')).toBe(false) }) it('color', async () => { @@ -53,7 +52,6 @@ describe('Radio.uvue', () => { await page.setData({ color: '#63acfc', }) - await page.waitFor(500) expect(await radio.property('color')).toBe('#63acfc') }) it('disabled', async () => { @@ -62,7 +60,6 @@ describe('Radio.uvue', () => { await page.setData({ disabled: false, }) - await page.waitFor(500) expect(await radio.property('disabled')).toBe(false) }) }) diff --git a/pages/component/textarea/textarea.test.js b/pages/component/textarea/textarea.test.js index 7f7f57c00f23afd45087878be4fdcc3371ea3ea1..dc97a1e478313c75f5f9b85408cf5b9cd00247af 100644 --- a/pages/component/textarea/textarea.test.js +++ b/pages/component/textarea/textarea.test.js @@ -12,12 +12,12 @@ describe('component-native-textarea', () => { }); it('focus', async () => { - expect(await textarea.property("focus")).toBe(false) + expect(await textarea.property("focus")).toBe("false") await page.setData({ focus_boolean: true, }) await page.waitFor(500) - expect(await textarea.property("focus")).toBe(true) + expect(await textarea.property("focus")).toBe("true") }); /* it("auto-height", async () => { await page.setData({ diff --git a/pages/component/video/video.uvue b/pages/component/video/video.uvue index 0d0cccc3af9eca3175257b19dad1f6f414051c6c..30a3084c68e2ee7566e14da1b808c87858426d6a 100644 --- a/pages/component/video/video.uvue +++ b/pages/component/video/video.uvue @@ -223,7 +223,8 @@ }, pause: function () { console.log("pause"); - this.videoContext?.pause(); + (uni.getElementById("video") as UniVideoElement).pause(); //as写法测试。注意id不对时as会崩溃 + // this.videoContext?.pause(); }, seek: function (pos : number) { console.log("seek -> " + pos); @@ -239,7 +240,8 @@ }, stop: function () { console.log("stop"); - this.videoContext?.stop(); + uni.getElementById("video")?.stop(); //泛型写法测试 + // this.videoContext?.stop(); }, sendDanmu: function (danmu : Danmu) { console.log("sendDanmu -> " + danmu); diff --git a/pages/tabBar/API.uvue b/pages/tabBar/API.uvue index 46c4a3fa88d98c9287dc5148ef4bf8d82395bdc7..a002cb775d8a7d192aaaab6bdabcdf8547f41cf7 100644 --- a/pages/tabBar/API.uvue +++ b/pages/tabBar/API.uvue @@ -102,12 +102,11 @@ url: 'navigator', api: ["navigateTo", "reLaunch", "navigateBack", "redirectTo", "switchTab"] }, - /* + { name: '设置导航条标题', url: 'set-navigation-bar-title', - enable: false, - }, */ + }, { name: '设置导航条颜色', url: 'set-navigation-bar-color', @@ -253,7 +252,11 @@ { name: '电量', url: 'get-battery-info', - }, + }, + { + name: '安装Apk', + url: 'install-apk' + } /* { name: "打电话", url: "make-phone-call", diff --git a/pages/template/custom-tab-bar/custom-tab-bar-tab1.uvue b/pages/template/custom-tab-bar/custom-tab-bar-tab1.uvue index 8d399308bfeda2b1c5b343cc46fdeda17e5e640f..c0b2f1528e3b10055108a75fb03d5e0dfc384cdc 100644 --- a/pages/template/custom-tab-bar/custom-tab-bar-tab1.uvue +++ b/pages/template/custom-tab-bar/custom-tab-bar-tab1.uvue @@ -35,7 +35,7 @@ uni.$emit('tabchange', e.detail.scrollTop) }, scrollTop(top : number) { - (this.$refs["listView"] as Element).setAttribute('scrollTop', top) + (this.$refs["listView"] as Element).scrollTop = top } } } diff --git a/pages/template/long-list/long-list-page.uvue b/pages/template/long-list/long-list-page.uvue index cfa34b28da3e36e4ab2481f161e08cfe8fd2340b..bec3a4234b4bfefc2489935f19cd458cb6bcea2c 100644 --- a/pages/template/long-list/long-list-page.uvue +++ b/pages/template/long-list/long-list-page.uvue @@ -1,5 +1,5 @@