diff --git a/pages/component/general-attribute/general-attribute.uvue b/pages/component/general-attribute/general-attribute.uvue index 3b3e7d751991336e119c56442f014b54a69d122c..1f4aac95eccd3595fe4a2abe2bd19bc1c41dd6c3 100644 --- a/pages/component/general-attribute/general-attribute.uvue +++ b/pages/component/general-attribute/general-attribute.uvue @@ -69,7 +69,7 @@ export default { }, methods: { validateGeneralAttributes() { - const generalTarget = this.$refs.get('general-target') as Element + const generalTarget = this.$refs['general-target'] as Element const generalId = generalTarget.getAttribute('id') if (generalId != this.generalId) { this.validateGeneralAttrText = '基础属性 id 验证失败' diff --git a/pages/component/image/image.test.js b/pages/component/image/image.test.js new file mode 100644 index 0000000000000000000000000000000000000000..f87144076bfe56e8ec6929eeab2d5bf5093e04ab --- /dev/null +++ b/pages/component/image/image.test.js @@ -0,0 +1,14 @@ +// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/ + +describe('component-native-image', () => { + + let page; + beforeAll(async () => { + page = await program.reLaunch('/pages/component/image/image'); + await page.waitFor(600); + }); + + it('check_image_load', async () => { + expect(await page.data('loadError')).toBe(false) + }); +}); diff --git a/pages/component/image/image.uvue b/pages/component/image/image.uvue index 9e6345ee63ec73feb6a26b90a8b3bc67861d00e0..652e2c5fcca99e5ee5746e32534eed47cb0c03b3 100644 --- a/pages/component/image/image.uvue +++ b/pages/component/image/image.uvue @@ -25,11 +25,13 @@ export default { data() { return { - title: 'image' + title: 'image', + loadError: false } }, methods: { - error(event : ImageErrorEvent) { + error(event : ImageErrorEvent) { + this.loadError = true console.log(event.type, event.detail); }, load(event : ImageLoadEvent) { @@ -63,4 +65,4 @@ margin: 40rpx auto; width: 200rpx; } - \ No newline at end of file + diff --git a/pages/component/scroll-view/scroll-view-props.test.js b/pages/component/scroll-view/scroll-view-props.test.js new file mode 100644 index 0000000000000000000000000000000000000000..34990810078e4946dc4d1dd78288a97ba863f010 --- /dev/null +++ b/pages/component/scroll-view/scroll-view-props.test.js @@ -0,0 +1,85 @@ +// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/ + +describe('component-native-scroll-view', () => { + + let page; + beforeAll(async () => { + page = await program.reLaunch('/pages/component/scroll-view/scroll-view-props'); + await page.waitFor(300); + }); + + //检测竖向可滚动区域 + it('check_scroll_height', async () => { + await page.setData({ + scrollX: false + }) + await page.waitFor(300); + const value = await page.callMethod('checkScrollHeight') + expect(value).toBe(true) + }) + + //检测竖向scrolltop属性赋值 + it('check_scroll_top', async () => { + await page.setData({ + scrollTop: 600 + }) + await page.waitFor(600) + const element = await page.$('#scrollViewY') + const scrollTop = await element.attribute("scrollTop") + console.log("check_scroll_top---"+scrollTop) + expect(scrollTop-600).toBeGreaterThanOrEqual(0) + }) + + //检测竖向scroll_into_view属性赋值 + it('check_scroll_into_view_top', async () => { + await page.setData({ + scrollIntoView: "item3" + }) + await page.waitFor(600) + const element = await page.$('#scrollViewY') + const scrollTop = await element.attribute("scrollTop") + console.log("check_scroll_into_view_top--"+scrollTop) + await page.setData({ + scrollIntoView: "" + }) + expect(scrollTop-690).toBeGreaterThanOrEqual(0) + }) + + //检测横向可滚动区域 + it('check_scroll_width', async () => { + await page.setData({ + scrollX: true + }) + await page.waitFor(300); + const value = await page.callMethod('checkScrollWidth') + expect(value).toBe(true) + }) + + //检测横向scrollLeft属性赋值 + it('check_scroll_left', async () => { + await page.setData({ + scrollLeft: 600 + }) + await page.waitFor(600) + const element = await page.$('#scrollViewX') + const scrollLeft = await element.attribute("scrollLeft") + console.log("check_scroll_left---"+scrollLeft) + expect(scrollLeft-600).toBeGreaterThanOrEqual(0) + }) + + //检测横向scroll_into_view属性赋值 + it('check_scroll_into_view_left', async () => { + await page.setData({ + scrollIntoView: "horizontal_item3" + }) + await page.waitFor(600) + const element = await page.$('#scrollViewX') + const scrollLeft = await element.attribute("scrollLeft") + console.log("check_scroll_into_view_left--"+scrollLeft) + await page.setData({ + scrollIntoView: "" + }) + expect(scrollLeft-1080).toBeGreaterThanOrEqual(0) + }) + +}); diff --git a/pages/component/scroll-view/scroll-view-props.uvue b/pages/component/scroll-view/scroll-view-props.uvue index 6ec4680eca52eaa5b6f4d610754341702fd0e665..9046f48fcb471ee30094b540944629925f4e2dd1 100644 --- a/pages/component/scroll-view/scroll-view-props.uvue +++ b/pages/component/scroll-view/scroll-view-props.uvue @@ -5,11 +5,11 @@ - + @scrolltolower="scrolltolower" @scroll="scroll" @scrollend="scrollend" ref="scrollViewX" id="scrollViewX"> {{item.label}} @@ -18,7 +18,7 @@ :upper-threshold="upperThreshold" :lower-threshold="lowerThreshold" :scroll-into-view="scrollIntoView" :enable-back-to-top="enableBackToTop" :scroll-with-animation="scrollWithAnimation" :show-scrollbar="showScrollbar" :rebound="rebound" @scrolltoupper="scrolltoupper" - @scrolltolower="scrolltolower" @scroll="scroll" @scrollend="scrollend"> + @scrolltolower="scrolltolower" @scroll="scroll" @scrollend="scrollend" ref="scrollViewY" id="scrollViewY"> {{item.label}} @@ -161,7 +161,31 @@ }, scrollend() { console.log("滚动停止"); - } + }, + //自动化测试专用 + checkScrollHeight(): Boolean { + var element = this.$refs["scrollViewY"] + if(element != null) { + var scrollHeight = (element as Element).scrollHeight + console.log("checkScrollHeight"+scrollHeight) + if(scrollHeight > 1900) { + return true + } + } + return false + }, + //自动化测试专用 + checkScrollWidth(): Boolean { + var element = this.$refs["scrollViewX"] + if(element != null) { + var scrollWidth = (element as Element).scrollWidth + console.log("checkScrollWidth---"+scrollWidth) + if(scrollWidth > 1900) { + return true + } + } + return false + } } } @@ -206,4 +230,4 @@ padding: 30rpx; justify-content: center; } - \ No newline at end of file + diff --git a/pages/template/drop-card/card/card.uvue b/pages/template/drop-card/card/card.uvue index 981847d8b1f269fd548c63fdcde48119e0b672ca..56e15b81a640d286ec7559e8ceb5d79b89a1f80b 100644 --- a/pages/template/drop-card/card/card.uvue +++ b/pages/template/drop-card/card/card.uvue @@ -82,7 +82,7 @@ setElementStyle(refName:string,propertyName : string, propertyStyle : any) : void { let element : Element | null = this.$elementMap.get(refName) if(element == null){ - element = this.$refs.get(refName) as Element; + element = this.$refs[refName] as Element; this.$elementMap.set(refName,element) }else{ // console.log('直接拿'); diff --git a/pages/template/pull-zoom-image/pull-zoom-image.uvue b/pages/template/pull-zoom-image/pull-zoom-image.uvue index e9010315f4703bb4a8e4254aef4ed6c7aa7726cf..91722d71a088fc113af611af74580d9c41a8656b 100644 --- a/pages/template/pull-zoom-image/pull-zoom-image.uvue +++ b/pages/template/pull-zoom-image/pull-zoom-image.uvue @@ -64,7 +64,7 @@ setElementStyle(refName : string, propertyName : string, propertyStyle : any) : void { let element : Element | null = this.$elementMap.get(refName) if (element == null) { - element = this.$refs.get(refName) as Element; + element = this.$refs[refName] as Element; this.$elementMap.set(refName, element) } element.style.setProperty(propertyName, propertyStyle);