diff --git a/pages/API/action-sheet/action-sheet.test.js b/pages/API/action-sheet/action-sheet.test.js new file mode 100644 index 0000000000000000000000000000000000000000..ff37aa33f6aed5d431cfdac18509034e2c673573 --- /dev/null +++ b/pages/API/action-sheet/action-sheet.test.js @@ -0,0 +1,540 @@ +// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/ + +describe('API-loading', () => { + + let page; + const isAndroid = process.env.UNI_OS_NAME === "android"; + + beforeAll(async () => { + page = await program.reLaunch('/pages/API/action-sheet/action-sheet') + await page.waitFor(200); + + }); + + + it("onload-action-sheet-test", async () => { + if (isAndroid) { + + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + width:windowWidth + }, + }); + + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + }) + + + it("action-sheet-test-current-0", async () => { + + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; + + + await page.setData({ + showErrorToast:false, + current: 0, + itemContentLarge:false, + itemNumLargeSelect:false, + itemColorCustom:false, + }) + + const btnToastDurationButton = await page.$('#btn-action-sheet-show') + await btnToastDurationButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + width:windowWidth + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + + }) + + + it("action-sheet-test-current-0-largeContent", async () => { + + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; + + + await page.setData({ + showErrorToast:false, + current: 0, + itemContentLarge:true, + itemNumLargeSelect:false, + itemColorCustom:false, + }) + + const btnToastDurationButton = await page.$('#btn-action-sheet-show') + await btnToastDurationButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + width:windowWidth + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + + }) + + + it("action-sheet-test-current-0-largeContent-largeNum", async () => { + + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; + + await page.setData({ + showErrorToast:false, + current: 0, + itemContentLarge:true, + itemNumLargeSelect:true, + itemColorCustom:false, + }) + + const btnToastDurationButton = await page.$('#btn-action-sheet-show') + await btnToastDurationButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + width:windowWidth + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + + }) + + + it("action-sheet-test-current-0-largeContent-largeNum-customColor", async () => { + + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; + + await page.setData({ + showErrorToast:false, + current: 0, + itemContentLarge:true, + itemNumLargeSelect:true, + itemColorCustom:true, + }) + + const btnToastDurationButton = await page.$('#btn-action-sheet-show') + await btnToastDurationButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + width:windowWidth + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + }) + + + + it("action-sheet-test-current-1", async () => { + + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; + + + await page.setData({ + current: 1, + itemContentLarge:false, + itemNumLargeSelect:false, + itemColorCustom:false, + }) + + const btnToastDurationButton = await page.$('#btn-action-sheet-show') + await btnToastDurationButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + width:windowWidth + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + + + }) + + + + it("action-sheet-test-current-1-largeContent", async () => { + + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; + + + await page.setData({ + showErrorToast:false, + current: 1, + itemContentLarge:true, + itemNumLargeSelect:false, + itemColorCustom:false, + }) + + const btnToastDurationButton = await page.$('#btn-action-sheet-show') + await btnToastDurationButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + width:windowWidth + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + + }) + + + it("action-sheet-test-current-1-largeContent-largeNum", async () => { + + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; + + await page.setData({ + showErrorToast:false, + current: 1, + itemContentLarge:true, + itemNumLargeSelect:true, + itemColorCustom:false, + }) + + const btnToastDurationButton = await page.$('#btn-action-sheet-show') + await btnToastDurationButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + width:windowWidth + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + + }) + + + it("action-sheet-test-current-1-largeContent-largeNum-customColor", async () => { + + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; + + await page.setData({ + showErrorToast:false, + current: 1, + itemContentLarge:true, + itemNumLargeSelect:true, + itemColorCustom:true, + }) + + const btnToastDurationButton = await page.$('#btn-action-sheet-show') + await btnToastDurationButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + width:windowWidth + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + }) + + + + it("action-sheet-test-current-2", async () => { + + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; + + + await page.setData({ + current: 2, + itemContentLarge:false, + itemNumLargeSelect:false, + itemColorCustom:false, + }) + + const btnToastDurationButton = await page.$('#btn-action-sheet-show') + await btnToastDurationButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + width:windowWidth + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + + }) + + + it("action-sheet-test-current-2-largeContent", async () => { + + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; + + + await page.setData({ + showErrorToast:false, + current: 2, + itemContentLarge:true, + itemNumLargeSelect:false, + itemColorCustom:false, + }) + + const btnToastDurationButton = await page.$('#btn-action-sheet-show') + await btnToastDurationButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + width:windowWidth + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + + }) + + + it("action-sheet-test-current-2-largeContent-largeNum", async () => { + + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; + + await page.setData({ + showErrorToast:false, + current: 2, + itemContentLarge:true, + itemNumLargeSelect:true, + itemColorCustom:false, + }) + + const btnToastDurationButton = await page.$('#btn-action-sheet-show') + await btnToastDurationButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + width:windowWidth + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + + }) + + + it("action-sheet-test-current-2-largeContent-largeNum-customColor", async () => { + + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + const windowWidth = res.windowWidth * res.pixelRatio; + + await page.setData({ + showErrorToast:false, + current: 2, + itemContentLarge:true, + itemNumLargeSelect:true, + itemColorCustom:true, + }) + + const btnToastDurationButton = await page.$('#btn-action-sheet-show') + await btnToastDurationButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + width:windowWidth + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + }) + + + +}); diff --git a/pages/API/action-sheet/action-sheet.uvue b/pages/API/action-sheet/action-sheet.uvue index 90deb477d7039c6b301ce4aa1216aabef5edea59..2642faa5868fdc7959b68e3daf3f799f0722d82e 100644 --- a/pages/API/action-sheet/action-sheet.uvue +++ b/pages/API/action-sheet/action-sheet.uvue @@ -25,7 +25,7 @@ - + @@ -41,7 +41,8 @@ title: 'action-sheet', itemColorCustom: false, itemContentLarge: false, - itemNumLargeSelect: false, + itemNumLargeSelect: false, + showErrorToast:true, items: [{ value: '标题', name: '有标题' @@ -64,7 +65,11 @@ itemList:['item1', 'item2'], }) }, - methods: { + methods: { + //自动化测试例专用 + jest_getWindowInfo() : GetWindowInfoResult { + return uni.getWindowInfo(); + }, radioChange(e : UniRadioGroupChangeEvent) { for (let i = 0; i < this.items.length; i++) { if (this.items[i].value === e.detail.value) { @@ -127,11 +132,13 @@ }) }, fail: (e) => { - console.log(e); - uni.showToast({ - title: e.errMsg, - icon: "none" - }) + console.log(e); + if(this.showErrorToast){ + uni.showToast({ + title: e.errMsg, + icon: "none" + }) + } } }) } diff --git a/pages/API/loading/loading.test.js b/pages/API/loading/loading.test.js new file mode 100644 index 0000000000000000000000000000000000000000..657c35088d5543a21ad7c5556f3f40ec82855091 --- /dev/null +++ b/pages/API/loading/loading.test.js @@ -0,0 +1,42 @@ +// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/ + +describe('API-loading', () => { + + let page; + const isAndroid = process.env.UNI_OS_NAME === "android"; + + beforeAll(async () => { + page = await program.reLaunch('/pages/API/loading/loading') + + await page.waitFor(200); + + }); + + + + // it("onload-loading-test", async () => { + // if (isAndroid) { + // const res = await page.callMethod('jest_getWindowInfo') + // const windowHeight = res.windowHeight * res.pixelRatio; + // const windowWidth = res.windowWidth * res.pixelRatio; + // const image = await program.screenshot({ + // adb: true, + // area: { + // x: 0, + // y: windowHeight / 2 + 120, + // height: windowHeight / 2, + // width:windowWidth + // }, + // }); + // expect(image).toMatchImageSnapshot(); + // }else{ + // const image = await program.screenshot({ + // adb: true, + // fullPage: true + // }); + // expect(image).toMatchImageSnapshot() + // } + // }) + + +}); diff --git a/pages/API/loading/loading.uvue b/pages/API/loading/loading.uvue index 76acb14faa880552659bf95a400398c4284a0d71..468ebbbdfa8174387348744a25022dffe1416f14 100644 --- a/pages/API/loading/loading.uvue +++ b/pages/API/loading/loading.uvue @@ -67,6 +67,10 @@ }, 2000); }, methods: { + //自动化测试例专用 + jest_getWindowInfo() : GetWindowInfoResult { + return uni.getWindowInfo(); + }, radioChange(e : UniRadioGroupChangeEvent) { const selected = this.items.find((item) : boolean => { diff --git a/pages/API/modal/modal.test.js b/pages/API/modal/modal.test.js new file mode 100644 index 0000000000000000000000000000000000000000..01f2012bd9a70685f2ed7bf7a3dd30d423690464 --- /dev/null +++ b/pages/API/modal/modal.test.js @@ -0,0 +1,702 @@ +// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/ + +describe('API-loading', () => { + + let page; + const isAndroid = process.env.UNI_OS_NAME === "android"; + + beforeAll(async () => { + page = await program.reLaunch('/pages/API/modal/modal') + await page.waitFor(200); + + }); + + + it("onload-modal-test", async () => { + if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + }) + + + it("modal-test-current-0", async () => { + + await page.setData({ + current: 0, + showCancelSelect: false, + cancelTextSelect: false, + confirmTextSelect: false, + editableSelect: false, + placeholderTextSelect: false, + }) + + const btnModalButton = await page.$('#btn-modal-show') + await btnModalButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + }) + + + it("modal-test-current-1", async () => { + + await page.setData({ + current: 1, + showCancelSelect: false, + cancelTextSelect: false, + confirmTextSelect: false, + editableSelect: false, + placeholderTextSelect: false, + }) + + const btnModalButton = await page.$('#btn-modal-show') + await btnModalButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + }) + + + it("modal-test-current-2", async () => { + + await page.setData({ + current: 2, + showCancelSelect: false, + cancelTextSelect: false, + confirmTextSelect: false, + editableSelect: false, + placeholderTextSelect: false, + }) + + const btnModalButton = await page.$('#btn-modal-show') + await btnModalButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + }) + + + it("modal-test-current-2-showCancel", async () => { + + await page.setData({ + current: 2, + showCancelSelect: true, + cancelTextSelect: false, + confirmTextSelect: false, + editableSelect: false, + placeholderTextSelect: false, + }) + + const btnModalButton = await page.$('#btn-modal-show') + await btnModalButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + }) + + + it("modal-test-current-2-showCancel-cancelText", async () => { + + await page.setData({ + current: 2, + showCancelSelect: true, + cancelTextSelect: true, + confirmTextSelect: false, + editableSelect: false, + placeholderTextSelect: false, + }) + + const btnModalButton = await page.$('#btn-modal-show') + await btnModalButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + }) + + + it("modal-test-current-2-showCancel-cancelText-confirmText", async () => { + + await page.setData({ + current: 2, + showCancelSelect: true, + cancelTextSelect: true, + confirmTextSelect: true, + editableSelect: false, + placeholderTextSelect: false, + }) + + const btnModalButton = await page.$('#btn-modal-show') + await btnModalButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + }) + + + it("modal-test-current-2-showCancel-cancelText-confirmText-editable-placeholder", async () => { + + await page.setData({ + current: 2, + showCancelSelect: true, + cancelTextSelect: true, + confirmTextSelect: true, + editableSelect: true, + placeholderTextSelect: true, + }) + + const btnModalButton = await page.$('#btn-modal-show') + await btnModalButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + }) + + + it("modal-test-current-2-showCancel-confirmText-editable-placeholder", async () => { + + await page.setData({ + current: 2, + showCancelSelect: true, + cancelTextSelect: false, + confirmTextSelect: true, + editableSelect: true, + placeholderTextSelect: true, + }) + + const btnModalButton = await page.$('#btn-modal-show') + await btnModalButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + }) + + + it("modal-test-current-2-showCancel-editable-placeholder", async () => { + + await page.setData({ + current: 2, + showCancelSelect: true, + cancelTextSelect: false, + confirmTextSelect: false, + editableSelect: true, + placeholderTextSelect: true, + }) + + const btnModalButton = await page.$('#btn-modal-show') + await btnModalButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + }) + + + it("modal-test-current-2-showCancel-placeholder", async () => { + + await page.setData({ + current: 2, + showCancelSelect: true, + cancelTextSelect: false, + confirmTextSelect: false, + editableSelect: false, + placeholderTextSelect: true, + }) + + const btnModalButton = await page.$('#btn-modal-show') + await btnModalButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + }) + + + it("modal-test-current-2-showCancel", async () => { + + await page.setData({ + current: 2, + showCancelSelect: true, + cancelTextSelect: false, + confirmTextSelect: false, + editableSelect: false, + placeholderTextSelect: false, + }) + + const btnModalButton = await page.$('#btn-modal-show') + await btnModalButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + }) + + + it("modal-test-current-2-showCancel-cancelText-editable-placeholder", async () => { + + await page.setData({ + current: 2, + showCancelSelect: true, + cancelTextSelect: true, + confirmTextSelect: false, + editableSelect: true, + placeholderTextSelect: true, + }) + + const btnModalButton = await page.$('#btn-modal-show') + await btnModalButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + }) + + + it("modal-test-current-2-showCancel-cancelText-placeholder", async () => { + + await page.setData({ + current: 2, + showCancelSelect: true, + cancelTextSelect: true, + confirmTextSelect: false, + editableSelect: false, + placeholderTextSelect: true, + }) + + const btnModalButton = await page.$('#btn-modal-show') + await btnModalButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + }) + + + it("modal-test-current-2-showCancel-cancelText", async () => { + + await page.setData({ + current: 2, + showCancelSelect: true, + cancelTextSelect: true, + confirmTextSelect: false, + editableSelect: false, + placeholderTextSelect: false, + }) + + const btnModalButton = await page.$('#btn-modal-show') + await btnModalButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + }) + + + + it("modal-test-current-2-showCancel-cancelText-confirmText-placeholder", async () => { + + await page.setData({ + current: 2, + showCancelSelect: true, + cancelTextSelect: true, + confirmTextSelect: true, + editableSelect: false, + placeholderTextSelect: true, + }) + + const btnModalButton = await page.$('#btn-modal-show') + await btnModalButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + }) + + + it("modal-test-current-2-showCancel-cancelText-confirmText", async () => { + + await page.setData({ + current: 2, + showCancelSelect: true, + cancelTextSelect: true, + confirmTextSelect: true, + editableSelect: false, + placeholderTextSelect: false, + }) + + const btnModalButton = await page.$('#btn-modal-show') + await btnModalButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + }) + + + it("modal-test-current-2-showCancel-cancelText-confirmText-editable", async () => { + + await page.setData({ + current: 2, + showCancelSelect: true, + cancelTextSelect: true, + confirmTextSelect: true, + editableSelect: true, + placeholderTextSelect: false, + }) + + const btnModalButton = await page.$('#btn-modal-show') + await btnModalButton.tap() + await page.waitFor(500); + + if (isAndroid) { + const res = await page.callMethod('jest_getWindowInfo') + const windowHeight = res.windowHeight * res.pixelRatio; + + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + height: windowHeight, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + + }) + +}); diff --git a/pages/API/modal/modal.uvue b/pages/API/modal/modal.uvue index 0d3acc7e2002d8f275750d9aad35b9b16fe657cb..a17b1c1bdc280010d1644889a14d1893e1611afe 100644 --- a/pages/API/modal/modal.uvue +++ b/pages/API/modal/modal.uvue @@ -37,7 +37,7 @@ - @@ -87,6 +87,10 @@ }) }, methods: { + //自动化测试例专用 + jest_getWindowInfo() : GetWindowInfoResult { + return uni.getWindowInfo(); + }, showCancelChange: function (e : UniSwitchChangeEvent) { this.showCancelSelect = e.detail.value }, diff --git a/pages/API/toast/toast.test.js b/pages/API/toast/toast.test.js new file mode 100644 index 0000000000000000000000000000000000000000..05c94e65e53574e07c3b91b3d6141ad010b17bd6 --- /dev/null +++ b/pages/API/toast/toast.test.js @@ -0,0 +1,161 @@ +// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/ + +describe('API-toast', () => { + + let page; + const isAndroid = process.env.UNI_OS_NAME === "android"; + + beforeAll(async () => { + page = await program.reLaunch('/pages/API/toast/toast') + await page.waitFor(600); + }); + + + + it("onload-toast-test", async () => { + if (isAndroid) { + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + }) + + + + it("btn-toast-default-1", async () => { + const btnToastDefaultButton = await page.$('#btn-toast-default') + await btnToastDefaultButton.tap() + await page.waitFor(200) + if (isAndroid) { + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + }) + + + + it("btn-toast-duration-1", async () => { + const btnToastDurationButton = await page.$('#btn-toast-duration') + await btnToastDurationButton.tap() + await page.waitFor(2000) + if (isAndroid) { + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + }) + + it("btn-toast-errorIcon-1", async () => { + const btnToastErrorIconButton = await page.$('#btn-toast-errorIcon') + await btnToastErrorIconButton.tap() + await page.waitFor(200) + if (isAndroid) { + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + }) + + + it("btn-toast-loading-1", async () => { + const btnToastLoadingButton = await page.$('#btn-toast-loading') + await btnToastLoadingButton.tap() + await page.waitFor(200) + + const btnToastHideButton = await page.$('#btn-toast-hide') + await btnToastHideButton.tap() + await page.waitFor(200) + + if (isAndroid) { + const image = await program.screenshot({ + adb: true, + area: { + x: 0, + y: 200, + }, + }); + expect(image).toMatchImageSnapshot(); + }else{ + const image = await program.screenshot({ + adb: true, + fullPage: true + }); + expect(image).toMatchImageSnapshot() + } + }) + + + // it("btn-toast-postion-bottom-1", async () => { + // const btnToastButton = await page.$('#btn-toast-postion-bottom') + // await btnToastButton.tap() + // await page.waitFor(200) + // if (isAndroid) { + // const windowHeight = uni.getWindowInfo().windowHeight; + // const windowWidth = uni.getWindowInfo().windowWidth; + // const image = await program.screenshot({ + // adb: true, + // area: { + // x: 0, + // y: 200, + // height: windowHeight, + // width:windowWidth + // }, + // }); + // expect(image).toMatchImageSnapshot(); + // }else{ + // const image = await program.screenshot({ + // adb: true, + // fullPage: true + // }); + // expect(image).toMatchImageSnapshot() + // } + // }) + + + +}); diff --git a/pages/API/toast/toast.uvue b/pages/API/toast/toast.uvue index 4e6b8f96b17eaf6992fb895e2341ff798bea7383..8ad3f8a08a7e70fb9596bf284b2e499990fec8c4 100644 --- a/pages/API/toast/toast.uvue +++ b/pages/API/toast/toast.uvue @@ -3,17 +3,17 @@ - - - - + + + + - + - + {{exeRet}} @@ -41,7 +41,7 @@ uni.showToast({ title: "默认", success: (res) => { - this.exeRet = "success:" + JSON.stringify(res) + new Date() + this.exeRet = "success:" + JSON.stringify(res) }, fail: (res) => { this.exeRet = "fail:" + JSON.stringify(res) @@ -53,7 +53,7 @@ title: "默认", icon: 'error', success: (res) => { - this.exeRet = "success:" + JSON.stringify(res) + new Date() + this.exeRet = "success:" + JSON.stringify(res) }, fail: (res) => { this.exeRet = "fail:" + JSON.stringify(res) @@ -65,7 +65,7 @@ title: "duration 3000", duration: 3000, success: (res) => { - this.exeRet = "success:" + JSON.stringify(res) + new Date() + this.exeRet = "success:" + JSON.stringify(res) }, fail: (res) => { this.exeRet = "fail:" + JSON.stringify(res) @@ -78,7 +78,7 @@ icon: "loading", duration: 5000, success: (res) => { - this.exeRet = "success:" + JSON.stringify(res) + new Date() + this.exeRet = "success:" + JSON.stringify(res) }, fail: (res) => { this.exeRet = "fail:" + JSON.stringify(res) @@ -90,7 +90,7 @@ title: "logo", image: "/static/uni.png", success: (res) => { - this.exeRet = "success:" + JSON.stringify(res) + new Date() + this.exeRet = "success:" + JSON.stringify(res) }, fail: (res) => { this.exeRet = "fail:" + JSON.stringify(res) @@ -103,7 +103,7 @@ title: "显示一段轻提示", position: 'bottom', success: (res) => { - this.exeRet = "success:" + JSON.stringify(res) + new Date() + this.exeRet = "success:" + JSON.stringify(res) }, fail: (res) => { this.exeRet = "fail:" + JSON.stringify(res)