From a726617370391c149d23f08b1cb58a7d6e11f8ce Mon Sep 17 00:00:00 2001 From: XHY Date: Mon, 19 Aug 2024 13:07:52 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0=20rich-text-complex.test.j?= =?UTF-8?q?s=20=E6=B5=8B=E8=AF=95=E4=BE=8B=20=E7=94=A8=E4=BA=8E=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=82=B9=E5=87=BB=E4=BA=8B=E4=BB=B6;=202.=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20view.test.js=20=E6=B5=8B=E8=AF=95=E4=BE=8B=EF=BC=8C?= =?UTF-8?q?=E4=BB=85=E7=94=A8=E4=BA=8E=E5=85=B3=E9=97=ADiOS=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E5=BC=B9=E7=AA=97;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 440b04174bfadeadfe3c2b42ce1d3cbce13d99ce) --- .../rich-text/rich-text-complex.test.js | 72 +++++++++++++++++++ .../rich-text/rich-text-complex.uvue | 16 +++-- pages/component/view/view.test.js | 45 ++++++++++++ testSequencer.js | 1 + 4 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 pages/component/rich-text/rich-text-complex.test.js create mode 100644 pages/component/view/view.test.js diff --git a/pages/component/rich-text/rich-text-complex.test.js b/pages/component/rich-text/rich-text-complex.test.js new file mode 100644 index 00000000..8c633e82 --- /dev/null +++ b/pages/component/rich-text/rich-text-complex.test.js @@ -0,0 +1,72 @@ +const PAGE_PATH = '/pages/component/rich-text/rich-text-complex' + +describe('rich-text-test', () => { + + // 先屏蔽 android 及 web 平台 + if (process.env.uniTestPlatformInfo.startsWith('android') || process.env.uniTestPlatformInfo.startsWith('web')) { + it('other platform', () => { + expect(1).toBe(1) + }) + return + } + + let page + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(1500); + }) + + + it('click-event', async () => { + await program.tap({ + x: 210, + y: 280, + duration: 100 + }) + + await page.waitFor(1000); + const fViewClicked = await page.data('fViewClicked') + const selfClicked = await page.data('selfClicked') + expect(fViewClicked).toBe(true) + expect(selfClicked).toBe(true) + }) + + + it('itemclick-event', async () => { + await program.tap({ + x: 66, + y: 266, + duration: 100 + }) + + await page.waitFor(500); + + // 关闭弹窗逻辑各平台需要适配不同机型 + if (process.env.uniTestPlatformInfo.startsWith('IOS')) { + // 关闭弹窗 iPhone Pro 机型 + await program.tap({ + x: 200, + y: 433, + duration: 100 + }) + + // 关闭弹窗 iPhone ProMax 机型 + await program.tap({ + x: 220, + y: 476, + duration: 100 + }) + + // 关闭弹窗 iPhone mini 机型 + await program.tap({ + x: 186, + y: 400, + duration: 100 + }) + } + + const imageClicked = await page.data('imageClicked') + expect(imageClicked).toBe(true) + }) + +}) diff --git a/pages/component/rich-text/rich-text-complex.uvue b/pages/component/rich-text/rich-text-complex.uvue index 6e5b1c10..2d802482 100644 --- a/pages/component/rich-text/rich-text-complex.uvue +++ b/pages/component/rich-text/rich-text-complex.uvue @@ -4,8 +4,8 @@ - - + + @@ -17,6 +17,9 @@ export default { data() { return { + imageClicked: false, + fViewClicked: false, + selfClicked: false, htmlString: '

HBuilderX

HBuilderX,轻巧、极速,极客编辑器

HBuilderX,轻巧、极速,极客编辑器 HBuilderX,轻巧、极速,极客编辑器HBuilderX,轻巧、极速,极客编辑器HBuilderX,轻巧、极速,极客编辑器 HBuilderX,轻巧、极速,极客编辑器HBuilderX,轻巧、极速,极客编辑器

uni-app x,终极跨平台方案

uni-app x,终极跨平台方案 uni-app x,终极跨平台方案uni-appx,终极跨平台方案 uni-app x,终极跨平台方案 uni-app x,终极跨平台方案 uni-appx,终极跨平台方案

uniCloud,js serverless云服务

uniCloud,js serverless云服务 uniCloud,jsserverless云服务uniCloud,js serverless云服务 uniCloud,js serverless云服务 uniCloud,jsserverless云服务uniCloud,js serverless云服务

uts,大一统语言

uts,大一统语言 uts,大一统语言 uts,大一统语言uts,大一统语言uts,大一统语言 uts,大一统语言

uniMPSdk,让你的App具备小程序能力
uni-admin,开源、现成的全端管理后台
uni-app

' } }, @@ -26,6 +29,7 @@ let clicktext = ''; if (e.detail.src != null) { clicktext = '点击了图片,src = ' + e.detail.src; + this.imageClicked = true } else if (e.detail.href != null) { clicktext = '点击了链接,href = ' + e.detail.href; } @@ -34,9 +38,13 @@ showCancel:false }); }, - testClick(e:string) { - // 测试点击rich-text是否正常触发自身及父节点 click 事件 + fViewClick(e:string) { console.log(e) + this.fViewClicked = true + }, + selfClick(e:string) { + console.log(e) + this.selfClicked = true } } } diff --git a/pages/component/view/view.test.js b/pages/component/view/view.test.js new file mode 100644 index 00000000..9f875668 --- /dev/null +++ b/pages/component/view/view.test.js @@ -0,0 +1,45 @@ +const PAGE_PATH = '/pages/component/view/view' + +// 此用例仅用于模拟点击关闭iOS弹窗逻辑,无实际意义 +describe('view-test', () => { + + // 先屏蔽 android 及 web 平台 + if (process.env.uniTestPlatformInfo.startsWith('android') || process.env.uniTestPlatformInfo.startsWith('web')) { + it('other platform', () => { + expect(1).toBe(1) + }) + return + } + + let page + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(1000); + }) + + + it('itemclick-event', async () => { + // 关闭弹窗 iPhone Pro 机型 + await program.tap({ + x: 220, + y: 516, + duration: 100 + }) + + // 关闭弹窗 iPhone ProMax 机型 + await program.tap({ + x: 220, + y: 546, + duration: 100 + }) + + // 关闭弹窗 iPhone mini 机型 + await program.tap({ + x: 186, + y: 463, + duration: 100 + }) + expect(1).toBe(1) + }) + +}) diff --git a/testSequencer.js b/testSequencer.js index 262eb84c..4835bf83 100644 --- a/testSequencer.js +++ b/testSequencer.js @@ -1,5 +1,6 @@ const Sequencer = require("@jest/test-sequencer").default const sortTestFilePaths = [ + "pages/component/view/view.test.js", "pages/API/pull-down-refresh/pull-down-refresh.test.js", "pages/component/global-events/global-events.test.js", "pages/component/list-view/list-view-refresh.test.js" -- GitLab