From 8c6d49f3e29ca42b3edd4699abb7fd30632eb183 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Thu, 21 Nov 2024 19:44:43 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E5=A4=84=E7=90=86=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E5=85=BC=E5=AE=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global-events/global-events.test.js | 125 ++++++++++++------ .../global-properties/global-properties.uvue | 65 ++++----- pages/component/list-view/issue-2199.test.js | 12 +- .../list-view-children-in-slot.test.js | 10 ++ .../list-view/list-view-multiplex.test.js | 10 ++ pages/component/list-view/list-view.test.js | 22 ++- .../nested-scroll-body.test.js | 10 ++ .../nested-scroll-header.test.js | 10 ++ .../sticky-header/sticky-header.test.js | 10 ++ .../sticky-section/sticky-section.test.js | 12 +- pages/component/swiper/swiper2.test.js | 6 +- 11 files changed, 208 insertions(+), 84 deletions(-) diff --git a/pages/component/global-events/global-events.test.js b/pages/component/global-events/global-events.test.js index 1594db5e..0198554f 100644 --- a/pages/component/global-events/global-events.test.js +++ b/pages/component/global-events/global-events.test.js @@ -1,3 +1,5 @@ +const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() +const isMP = platformInfo.startsWith('mp') const PAGE_PATH = '/pages/component/global-events/global-events' describe('event trigger', () => { @@ -177,55 +179,90 @@ describe('event trigger', () => { } }) - it('click', async () => { - const el = await page.$('#longpress-target') - await el.tap() - const targetX = '0' - const targetY = '0' - const tapEventX = await page.$('#tap-event-x') - expect(await tapEventX.text()).toBe(targetX) - const tapEventY = await page.$('#tap-event-y') - expect(await tapEventY.text()).toBe(targetY) - const clickEventX = await page.$('#click-event-x') - expect(await clickEventX.text()).toBe(targetX) - const clickEventY = await page.$('#click-event-y') - expect(await clickEventY.text()).toBe(targetY) + it('click', async () => { + if (isMP) { + page = await program.navigateTo(PAGE_PATH) + await page.waitFor('view') + const el = await page.$('#longpress-target') + await el.tap() + await page.waitFor(500) + const clickEventX = await page.$('#click-event-x') + expect(parseInt(await clickEventX.text())).toBeGreaterThan(0) + const clickEventY = await page.$('#click-event-y') + expect(parseInt(await clickEventY.text())).toBeGreaterThan(0) + } else { + const el = await page.$('#longpress-target') + await el.tap() + const targetX = '0' + const targetY = '0' + const tapEventX = await page.$('#tap-event-x') + expect(await tapEventX.text()).toBe(targetX) + const tapEventY = await page.$('#tap-event-y') + expect(await tapEventY.text()).toBe(targetY) + const clickEventX = await page.$('#click-event-x') + expect(await clickEventX.text()).toBe(targetX) + const clickEventY = await page.$('#click-event-y') + expect(await clickEventY.text()).toBe(targetY) + } }) it('longPress', async () => { if (!process.env.UNI_AUTOMATOR_APP_WEBVIEW) { const el = await page.$('#longpress-target') await el.longpress() - const longPressTouchTargetIdentifier = '1' - const longPressTouchTargetValue = '0' - const longPressTouchIdentifier = await page.$('#long-press-touch-identifier') - expect(await longPressTouchIdentifier.text()).toBe(longPressTouchTargetIdentifier) - const longPressTouchPageX = await page.$('#long-press-touch-page-x') - expect(await longPressTouchPageX.text()).toBe(longPressTouchTargetValue) - const longPressTouchPageY = await page.$('#long-press-touch-page-y') - expect(await longPressTouchPageY.text()).toBe(longPressTouchTargetValue) - const longPressTouchClientX = await page.$('#long-press-touch-client-x') - expect(await longPressTouchClientX.text()).toBe(longPressTouchTargetValue) - const longPressTouchClientY = await page.$('#long-press-touch-client-y') - expect(await longPressTouchClientY.text()).toBe(longPressTouchTargetValue) - const longPressTouchScreenX = await page.$('#long-press-touch-screen-x') - expect(await longPressTouchScreenX.text()).toBe(longPressTouchTargetValue) - const longPressTouchScreenY = await page.$('#long-press-touch-screen-y') - expect(await longPressTouchScreenY.text()).toBe(longPressTouchTargetValue) - const longPressChangedTouchIdentifier = await page.$('#long-press-changed-touch-identifier') - expect(await longPressChangedTouchIdentifier.text()).toBe(longPressTouchTargetIdentifier) - const longPressChangedTouchPageX = await page.$('#long-press-changed-touch-page-x') - expect(await longPressChangedTouchPageX.text()).toBe(longPressTouchTargetValue) - const longPressChangedTouchPageY = await page.$('#long-press-changed-touch-page-y') - expect(await longPressChangedTouchPageY.text()).toBe(longPressTouchTargetValue) - const longPressChangedTouchClientX = await page.$('#long-press-changed-touch-client-x') - expect(await longPressChangedTouchClientX.text()).toBe(longPressTouchTargetValue) - const longPressChangedTouchClientY = await page.$('#long-press-changed-touch-client-y') - expect(await longPressChangedTouchClientY.text()).toBe(longPressTouchTargetValue) - const longPressChangedTouchScreenX = await page.$('#long-press-changed-touch-screen-x') - expect(await longPressChangedTouchScreenX.text()).toBe(longPressTouchTargetValue) - const longPressChangedTouchScreenY = await page.$('#long-press-changed-touch-screen-y') - expect(await longPressChangedTouchScreenY.text()).toBe(longPressTouchTargetValue) + if (isMP) { + const longPressTouchIdentifier = await page.$('#long-press-touch-identifier') + expect(await longPressTouchIdentifier.text()).toBe('0') + const longPressTouchPageX = await page.$('#long-press-touch-page-x') + expect(parseInt(await longPressTouchPageX.text())).toBeGreaterThan(0) + const longPressTouchPageY = await page.$('#long-press-touch-page-y') + expect(parseInt(await longPressTouchPageY.text())).toBeGreaterThan(0) + const longPressTouchClientX = await page.$('#long-press-touch-client-x') + expect(parseInt(await longPressTouchClientX.text())).toBeGreaterThan(0) + const longPressTouchClientY = await page.$('#long-press-touch-client-y') + expect(parseInt(await longPressTouchClientY.text())).toBeGreaterThan(0) + const longPressChangedTouchIdentifier = await page.$('#long-press-changed-touch-identifier') + expect(await longPressChangedTouchIdentifier.text()).toBe('0') + const longPressChangedTouchPageX = await page.$('#long-press-changed-touch-page-x') + expect(parseInt(await longPressChangedTouchPageX.text())).toBeGreaterThan(0) + const longPressChangedTouchPageY = await page.$('#long-press-changed-touch-page-y') + expect(parseInt(await longPressChangedTouchPageY.text())).toBeGreaterThan(0) + const longPressChangedTouchClientX = await page.$('#long-press-changed-touch-client-x') + expect(parseInt(await longPressChangedTouchClientX.text())).toBeGreaterThan(0) + const longPressChangedTouchClientY = await page.$('#long-press-changed-touch-client-y') + expect(parseInt(await longPressChangedTouchClientY.text())).toBeGreaterThan(0) + } else { + const longPressTouchTargetIdentifier = '1' + const longPressTouchTargetValue = '0' + const longPressTouchIdentifier = await page.$('#long-press-touch-identifier') + expect(await longPressTouchIdentifier.text()).toBe(longPressTouchTargetIdentifier) + const longPressTouchPageX = await page.$('#long-press-touch-page-x') + expect(await longPressTouchPageX.text()).toBe(longPressTouchTargetValue) + const longPressTouchPageY = await page.$('#long-press-touch-page-y') + expect(await longPressTouchPageY.text()).toBe(longPressTouchTargetValue) + const longPressTouchClientX = await page.$('#long-press-touch-client-x') + expect(await longPressTouchClientX.text()).toBe(longPressTouchTargetValue) + const longPressTouchClientY = await page.$('#long-press-touch-client-y') + expect(await longPressTouchClientY.text()).toBe(longPressTouchTargetValue) + const longPressTouchScreenX = await page.$('#long-press-touch-screen-x') + expect(await longPressTouchScreenX.text()).toBe(longPressTouchTargetValue) + const longPressTouchScreenY = await page.$('#long-press-touch-screen-y') + expect(await longPressTouchScreenY.text()).toBe(longPressTouchTargetValue) + const longPressChangedTouchIdentifier = await page.$('#long-press-changed-touch-identifier') + expect(await longPressChangedTouchIdentifier.text()).toBe(longPressTouchTargetIdentifier) + const longPressChangedTouchPageX = await page.$('#long-press-changed-touch-page-x') + expect(await longPressChangedTouchPageX.text()).toBe(longPressTouchTargetValue) + const longPressChangedTouchPageY = await page.$('#long-press-changed-touch-page-y') + expect(await longPressChangedTouchPageY.text()).toBe(longPressTouchTargetValue) + const longPressChangedTouchClientX = await page.$('#long-press-changed-touch-client-x') + expect(await longPressChangedTouchClientX.text()).toBe(longPressTouchTargetValue) + const longPressChangedTouchClientY = await page.$('#long-press-changed-touch-client-y') + expect(await longPressChangedTouchClientY.text()).toBe(longPressTouchTargetValue) + const longPressChangedTouchScreenX = await page.$('#long-press-changed-touch-screen-x') + expect(await longPressChangedTouchScreenX.text()).toBe(longPressTouchTargetValue) + const longPressChangedTouchScreenY = await page.$('#long-press-changed-touch-screen-y') + expect(await longPressChangedTouchScreenY.text()).toBe(longPressTouchTargetValue) + } if (isAndroid || isIos) { if (isIos) { @@ -319,4 +356,4 @@ describe('event trigger', () => { expect(1).toBe(1) } }) -}) +}) diff --git a/pages/component/global-properties/global-properties.uvue b/pages/component/global-properties/global-properties.uvue index 136458ed..87f94365 100644 --- a/pages/component/global-properties/global-properties.uvue +++ b/pages/component/global-properties/global-properties.uvue @@ -63,37 +63,42 @@ } // #ifdef APP if (!generalTarget.classList.includes('general-class')) { - // #endif - // #ifndef APP - if (!Array.from(generalTarget.classList).includes('general-class')) { - // #endif - this.validateGeneralAttrText = '基础属性 class 验证失败' - return - } - const generalName = generalTarget.getAttribute('name') - if (generalName != this.generalName) { - this.validateGeneralAttrText = '基础属性 name 验证失败' - return - } - const generalTitle = generalTarget.getAttribute('title') - if (generalTitle != this.generalTitle) { - this.validateGeneralAttrText = '基础属性 title 验证失败' - return - } - const generalData = generalTarget.getAttribute('data-test') - if (generalData != this.generalData) { - this.validateGeneralAttrText = '基础属性 data-test 验证失败' - return - } - this.validateGeneralAttrText = '基础属性验证成功' - }, - changeHeight(){ - const generalTarget = this.$refs['general-target'] as UniElement - this.changeHeightByRefText = '已通过 ref 修改高度' - generalTarget.style.setProperty('height', '200px') + this.validateGeneralAttrText = '基础属性 class 验证失败' + return + } + // #endif + // #ifdef WEB + if (!Array.from(generalTarget.classList).includes('general-class')) { + this.validateGeneralAttrText = '基础属性 class 验证失败' + return + } + // #endif + // #ifndef MP + const generalName = generalTarget.getAttribute('name') + if (generalName != this.generalName) { + this.validateGeneralAttrText = '基础属性 name 验证失败' + return + } + const generalTitle = generalTarget.getAttribute('title') + if (generalTitle != this.generalTitle) { + this.validateGeneralAttrText = '基础属性 title 验证失败' + return } + const generalData = generalTarget.getAttribute('data-test') + if (generalData != this.generalData) { + this.validateGeneralAttrText = '基础属性 data-test 验证失败' + return + } + // #endif + this.validateGeneralAttrText = '基础属性验证成功' }, - } + changeHeight() { + const generalTarget = this.$refs['general-target'] as UniElement + this.changeHeightByRefText = '已通过 ref 修改高度' + generalTarget.style.setProperty('height', '200px') + } + }, + } + diff --git a/pages/component/list-view/issue-2199.test.js b/pages/component/list-view/issue-2199.test.js index eec53ee0..622ba28b 100644 --- a/pages/component/list-view/issue-2199.test.js +++ b/pages/component/list-view/issue-2199.test.js @@ -1,5 +1,15 @@ +const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() +const isMP = platformInfo.startsWith('mp') + describe('issue-2199', () => { + if (isMP) { + it('skip mp', () => { + expect(1).toBe(1) + }) + return + } let page + beforeAll(async () => { page = await program.reLaunch('/pages/component/list-view/issue-2199') await page.waitFor(600) @@ -12,4 +22,4 @@ describe('issue-2199', () => { expect(image).toSaveImageSnapshot(); }) -}) +}) diff --git a/pages/component/list-view/list-view-children-in-slot.test.js b/pages/component/list-view/list-view-children-in-slot.test.js index 10ddffcb..bbcb93a4 100644 --- a/pages/component/list-view/list-view-children-in-slot.test.js +++ b/pages/component/list-view/list-view-children-in-slot.test.js @@ -1,4 +1,14 @@ +const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() +const isMP = platformInfo.startsWith('mp') + describe('list-view-children-in-slot', () => { + if (isMP) { + it('skip mp', () => { + expect(1).toBe(1) + }) + return + } + let page beforeAll(async () => { page = await program.reLaunch('/pages/component/list-view/list-view-children-in-slot') diff --git a/pages/component/list-view/list-view-multiplex.test.js b/pages/component/list-view/list-view-multiplex.test.js index ae8aded5..c1397612 100644 --- a/pages/component/list-view/list-view-multiplex.test.js +++ b/pages/component/list-view/list-view-multiplex.test.js @@ -1,4 +1,14 @@ +const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() +const isMP = platformInfo.startsWith('mp') + describe('component-native-list-view', () => { + if (isMP) { + it('skip mp', () => { + expect(1).toBe(1) + }) + return + } + let page beforeAll(async () => { //打开list-view-multiplex测试页 diff --git a/pages/component/list-view/list-view.test.js b/pages/component/list-view/list-view.test.js index fc9c9602..16877ded 100644 --- a/pages/component/list-view/list-view.test.js +++ b/pages/component/list-view/list-view.test.js @@ -1,9 +1,19 @@ -describe('component-native-list-view', () => { - let page +const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() +const isMP = platformInfo.startsWith('mp') + +describe('component-native-list-view', () => { + if (isMP) { + it('skip mp', () => { + expect(1).toBe(1) + }) + return + } + + let page beforeAll(async () => { - //打开list-view测试页 - page = await program.reLaunch('/pages/component/list-view/list-view') - await page.waitFor(600) + //打开list-view测试页 + page = await program.reLaunch('/pages/component/list-view/list-view') + await page.waitFor(600) }) //检测竖向scrolltop属性赋值 @@ -45,7 +55,7 @@ describe('component-native-list-view', () => { expect([300, 299.8095]).toContain(scrollDetail.scrollTop); expect(scrollDetail.scrollHeight).toBeGreaterThan(0) expect(scrollDetail.scrollWidth).toBeGreaterThan(0) - expect(scrollDetail.deltaX).toBe(0) + expect(scrollDetail.deltaX).toBe(0) //此处可判断安卓issues:9121的问题 expect([300.1905, 300, 299.8095]).toContain(scrollDetail.deltaY); expect(await page.data('isScrollTest')).toBe('scroll:Success') diff --git a/pages/component/nested-scroll-body/nested-scroll-body.test.js b/pages/component/nested-scroll-body/nested-scroll-body.test.js index a39a2358..c1b3417e 100644 --- a/pages/component/nested-scroll-body/nested-scroll-body.test.js +++ b/pages/component/nested-scroll-body/nested-scroll-body.test.js @@ -1,4 +1,14 @@ +const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() +const isMP = platformInfo.startsWith('mp') + describe('component-native-nested-scroll-body', () => { + if (isMP) { + it('skip mp', () => { + expect(1).toBe(1) + }) + return + } + if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') { it('dummyTest', () => { expect(1).toBe(1) diff --git a/pages/component/nested-scroll-header/nested-scroll-header.test.js b/pages/component/nested-scroll-header/nested-scroll-header.test.js index d4eb2bb7..1b3a4a1b 100644 --- a/pages/component/nested-scroll-header/nested-scroll-header.test.js +++ b/pages/component/nested-scroll-header/nested-scroll-header.test.js @@ -1,4 +1,14 @@ +const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() +const isMP = platformInfo.startsWith('mp') + describe('component-native-nested-scroll-header', () => { + if (isMP) { + it('skip mp', () => { + expect(1).toBe(1) + }) + return + } + if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') { it('dummyTest', () => { expect(1).toBe(1) diff --git a/pages/component/sticky-header/sticky-header.test.js b/pages/component/sticky-header/sticky-header.test.js index f7b87a43..d216aedb 100644 --- a/pages/component/sticky-header/sticky-header.test.js +++ b/pages/component/sticky-header/sticky-header.test.js @@ -1,4 +1,14 @@ +const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() +const isMP = platformInfo.startsWith('mp') + describe('component-native-sticky-header', () => { + if (isMP) { + it('skip mp', () => { + expect(1).toBe(1) + }) + return + } + let page async function getWindowInfo() { const windowInfoPage = await program.reLaunch('/pages/API/get-window-info/get-window-info') diff --git a/pages/component/sticky-section/sticky-section.test.js b/pages/component/sticky-section/sticky-section.test.js index 8f836a43..e751b3e1 100644 --- a/pages/component/sticky-section/sticky-section.test.js +++ b/pages/component/sticky-section/sticky-section.test.js @@ -1,4 +1,14 @@ +const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() +const isMP = platformInfo.startsWith('mp') + describe('component-native-sticky-section', () => { + if (isMP) { + it('skip mp', () => { + expect(1).toBe(1) + }) + return + } + let page beforeAll(async () => { page = await program.reLaunch('/pages/component/sticky-section/sticky-section') @@ -6,7 +16,7 @@ describe('component-native-sticky-section', () => { }) //检测吸顶上推效果 - it('check_sticky_section', async () => { + it('check_sticky_section', async () => { page.waitFor(300) await page.callMethod('listViewScrollByY', 1000) const image = await program.screenshot({fullPage: true}); diff --git a/pages/component/swiper/swiper2.test.js b/pages/component/swiper/swiper2.test.js index 229d8677..8b0d57f8 100644 --- a/pages/component/swiper/swiper2.test.js +++ b/pages/component/swiper/swiper2.test.js @@ -4,8 +4,10 @@ describe('swiper-touch-test', () => { const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() const isAndroid = platformInfo.startsWith('android') const isWeb = platformInfo.startsWith('web') - // 屏蔽 web * android 平台 - if (isWeb || isAndroid) { +const isMP = platformInfo.startsWith('mp') + // 屏蔽 web * android 平台, 需要针对调整坐标 + // 屏蔽 小程序,不支持 program.swipe + if (isWeb || isAndroid || isMp) { it('other platform', () => { expect(1).toBe(1) }) -- GitLab