From 6db1c7cd9ac987bee1dd289aeefa45509c715d6c Mon Sep 17 00:00:00 2001 From: Anne_LXM Date: Wed, 12 Jun 2024 21:22:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=B5=8B=E8=AF=95=E4=BE=8B?= =?UTF-8?q?=EF=BC=9A=E5=9B=A0=E4=BA=8B=E4=BB=B6event=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E4=B8=AD=E5=AD=98=E5=9C=A8=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=E5=BC=95=E7=94=A8=EF=BC=8C=E5=9C=A8ios=E7=AB=AFJSON.stringify?= =?UTF-8?q?=E6=8A=A5=E9=94=99=EF=BC=8C=E8=87=AA=E5=8A=A8=E5=8C=96=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=97=A0=E6=B3=95page.data=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scroll-view/scroll-view-refresher.test.js | 27 ++-- .../scroll-view/scroll-view-refresher.uvue | 77 ++++++++--- .../component/scroll-view/scroll-view.test.js | 122 +++++++----------- pages/component/scroll-view/scroll-view.uvue | 68 +++++++++- pages/component/swiper/swiper.test.js | 6 +- pages/component/swiper/swiper.uvue | 37 +++--- 6 files changed, 206 insertions(+), 131 deletions(-) diff --git a/pages/component/scroll-view/scroll-view-refresher.test.js b/pages/component/scroll-view/scroll-view-refresher.test.js index 92315f79..3fdd958e 100644 --- a/pages/component/scroll-view/scroll-view-refresher.test.js +++ b/pages/component/scroll-view/scroll-view-refresher.test.js @@ -12,14 +12,6 @@ describe('component-native-scroll-view-refresher', () => { page = await program.reLaunch('/pages/component/scroll-view/scroll-view-refresher'); await page.waitFor(300); }); - - async function eventCheck(dataName,typeName){ - const eventInfo = await page.data(dataName) - expect(eventInfo.type).toBe(typeName) - expect(eventInfo.currentTarget).not.toBeFalsy(); - expect(eventInfo.target).not.toBeFalsy(); - expect(eventInfo.detail.dy).toBeGreaterThan(0) - } it('scroll-view-refresher-screenshot', async () => { //禁止滚动条 @@ -39,12 +31,25 @@ describe('component-native-scroll-view-refresher', () => { expect(await page.data('refresherrefreshTimes')).toBe(1) // 手动设置下拉刷新状态refresher-triggered为true时,在web和iOS不触发@refresherpulling事件 if(process.env.uniTestPlatformInfo.startsWith('android')){ - await eventCheck('onRefresherpullingTest','refresherpulling') + expect(await page.data('onRefresherpullingTest')).toBe('refresherpulling:Success') } - await eventCheck('refresherrefreshTest','refresherrefresh') + expect(await page.data('refresherrefreshTest')).toBe('refresherrefresh:Success') await page.waitFor(1000); - await eventCheck('onRefresherrestoreTest','refresherrestore') + expect(await page.data('onRefresherrestoreTest')).toBe('refresherrestore:Success') }); + + // 仅App端支持手势下拉刷新 + if(!process.env.uniTestPlatformInfo.startsWith('web')){ + it('check_refresherabort', async () => { + await program.swipe({ + startPoint: {x: 100,y: 500}, + endPoint: {x: 100,y: 630}, + duration: 1000 + }) + await page.waitFor(1500) + expect(await page.data('onRefresherabortTest')).toBe('refresherabort:Success') + }); + } it('check_refresher_snapshot', async () => { await page.setData({ diff --git a/pages/component/scroll-view/scroll-view-refresher.uvue b/pages/component/scroll-view/scroll-view-refresher.uvue index 773103d9..ddd5611a 100644 --- a/pages/component/scroll-view/scroll-view-refresher.uvue +++ b/pages/component/scroll-view/scroll-view-refresher.uvue @@ -13,6 +13,12 @@ diff --git a/pages/component/swiper/swiper.test.js b/pages/component/swiper/swiper.test.js index c26669f1..07bec724 100644 --- a/pages/component/swiper/swiper.test.js +++ b/pages/component/swiper/swiper.test.js @@ -98,7 +98,7 @@ describe('test swiper', () => { expect(transitionDetailInfo.dy).toBe(0) } expect(transitionDetailInfo.dx).not.toBe(0) - expect(await page.data('isTransitionTest')).toBe('transition:Pass') + expect(await page.data('isTransitionTest')).toBe('transition:Success') } }); @@ -110,7 +110,7 @@ describe('test swiper', () => { }else{ expect(changeDetailInfo).toEqual(appDetailRes) } - expect(await page.data('isChangeTest')).toBe('change:Pass') + expect(await page.data('isChangeTest')).toBe('change:Success') } }); @@ -124,7 +124,7 @@ describe('test swiper', () => { }else{ expect(animationfinishDetailInfo).toEqual(appDetailRes) } - expect(await page.data('isAnimationfinishTest')).toBe('animationfinish:Pass') + expect(await page.data('isAnimationfinishTest')).toBe('animationfinish:Success') } }); }); diff --git a/pages/component/swiper/swiper.uvue b/pages/component/swiper/swiper.uvue index 9dc55208..b879b77a 100644 --- a/pages/component/swiper/swiper.uvue +++ b/pages/component/swiper/swiper.uvue @@ -129,24 +129,6 @@ } }, methods: { - // 自动化测试专用(由于事件event参数对象中存在循环引用,在ios端JSON.stringify报错,自动化测试无法page.data获取) - checkEventTest(e:SwiperEventTest, eventName:String){ - const isPass = e.type === eventName && e.target instanceof UniElement && e.currentTarget instanceof UniElement; - const result = isPass ? `${eventName}:Pass` : `${eventName}:NoPass`; - switch (eventName){ - case 'change': - this.isChangeTest = result - break; - case 'transition': - this.isTransitionTest = result - break; - case 'animationfinish': - this.isAnimationfinishTest = result - break; - default: - break; - } - }, swiperChange: function (e : UniSwiperChangeEvent) { // #ifndef APP-ANDROID this.changeDetailTest = e.detail @@ -191,7 +173,24 @@ console.log(e) } }, - + // 自动化测试专用(由于事件event参数对象中存在循环引用,在ios端JSON.stringify报错,自动化测试无法page.data获取) + checkEventTest(e:SwiperEventTest, eventName:String){ + const isPass = e.type === eventName && e.target instanceof UniElement && e.currentTarget instanceof UniElement; + const result = isPass ? `${eventName}:Success` : `${eventName}:Fail`; + switch (eventName){ + case 'change': + this.isChangeTest = result + break; + case 'transition': + this.isTransitionTest = result + break; + case 'animationfinish': + this.isAnimationfinishTest = result + break; + default: + break; + } + }, dotsChange: function (e : UniSwitchChangeEvent) { this.dotsSelect = e.detail.value }, -- GitLab