From 118070d546c6c4a18673cd40fa62576e5fed8c95 Mon Sep 17 00:00:00 2001 From: hdx Date: Mon, 29 Jan 2024 16:29:20 +0800 Subject: [PATCH] =?UTF-8?q?nodes-info:=20=E6=96=B0=E5=A2=9E=20=E6=A0=B9?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E6=B5=8B=E8=AF=95=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/nodes-info/nodes-info.test.js | 8 ++++++++ pages/API/nodes-info/nodes-info.uvue | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/pages/API/nodes-info/nodes-info.test.js b/pages/API/nodes-info/nodes-info.test.js index 6db2b999..0f392677 100644 --- a/pages/API/nodes-info/nodes-info.test.js +++ b/pages/API/nodes-info/nodes-info.test.js @@ -10,6 +10,14 @@ describe('nodes-info', () => { page = await program.reLaunch(PAGE_PATH) await page.waitFor(500) }) + it('get-root-node-info', async () => { + const page = await program.currentPage() + await page.callMethod('getRootNodeInfo') + await page.waitFor(100) + + const data = await page.data() + expect(data.rootNodeInfo != null).toBe(true) + }) it('get-node-info', async () => { const btnGetNodeInfo = await page.$('.btn-get-node-info') diff --git a/pages/API/nodes-info/nodes-info.uvue b/pages/API/nodes-info/nodes-info.uvue index 299d8e15..0e81b123 100644 --- a/pages/API/nodes-info/nodes-info.uvue +++ b/pages/API/nodes-info/nodes-info.uvue @@ -53,6 +53,8 @@ return { title: 'createSelectorQuery', nodeInfoList: [] as NodeInfoType[], + // 仅用于自动化测试 + rootNodeInfo: null as NodeInfoType | null, //供自动化测试使用 // resizeRectValid: false } @@ -68,6 +70,23 @@ } */ }, methods: { + // 仅用于自动化测试 + getRootNodeInfo() { + uni.createSelectorQuery().select('.page').boundingClientRect().exec((ret) => { + if (ret.length == 1) { + const nodeInfo = ret[0] as NodeInfo; + const nodeType = { + left: nodeInfo.left, + top: nodeInfo.top, + right: nodeInfo.right, + bottom: nodeInfo.bottom, + width: nodeInfo.width, + height: nodeInfo.height, + } as NodeInfoType; + this.rootNodeInfo = nodeType + } + }) + }, getNodeInfo() { uni.createSelectorQuery().select('.rect1').boundingClientRect().exec((ret) => { this.nodeInfoList.length = 0 -- GitLab