diff --git a/pages/API/nodes-info/nodes-info.test.js b/pages/API/nodes-info/nodes-info.test.js index 6db2b9991e1417fefcfbb40e8c5788b248fed207..0f3926770d5241d9e4c23493edabbc3e65c07fad 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 299d8e151a0c8205015a253ec6947703012bd97a..0e81b123e08f98c3460857360fd1f7a0a2f044a0 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