diff --git a/pages.json b/pages.json index 41538bc01da1ab04407d102539fbb90644b0bc96..dcfce5fe9f8f38bfa290a7f45dcec104e302f597 100644 --- a/pages.json +++ b/pages.json @@ -1309,13 +1309,13 @@ "navigationBarTitleText": "日历" } }, + // #endif { "path": "pages/template/schema/schema", "style": { "navigationBarTitleText": "打开schema示例" } }, - // #endif // #ifdef APP-ANDROID { "path": "pages/template/share/share", @@ -1380,13 +1380,13 @@ "enablePullDownRefresh": false } }, - { - "path": "pages/API/theme-change/theme-change", - "style": { - "navigationBarTitleText": "主题切换", - "enablePullDownRefresh": false - } - }, + // { + // "path": "pages/API/theme-change/theme-change", + // "style": { + // "navigationBarTitleText": "主题切换", + // "enablePullDownRefresh": false + // } + // }, { "path": "uni_modules/uni-pay-x/pages/success/success", "style": { @@ -1434,7 +1434,6 @@ "backgroundColorContent": "#fffae8" } }, - // #ifdef APP-ANDROID || WEB { "path" : "pages/API/resize-observer/resize-observer", "style" : @@ -1442,7 +1441,6 @@ "navigationBarTitleText" : "resize observer" } }, - // #endif { "path" : "pages/CSS/overflow/overflow-visible-event", "style" : diff --git a/pages/API/env/env.uvue b/pages/API/env/env.uvue index b9004a9f2b761d6b57c74fc22313b3e135cc9621..adce29875ced55fc07f18074c1537561466d39a6 100644 --- a/pages/API/env/env.uvue +++ b/pages/API/env/env.uvue @@ -33,7 +33,10 @@ methods: { geAbsPath(path ?: Any) { - this.log += UTSAndroid.convert2AbsFullPath(path as String) + '\n' + // #ifdef APP-ANDROID + this.log += UTSAndroid.convert2AbsFullPath(path as String) + '\n' + // #endif + } } } diff --git a/pages/API/get-battery-info/get-battery-info.uvue b/pages/API/get-battery-info/get-battery-info.uvue index 84c733122cd8c9ecef08ac92427092724fb49184..e55d296d8d38c0218e77ce15956040fcc8956f1d 100644 --- a/pages/API/get-battery-info/get-battery-info.uvue +++ b/pages/API/get-battery-info/get-battery-info.uvue @@ -1,28 +1,33 @@ - \ No newline at end of file diff --git a/pages/API/get-file-system-manager/get-file-system-manager.test.js b/pages/API/get-file-system-manager/get-file-system-manager.test.js index 45ccdedf3572e3b03010c75c36cbf82be1a03a5b..090247311d5d7d6d3f25dcf3dd53e98cfe39e3de 100644 --- a/pages/API/get-file-system-manager/get-file-system-manager.test.js +++ b/pages/API/get-file-system-manager/get-file-system-manager.test.js @@ -97,10 +97,10 @@ describe('ExtApi-FileManagerTest', () => { let lastFailError = await getData('lastFailError') expect(lastFailError.errCode).toEqual(1300002) - expect(lastFailError.errMsg).toEqual('no such file or directory:unifile://usr/a/b/c') + expect(lastFailError.errMsg).toEqual('no such file or directory') let lastCompleteError = await getData('lastCompleteError') expect(lastCompleteError.errCode).toEqual(1300002) - expect(lastCompleteError.errMsg).toEqual('no such file or directory:unifile://usr/a/b/c') + expect(lastCompleteError.errMsg).toEqual('no such file or directory') // 测试 recursive = true 期望文件夹创建成功 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 f8b2f9d3494ba8c06bd810dd1f0a5667942b85e2..9cc4c2da4c0ba1992d4c6847eabe66ced211aa81 100644 --- a/pages/API/get-system-info/get-system-info.test.js +++ b/pages/API/get-system-info/get-system-info.test.js @@ -1,55 +1,53 @@ -const PAGE_PATH = '/pages/API/get-system-info/get-system-info' - -describe('ExtApi-GetSystemInfo', () => { - - let page; - let res; - const stringProperties = [ - 'appId', 'appLanguage', 'appName', 'appVersion', 'appVersionCode', - 'brand', 'deviceId', 'deviceBrand', 'deviceModel', 'deviceType', 'language', - 'model', 'osName', 'osVersion', 'osLanguage', 'platform', 'system', 'ua', 'uniCompilerVersion', - 'uniPlatform', 'uniRuntimeVersion', 'romName', 'romVersion', - ] - const numberProperties = [ - 'osAndroidAPILevel', 'devicePixelRatio', 'pixelRatio', 'screenWidth', 'screenHeight', 'statusBarHeight', - 'windowWidth', - 'windowHeight', 'windowTop', 'windowBottom', 'screenTop', - 'uniCompilerVersionCode', 'uniRuntimeVersionCode' +const PAGE_PATH = '/pages/API/get-system-info/get-system-info' + +describe('ExtApi-GetSystemInfo', () => { + + let page; + let res; + const stringProperties = [ + 'appId', 'appLanguage', 'appName', 'appVersion', 'appVersionCode', + 'brand', 'deviceId', 'deviceBrand', 'deviceModel', 'deviceType', 'language', + 'model', 'osName', 'osVersion', 'osLanguage', 'platform', 'system', 'ua', 'uniCompilerVersion', + 'uniPlatform', 'uniRuntimeVersion', 'romName', 'romVersion', + ] + const numberProperties = [ + 'osAndroidAPILevel', 'devicePixelRatio', 'pixelRatio', 'screenWidth', 'screenHeight', 'statusBarHeight', + 'windowWidth', + 'windowHeight', 'windowTop', 'windowBottom', 'screenTop', + 'uniCompilerVersionCode', 'uniRuntimeVersionCode' ] const booleanProperties = [ - 'isUniAppX' ] const requiredProperties = [ 'uniCompilerVersion', 'uniCompilerVersionCode', 'uniRuntimeVersion', - 'uniRuntimeVersionCode', - 'isUniAppX' - ] - - beforeAll(async () => { - page = await program.reLaunch(PAGE_PATH) - await page.waitFor(600); - res = await page.callMethod('jest_getSystemInfo') - }); - it('Check GetSystemInfoSync', async () => { - for (const key in res) { - const value = res[key]; - console.log("key :",key , "value :", value); - if (stringProperties.indexOf(key) != -1) { + 'uniRuntimeVersionCode' + ] + + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(600); + res = await page.callMethod('jest_getSystemInfo') + }); + it('Check GetSystemInfoSync', async () => { + for (const key in res) { + const value = res[key]; + console.log("key :",key , "value :", value); + if (stringProperties.indexOf(key) != -1) { expect(value).not.toBeNull(); - expect(value).not.toBe(""); - } - if (numberProperties.indexOf(key) != -1) { + expect(value).not.toBe(""); + } + if (numberProperties.indexOf(key) != -1) { expect(value).not.toBeNull(); - expect(value).toBeGreaterThanOrEqual(0); - } - if (booleanProperties.indexOf(key) != -1) { + expect(value).toBeGreaterThanOrEqual(0); + } + if (booleanProperties.indexOf(key) != -1) { expect(value).not.toBeNull(); - expect(typeof value).toBe('boolean'); - } - if (key == 'deviceOrientation') { - expect(['portrait', 'landscape']).toContain(value); + expect(typeof value).toBe('boolean'); + } + if (key == 'deviceOrientation') { + expect(['portrait', 'landscape']).toContain(value); } if (key == "osTheme") { expect(['light', 'dark']).toContain(value); @@ -57,12 +55,12 @@ describe('ExtApi-GetSystemInfo', () => { if (key == "appTheme") { expect(['light', 'dark', 'auto']).toContain(value); } - } + } }); it('Check GetSystemInfoSync required properties', async () => { for (let i = 0; i < requiredProperties.length; i++) { const key = requiredProperties[i] expect(`${key} not null: ${res[key] != null}`).toBe(`${key} not null: true`) } - }) + }) }); diff --git a/pages/API/map/map.test.js b/pages/API/map/map.test.js new file mode 100644 index 0000000000000000000000000000000000000000..f1dd4cde0e1699d7af5af9814f11a35c57ae261c --- /dev/null +++ b/pages/API/map/map.test.js @@ -0,0 +1,52 @@ +const PAGE_PATH = '/pages/API/map/map' +let page; +describe('web-map', () => { + console.log("uniTestPlatformInfo",process.env.uniTestPlatformInfo) + if (!process.env.uniTestPlatformInfo.startsWith('web')) { + it('app', () => { + expect(1).toBe(1) + }) + return + } + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor('view'); + // 等待地图加载完成 + await page.waitFor(4000); + await page.setData({autoTest:true}) + }); + + it('Check MapMethods', async () => { + const mapMethods = ['changeScale', 'addMarkers', 'addPolyline', 'addPolygons', 'addCircles', + 'includePoint', 'handleTranslateMarker' + ] + for (var i = 0; i < mapMethods.length; i++) { + await page.callMethod(mapMethods[i]) + if (mapMethods[i] == 'handleTranslateMarker') { + await page.waitFor(2000); + } else { + await page.waitFor(500); + } + expect(await program.screenshot()).toSaveImageSnapshot(); + await page.waitFor(500); + } + }); + it('handleGetCenterLocation', async () => { + await page.callMethod('handleGetCenterLocation') + await page.waitFor(500); + const centerLocationRes = await page.data('getCenterLocationTest') + expect(centerLocationRes.latitude).not.toBeNull(); + expect(centerLocationRes.longitude).not.toBeNull(); + }); + it('handleGetRegion', async () => { + await page.callMethod('handleGetRegion') + await page.waitFor(500); + const regionRes = await page.data('getRegionTest') + const getRegionExpected = { + southwest: { latitude: 39.88334279187766, longitude: 116.31050146728515 }, + northeast: { latitude: 40.0149408585477, longitude: 116.56799353271484 }, + errMsg: 'getRegion:ok' + } + expect(regionRes).toEqual(expect.objectContaining(getRegionExpected)); + }); +}); diff --git a/pages/API/map/map.uvue b/pages/API/map/map.uvue index f4dbf29e2aec94f3dd5b545820e6462ca477818d..e2d03bba1493882c09a60eadbfa7a2d9238f9a40 100644 --- a/pages/API/map/map.uvue +++ b/pages/API/map/map.uvue @@ -304,7 +304,11 @@ includePoints: [] as Points[], rotate: 0, skew: 0, - map: null as MapContext | null + map: null as MapContext | null, + // 自动化测试 + autoTest: false, + getCenterLocationTest:{}, + getRegionTest:{}, } }, onReady() { @@ -359,9 +363,12 @@ this.map!.getCenterLocation({ success: ret => { console.log(JSON.stringify(ret)); - uni.showModal({ - content: JSON.stringify(ret) - }) + this.getCenterLocationTest = ret + if(!this.autoTest){ + uni.showModal({ + content: JSON.stringify(ret) + }) + } } }) }, @@ -369,9 +376,12 @@ this.map!.getRegion({ success: ret => { console.log(JSON.stringify(ret)); - uni.showModal({ - content: JSON.stringify(ret) - }) + this.getRegionTest = ret + if(!this.autoTest){ + uni.showModal({ + content: JSON.stringify(ret) + }) + } } }) }, diff --git a/pages/API/request-payment/reqeust-payment.test.js b/pages/API/request-payment/reqeust-payment.test.js index 2c4fd3b20431c9608837cdd75514ff269ceef8fd..1e314a311da5d1ac16adb81a833cf977320d431b 100644 --- a/pages/API/request-payment/reqeust-payment.test.js +++ b/pages/API/request-payment/reqeust-payment.test.js @@ -18,8 +18,8 @@ describe("payment", () => { page = await program.reLaunch(PAGE_PATH) await page.waitFor(600) }); - //支付失败700711 - it("errorcode700711", async () => { + //支付失败701100 + it("errorcode701100", async () => { let orderInfo = "service=\"mobile.securitypay.pay\"&partner=\"2088801273866834\"&_input_charset=\"UTF-8\"&out_trade_no=\"20240229115452\"&subject=\"DCloud项目捐赠\"&payment_type=\"1\"&seller_id=\"payservice@dcloud.io\"&total_fee=\"0.01\"&body=\"DCloud致力于打造HTML5最好的移动开发工具,包括终端的Runtime、云端的服务和IDE,同时提供各项配套的开发者服务。\"&it_b_pay=\"1d\"¬ify_url=\"http%3A%2F%2Fdemo.dcloud.net.cn%2Fpayment%2Falipay%2Fnotify.php\"&show_url=\"http%3A%2F%2Fwww.dcloud.io%2Fhelloh5%2F\"&sign=\"diZdkTX2iIP1oZh25UCGqx%2BpkViqAN8xdvMNSJF79aq0JiunX2mtr%2BbNlDsP0YL5x85KjULsqx%2Fq%2B5wij6eMoBVeJ%2BHhyjkwt0PYuwntroJ2Ho8bdUVEybBgOjy240NbCUtKmZzNRQAGsmLztKWzsg1srsQ8Se3Qi8KGDaOhqBs%3D\"&sign_type=\"RSA\""; await page.setData({ @@ -29,6 +29,6 @@ describe("payment", () => { await page.waitFor(async () => { return await page.data('complete') === true; }); - expect((await page.data())['errorCode']).toEqual(700711) + expect((await page.data())['errorCode']).toEqual(701100) }); }); diff --git a/pages/API/resize-observer/resize-observer.test.js b/pages/API/resize-observer/resize-observer.test.js index 22160835196358c0332b10f71d7863294c9283e4..ad6de613af2bfc44912faf0f1d4dbf39d48b88f1 100644 --- a/pages/API/resize-observer/resize-observer.test.js +++ b/pages/API/resize-observer/resize-observer.test.js @@ -1,13 +1,5 @@ describe('api-resize-observer', () => { - if ( - !process.env.uniTestPlatformInfo.startsWith('android') && - !process.env.uniTestPlatformInfo.startsWith('web') - ) { - it('dummyTest', async () => { - expect(1).toBe(1) - }) - return - } + let page beforeAll(async () => { diff --git a/pages/API/resize-observer/resize-observer.uvue b/pages/API/resize-observer/resize-observer.uvue index d2377add5f940a4bcfabd86e00dacaefc8f84f28..b8a60099211c4e2a87ec626ff4b3f07638486cf6 100644 --- a/pages/API/resize-observer/resize-observer.uvue +++ b/pages/API/resize-observer/resize-observer.uvue @@ -4,13 +4,15 @@ + id="outBox" @click="outBoxClick"> - + + + 蓝色方块元素: @@ -34,7 +36,7 @@ boxDisplay: false, outBoxElement: null as UniElement | null, innerBoxElement: null as UniElement | null, - resizeObserver: null as UniResizeObserver | null, + resizeObserver: null as UniResizeObserver | null, outBoxElementOnResize: false } }, @@ -47,9 +49,10 @@ onReady() { if (this.resizeObserver == null) { this.resizeObserver = new UniResizeObserver((entries : Array) => { + entries.forEach(entry => { if (entry.target == this.outBoxElement) { - this.outBoxSizeInfo = this.analysisResizeObserverEntry(entry) + this.outBoxSizeInfo = this.analysisResizeObserverEntry(entry) this.outBoxElementOnResize = true } else if (entry.target == this.innerBoxElement) { this.innerBoxSizeInfo = this.analysisResizeObserverEntry(entry) @@ -63,7 +66,7 @@ this.innerBoxElement = uni.getElementById("innerBox") if (this.innerBoxElement != null) { this.resizeObserver!.observe(this.innerBoxElement!) - } + } this.boxDisplay = true } }, @@ -89,13 +92,13 @@ this.innerBoxElement!.style.setProperty("width", "80px") this.innerBoxElement!.style.setProperty("height", "80px") } - }, - //自动化测试专用 - setOutBoxMarginLeft(value: string) { - if (this.outBoxElement != null) { - this.outBoxElementOnResize = false - this.outBoxElement!.style.setProperty("margin-left", value) - } + }, + //自动化测试专用 + setOutBoxMarginLeft(value : string) { + if (this.outBoxElement != null) { + this.outBoxElementOnResize = false + this.outBoxElement!.style.setProperty("margin-left", value) + } }, toggleDisplay() { this.boxDisplay = !this.boxDisplay @@ -108,6 +111,15 @@ "contentBoxSize: \n{blockSize:" + contentBoxSize.blockSize + ", inlineSize:" + contentBoxSize.inlineSize + "}\n" + "devicePixelContentBoxSize: \n{blockSize:" + devicePixelContentBoxSize.blockSize + ", inlineSize:" + devicePixelContentBoxSize.inlineSize + "}\n" + "contentRect: \n{x:" + entry.contentRect.x + ", y:" + entry.contentRect.y + ", width:" + entry.contentRect.width + ", height:" + entry.contentRect.height + "}" + }, + cancelListen(){ + // this.resizeObserver?.unobserve() + this.resizeObserver!.unobserve(this.outBoxElement!) + this.resizeObserver!.unobserve(this.innerBoxElement!) + }, + goOnListen(){ + this.resizeObserver!.observe(this.outBoxElement!) + this.resizeObserver!.observe(this.innerBoxElement!) } } } diff --git a/pages/API/theme-change/theme-change.uvue b/pages/API/theme-change/theme-change.uvue index 9c3b662aebad42b194792efba1834638b950496b..4afff9df03afb8b1912033de755b4fe6002a4d2a 100644 --- a/pages/API/theme-change/theme-change.uvue +++ b/pages/API/theme-change/theme-change.uvue @@ -1,14 +1,14 @@