From 28a38994a047cc93f22cb6b254c40712b4ed8def Mon Sep 17 00:00:00 2001 From: jixinbao Date: Tue, 15 Oct 2024 15:31:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9D=90=E6=A0=87=20tap=20=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=20getBoundingCentRect=20=E8=8E=B7=E5=8F=96=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global-events/global-events.test.js | 24 ++++++++----------- .../global-events/global-events.uvue | 23 +++++++++++++++--- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/pages/component/global-events/global-events.test.js b/pages/component/global-events/global-events.test.js index dbaa8121..22e7d406 100644 --- a/pages/component/global-events/global-events.test.js +++ b/pages/component/global-events/global-events.test.js @@ -292,25 +292,20 @@ describe('event trigger', () => { page = await program.reLaunch(PAGE_PATH) await page.waitFor('view') - const el = await page.$('#longpress-target') - const size = await el.size() - const position = await el.offset() - // console.log('position', position) - // console.log('size', size); - const x = position.left + size.width / 2.0 - const y = position.top + size.height / 2.0 - const res = await uni.getWindowInfo(); - // console.log('res', res.statusBarHeight); - const baseStatusTextHeight = 44 - const baseTop = res.statusBarHeight ?? 0 + const [ + x, + y + ] = await page.callMethod('jest_getRect') + + expect(x > 0).toBe(true) + expect(y > 0).toBe(true) await program.tap({ x: x, - y: y + baseTop + baseStatusTextHeight, - duration: 100 + y: y }) - await page.waitFor(500) + await page.waitFor(200) const clickEventX = await page.$('#click-event-x') const StringX = await clickEventX.text() @@ -324,3 +319,4 @@ describe('event trigger', () => { } }) }) + diff --git a/pages/component/global-events/global-events.uvue b/pages/component/global-events/global-events.uvue index c89a6b2d..ffb2a228 100644 --- a/pages/component/global-events/global-events.uvue +++ b/pages/component/global-events/global-events.uvue @@ -6,8 +6,7 @@ - - + touchStart Event: touches: