From 5cc644b35e485816f2cdd88067ac36f1043c25ca Mon Sep 17 00:00:00 2001 From: wangyaqi Date: Wed, 27 Dec 2023 18:12:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=80=82=E9=85=8Dweb=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.uvue | 5 +- components/input-data/input-data.vue | 13 +- .../uni-collapse-item/uni-collapse-item.vue | 34 +-- .../get-app-base-info.test.js | 7 +- pages/API/get-app/get-app.uvue | 100 ++++----- .../get-element-by-id-multiple-root-node.uvue | 8 +- .../get-element-by-id/get-element-by-id.uvue | 14 +- .../get-system-info/get-system-info.test.js | 9 +- pages/API/navigator/new-page/onLoad.uvue | 6 +- pages/API/request/request.test.js | 10 +- pages/CSS/display/flex.uvue | 4 - pages/CSS/display/none.uvue | 4 - pages/CSS/layout/z-index.uvue | 2 +- pages/CSS/transform/rotate.uvue | 4 - pages/CSS/transform/scale.uvue | 6 - pages/CSS/transform/translate.uvue | 6 - pages/CSS/transition/transition.uvue | 18 +- pages/component/checkbox/checkbox.test.js | 12 +- pages/component/form/form.uvue | 8 +- .../general-attribute/general-attribute.uvue | 4 +- .../component/general-event/touch-event.uvue | 2 +- .../general-event/transition-event.test.js | 7 +- .../general-event/transition-event.uvue | 4 +- pages/component/input/input.test.js | 52 ++--- pages/component/input/input.uvue | 134 +++++------ pages/component/list-view/list-view.uvue | 4 +- .../mixin-datacom/mixin-datacom.test.js | 6 + .../component/picker-view/picker-view.test.js | 12 +- pages/component/progress/progress.test.js | 36 +-- pages/component/radio/radio.test.js | 12 +- .../scroll-view/scroll-view-props.uvue | 96 ++++---- .../scroll-view-refresher-props.uvue | 4 +- pages/component/slider-100/slider-100.test.js | 4 +- pages/component/slider-100/slider-100.uvue | 4 - pages/component/slider/slider.test.js | 18 +- .../sticky-section/sticky-section.uvue | 54 ++--- pages/component/swiper/swiper.test.js | 3 +- pages/component/swiper/swiper.uvue | 1 - pages/component/switch/switch.test.js | 8 +- pages/component/textarea/textarea.test.js | 8 +- pages/component/video/video-format.uvue | 7 +- pages/component/video/video.test.js | 3 +- pages/component/video/video.uvue | 7 +- pages/component/web-view/web-view.uvue | 3 + pages/tabBar/API.uvue | 212 +++++++++--------- pages/tabBar/component.uvue | 3 + pages/template/calendar/calendar.uvue | 6 +- .../custom-tab-bar/custom-tab-bar-tab1.uvue | 2 +- .../custom-tab-bar/custom-tab-bar.uvue | 2 +- pages/template/drop-card/card/card.uvue | 10 +- pages/template/half-screen/half-screen.uvue | 6 +- pages/template/long-list/long-list.uvue | 18 +- pages/template/long-list2/long-list2.uvue | 18 +- .../pull-zoom-image/pull-zoom-image.uvue | 10 +- .../scroll-fold-nav/scroll-fold-nav.uvue | 14 +- .../template/scroll-sticky/scroll-sticky.uvue | 6 +- pages/template/swiper-list/swiper-list.uvue | 12 +- pages/template/swiper-list2/swiper-list2.uvue | 8 +- 58 files changed, 550 insertions(+), 540 deletions(-) diff --git a/App.uvue b/App.uvue index f1aa02c9..5fe17214 100644 --- a/App.uvue +++ b/App.uvue @@ -63,5 +63,8 @@ diff --git a/components/input-data/input-data.vue b/components/input-data/input-data.vue index d650aa6e..74b8baa6 100644 --- a/components/input-data/input-data.vue +++ b/components/input-data/input-data.vue @@ -81,7 +81,7 @@ {{title}} - + @@ -90,20 +90,15 @@ + diff --git a/pages/API/get-app-base-info/get-app-base-info.test.js b/pages/API/get-app-base-info/get-app-base-info.test.js index 4c61b7bf..0ff7c3c5 100644 --- a/pages/API/get-app-base-info/get-app-base-info.test.js +++ b/pages/API/get-app-base-info/get-app-base-info.test.js @@ -6,11 +6,14 @@ describe('ExtApi-GetAppBaseInfo', () => { let res; const stringProperties = [ 'appId', 'appName', 'appVersion', 'appVersionCode', 'appLanguage', - 'language', 'version', 'uniCompileVersion', 'uniPlatform', 'uniRuntimeVersion', + 'language', 'uniCompileVersion', 'uniPlatform', 'uniRuntimeVersion', ] const numberProperties = [ 'uniCompileVersionCode', 'uniRuntimeVersionCode' - ] + ] + if (process.env.uniTestPlatformInfo.indexOf('web') === -1) { + stringProperties.push('version') + } beforeAll(async () => { page = await program.reLaunch(PAGE_PATH) await page.waitFor(600); diff --git a/pages/API/get-app/get-app.uvue b/pages/API/get-app/get-app.uvue index aaf5fa1a..c2ba5462 100644 --- a/pages/API/get-app/get-app.uvue +++ b/pages/API/get-app/get-app.uvue @@ -1,52 +1,52 @@ - - - - - diff --git a/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.uvue b/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.uvue index bbce9555..f1e84cc8 100644 --- a/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.uvue +++ b/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.uvue @@ -23,7 +23,7 @@ } }, methods: { - getElementByNotExistId() : Element | null { + getElementByNotExistId() : UniElement | null { return uni.getElementById('not-exist-id') }, changePageHeadBackgroundColor() { @@ -37,11 +37,11 @@ changeViewStyle() { const view = uni.getElementById('view') if (view !== null) { - view.style['width'] = '90%' - view.style['height'] = '50px' + view.style['width'] = '90%' + view.style['height'] = '50px' view.style['backgroundColor'] = '#007AFF' } } } } - + diff --git a/pages/API/get-element-by-id/get-element-by-id.uvue b/pages/API/get-element-by-id/get-element-by-id.uvue index 24559446..201178ac 100644 --- a/pages/API/get-element-by-id/get-element-by-id.uvue +++ b/pages/API/get-element-by-id/get-element-by-id.uvue @@ -30,7 +30,7 @@ } }, methods: { - getElementByNotExistId() : Element | null { + getElementByNotExistId() : UniElement | null { return uni.getElementById('not-exist-id') }, changePageHeadBackgroundColor() { @@ -38,14 +38,14 @@ pageHead.style['backgroundColor'] = 'red' }, changeTextColor() { - const text = uni.getElementById('text')! - text.style['color'] = 'red' - }, + const text = uni.getElementById('text')! + text.style['color'] = 'red' + }, changeViewStyle() { const view = uni.getElementById('view') if (view !== null) { - view.style['width'] = '90%' - view.style['height'] = '50px' + view.style['width'] = '90%' + view.style['height'] = '50px' view.style['backgroundColor'] = '#007AFF' } }, @@ -54,4 +54,4 @@ } } } - + diff --git a/pages/API/get-system-info/get-system-info.test.js b/pages/API/get-system-info/get-system-info.test.js index 5a614780..c59da342 100644 --- a/pages/API/get-system-info/get-system-info.test.js +++ b/pages/API/get-system-info/get-system-info.test.js @@ -7,7 +7,7 @@ describe('ExtApi-GetSystemInfo', () => { const stringProperties = [ 'appId', 'appLanguage', 'appName', 'appVersion', 'appVersionCode', 'brand', 'deviceId', 'deviceBrand', 'deviceModel', 'deviceType', 'language', - 'model', 'version', 'osName', 'osVersion', 'osLanguage', 'platform', 'system', 'ua', 'uniCompileVersion', + 'model', 'osName', 'osVersion', 'osLanguage', 'platform', 'system', 'ua', 'uniCompileVersion', 'uniPlatform', 'uniRuntimeVersion', 'romName', 'romVersion', ] const numberProperties = [ @@ -15,7 +15,12 @@ describe('ExtApi-GetSystemInfo', () => { 'windowWidth', 'windowHeight', 'windowTop', 'windowBottom', 'screenTop', 'uniCompileVersionCode', 'uniRuntimeVersionCode' - ] + ] + + + if (process.env.uniTestPlatformInfo.indexOf('web') === -1) { + stringProperties.push('version') + } beforeAll(async () => { page = await program.reLaunch(PAGE_PATH) diff --git a/pages/API/navigator/new-page/onLoad.uvue b/pages/API/navigator/new-page/onLoad.uvue index a13dfa2e..04e5b90e 100644 --- a/pages/API/navigator/new-page/onLoad.uvue +++ b/pages/API/navigator/new-page/onLoad.uvue @@ -55,11 +55,13 @@ export default { }, // #ifdef WEB onUnload() { - // web 端页面销毁前,关闭 modal 和 actionsheet + // web 端页面销毁前,关闭 modal 和 actionsheet + // @ts-ignore const modalBtn = document.querySelector('.uni-modal__btn') if (modalBtn) { modalBtn.click() - } + } + // @ts-ignore const actionSheetBtn = document.querySelector('.uni-actionsheet__action .uni-actionsheet__cell') if (actionSheetBtn) { actionSheetBtn.click() diff --git a/pages/API/request/request.test.js b/pages/API/request/request.test.js index e4157b0a..d4fbf939 100644 --- a/pages/API/request/request.test.js +++ b/pages/API/request/request.test.js @@ -69,10 +69,12 @@ describe('ExtApi-Request', () => { }); it('Check PATCH', async () => { await request(page, 'PATCH'); - }); - it('Check OPTIONS', async () => { - await request(page, 'OPTIONS'); - }); + }); + if (process.env.uniTestPlatformInfo.indexOf('web') === -1) { + it('Check OPTIONS', async () => { + await request(page, 'OPTIONS'); + }); + } it('Check HEAD', async () => { await request(page, 'HEAD'); }); diff --git a/pages/CSS/display/flex.uvue b/pages/CSS/display/flex.uvue index 33e4055d..182561dc 100644 --- a/pages/CSS/display/flex.uvue +++ b/pages/CSS/display/flex.uvue @@ -1,7 +1,5 @@ + .uni-input-placeholder-class-ts { + background-color: orange; + } + diff --git a/pages/component/list-view/list-view.uvue b/pages/component/list-view/list-view.uvue index 51bcb9fe..e43c308e 100644 --- a/pages/component/list-view/list-view.uvue +++ b/pages/component/list-view/list-view.uvue @@ -92,7 +92,7 @@ item_change_size_enum(index : number) { this.scrollIntoView = "item---"+index }, //自动化测试例专用 check_scroll_height(): Boolean { - var listElement = this.$refs["listview"] as Element + var listElement = this.$refs["listview"] as UniElement console.log("check_scroll_height--"+listElement.scrollHeight) if(listElement.scrollHeight > 2000) { return true @@ -101,7 +101,7 @@ }, //自动化测试例专用 check_scroll_width(): Boolean { - var listElement = this.$refs["listview"] as Element + var listElement = this.$refs["listview"] as UniElement console.log("check_scroll_width"+listElement.scrollWidth) if(listElement.scrollWidth > 2000) { return true diff --git a/pages/component/mixin-datacom/mixin-datacom.test.js b/pages/component/mixin-datacom/mixin-datacom.test.js index f70ed01b..95a8804a 100644 --- a/pages/component/mixin-datacom/mixin-datacom.test.js +++ b/pages/component/mixin-datacom/mixin-datacom.test.js @@ -1,6 +1,12 @@ const PAGE_PATH = '/pages/component/mixin-datacom/mixin-datacom' describe('mixin-datacom', () => { + if (process.env.uniTestPlatformInfo.startsWith('web')) { + it('dummyTest', async () => { + expect(1).toBe(1) + }) + return + } let page beforeAll(async () => { page = await program.reLaunch(PAGE_PATH) diff --git a/pages/component/picker-view/picker-view.test.js b/pages/component/picker-view/picker-view.test.js index 430805e3..6bf1e763 100644 --- a/pages/component/picker-view/picker-view.test.js +++ b/pages/component/picker-view/picker-view.test.js @@ -16,14 +16,14 @@ describe('PickerView.uvue', () => { const el = await page.$('.picker-view') await page.callMethod('setValue') await page.waitFor(1000) - expect(await el.property('value')).toEqual([0, 0, 0]) + expect(await el.attribute('value')).toEqual([0, 0, 0]) if (process.env.UNI_PLATFORM === 'app-android') { expect(await getData('result')).toEqual([0, 0, 0]) } await page.callMethod('setValue1') await page.waitFor(1000) - expect(await el.property('value')).toEqual([10, 10, 10]) + expect(await el.attribute('value')).toEqual([10, 10, 10]) if (process.env.UNI_PLATFORM === 'app-android') { expect(await getData('result')).toEqual([10, 10, 10]) } @@ -39,22 +39,22 @@ describe('PickerView.uvue', () => { const el = await page.$('.picker-view') await page.setData({ indicatorStyle: 'height: 100px;', - }) + }) await page.waitFor(500) - expect(await el.property('indicatorStyle')).toBe('height: 100px;') + expect(await el.attribute('indicatorStyle')).toBe('height: 100px;') }) it('mask-top-style', async () => { const el = await page.$('.picker-view') await page.setData({ maskTopStyle: 'background: #ffffff;', }) - expect(await el.property('mask-top-style')).toBe('background: #ffffff;') + expect(await el.attribute('mask-top-style')).toBe('background: #ffffff;') }) it('mask-bottom-style', async () => { const el = await page.$('.picker-view') await page.setData({ maskBottomStyle: 'background: #ffffff;', }) - expect(await el.property('mask-bottom-style')).toBe('background: #ffffff;') + expect(await el.attribute('mask-bottom-style')).toBe('background: #ffffff;') }) }) diff --git a/pages/component/progress/progress.test.js b/pages/component/progress/progress.test.js index a572aeae..2ce2fe5a 100644 --- a/pages/component/progress/progress.test.js +++ b/pages/component/progress/progress.test.js @@ -16,22 +16,22 @@ describe('Progress.uvue', () => { await page.callMethod('setProgress') await page.waitFor(1000); const p = await page.$('.p') - expect(await p.property('percent')).toEqual(20) + expect(await p.attribute('percent')).toEqual(20) const p1 = await page.$('.p1') - expect(await p1.property('percent')).toEqual(40) + expect(await p1.attribute('percent')).toEqual(40) const p2 = await page.$('.p2') - expect(await p2.property('percent')).toEqual(60) + expect(await p2.attribute('percent')).toEqual(60) const p3 = await page.$('.p3') - expect(await p3.property('percent')).toEqual(80) + expect(await p3.attribute('percent')).toEqual(80) if (process.env.UNI_PLATFORM === 'app-android') { expect(await getData('curPercent')).toEqual(20) } await page.callMethod('clearProgress') await page.waitFor(1000) - expect(await p.property('percent')).toEqual(0) - expect(await p1.property('percent')).toEqual(0) - expect(await p2.property('percent')).toEqual(0) - expect(await p3.property('percent')).toEqual(0) + expect(await p.attribute('percent')).toEqual(0) + expect(await p1.attribute('percent')).toEqual(0) + expect(await p2.attribute('percent')).toEqual(0) + expect(await p3.attribute('percent')).toEqual(0) if (process.env.UNI_PLATFORM === 'app-android') { expect(await getData('curPercent')).toEqual(0) } @@ -42,42 +42,42 @@ describe('Progress.uvue', () => { }) it('show-info', async () => { const el = await page.$('.p') - expect(await el.property('show-info')).toEqual(true) + expect(await el.attribute('show-info')).toEqual(true) await page.setData({ showInfo: false }) - expect(await el.property('show-info')).toEqual(false) + expect(await el.attribute('show-info')).toEqual(false) }) it('border-radius', async () => { const el = await page.$('.p') - expect(await el.property('border-radius')).toEqual(0) + expect(await el.attribute('border-radius')).toEqual(0) await page.setData({ borderRadius: 5 }) - expect(await el.property('border-radius')).toEqual(5) + expect(await el.attribute('border-radius')).toEqual(5) }) it('font-size', async () => { const el = await page.$('.p') - expect(await el.property('font-size')).toEqual(16) + expect(await el.attribute('font-size')).toEqual(16) await page.setData({ fontSize: 18 }) - expect(await el.property('font-size')).toEqual(18) + expect(await el.attribute('font-size')).toEqual(18) }) it('stroke-width', async () => { const el = await page.$('.p') - expect(await el.property('stroke-width')).toEqual(3) + expect(await el.attribute('stroke-width')).toEqual(3) await page.setData({ strokeWidth: 6 }) - expect(await el.property('stroke-width')).toEqual(6) + expect(await el.attribute('stroke-width')).toEqual(6) }) it('backgroundColor', async () => { const el = await page.$('.p') - expect(await el.property('background-color')).toEqual('#EBEBEB') + expect(await el.attribute('background-color')).toEqual('#EBEBEB') await page.setData({ backgroundColor: "#007aff" }) - expect(await el.property('background-color')).toEqual('#007aff') + expect(await el.attribute('background-color')).toEqual('#007aff') }) }) \ No newline at end of file diff --git a/pages/component/radio/radio.test.js b/pages/component/radio/radio.test.js index aa14de52..e0fe4401 100644 --- a/pages/component/radio/radio.test.js +++ b/pages/component/radio/radio.test.js @@ -40,26 +40,26 @@ describe('Radio.uvue', () => { }) it('checked', async () => { const radio = await page.$('.r') - expect(await radio.property('checked')).toBe(true) + expect(await radio.attribute('checked')).toBe(true) await page.setData({ checked: false, }) - expect(await radio.property('checked')).toBe(false) + expect(await radio.attribute('checked')).toBe(false) }) it('color', async () => { const radio = await page.$('.r') - expect(await radio.property('color')).toBe('#007aff') + expect(await radio.attribute('color')).toBe('#007aff') await page.setData({ color: '#63acfc', }) - expect(await radio.property('color')).toBe('#63acfc') + expect(await radio.attribute('color')).toBe('#63acfc') }) it('disabled', async () => { const radio = await page.$('.r2') - expect(await radio.property('disabled')).toBe(true) + expect(await radio.attribute('disabled')).toBe(true) await page.setData({ disabled: false, }) - expect(await radio.property('disabled')).toBe(false) + expect(await radio.attribute('disabled')).toBe(false) }) }) diff --git a/pages/component/scroll-view/scroll-view-props.uvue b/pages/component/scroll-view/scroll-view-props.uvue index 556b4bd6..a5b52114 100644 --- a/pages/component/scroll-view/scroll-view-props.uvue +++ b/pages/component/scroll-view/scroll-view-props.uvue @@ -5,7 +5,7 @@ @@ -15,9 +15,9 @@ + @scrolltolower="scrolltolower" @scroll="scroll" @scrollend="scrollend" ref="scrollViewY" id="scrollViewY" style="width: 100%;height: 100%;"> {{item.label}} @@ -40,10 +40,10 @@ 是否横向滚动 - - - 是否竖向滚动 - + + + 是否竖向滚动 + @@ -91,7 +91,7 @@ data() { return { items: [] as Item[], - scrollX: false, + scrollX: false, scrollY: true, rebound: false, scrollTop: 0, @@ -122,20 +122,20 @@ this.scrollTop = e.detail.value; }, changeDirectionX() { - this.scrollX = !this.scrollX; - if(this.scrollX) { - this.scrollY = false + this.scrollX = !this.scrollX; + if(this.scrollX) { + this.scrollY = false + } + this.scrollTop = 0; + this.scrollLeft = 0; + }, + changeDirectionY() { + this.scrollY = !this.scrollY; + if(this.scrollY) { + this.scrollX = false } this.scrollTop = 0; this.scrollLeft = 0; - }, - changeDirectionY() { - this.scrollY = !this.scrollY; - if(this.scrollY) { - this.scrollX = false - } - this.scrollTop = 0; - this.scrollLeft = 0; }, handleScrollIntoView() { if (this.scrollX) { @@ -176,33 +176,33 @@ }, scrollend() { console.log("滚动停止"); - }, - onTouchMove() { - console.log("TouchMove"); - }, - //自动化测试专用 - 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 + }, + onTouchMove() { + console.log("TouchMove"); + }, + //自动化测试专用 + checkScrollHeight(): Boolean { + var element = this.$refs["scrollViewY"] + if(element != null) { + var scrollHeight = (element as UniElement).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 UniElement).scrollWidth + console.log("checkScrollWidth---"+scrollWidth) + if(scrollWidth > 1900) { + return true + } + } + return false } } } @@ -221,7 +221,7 @@ height: 400rpx; width: 100%; background-color: azure; - border-width: 2rpx; + border-width: 2rpx; border-style: solid; border-color: chocolate; } @@ -249,4 +249,4 @@ padding: 30rpx; justify-content: center; } - + diff --git a/pages/component/scroll-view/scroll-view-refresher-props.uvue b/pages/component/scroll-view/scroll-view-refresher-props.uvue index a6c45b64..f7afa3c2 100644 --- a/pages/component/scroll-view/scroll-view-refresher-props.uvue +++ b/pages/component/scroll-view/scroll-view-refresher-props.uvue @@ -2,11 +2,11 @@ - + @refresherabort="refresherabort" style="width: 100%;height: 100%;"> {{item.label}} diff --git a/pages/component/slider-100/slider-100.test.js b/pages/component/slider-100/slider-100.test.js index bf942e1c..2bee9dff 100644 --- a/pages/component/slider-100/slider-100.test.js +++ b/pages/component/slider-100/slider-100.test.js @@ -15,12 +15,12 @@ describe('slider', () => { // TODO 暂时仅获取第一个 const slider1 = await page.$('.slider') - expect(await slider1.property('value')).toBe(sliderValue) + expect(await slider1.attribute('value')).toBe(sliderValue) // const slider100 = await page.$$('.slider') // for (let i = 0; i < slider100.length; i++) { // const slider = slider100[i]; - // expect(await slider.property('value')).toBe(sliderValue) + // expect(await slider.attribute('value')).toBe(sliderValue) // } }) }) diff --git a/pages/component/slider-100/slider-100.uvue b/pages/component/slider-100/slider-100.uvue index d90ad7ca..78fab4b5 100644 --- a/pages/component/slider-100/slider-100.uvue +++ b/pages/component/slider-100/slider-100.uvue @@ -1,7 +1,5 @@