diff --git a/common/uni.css b/common/uni.css index 6a8221132b534dc2d8c584fd72e2299e744a512a..cc196f2c516783147c43150bc83124d5fa82c731 100644 --- a/common/uni.css +++ b/common/uni.css @@ -83,7 +83,7 @@ .uni-input { height: 50rpx; padding: 15rpx 25rpx; - line-height: 50rpx; + /* line-height: 50rpx; */ font-size: 28rpx; background: #FFF; flex: 1; diff --git a/components/enum-data/enum-data.vue b/components/enum-data/enum-data.vue index 85b1f50ad69c4070f34a16e7e1f15c227d34e806..61243fe4ec55da34ff1303ef87d991ad496f539e 100644 --- a/components/enum-data/enum-data.vue +++ b/components/enum-data/enum-data.vue @@ -1,4 +1,6 @@ \ No newline at end of file diff --git a/components/u-link/u-link.vue b/components/u-link/u-link.vue index 247030dc899e73ccfc86b7dfaa6322fe39886de0..045ded60ba0c454c3a49e80314e33003173eafc8 100644 --- a/components/u-link/u-link.vue +++ b/components/u-link/u-link.vue @@ -4,7 +4,7 @@ - + + diff --git a/components/uni-navbar-lite/uni-navbar-lite.vue b/components/uni-navbar-lite/uni-navbar-lite.vue new file mode 100644 index 0000000000000000000000000000000000000000..5efd192fa33fe8ff82e9e66fb13827a593ff9211 --- /dev/null +++ b/components/uni-navbar-lite/uni-navbar-lite.vue @@ -0,0 +1,94 @@ + + + + + diff --git a/components/uni-navbar-lite/uniicons.ttf b/components/uni-navbar-lite/uniicons.ttf new file mode 100644 index 0000000000000000000000000000000000000000..e370efe839a69693e9ee79483f7bbca34f49dcfd Binary files /dev/null and b/components/uni-navbar-lite/uniicons.ttf differ diff --git a/hello-uniapp-x.apk b/hello-uniapp-x.apk index 34d4669de39cc3e77920ad46e63757b15a47bd4c..aef6105e1b7396f9cfb32182e8418b8fe113845c 100644 Binary files a/hello-uniapp-x.apk and b/hello-uniapp-x.apk differ diff --git a/jest-setup.js b/jest-setup.js index 8ddb4e3dcc2ab8cec2a57e4b4696418e07e6ea10..0864a9dead1eb066c6899d7df57909b744e534f6 100644 --- a/jest-setup.js +++ b/jest-setup.js @@ -6,13 +6,14 @@ const { const hbuilderx_version = process.env.HX_Version const uniTestPlatformInfo = process.env.uniTestPlatformInfo ? process.env.uniTestPlatformInfo.replace(/\s/g,'_') : '' const folderName = `__image_snapshots__/${hbuilderx_version}/__${uniTestPlatformInfo}__` +const baseFolderName = `__image_snapshots__/base` expect.extend({ toMatchImageSnapshot: configureToMatchImageSnapshot({ customSnapshotIdentifier(args) { return args.currentTestName.replace(/\//g, '-').replace(' ', '-'); }, - customSnapshotsDir: path.join(__dirname, folderName), + customSnapshotsDir: path.join(__dirname, baseFolderName), customDiffDir: path.join(__dirname, `${folderName}/`, 'diff'), }), }); \ No newline at end of file diff --git a/jest.config.js b/jest.config.js index f3dd67c9d447ee3bd768582a2f7e79c1c68b5f9a..1ce69aa8cf578672d1fc77048cc5e05eed9e6e29 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,10 +1,10 @@ module.exports = { - testTimeout: 10000, + testTimeout: 30000, reporters: ['default'], watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'], moduleFileExtensions: ['js', 'json'], rootDir: __dirname, - testMatch: ["/pages/**/*test.[jt]s?(x)"], + testMatch: ["/pages/API/storage/storage.test.js"], testPathIgnorePatterns: ['/node_modules/'], setupFilesAfterEnv: ['/jest-setup.js'], } diff --git a/manifest.json b/manifest.json index e309c620b13199348ba00591d8443559b7223beb..5644e684dc448688844ffce447f98ee01fc7bc00 100644 --- a/manifest.json +++ b/manifest.json @@ -2,8 +2,8 @@ "name" : "hello-uniapp x", "appid" : "__UNI__3584C99", "description" : "", - "versionName" : "1.0.5", - "versionCode" : 105, + "versionName" : "1.0.10", + "versionCode" : 10010, "uni-app-x" : {}, /* 快应用特有相关 */ "quickapp" : {}, @@ -27,5 +27,10 @@ "uniStatistics" : { "enable" : false }, + "app": { + "duts": [ + "uni-facialRecognitionVerify" + ] + }, "vueVersion" : "3" } diff --git a/pages.json b/pages.json index 910a1da3516257a79ba57a51def55acb8d0f5544..4a17638b235d867452a0cbac19d49722a5966551 100644 --- a/pages.json +++ b/pages.json @@ -243,6 +243,13 @@ "navigationBarTitleText": "设置导航条颜色" } }, + { + "path": "pages/API/set-navigation-bar-color/set-custom-navigation-bar-color", + "style": { + "navigationBarTitleText": "设置自定义导航栏颜色", + "navigationStyle": "custom" + } + }, { "path": "pages/API/navigator/new-page/new-page-1", "style": { @@ -263,6 +270,12 @@ "enablePullDownRefresh": true } }, + { + "path": "pages/API/get-element-by-id/get-element-by-id", + "style": { + "navigationBarTitleText": "获取节点" + } + }, { "path": "pages/API/nodes-info/nodes-info", "style": { @@ -288,7 +301,7 @@ } }, { - "path": "pages/API/show-loading/show-loading", + "path": "pages/API/loading/loading", "style": { "navigationBarTitleText": "加载提示框" } @@ -336,24 +349,48 @@ "navigationBarTitleText": "background-image" } }, + { + "path": "pages/CSS/border/border-bottom", + "style": { + "navigationBarTitleText": "border-bottom" + } + }, { "path": "pages/CSS/border/border-color", "style": { "navigationBarTitleText": "border-color" } }, + { + "path": "pages/CSS/border/border-left", + "style": { + "navigationBarTitleText": "border-left" + } + }, { "path": "pages/CSS/border/border-radius", "style": { "navigationBarTitleText": "border-radius" } }, + { + "path": "pages/CSS/border/border-right", + "style": { + "navigationBarTitleText": "border-right" + } + }, { "path": "pages/CSS/border/border-style", "style": { "navigationBarTitleText": "border-style" } }, + { + "path": "pages/CSS/border/border-top", + "style": { + "navigationBarTitleText": "border-top" + } + }, { "path": "pages/CSS/border/border-width", "style": { @@ -479,12 +516,12 @@ "style": { "navigationBarTitleText": "width" } - }, - { - "path": "pages/CSS/layout/z-index", - "style": { - "navigationBarTitleText": "z-index" - } + }, + { + "path": "pages/CSS/layout/z-index", + "style": { + "navigationBarTitleText": "z-index" + } }, { "path": "pages/CSS/layout/visibility", @@ -667,7 +704,13 @@ } }, { - "path": "pages/API/call-function/call-function", + "path": "pages/API/unicloud-call-function/unicloud-call-function", + "style": { + "navigationBarTitleText": "" + } + }, + { + "path": "pages/API/unicloud-import-object/unicloud-import-object", "style": { "navigationBarTitleText": "" } @@ -709,11 +752,17 @@ } }, { - "path": "pages/API/save-image-to-album/save-image-to-album", + "path": "pages/API/save-image-to-photos-album/save-image-to-photos-album", "style": { "navigationBarTitleText": "保存图片到相册" } }, + { + "path": "pages/API/choose-image/choose-image", + "style": { + "navigationBarTitleText": "图片" + } + }, { "path": "pages/component/scroll-view/scroll-view-refresher", "style": { @@ -762,18 +811,6 @@ "navigationBarTitleText": "模板" } }, - { - "path": "pages/component/long-list/long-list", - "style": { - "navigationBarTitleText": "长列表示例" - } - }, - { - "path": "pages/component/long-list/detail/detail", - "style": { - "navigationBarTitleText": "详情示例" - } - }, { "path": "pages/template/swiper-list/swiper-list", "style": { @@ -875,9 +912,40 @@ { "path": "pages/template/pull-zoom-image/pull-zoom-image", "style": { - "enablePullDownRefresh": false, "navigationStyle": "custom" } + }, + { + "path": "pages/API/unicloud-file-api/unicloud-file-api", + "style": { + "navigationBarTitleText": "" + } + }, + { + "path": "pages/API/unicloud-database/unicloud-database", + "style": { + "navigationBarTitleText": "" + } + }, + { + "path": "pages/template/navbar-lite/navbar-lite", + "style": { + "navigationBarTitleText": "自定义导航栏", + "navigationStyle": "custom" + } + }, + { + "path": "pages/template/custom-tab-bar/custom-tab-bar", + "style": { + "navigationBarTitleText": "自定义TabBar" + } + }, { + "path": "pages/API/facial-recognition-verify/facial-recognition-verify", + "style": { + "navigationBarTitleText": "", + "enablePullDownRefresh": false + } + } ], "globalStyle": { @@ -929,4 +997,4 @@ "query": "" //启动参数,在页面的onLoad函数里面得到 }] } -} +} \ No newline at end of file diff --git a/pages/API/action-sheet/action-sheet.uvue b/pages/API/action-sheet/action-sheet.uvue index 60e8adc88ee0c1e617c488d0ca8878c0b13ce17d..a16c30bde2a2acf73ca8ec9585402a9a5937500b 100644 --- a/pages/API/action-sheet/action-sheet.uvue +++ b/pages/API/action-sheet/action-sheet.uvue @@ -82,9 +82,11 @@ if (this.itemContentLarge) { itemInfo = ['两个黄鹂鸣翠柳,一行白鹭上青天。窗含西岭千秋雪,门泊东吴万里船', '水光潋滟晴方好,山色空蒙雨亦奇。 欲把西湖比西子,淡妆浓抹总相宜', ''] - } else if (this.itemNumLargeSelect) { + } + + if (this.itemNumLargeSelect) { // 大量选项测试,不能超过6个元素 https://uniapp.dcloud.net.cn/api/ui/prompt.html#showactionsheet - itemInfo = [] + itemInfo = [] for (var i = 1; i <= 10; i++) { itemInfo.push('两个黄鹂鸣翠柳,一行白鹭上青天'); } diff --git a/pages/API/choose-image/choose-image.uvue b/pages/API/choose-image/choose-image.uvue new file mode 100644 index 0000000000000000000000000000000000000000..87806047bdd028a94e9cba64f02646312d4103b5 --- /dev/null +++ b/pages/API/choose-image/choose-image.uvue @@ -0,0 +1,292 @@ + + + + + \ No newline at end of file diff --git a/pages/API/download-file/download-file.test.js b/pages/API/download-file/download-file.test.js new file mode 100644 index 0000000000000000000000000000000000000000..9b41ee42097f2cf6240fd095bc47f1dafe551f33 --- /dev/null +++ b/pages/API/download-file/download-file.test.js @@ -0,0 +1,18 @@ +const PAGE_PATH = '/pages/API/download-file/download-file' + +describe('ExtApi-DownloadFile', () => { + + let page; + let res; + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(600); + await page.callMethod('jest_downloadFile'); + await page.waitFor(500); + res = await page.data('jest_result'); + }); + + it('Check ', async () => { + expect(res).toBe(true); + }); +}); diff --git a/pages/API/download-file/download-file.uvue b/pages/API/download-file/download-file.uvue index e028784e245e9c2c4851fc9584eb22e5a4073f31..0b00386498952ed858f520c7b577357a0293853e 100644 --- a/pages/API/download-file/download-file.uvue +++ b/pages/API/download-file/download-file.uvue @@ -21,14 +21,15 @@ diff --git a/pages/API/facial-recognition-verify/facial-recognition-verify.uvue b/pages/API/facial-recognition-verify/facial-recognition-verify.uvue new file mode 100644 index 0000000000000000000000000000000000000000..b1bbd655554c33e5192407670306d094fa4173bb --- /dev/null +++ b/pages/API/facial-recognition-verify/facial-recognition-verify.uvue @@ -0,0 +1,91 @@ + + + + + diff --git a/pages/API/get-app-authorize-setting/get-app-authorize-setting.test.js b/pages/API/get-app-authorize-setting/get-app-authorize-setting.test.js new file mode 100644 index 0000000000000000000000000000000000000000..f182c9431135bc9321d0c6fbb2e1fae50245ead6 --- /dev/null +++ b/pages/API/get-app-authorize-setting/get-app-authorize-setting.test.js @@ -0,0 +1,34 @@ +const PAGE_PATH = '/pages/API/get-app-authorize-setting/get-app-authorize-setting' + +describe('ExtApi-GetAppAuthorizeSetting', () => { + + let page; + let res; + let commonSupportList = [ + 'authorized', 'denied', 'not determined', 'config error' + ] + let locationAccuracySupportList = [ + 'reduced', 'full', 'unsupported' + ] + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(600); + res = await uni.getAppAuthorizeSetting(); + }); + it('Check cameraAuthorized', async () => { + expect(commonSupportList).toContain(res.cameraAuthorized) + }); + + it('Check locationAuthorized', async () => { + expect(commonSupportList).toContain(res.locationAuthorized) + }); + it('Check locationAccuracy', async () => { + expect(locationAccuracySupportList).toContain(res.locationAccuracy) + }); + it('Check microphoneAuthorized', async () => { + expect(commonSupportList).toContain(res.microphoneAuthorized) + }); + it('Check notificationAuthorized', async () => { + expect(commonSupportList).toContain(res.notificationAuthorized) + }); +}); 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 new file mode 100644 index 0000000000000000000000000000000000000000..4c61b7bfafed7d025d8eae7c882c4c567bb34d49 --- /dev/null +++ b/pages/API/get-app-base-info/get-app-base-info.test.js @@ -0,0 +1,33 @@ +const PAGE_PATH = '/pages/API/get-app-base-info/get-app-base-info' + +describe('ExtApi-GetAppBaseInfo', () => { + + let page; + let res; + const stringProperties = [ + 'appId', 'appName', 'appVersion', 'appVersionCode', 'appLanguage', + 'language', 'version', 'uniCompileVersion', 'uniPlatform', 'uniRuntimeVersion', + ] + const numberProperties = [ + 'uniCompileVersionCode', 'uniRuntimeVersionCode' + ] + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(600); + res = await uni.getAppBaseInfo(); + }); + it('Check properties', 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.toBeNull(); + expect(value).toBeGreaterThanOrEqual(3.90); + } + } + }); +}); diff --git a/pages/API/get-app-base-info/get-app-base-info.uvue b/pages/API/get-app-base-info/get-app-base-info.uvue index 4d603059b50b0226157bc3fa2a3a6b93997f9da7..43b159394ebd30e0c4f550368921cf7a8f427f95 100644 --- a/pages/API/get-app-base-info/get-app-base-info.uvue +++ b/pages/API/get-app-base-info/get-app-base-info.uvue @@ -37,17 +37,17 @@ methods: { getAppBaseInfo: function () { const res = uni.getAppBaseInfo(); - //类型对象暂时不支持forin或Object.keys(), 临时通过字符串进行转化。 - const json = JSON.stringify(res); - const result = JSON.parse>(json); - this.items = [] as Item[]; - result?.forEach((value, key) => { - const item = { - label: key, - value: "" + value - } as Item; - this.items.push(item); - }) + this.items = [] as Item[]; + for(const key in res){ + const value = res[key]; + if(value != null){ + const item = { + label: key, + value: "" + ((typeof value == "object")? JSON.stringify(value) : value) + } as Item; + this.items.push(item); + } + } } } } diff --git a/pages/API/get-battery-info/get-battery-info.test.js b/pages/API/get-battery-info/get-battery-info.test.js new file mode 100644 index 0000000000000000000000000000000000000000..30687272161f9653c97b39c43eed171339ecf647 --- /dev/null +++ b/pages/API/get-battery-info/get-battery-info.test.js @@ -0,0 +1,26 @@ +const PAGE_PATH = '/pages/API/get-battery-info/get-battery-info' + +describe('ExtApi-GetBatteryInfo', () => { + + let page; + let res; + + const numberProperties = [ + 'level' + ] + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(600); + res = await uni.getBatteryInfo(); + }); + + it('Check properties', async () => { + for (const key in res) { + const value = res[key]; + expect(value).not.toBeNull(); + if (numberProperties.indexOf(key) != -1) { + expect(value).toBeGreaterThanOrEqual(0.1); + } + } + }); +}); diff --git a/pages/API/get-device-info/get-device-info.test.js b/pages/API/get-device-info/get-device-info.test.js new file mode 100644 index 0000000000000000000000000000000000000000..d0027337dc8c0ca9d760314ea6abf8796dd6ac1b --- /dev/null +++ b/pages/API/get-device-info/get-device-info.test.js @@ -0,0 +1,30 @@ +const PAGE_PATH = '/pages/API/get-device-info/get-device-info' + +describe('ExtApi-GetDeviceInfo', () => { + + let page; + let res; + const stringProperties = [ + 'brand', 'deviceBrand', 'deviceId', 'model', 'deviceModel', + 'deviceType', 'devicePixelRatio', 'system', 'platform', 'uniRuntimeVersion', + ] + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(600); + res = await uni.getDeviceInfo(); + }); + it('Check properties', 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 (key == 'deviceOrientation') { + expect(value).not.toBeNull(); + expect(['portrait', 'landscape']).toContain(value); + } + } + }); +}); diff --git a/pages/API/get-device-info/get-device-info.uvue b/pages/API/get-device-info/get-device-info.uvue index 69f3bdbc45b96a252dc9dfbb1fafd86785094a6c..788ec9b2c11f39c8aa07126ac348acdf586c5488 100644 --- a/pages/API/get-device-info/get-device-info.uvue +++ b/pages/API/get-device-info/get-device-info.uvue @@ -55,18 +55,18 @@ export default { }, methods: { getDeviceInfo: function () { - const res = uni.getDeviceInfo(); - //类型对象暂时不支持forin或Object.keys(), 临时通过字符串进行转化。 - const json = JSON.stringify(res); - const result = JSON.parse>(json); - this.items = [] as Item[]; - result?.forEach((value, key) => { - const item = { - label: key, - value: "" + value - } as Item; - this.items.push(item); - }) + const res = uni.getDeviceInfo(); + this.items = [] as Item[]; + for(const key in res){ + const value = res[key]; + if(value != null){ + const item = { + label: key, + value: "" + ((typeof value == "object")? JSON.stringify(value) : value) + } as Item; + this.items.push(item); + } + } } } } diff --git a/pages/API/get-element-by-id/get-element-by-id.test.js b/pages/API/get-element-by-id/get-element-by-id.test.js new file mode 100644 index 0000000000000000000000000000000000000000..34cd75ede394262db4f4eca5e5921d75e472b8c2 --- /dev/null +++ b/pages/API/get-element-by-id/get-element-by-id.test.js @@ -0,0 +1,20 @@ +const PAGE_PATH = "/pages/API/get-element-by-id/get-element-by-id"; +let page; + +describe("getElementById", () => { + beforeAll(async () => { + page = await program.navigateTo(PAGE_PATH); + await page.waitFor(1000); + }); + it("getElementByNotExistId", async () => { + const res = await page.callMethod("getElementByNotExistId"); + expect(!!res).toBe(false); + }); + it("changeStyle", async () => { + await page.callMethod("changePageHeadBackgroundColor"); + await page.callMethod("changeTextColor"); + await page.callMethod("changeViewStyle"); + const image = await program.screenshot(); + expect(image).toMatchImageSnapshot(); + }); +}); 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 new file mode 100644 index 0000000000000000000000000000000000000000..6975757b1f4ca33586de1ea15435359eac03b1c7 --- /dev/null +++ b/pages/API/get-element-by-id/get-element-by-id.uvue @@ -0,0 +1,51 @@ + + + diff --git a/pages/API/get-launch-options-sync/get-launch-options-sync.uvue b/pages/API/get-launch-options-sync/get-launch-options-sync.uvue index b4e550e6a3455bdf3e88e3e913320986dc975b77..0e1ce6975d4921c357846563a33841bfc1c17c56 100644 --- a/pages/API/get-launch-options-sync/get-launch-options-sync.uvue +++ b/pages/API/get-launch-options-sync/get-launch-options-sync.uvue @@ -1,13 +1,12 @@ @@ -22,7 +21,7 @@ export default { } }, methods: { - getLaunchOptionsSync: function () { + getLaunchOptionsSync() { const launchOptions = uni.getLaunchOptionsSync() this.launchOptionsPath = launchOptions.path if (launchOptions.path == this.homePagePath) { diff --git a/pages/API/get-location/get-location.uvue b/pages/API/get-location/get-location.uvue index e7d2c5631a3368e29fe31b882241cea078eafa66..533bb80066895ae27b2012d888c4b29e39054e3f 100644 --- a/pages/API/get-location/get-location.uvue +++ b/pages/API/get-location/get-location.uvue @@ -6,7 +6,7 @@ 真机运行标准基座仅包含系统定位,即system。\n 部分手机因gms兼容不好可能导致无法定位。\n gcj国标、逆地理信息等功能需三方sdk定位。如果需要类似能力可以下载腾讯定位插件,打包自定义基座。参考示例: - + diff --git a/pages/API/get-network-type/get-network-type.test.js b/pages/API/get-network-type/get-network-type.test.js new file mode 100644 index 0000000000000000000000000000000000000000..0e7cb59470a75f9b5ff31a7ab1c5da811b920f6c --- /dev/null +++ b/pages/API/get-network-type/get-network-type.test.js @@ -0,0 +1,18 @@ +const PAGE_PATH = '/pages/API/get-network-type/get-network-type' + +describe('ExtApi-GetNetworkType', () => { + + let page; + let res; + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(600); + await page.callMethod('jest_getNetworkType'); + await page.waitFor(200); + res = await page.data('jest_result'); + }); + + it('Check ', async () => { + expect(res).toBe(true); + }); +}); diff --git a/pages/API/get-network-type/get-network-type.uvue b/pages/API/get-network-type/get-network-type.uvue index aef82001acfa33b898a8432bc3341bca58cc6916..dcae67e586dbe9c737135e900e9e30e4c13e33b7 100644 --- a/pages/API/get-network-type/get-network-type.uvue +++ b/pages/API/get-network-type/get-network-type.uvue @@ -3,10 +3,10 @@ - 网络状态 + 网络状态 未获取 - 请点击下面按钮获取网络状态 + 请点击下面按钮获取网络状态 {{networkType}} @@ -27,7 +27,9 @@ hasNetworkType: false, networkType: '', connectedWifi: '', - pageVisible: false + pageVisible: false, + //自动化测试例专用 + jest_result:false, } }, onLoad() { @@ -60,11 +62,22 @@ this.hasNetworkType = false; this.networkType = ''; this.connectedWifi = ''; - }, + }, + //自动化测试例专用 + jest_getNetworkType(){ + uni.getNetworkType({ + success: () => { + this.jest_result = true; + }, + fail: () => { + this.jest_result = false; + } + }) + } } } \ No newline at end of file + diff --git a/pages/API/get-system-info/get-system-info.test.js b/pages/API/get-system-info/get-system-info.test.js new file mode 100644 index 0000000000000000000000000000000000000000..5a614780afe15fe8a0b92e7dddf241f0b42d883d --- /dev/null +++ b/pages/API/get-system-info/get-system-info.test.js @@ -0,0 +1,42 @@ +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', 'version', 'osName', 'osVersion', 'osLanguage', 'platform', 'system', 'ua', 'uniCompileVersion', + 'uniPlatform', 'uniRuntimeVersion', 'romName', 'romVersion', + ] + const numberProperties = [ + 'osAndroidAPILevel', 'devicePixelRatio', 'pixelRatio', 'screenWidth', 'screenHeight', 'statusBarHeight', + 'windowWidth', + 'windowHeight', 'windowTop', 'windowBottom', 'screenTop', + 'uniCompileVersionCode', '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.toBeNull(); + expect(value).toBeGreaterThanOrEqual(0); + } + if (key == 'deviceOrientation') { + expect(['portrait', 'landscape']).toContain(value); + } + } + }); +}); diff --git a/pages/API/get-system-info/get-system-info.uvue b/pages/API/get-system-info/get-system-info.uvue index 7acbba04a8128614e2b278c5e914388579d32754..a97ac104f50d62cef94c2e488daa97bea651976c 100644 --- a/pages/API/get-system-info/get-system-info.uvue +++ b/pages/API/get-system-info/get-system-info.uvue @@ -28,8 +28,11 @@ - + @@ -54,23 +57,41 @@ export default { onUnload: function () { }, methods: { - getSystemInfo: function () { + getSystemInfo: function () { uni.getSystemInfo({ - success: (res) => { - //类型对象暂时不支持forin或Object.keys(), 临时通过字符串进行转化。 - const json = JSON.stringify(res); - const result = JSON.parse>(json); - this.items = [] as Item[]; - result?.forEach((value, key) => { - const item = { - label: key, - value: "" + value - } as Item; - this.items.push(item); - }) + success: (res) => { + this.items = [] as Item[]; + for(const key in res){ + const value = res[key]; + if(value != null){ + const item = { + label: key, + value: "" + ((typeof value == "object")? JSON.stringify(value) : value) + } as Item; + this.items.push(item); + } + } }, }) - } + }, + getSystemInfoSync: function () { + this.items = [] as Item[]; + const res = uni.getSystemInfoSync() + for(const key in res){ + const value = res[key]; + if(value != null){ + const item = { + label: key, + value: "" + ((typeof value == "object")? JSON.stringify(value) : value) + } as Item; + this.items.push(item); + } + } + }, + //自动化测试例专用 + jest_getSystemInfo():GetSystemInfoResult{ + return uni.getSystemInfoSync(); + }, } } diff --git a/pages/API/get-system-setting/get-system-setting.test.js b/pages/API/get-system-setting/get-system-setting.test.js new file mode 100644 index 0000000000000000000000000000000000000000..851dd0764f3c772cee6bdc2af1e44a4469b82f84 --- /dev/null +++ b/pages/API/get-system-setting/get-system-setting.test.js @@ -0,0 +1,32 @@ +const PAGE_PATH = '/pages/API/get-system-setting/get-system-setting' + +describe('ExtApi-GetSystemSetting', () => { + + let page; + let res; + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(600); + res = await uni.getSystemSetting() + }); + it('Check GetSystemSetting', async () => { + for (const key in res) { + const value = res[key]; + if (res['bluetoothEnabled'] == undefined) { + expect(res['bluetoothError']).not.toBe("") + } else { + expect(res['bluetoothError'] == undefined).toBe(true) + } + + if (res['wifiEnabled'] == undefined) { + expect(res['wifiError']).not.toBe("") + } else { + expect(res['wifiError'] == undefined).toBe(true) + } + + if (key == 'deviceOrientation') { + expect(['portrait', 'landscape']).toContain(value); + } + } + }); +}); diff --git a/pages/API/get-system-setting/get-system-setting.uvue b/pages/API/get-system-setting/get-system-setting.uvue index b3d348ea06d603f19cedb5fea5b938fdb5110fa4..253d6e0d85df8513d29e46b707c998754719a701 100644 --- a/pages/API/get-system-setting/get-system-setting.uvue +++ b/pages/API/get-system-setting/get-system-setting.uvue @@ -61,9 +61,9 @@ getSystemSetting: function () { const res = uni.getSystemSetting(); this.bluetoothEnabled = (res.bluetoothEnabled ?? false) ? "开启" : "关闭"; - this.locationEnabled = (res.locationEnabled ?? false) ? "开启" : "关闭"; + this.locationEnabled = res.locationEnabled ? "开启" : "关闭"; this.wifiEnabled = (res.wifiEnabled ?? false) ? "开启" : "关闭"; - this.deviceOrientation = res.deviceOrientation ?? ""; + this.deviceOrientation = res.deviceOrientation } } } diff --git a/pages/API/get-window-info/get-window-info.test.js b/pages/API/get-window-info/get-window-info.test.js new file mode 100644 index 0000000000000000000000000000000000000000..a6a636178c22548973017942059bbf4a719584df --- /dev/null +++ b/pages/API/get-window-info/get-window-info.test.js @@ -0,0 +1,28 @@ +const PAGE_PATH = '/pages/API/get-window-info/get-window-info' + +describe('ExtApi-GetWindowInfo', () => { + + let page; + let res; + const numberProperties = [ + 'pixelRatio', 'screenWidth', 'screenHeight', 'statusBarHeight', + 'windowWidth', + 'windowHeight', 'windowTop', 'windowBottom', 'screenTop' + ] + + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(600); + res = await page.callMethod('jest_getWindowInfo') + }); + + it('Check GetWindowInfo', async () => { + for (const key in res) { + const value = res[key]; + expect(value).not.toBeNull(); + if (numberProperties.indexOf(key) != -1) { + expect(value).toBeGreaterThanOrEqual(0); + } + } + }); +}); diff --git a/pages/API/get-window-info/get-window-info.uvue b/pages/API/get-window-info/get-window-info.uvue index 42ffd05ddcde75bdf4b719759f61566fcba1e05f..2931fdb31078a874fe4c609b63500e9a96c7bc9f 100644 --- a/pages/API/get-window-info/get-window-info.uvue +++ b/pages/API/get-window-info/get-window-info.uvue @@ -37,18 +37,22 @@ methods: { getWindowInfo: function () { const res = uni.getWindowInfo(); - //类型对象暂时不支持forin或Object.keys(), 临时通过字符串进行转化。 - const json = JSON.stringify(res); - const result = JSON.parse>(json); - this.items = [] as Item[]; - result?.forEach((value, key) => { - const item = { - label: key, - value: "" + value - } as Item; - this.items.push(item); - }) - } + this.items = [] as Item[]; + for(const key in res){ + const value = res[key]; + if(value != null){ + const item = { + label: key, + value: "" + ((typeof value == "object")? JSON.stringify(value) : value) + } as Item; + this.items.push(item); + } + } + }, + //自动化测试例专用 + jest_getWindowInfo():GetWindowInfoResult{ + return uni.getWindowInfo(); + }, } } diff --git a/pages/API/loading/loading.uvue b/pages/API/loading/loading.uvue new file mode 100644 index 0000000000000000000000000000000000000000..47639cd8acd4c79666f466367e62fb0721d036cf --- /dev/null +++ b/pages/API/loading/loading.uvue @@ -0,0 +1,113 @@ + + \ No newline at end of file diff --git a/pages/API/navigator/new-page/new-page-2.test.js b/pages/API/navigator/new-page/new-page-2.test.js index e559e69963af0c15cfb2ac75bf409eeece5c5212..2ea7cadc05aaa00df4b62bb7280d8ed665b61755 100644 --- a/pages/API/navigator/new-page/new-page-2.test.js +++ b/pages/API/navigator/new-page/new-page-2.test.js @@ -1,3 +1,4 @@ +jest.setTimeout(30000) const PAGE_PATH = '/pages/API/navigator/new-page/new-page-2' const INTERMEDIATE_PAGE_PATH = '/pages/API/navigator/navigator' let page diff --git a/pages/API/navigator/new-page/new-page-2.uvue b/pages/API/navigator/new-page/new-page-2.uvue index b41bbc33bbb1ba9591045d2c13661bfa6b967764..661f8bfcbf0d77dafd52163931c3d5e6f100b42f 100644 --- a/pages/API/navigator/new-page/new-page-2.uvue +++ b/pages/API/navigator/new-page/new-page-2.uvue @@ -12,7 +12,7 @@ \ No newline at end of file + export default { + data() { + return { + title: 'request', + res: '', + task: null as RequestTask | null, + pageVisible: false, + host: "http://request.dcloud.net.cn", + url: "/api/http/method/get", + method: "GET" as RequestMethod | null, + data: null as any | null, + header: null as UTSJSONObject | null, + errorCodeUrls: [ + "/api/http/statusCode/200", + "/api/http/statusCode/204", + "/api/http/statusCode/301", + "/api/http/statusCode/302", + "/api/http/statusCode/307", + "/api/http/statusCode/400", + "/api/http/statusCode/401", + "/api/http/statusCode/403", + "/api/http/statusCode/404", + "/api/http/statusCode/405", + "/api/http/statusCode/500", + "/api/http/statusCode/502", + "/api/http/statusCode/503", + "/api/http/statusCode/504", + ], + headerUrls: [ + "/api/http/header/ua", + "/api/http/header/referer", + "/api/http/header/requestCookie", + "/api/http/header/setCookie", + "/api/http/header/deleteCookie" + ], + contentTypeUrls: [ + "/api/http/contentType/text/plain", + "/api/http/contentType/text/html", + "/api/http/contentType/text/xml", + "/api/http/contentType/image/gif", + "/api/http/contentType/image/jpeg", + "/api/http/contentType/image/png", + "/api/http/contentType/application/json", + "/api/http/contentType/application/octetStream", + ], + postUrls: [ + "/api/http/contentType/json", + "/api/http/contentType/xWwwFormUrlencoded", + ], + //自动化测试例专用 + jest_result: false + } + }, + onLoad() { + this.pageVisible = true; + }, + onUnload() { + this.pageVisible = false; + uni.hideLoading(); + this.task?.abort(); + }, + methods: { + changeMethod(e : RequestMethod) { + this.method = e; + this.url = methodMap[e] as string; + this.data = null; + this.header = null; + }, + changeUrl(e : string) { + this.method = "GET"; + this.url = e; + this.data = null; + this.header = null; + }, + changeUrlFromPost(e : string) { + this.method = "POST"; + this.url = e; + switch (e) { + case "/api/http/contentType/json": + this.header = { + "Content-Type": "application/json" + }; + this.data = { + "hello": "world" + }; + break; + case "/api/http/contentType/xWwwFormUrlencoded": + this.header = { + "Content-Type": "application/x-www-form-urlencoded" + }; + this.data = "hello=world"; + break; + } + }, + sendRequest() { + uni.showLoading({ + title: "请求中..." + }) + this.task = uni.request({ + url: this.host + this.url, + // dataType: "json", + // responseType: "json", + method: this.method, + data: this.data, + header: this.header, + timeout: 6000, + sslVerify: false, + withCredentials: false, + firstIpv4: false, + success(res) { + if (this.pageVisible) { + console.log('request success', JSON.stringify(res.data)) + uni.showToast({ + title: '请求成功', + icon: 'success', + mask: true, + duration: duration + }); + this.res = '请求结果 : ' + JSON.stringify(res); + } + }, + fail(err) { + if (this.pageVisible) { + console.log('request fail', err); + uni.showModal({ + content: err.errMsg, + showCancel: false + }); + } + }, + complete() { + uni.hideLoading() + }, + }); + }, + //自动化测试例专用 + jest_request() { + uni.request({ + url: this.host + this.url, + // dataType: "json", + // responseType: "json", + method: this.method, + data: this.data, + header: this.header, + timeout: 6000, + sslVerify: false, + withCredentials: false, + firstIpv4: false, + success() { + this.jest_result = true; + }, + fail() { + this.jest_result = false; + }, + }); + } + } + } + diff --git a/pages/API/save-image-to-album/save-image-to-album.uvue b/pages/API/save-image-to-photos-album/save-image-to-photos-album.uvue similarity index 100% rename from pages/API/save-image-to-album/save-image-to-album.uvue rename to pages/API/save-image-to-photos-album/save-image-to-photos-album.uvue diff --git a/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js b/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js new file mode 100644 index 0000000000000000000000000000000000000000..08f72a9d10c0ff7f0d160d3426e3e0750dd54235 --- /dev/null +++ b/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js @@ -0,0 +1,30 @@ +const CURRENT_PAGE_PATH = + "/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color"; + +describe("setCustomNavigationBarColor", () => { + let page; + let originLifeCycleNum; + beforeAll(async () => { + page = await program.navigateTo(CURRENT_PAGE_PATH); + await page.waitFor(1000); + originLifeCycleNum = await page.callMethod("getLifeCycleNum"); + }); + + afterAll(async () => { + await page.callMethod("setLifeCycleNum", originLifeCycleNum); + const lifeCycleNum = await page.callMethod("getLifeCycleNum"); + expect(lifeCycleNum).toBe(originLifeCycleNum); + }); + + it("setNavigationBarColor2", async () => { + await page.callMethod("setNavigationBarColor2"); + const image = await program.screenshot({adb: true, area:{x:1000, y: 0, width: 80, height: 88}}); + expect(image).toMatchImageSnapshot(); + }); + + it("setNavigationBarColor1", async () => { + await page.callMethod("setNavigationBarColor1"); + const image = await program.screenshot({adb: true, area:{x:1000, y: 0, width: 80, height: 88}}); + expect(image).toMatchImageSnapshot(); + }); +}); diff --git a/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue b/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue new file mode 100644 index 0000000000000000000000000000000000000000..dac025f6657c59c6d8354594fe969a577324e887 --- /dev/null +++ b/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue @@ -0,0 +1,105 @@ + + + + + diff --git a/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js b/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js index aeb3a668d28cb8b73a444b8c259c75ebd0a72291..a293b96b61498f6afbb943c7b787affcb1313045 100644 --- a/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js +++ b/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js @@ -4,7 +4,6 @@ const CURRENT_PAGE_PATH = describe('setNavigationBarColor', () => { let page let originLifeCycleNum - let lifeCycleNum beforeAll(async () => { page = await program.navigateTo(CURRENT_PAGE_PATH) await page.waitFor(1000) @@ -13,7 +12,7 @@ describe('setNavigationBarColor', () => { afterAll(async () => { await page.callMethod('setLifeCycleNum', originLifeCycleNum) - lifeCycleNum = await page.callMethod('getLifeCycleNum') + const lifeCycleNum = await page.callMethod('getLifeCycleNum') expect(lifeCycleNum).toBe(originLifeCycleNum) }) diff --git a/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue b/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue index ee5d7a76016b97528faf507a83b31e74d0c27ab6..913daf0a1c8f9c0d26cbd0c0831207abf84ae9ea 100644 --- a/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue +++ b/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue @@ -8,19 +8,17 @@ + diff --git a/pages/API/show-loading/show-loading.uvue b/pages/API/show-loading/show-loading.uvue deleted file mode 100644 index 15889b855f46ff0a42ba9d23639a0daa96407b32..0000000000000000000000000000000000000000 --- a/pages/API/show-loading/show-loading.uvue +++ /dev/null @@ -1,120 +0,0 @@ - - \ No newline at end of file diff --git a/pages/API/storage/storage.test.js b/pages/API/storage/storage.test.js new file mode 100644 index 0000000000000000000000000000000000000000..86b330671b6eac9a1515dfc5d1add934c5974ecc --- /dev/null +++ b/pages/API/storage/storage.test.js @@ -0,0 +1,106 @@ +const PAGE_PATH = '/pages/API/storage/storage' + + +describe('ExtApi-StorageInfoTest', () => { + + let page; + function getData(key = '') { + return new Promise(async (resolve, reject) => { + const data = await page.data() + resolve(key ? data[key] : data) + }) + } + + + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(600); + }); + + it('Check async properties', async () => { + // 异步存储测试 + await page.setData({ + key: "autotest_key_mock", + data:"长安大道连狭斜,青牛白马七香车。玉辇纵横过主第,金鞭络绎向侯家。龙衔宝盖承朝日,凤吐流苏带晚霞。百尺游丝争绕树,一群娇鸟共啼花。游蜂戏蝶千门侧,碧树银台万种色。复道交窗作合欢,双阙连甍垂凤翼。" + }) + await page.waitFor(600) + const btnSetStorageButtonInfo = await page.$('.btn-setstorageAsync') + await btnSetStorageButtonInfo.tap() + await page.waitFor(600) + const btnGetStorageButtonInfo = await page.$('.btn-getstorageAsync') + await btnGetStorageButtonInfo.tap() + await page.waitFor(600) + expect(await getData('apiGetData')).toEqual("长安大道连狭斜,青牛白马七香车。玉辇纵横过主第,金鞭络绎向侯家。龙衔宝盖承朝日,凤吐流苏带晚霞。百尺游丝争绕树,一群娇鸟共啼花。游蜂戏蝶千门侧,碧树银台万种色。复道交窗作合欢,双阙连甍垂凤翼。") + + await page.setData({ + key: "autotest_key_mock", + data:1100.8989 + }) + await page.waitFor(600) + await btnSetStorageButtonInfo.tap() + await page.waitFor(600) + await btnGetStorageButtonInfo.tap() + await page.waitFor(600) + expect(await getData('apiGetData')).toEqual(1100.8989) + + await page.setData({ + key: "autotest_key_mock", + data:123456789 + }) + await page.waitFor(600) + await btnSetStorageButtonInfo.tap() + await page.waitFor(600) + await btnGetStorageButtonInfo.tap() + await page.waitFor(600) + expect(await getData('apiGetData')).toEqual(123456789) + + let userObj = { + name:"zhangsan", + age:12 + } + await page.setData({ + key: "autotest_key_mock", + data:userObj + }) + await page.waitFor(600) + await btnSetStorageButtonInfo.tap() + await page.waitFor(600) + await btnGetStorageButtonInfo.tap() + await page.waitFor(600) + expect(await getData('apiGetData')).toEqual(userObj) + + await page.setData({ + key: "autotest_key_mock", + data:"长安大道连狭斜,青牛白马七香车。玉辇纵横过主第,金鞭络绎向侯家。龙衔宝盖承朝日,凤吐流苏带晚霞。百尺游丝争绕树,一群娇鸟共啼花。游蜂戏蝶千门侧,碧树银台万种色。复道交窗作合欢,双阙连甍垂凤翼。" + }) + await page.waitFor(600) + const btnSetStorageButtonInfo2 = await page.$('.btn-setstorageSync') + await btnSetStorageButtonInfo2.tap() + await page.waitFor(600) + const btnGetStorageButtonInfo2 = await page.$('.btn-getstorageSync') + await btnGetStorageButtonInfo2.tap() + await page.waitFor(600) + expect(await getData('apiGetData')).toEqual("长安大道连狭斜,青牛白马七香车。玉辇纵横过主第,金鞭络绎向侯家。龙衔宝盖承朝日,凤吐流苏带晚霞。百尺游丝争绕树,一群娇鸟共啼花。游蜂戏蝶千门侧,碧树银台万种色。复道交窗作合欢,双阙连甍垂凤翼。") + + + }); + + + it('Check sync properties', async () => { + + await page.setData({ + key: "autotest_key_mock", + data:"长安大道连狭斜,青牛白马七香车。玉辇纵横过主第,金鞭络绎向侯家。龙衔宝盖承朝日,凤吐流苏带晚霞。百尺游丝争绕树,一群娇鸟共啼花。游蜂戏蝶千门侧,碧树银台万种色。复道交窗作合欢,双阙连甍垂凤翼。" + }) + await page.waitFor(600) + const btnSetStorageButtonInfo = await page.$('.btn-setstorageSync') + await btnSetStorageButtonInfo.tap() + await page.waitFor(600) + const btnGetStorageButtonInfo = await page.$('.btn-getstorageSync') + await btnGetStorageButtonInfo.tap() + await page.waitFor(600) + expect(await getData('apiGetData')).toEqual("长安大道连狭斜,青牛白马七香车。玉辇纵横过主第,金鞭络绎向侯家。龙衔宝盖承朝日,凤吐流苏带晚霞。百尺游丝争绕树,一群娇鸟共啼花。游蜂戏蝶千门侧,碧树银台万种色。复道交窗作合欢,双阙连甍垂凤翼。") + + }); + +}); diff --git a/pages/API/storage/storage.uvue b/pages/API/storage/storage.uvue index 82419e950079d90b8e50200815d48e9cfd37294e..c6a229ff1ee345402397eb26b3f8a10265bb9145 100644 --- a/pages/API/storage/storage.uvue +++ b/pages/API/storage/storage.uvue @@ -84,12 +84,12 @@ - + @@ -97,12 +97,12 @@ - + @@ -123,7 +123,8 @@ export default { return { title: 'get/set/clearStorage', key: '', - data: '' as any, + data: '' as any, + apiGetData:'' as any|null, storageInfo: '', } }, @@ -189,13 +190,15 @@ export default { content: 'key 不能为空', showCancel: false, }) - } else { + } else { + let that = this uni.getStorage({ key: key, - success: (res) => { + success: (res) => { + that.apiGetData = res.data uni.showModal({ title: '读取数据成功', - content: "data: '" + res.data + "'", + content: "data: '" + JSON.stringify(that.apiGetData) + "'", showCancel: false, }) }, @@ -218,10 +221,10 @@ export default { showCancel: false, }) } else { - let ret = uni.getStorageSync(key) + this.apiGetData = uni.getStorageSync(key) uni.showModal({ title: '读取数据成功', - content: "data: '" + ret + "'", + content: "data: '" + JSON.stringify(apiGetData) + "'", showCancel: false, }) } diff --git a/pages/API/toast/toast.uvue b/pages/API/toast/toast.uvue index 7c01fe90edc2ac7d8464f4babeb800ffa35306fc..9e41d537adea7daa0fa4082ed3fea0b3ff322c51 100644 --- a/pages/API/toast/toast.uvue +++ b/pages/API/toast/toast.uvue @@ -1,125 +1,110 @@ \ No newline at end of file + } + diff --git a/pages/API/unicloud-call-function/unicloud-call-function.test.js b/pages/API/unicloud-call-function/unicloud-call-function.test.js new file mode 100644 index 0000000000000000000000000000000000000000..ebfa88871fdbb632642047d8ba5ee8d73a796d3d --- /dev/null +++ b/pages/API/unicloud-call-function/unicloud-call-function.test.js @@ -0,0 +1,26 @@ +const PAGE_PATH = '/pages/API/unicloud-call-function/unicloud-call-function' + +describe('unicloud-call-function', () => { + let page + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(500) + await page.setData({ + isUniTest: true + }) + }) + + it('callFunction', async () => { + await page.callMethod('callFunction') + await page.waitFor(3000) + const { + callFunctionResult, + callFunctionError + } = await page.data() + console.error(callFunctionResult) + console.error(callFunctionError) + expect(callFunctionResult['showMessage']).toBe("Hello uniCloud function") + expect(callFunctionResult['event']['num']).toBe(1) + expect(callFunctionResult['event']['str']).toBe('ABC') + }) +}) diff --git a/pages/API/call-function/call-function.uvue b/pages/API/unicloud-call-function/unicloud-call-function.uvue similarity index 58% rename from pages/API/call-function/call-function.uvue rename to pages/API/unicloud-call-function/unicloud-call-function.uvue index 3756652e7ffd3ab18b2c2421d9bc1fb765b7c9a4..290927ef1040f36c4bce58040d403d6ab7036685 100644 --- a/pages/API/call-function/call-function.uvue +++ b/pages/API/unicloud-call-function/unicloud-call-function.uvue @@ -1,7 +1,7 @@ @@ -18,14 +18,33 @@ export default { data() { return { - title: 'uniCloud.callFunction' + title: '请求云函数', + callFunctionResult: {}, + callFunctionError: {}, + isUniTest: false } }, onLoad() { }, onUnload() { + if(this.isUniTest){ + uni.hideToast() + } }, methods: { + notify(content : string, title : string) { + if (!this.isUniTest) { + uni.showModal({ + title, + content, + showCancel: false + }) + } else { + uni.showToast({ + title: content + }) + } + }, callFunction: function () { uni.showLoading({ title: '加载中...' @@ -35,24 +54,21 @@ data: { num: 1, str: 'ABC' - } as UTSJSONObject + } }).then(res => { const result = res.result + this.callFunctionResult = result console.log(JSON.stringify(result)) uni.hideLoading() - uni.showModal({ - title: '提示', - content: result['showMessage'] as string, - showCancel: false - }) - }).catch((err: any | null) => { + this.notify(result['showMessage'] as string, '提示') + }).catch((err : any | null) => { const error = err as UniCloudError + this.callFunctionError = { + errCode: error.errCode, + errMsg: error.errMsg + } uni.hideLoading() - uni.showModal({ - title: '错误', - content: error.errMsg, - showCancel: false - }) + this.notify(error.errMsg, '错误') }) } } @@ -60,4 +76,4 @@ + \ No newline at end of file diff --git a/pages/API/unicloud-database/unicloud-database.test.js b/pages/API/unicloud-database/unicloud-database.test.js new file mode 100644 index 0000000000000000000000000000000000000000..f3ebac830c54ce0bf1c0b87d1c82838d13f4141f --- /dev/null +++ b/pages/API/unicloud-database/unicloud-database.test.js @@ -0,0 +1,61 @@ +const PAGE_PATH = '/pages/API/unicloud-database/unicloud-database' + +describe('unicloud-database', () => { + let page + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(500) + await page.setData({ + isUniTest: true + }) + }) + it('databaseBasic', async () => { + await page.callMethod('dbRemove') + await page.waitFor(3000) + await page.callMethod('dbAdd') + await page.waitFor(1500) + await page.callMethod('dbBatchAdd') + await page.waitFor(1500) + await page.callMethod('dbGet') + await page.waitFor(1500) + await page.callMethod('dbGetWithCommand') + await page.waitFor(1500) + await page.callMethod('dbUpdate') + await page.waitFor(1500) + await page.callMethod('dbRemove') + await page.waitFor(1500) + + const { + addId, + batchAddIds, + batchAddinserted, + updateUpdated, + getData, + getWithCommandData, + removeDeleted, + } = await page.data() + + expect(addId !== '').toBe(true) + expect(batchAddIds.length).toBe(2) + expect(batchAddinserted).toBe(2) + expect(getData.length).toBe(2) + expect(getWithCommandData.length).toBe(1) + expect(updateUpdated).toBe(3) + expect(removeDeleted).toBe(3) + + }) + + it('databaseLookup', async () => { + await page.callMethod('dbLookupInit') + await page.waitFor(3000) + await page.callMethod('dbLookup') + await page.waitFor(1500) + + const { + lookupData + } = await page.data() + expect(lookupData.length).toBe(2) + expect(lookupData[0]['foreign_id'].length).toBe(1) + expect(lookupData[1]['foreign_id'].length).toBe(1) + }) +}); \ No newline at end of file diff --git a/pages/API/unicloud-database/unicloud-database.uvue b/pages/API/unicloud-database/unicloud-database.uvue new file mode 100644 index 0000000000000000000000000000000000000000..8e2726abcecbcb1c09ee2e498c1cd6694de040b2 --- /dev/null +++ b/pages/API/unicloud-database/unicloud-database.uvue @@ -0,0 +1,290 @@ + + + + \ No newline at end of file diff --git a/pages/API/unicloud-file-api/unicloud-file-api.uvue b/pages/API/unicloud-file-api/unicloud-file-api.uvue new file mode 100644 index 0000000000000000000000000000000000000000..a37cc58735a52d4bb6ec2eaa54c7136d4fca1ac7 --- /dev/null +++ b/pages/API/unicloud-file-api/unicloud-file-api.uvue @@ -0,0 +1,71 @@ + + + + \ No newline at end of file diff --git a/pages/API/unicloud-import-object/unicloud-import-object.test.js b/pages/API/unicloud-import-object/unicloud-import-object.test.js new file mode 100644 index 0000000000000000000000000000000000000000..5c53f2179314937ae5eb8177cd8e428a93a1e10e --- /dev/null +++ b/pages/API/unicloud-import-object/unicloud-import-object.test.js @@ -0,0 +1,33 @@ +const PAGE_PATH = '/pages/API/unicloud-import-object/unicloud-import-object' + +describe('unicloud-import-object', () => { + let page + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(500) + await page.setData({ + isUniTest: true + }) + }) + it('importObject', async () => { + await page.callMethod('addTodo') + await page.callMethod('fail') + await page.callMethod('success') + await page.waitFor(3000) + + const { + todoTitle, + todoContent, + returnTodoTitle, + returnTodoContent, + failErrCode, + successErrCode, + } = await page.data() + + expect(returnTodoTitle).toBe(todoTitle) + expect(returnTodoContent).toBe(todoContent) + expect(failErrCode).toBe('TEST_ERROR_CODE') + expect(successErrCode).toBe(0) + + }) +}); \ No newline at end of file diff --git a/pages/API/unicloud-import-object/unicloud-import-object.uvue b/pages/API/unicloud-import-object/unicloud-import-object.uvue new file mode 100644 index 0000000000000000000000000000000000000000..ff42363115401a1c1cc301b067a07292fec70fc0 --- /dev/null +++ b/pages/API/unicloud-import-object/unicloud-import-object.uvue @@ -0,0 +1,124 @@ + + + + + \ No newline at end of file diff --git a/pages/API/upload-file/upload-file.test.js b/pages/API/upload-file/upload-file.test.js new file mode 100644 index 0000000000000000000000000000000000000000..b02e2bc12f1307e983d2717960a0a4354dcdc043 --- /dev/null +++ b/pages/API/upload-file/upload-file.test.js @@ -0,0 +1,18 @@ +const PAGE_PATH = '/pages/API/upload-file/upload-file' + +describe('ExtApi-UploadFile', () => { + + let page; + let res; + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(600); + await page.callMethod('jest_uploadFile'); + await page.waitFor(500); + res = await page.data('jest_result'); + }); + + it('Check ', async () => { + expect(res).toBe(true); + }); +}); diff --git a/pages/API/upload-file/upload-file.uvue b/pages/API/upload-file/upload-file.uvue index 7554d04c192dd9a9b5a2658a52b4983e3ad49bde..d239c13886d2b5f8e7048bc7336d3adaef99db76 100644 --- a/pages/API/upload-file/upload-file.uvue +++ b/pages/API/upload-file/upload-file.uvue @@ -23,14 +23,15 @@ diff --git a/pages/API/websocket-global/websocket-global.uvue b/pages/API/websocket-global/websocket-global.uvue index 3f751f5d2dd6b1d351c790d17e7e3271361e6ae3..72735bc82958b5c4743237ff194a78bc2cdd9a31 100644 --- a/pages/API/websocket-global/websocket-global.uvue +++ b/pages/API/websocket-global/websocket-global.uvue @@ -137,7 +137,7 @@ export default { uni.sendSocketMessage({ data: 'from ' + - platform + + this.platform + ' : ' + parseInt((Math.random() * 10000).toString()).toString(), success(res: any) { diff --git a/pages/API/websocket-socketTask/websocket-socketTask.test.js b/pages/API/websocket-socketTask/websocket-socketTask.test.js new file mode 100644 index 0000000000000000000000000000000000000000..6a3bc3d3b279d2f7a94022abb395813b5255b207 --- /dev/null +++ b/pages/API/websocket-socketTask/websocket-socketTask.test.js @@ -0,0 +1,18 @@ +const PAGE_PATH = '/pages/API/websocket-socketTask/websocket-socketTask' + +describe('ExtApi-WebSocket', () => { + + let page; + let res; + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(600); + await page.callMethod('jest_connectSocket'); + await page.waitFor(500); + res = await page.data('jest_result'); + }); + + it('Check ', async () => { + expect(res).toBe(2); + }); +}); diff --git a/pages/API/websocket-socketTask/websocket-socketTask.uvue b/pages/API/websocket-socketTask/websocket-socketTask.uvue index 8139774e680530b115010054e781a72cab801f20..8285294b15fd30778b811079ee00caf181d52ee5 100644 --- a/pages/API/websocket-socketTask/websocket-socketTask.uvue +++ b/pages/API/websocket-socketTask/websocket-socketTask.uvue @@ -35,7 +35,9 @@ export default { socketTask: null as SocketTask | null, msg: '', platform: '', - pageVisible: false, + pageVisible: false, + //自动化测试例专用 + jest_result: 0, } }, computed: { @@ -135,16 +137,16 @@ export default { } }) }, - send() { + send() { const data = 'from ' + - platform + + this.platform + ' : ' + parseInt(Math.random() * 10000 + '').toString() this.socketTask?.send({ data, success(res: any) { - console.log(res) + console.log(res) }, fail(err: any) { console.log(err) @@ -162,7 +164,38 @@ export default { console.log('uni.closeSocket fail', err) }, } as CloseSocketOptions) - }, + }, + //自动化测试例专用 + jest_connectSocket(){ + this.socketTask = uni.connectSocket({ + url: 'ws://websocket.dcloud.net.cn', + success:(_) => { + this.jest_result++ + }, + fail:(_) => { + this.jest_result = 0 + }, + }) + this.socketTask?.onOpen((_) => { + const data = + 'from ' + + this.platform + + ' : ' + + parseInt(Math.random() * 10000 + '').toString() + this.socketTask?.send({ + data, + success(_) { + this.jest_result++ + }, + fail(_) { + this.jest_result = 0 + }, + } as SendSocketMessageOptions) + }) + this.socketTask?.onError((_) => { + this.jest_result = 0; + }) + } }, } diff --git a/pages/CSS/border/border-bottom.uvue b/pages/CSS/border/border-bottom.uvue new file mode 100644 index 0000000000000000000000000000000000000000..5ac9b8af54b3b0b279a08bf845152eef0ad4267f --- /dev/null +++ b/pages/CSS/border/border-bottom.uvue @@ -0,0 +1,20 @@ + + + + + \ No newline at end of file diff --git a/pages/CSS/border/border-color.uvue b/pages/CSS/border/border-color.uvue index 31a7392d96b6ce7c2432a6cf7b9be8fbe74142b5..b3753438c5cb39fe59cb5577a46721d0da94f624 100644 --- a/pages/CSS/border/border-color.uvue +++ b/pages/CSS/border/border-color.uvue @@ -7,7 +7,7 @@ border-color: red @@ -15,7 +15,7 @@ border-left-color: red @@ -23,7 +23,7 @@ border-top-color: green @@ -31,7 +31,7 @@ border-right-color: yellow @@ -39,7 +39,7 @@ border-bottom-color: blue diff --git a/pages/CSS/border/border-left.uvue b/pages/CSS/border/border-left.uvue new file mode 100644 index 0000000000000000000000000000000000000000..5a36c535c42557b0198b4d06058400173872dd49 --- /dev/null +++ b/pages/CSS/border/border-left.uvue @@ -0,0 +1,20 @@ + + + + + \ No newline at end of file diff --git a/pages/CSS/border/border-right.uvue b/pages/CSS/border/border-right.uvue new file mode 100644 index 0000000000000000000000000000000000000000..e32239d4d4aacb37c964780680132d04e90be8e6 --- /dev/null +++ b/pages/CSS/border/border-right.uvue @@ -0,0 +1,20 @@ + + + + + \ No newline at end of file diff --git a/pages/CSS/border/border-top.uvue b/pages/CSS/border/border-top.uvue new file mode 100644 index 0000000000000000000000000000000000000000..17605ebbcba335d376f7dd39df672b967a32526e --- /dev/null +++ b/pages/CSS/border/border-top.uvue @@ -0,0 +1,20 @@ + + + + + \ No newline at end of file diff --git a/pages/CSS/border/border-width.uvue b/pages/CSS/border/border-width.uvue index 1de2a19d70af4ef4f8b0c26f762a5b8c1ea3f2f5..337338bc071ac66a5e6860efe75a5be0ef05faae 100644 --- a/pages/CSS/border/border-width.uvue +++ b/pages/CSS/border/border-width.uvue @@ -5,27 +5,27 @@ border-width: 10rpx - + border-left-width: 10rpx - + border-top-width: 20rpx - + border-right-width: 30rpx - + border-bottom-width: 40rpx - + diff --git a/pages/CSS/border/complex-border/complex-border.uvue b/pages/CSS/border/complex-border/complex-border.uvue index 107111efb7bf3659f7e553d1555618879ea1018e..d4245d92501844705536a3dbeb5f16190a2c4bae 100644 --- a/pages/CSS/border/complex-border/complex-border.uvue +++ b/pages/CSS/border/complex-border/complex-border.uvue @@ -33,7 +33,8 @@ width: 250rpx; height: 250rpx; background-color: #00dd00; - border-width: 20rpx; + border-width: 20rpx; + border-style: solid; border-color: #000000; border-bottom-width: 40rpx; border-bottom-color: #ff0000; @@ -45,7 +46,8 @@ .border-rect { width: 250rpx; - height: 250rpx; + height: 250rpx; + border-style: solid; background-color: #00dd00; border-width: 20rpx; border-color: #000000; @@ -53,4 +55,4 @@ border-bottom-color: #ff0000; border-right-color: #FFDC02; } - \ No newline at end of file + diff --git a/pages/CSS/layout/z-index.uvue b/pages/CSS/layout/z-index.uvue index 9eb4ec2d74ec92ad5b867132b9481df579c8d0f3..aa3b84e04678c97ca7b1cfd8d8bc29645a7b229b 100644 --- a/pages/CSS/layout/z-index.uvue +++ b/pages/CSS/layout/z-index.uvue @@ -24,7 +24,7 @@ methods: { changeZIndex(zIndex : number) { this.zIndex = 20; - (this.$refs['view'] as INode).style.setProperty('z-index', zIndex); + (this.$refs['view'] as Element).style.setProperty('z-index', zIndex); } } } diff --git a/pages/CSS/transition/transition.uvue b/pages/CSS/transition/transition.uvue index 6d39432ce8f44271f04c859fb25bc0f9013ade6c..5b26c35d7b10afa31c3bc337acbe4c8e61bafb5d 100644 --- a/pages/CSS/transition/transition.uvue +++ b/pages/CSS/transition/transition.uvue @@ -1,192 +1,189 @@ + .transition-position { + transition-property: left; + transition-duration: 1000; + } + \ No newline at end of file diff --git a/pages/component/general-attribute/general-attribute.uvue b/pages/component/general-attribute/general-attribute.uvue index 923513cc5b141914d415a13a9fd0b1c554a42074..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 INode + const generalTarget = this.$refs['general-target'] as Element const generalId = generalTarget.getAttribute('id') if (generalId != this.generalId) { this.validateGeneralAttrText = '基础属性 id 验证失败' @@ -98,8 +98,8 @@ export default { this.validateGeneralAttrText = '基础属性验证成功' }, changeHeight(){ - const generalTarget = this.$refs.get('general-target') as INode - generalTarget.style.set('height', '200px') + const generalTarget = this.$refs['general-target'] as Element + generalTarget.style.setProperty('height', '200px') } }, } diff --git a/pages/component/image/image-path.uvue b/pages/component/image/image-path.uvue index 0d561e8d38deb493bf41eeacac9434b9c6738dcd..847369a56bd19bec4786dfd1cbf7653b38b73886 100644 --- a/pages/component/image/image-path.uvue +++ b/pages/component/image/image-path.uvue @@ -32,7 +32,7 @@ }, { src: '../../../static/Test-Image/Logo.png', - description: '本地相对路径忽略大小写' + description: '本地相对路径忽略大小写(需注意Android打包后无效)' }, { src: logo, @@ -43,7 +43,7 @@ src: 'file:///storage/emulated/0/Android/data/io.dcloud.uniappx/apps/__UNI__3584C99/www/static/test-image/logo.png', // #endif // TODO iOS发版时还需再补路径 - description: '本地绝对路径file:///方式。需注意打包后包名appid匹配' + description: '本地绝对路径file://方式(需注意打包后包名appid匹配)' }, { src: 'testerror.jpg', diff --git a/pages/component/image/image.test.js b/pages/component/image/image.test.js new file mode 100644 index 0000000000000000000000000000000000000000..6a6ce934a7df8eb6065e1b250d7f398cc5091941 --- /dev/null +++ b/pages/component/image/image.test.js @@ -0,0 +1,32 @@ +// 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) + }); + + it('check_image_load_url', async () => { + await page.setData({ + loadError: false, + imageSrc: 'https://request.dcloud.net.cn/api/http/contentType/image/png' + }) + await page.waitFor(300); + expect(await page.data('loadError')).toBe(false) + }) + + it('check_image_load_error', async () => { + await page.setData({ + loadError: false, + imageSrc: 'testerror.jpg' + }) + await page.waitFor(300); + expect(await page.data('loadError')).toBe(true) + }) +}); diff --git a/pages/component/image/image.uvue b/pages/component/image/image.uvue index 9e6345ee63ec73feb6a26b90a8b3bc67861d00e0..6cb20282b61702fd79956348751bb518dd65a439 100644 --- a/pages/component/image/image.uvue +++ b/pages/component/image/image.uvue @@ -3,7 +3,7 @@ - @@ -25,11 +25,14 @@ export default { data() { return { - title: 'image' + title: 'image', + imageSrc: "/static/test-image/logo.png", + loadError: false } }, methods: { - error(event : ImageErrorEvent) { + error(event : ImageErrorEvent) { + this.loadError = true console.log(event.type, event.detail); }, load(event : ImageLoadEvent) { @@ -63,4 +66,4 @@ margin: 40rpx auto; width: 200rpx; } - \ No newline at end of file + diff --git a/pages/component/input/input.test.js b/pages/component/input/input.test.js new file mode 100644 index 0000000000000000000000000000000000000000..ab54276ea525e125c9cade9e66af3cab19cf2ee6 --- /dev/null +++ b/pages/component/input/input.test.js @@ -0,0 +1,148 @@ +// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/ + +describe('component-native-input', () => { + + let page; + beforeAll(async () => { + page = await program.reLaunch('/pages/component/input/input') + await page.waitFor(3000); + }); + + // it("beforeAllTestScreenshot", async () => { + // const image = await program.screenshot({ + // fullPage: true + // }) + // expect(image).toMatchImageSnapshot() + // }) + // 测试焦点及键盘弹起 + // it('focus', async () => { + // const input = await page.$('.uni-input-focus'); + // expect(await input.property('focus')).toBe(true) + // expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(true) + // await page.setData({ + // focus: false, + // }) + // expect(await input.property('focus')).toBe(false) + // await page.waitFor(1000) + // expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(false) + // await page.setData({ + // focus: true, + // }) + // expect(await input.property('focus')).toBe(true) + // await page.waitFor(1000) + // expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(true) + // await page.setData({ + // focus: false, + // }) + // expect(await input.property('focus')).toBe(false) + // await page.waitFor(1000) + // expect(await page.data("inputFocusKeyBoardChangeValue")).toBe(false) + // await page.waitFor(1000) + // }); + + // 测试修改value属性 + it("value", async () => { + const input = await page.$('.uni-input-default'); + expect(await input.property('value')).toEqual("hello uni-app x") + }) + + //测试input的类型 + it("type", async () => { + const text = await page.$('.uni-input-type-text'); + const number = await page.$('.uni-input-type-number'); + const digit = await page.$('.uni-input-type-digit'); + const tel = await page.$('.uni-input-type-tel'); + expect(await text.property('type')).toEqual("text") + expect(await number.property('type')).toEqual("number") + expect(await digit.property('type')).toEqual("digit") + expect(await tel.property('type')).toEqual("tel") + }) + + // 测试密码属性 + // it("password", async () => { + // const input = await page.$('.uni-input-password'); + // expect(await input.property('password')).toBe(true) + // await page.setData({ + // inputPassword: false, + // inputPasswordValue: "inputPasswordValue" + // }) + // expect(await input.property('password')).toBe(false) + // await page.waitFor(500) + // await page.setData({ + // inputPassword: true + // }) + // }) + // 测试placeholder + it("placeholder", async () => { + const placeholder1 = await page.$('.uni-input-placeholder1'); + expect(await placeholder1.property("placeholder-style")).toMatchObject({ + "color": "red" + }) + expect(await placeholder1.property("placeholder")).toEqual("占位符文字颜色为红色") + await page.setData({ + inputPlaceHolderStyle: "color:#CC00CC", + }) + expect(await placeholder1.property("placeholder-style")).toMatchObject({ + "color": "#CC00CC" + }) + + await page.setData({ + inputPlaceHolderStyle: "color:#CC19CC;background-color:#00b1c0", + }) + expect(await placeholder1.property("placeholder-style")).toMatchObject({ + "color": "#CC19CC", + "backgroundColor": "#00b1c0" + }) + + await page.setData({ + inputPlaceHolderStyle: "color:#CC19CC;background-color:#00b1c0;text-align:center;font-size:44px;font-weight:900", + }) + expect(await placeholder1.property("placeholder-style")).toEqual({ + "backgroundColor": "#00b1c0", + "color": "#CC19CC", + "fontSize": "44px", + "fontWeight": "900", + "textAlign": "center" + }) + + const placeholder2 = await page.$('.uni-input-placeholder2'); + expect(await placeholder2.property("placeholder-class")).toMatchObject({ + "backgroundColor": "#008000" + }) + await page.setData({ + inputPlaceHolderClass: "uni-input-placeholder-class-ts", + }) + expect(await placeholder2.property("placeholder-class")).toMatchObject({ + "backgroundColor": "#FFA500" + }) + expect(await placeholder2.property("placeholder")).toEqual("占位符背景色为绿色") + }) + + it("disable", async () => { + const input = await page.$('.uni-input-disable'); + expect(await input.property("disabled")).toBe(true) + }) + + it("confirm-type", async () => { + expect(await (await page.$('.uni-input-confirm-send')).property("confirmType")).toEqual("send") + expect(await (await page.$('.uni-input-confirm-search')).property("confirmType")).toEqual("search") + expect(await (await page.$('.uni-input-confirm-next')).property("confirmType")).toEqual("next") + expect(await (await page.$('.uni-input-confirm-go')).property("confirmType")).toEqual("go") + expect(await (await page.$('.uni-input-confirm-done')).property("confirmType")).toEqual("done") + }) + + // it("maxlength", async () => { + // const input = await page.$('.uni-input-maxlength'); + // await page.setData({ + // inputMaxLengthValue: "uni-input-maxlength" + // }) + // await page.waitFor(500) + // }) + + // it("afterAllTestScreenshot", async () => { + // const image = await program.screenshot({ + // fullPage: true + // }) + // expect(image).toMatchImageSnapshot() + // }) +}); diff --git a/pages/component/input/input.uvue b/pages/component/input/input.uvue index d824cbf79b114edc83eea8b2302d402dffb6e30c..91017ae21f954bd22687c53d7af81d701cbebbb6 100644 --- a/pages/component/input/input.uvue +++ b/pages/component/input/input.uvue @@ -1,310 +1,327 @@ \ No newline at end of file + .uni-input-placeholder-class { + background-color: green; + } + .uni-input-placeholder-class-ts { + background-color: orange; + } + diff --git a/pages/component/list-view/list-view.test.js b/pages/component/list-view/list-view.test.js new file mode 100644 index 0000000000000000000000000000000000000000..1b31fc1d51cbe8662c3f637fa9b6058394038b29 --- /dev/null +++ b/pages/component/list-view/list-view.test.js @@ -0,0 +1,79 @@ +describe('component-native-list-view', () => { + let page + beforeAll(async () => { + //打开list-view测试页 + page = await program.reLaunch('/pages/component/list-view/list-view') + await page.waitFor(600) + }) + + //检测竖向可滚动区域 + it('check_scroll_height', async () => { + await page.callMethod('change_scroll_y_boolean', true) + await page.callMethod('change_scroll_x_boolean', false) + await page.waitFor(600) + const value = await page.callMethod('check_scroll_height') + expect(value).toBe(true) + }) + + //检测竖向scrolltop属性赋值 + it('check_scroll_top', async () => { + await page.callMethod('confirm_scroll_top_input', 600) + await page.waitFor(600) + const listElement = await page.$('#listview') + const scrollTop = await listElement.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.callMethod('item_change_size_enum', 3) + await page.waitFor(600) + const listElement = await page.$('#listview') + const scrollTop = await listElement.attribute("scrollTop") + console.log("check_scroll_into_view_top--"+scrollTop) + await page.callMethod('item_change_size_enum', 0) + expect(scrollTop-690).toBeGreaterThanOrEqual(0) + }) + + //检测下拉刷新 + it('check_refresher', async () => { + await page.setData({ + refresher_enabled_boolean: true, + refresher_triggered_boolean: true + }) + await page.waitFor(2000) + expect(await page.data('refresherrefresh')).toBe(true) + }) + + //检测横向可滚动区域 + it('check_scroll_width', async () => { + await page.callMethod('change_scroll_y_boolean', false) + await page.callMethod('change_scroll_x_boolean', true) + await page.waitFor(600) + const value = await page.callMethod('check_scroll_width') + expect(value).toBe(true) + }) + + //检测横向scrollLeft属性赋值 + it('check_scroll_left', async () => { + await page.callMethod('confirm_scroll_left_input', 600) + await page.waitFor(600) + const listElement = await page.$('#listview') + const scrollLeft = await listElement.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.callMethod('item_change_size_enum', 3) + await page.waitFor(600) + const listElement = await page.$('#listview') + const scrollLeft = await listElement.attribute("scrollLeft") + console.log("check_scroll_into_view_left--"+scrollLeft) + await page.callMethod('item_change_size_enum', 0) + expect(scrollLeft-1080).toBeGreaterThanOrEqual(0) + }) + +}) diff --git a/pages/component/list-view/list-view.uvue b/pages/component/list-view/list-view.uvue index 5777db59f70ab904b6da818d8867ec9fbbbe8100..b9ee3f6608454089f7b86ccd6887093827a0753d 100644 --- a/pages/component/list-view/list-view.uvue +++ b/pages/component/list-view/list-view.uvue @@ -1,4 +1,5 @@ @@ -72,17 +99,17 @@ @@ -97,7 +124,7 @@ - + @@ -110,8 +137,9 @@ @confirm="confirm_lower_threshold_input"> - + diff --git a/pages/component/long-list/detail/detail.uvue b/pages/component/long-list/detail/detail.uvue deleted file mode 100644 index 118d8043d64be96a9cb9e1b13a0f373065cfd3cb..0000000000000000000000000000000000000000 --- a/pages/component/long-list/detail/detail.uvue +++ /dev/null @@ -1,35 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/component/long-list/long-list.uvue b/pages/component/long-list/long-list.uvue deleted file mode 100644 index 4aaa0a36513ac1bbcfbdf1c620f2a378389e48c3..0000000000000000000000000000000000000000 --- a/pages/component/long-list/long-list.uvue +++ /dev/null @@ -1,136 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/component/navigator/navigator.test.js b/pages/component/navigator/navigator.test.js new file mode 100644 index 0000000000000000000000000000000000000000..f424dded594c0b5e9b5e017735101b0ee7221cfa --- /dev/null +++ b/pages/component/navigator/navigator.test.js @@ -0,0 +1,30 @@ +const PAGE_PATH = '/pages/component/navigator/navigator' +const PAGE_PATH_NAVIGATE = '/pages/component/navigator/navigate' +const PAGE_PATH_REDIRECT = '/pages/component/navigator/redirect' + +describe('navigator', () => { + let page + beforeAll(async () => {}) + it('navigate', async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(500) + + const btnNavigate = await page.$('.navigate') + await btnNavigate.tap() + await page.waitFor(100) + + const currentPage = await program.currentPage() + expect(currentPage.path).toBe(PAGE_PATH_NAVIGATE.substring(1)) + }) + it('redirect', async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(500) + + const btnRedirect = await page.$('.redirect') + await btnRedirect.tap() + await page.waitFor(100) + + const currentPage = await program.currentPage() + expect(currentPage.path).toBe(PAGE_PATH_REDIRECT.substring(1)) + }) +}) diff --git a/pages/component/navigator/navigator.uvue b/pages/component/navigator/navigator.uvue index 81680683b4e3b4491db9c7156c906119de4d23f9..da656d03c7d9c5b29e53840156dc7b31fe83ec2d 100644 --- a/pages/component/navigator/navigator.uvue +++ b/pages/component/navigator/navigator.uvue @@ -2,10 +2,10 @@ - + - + diff --git a/pages/component/rich-text/rich-text.uvue b/pages/component/rich-text/rich-text.uvue index 901be5ff7e1ffda738b1da58d8e46a361ff33d04..bed489ae9c9fc50cb8de3a5a62ef854c732bd8f5 100644 --- a/pages/component/rich-text/rich-text.uvue +++ b/pages/component/rich-text/rich-text.uvue @@ -9,17 +9,27 @@ - + + + selectable + + + + + .text-box { + padding: 40rpx 0; + background-color: white; + } + \ No newline at end of file diff --git a/pages/component/scroll-view/scroll-view-custom-refresher-props.uvue b/pages/component/scroll-view/scroll-view-custom-refresher-props.uvue index 56a8d5f499665f750eed2ba9c4130eabdbe86b56..ab1c939257d01f01b1ed48ea34995e9056d07ba9 100644 --- a/pages/component/scroll-view/scroll-view-custom-refresher-props.uvue +++ b/pages/component/scroll-view/scroll-view-custom-refresher-props.uvue @@ -15,7 +15,6 @@ @@ -179,7 +203,8 @@ height: 400rpx; width: 100%; background-color: azure; - border-width: 2rpx; + border-width: 2rpx; + border-style: solid; border-color: chocolate; } @@ -206,4 +231,4 @@ padding: 30rpx; justify-content: center; } - \ No newline at end of file + diff --git a/pages/component/scroll-view/scroll-view-refresher-props.uvue b/pages/component/scroll-view/scroll-view-refresher-props.uvue index 90e5788531143e28eb90aad532c174a3d0d5bce6..beb739b98ef2faa94cfef8ce752685f88d36300e 100644 --- a/pages/component/scroll-view/scroll-view-refresher-props.uvue +++ b/pages/component/scroll-view/scroll-view-refresher-props.uvue @@ -31,13 +31,13 @@ 设置下拉刷新阈值 - 设置下拉刷新区域背景颜色 - @@ -54,7 +54,6 @@ - @@ -143,6 +142,7 @@ width: 100%; background-color: azure; border-width: 2rpx; + border-style: solid; border-color: chocolate; } diff --git a/pages/component/scroll-view/scroll-view-refresher.test.js b/pages/component/scroll-view/scroll-view-refresher.test.js new file mode 100644 index 0000000000000000000000000000000000000000..cc050d6656557cb028c9bcad31e440bd21d2d87c --- /dev/null +++ b/pages/component/scroll-view/scroll-view-refresher.test.js @@ -0,0 +1,19 @@ +// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/ + +describe('test title', () => { + + let page; + beforeAll(async () => { + page = await program.reLaunch('/pages/component/scroll-view/scroll-view-refresher'); + await page.waitFor(300); + }); + + + it('check_refresher', async () => { + await page.setData({ + refresherTriggered: true + }) + await page.waitFor(2000); + expect(await page.data('refresherrefresh')).toBe(true) + }); +}); diff --git a/pages/component/scroll-view/scroll-view-refresher.uvue b/pages/component/scroll-view/scroll-view-refresher.uvue index e335a7eabb0c7315d4f13849fc24b58ece6fd568..8d26c19e93a6477935c8c93da0da6c65000c29d2 100644 --- a/pages/component/scroll-view/scroll-view-refresher.uvue +++ b/pages/component/scroll-view/scroll-view-refresher.uvue @@ -13,14 +13,13 @@ diff --git a/pages/component/web-view-local/web-view-local.test.js b/pages/component/web-view-local/web-view-local.test.js new file mode 100644 index 0000000000000000000000000000000000000000..ed3ea2bff7041c0b138738b7be52c3c418d3bf95 --- /dev/null +++ b/pages/component/web-view-local/web-view-local.test.js @@ -0,0 +1,14 @@ +// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/ + +describe('test title', () => { + + let page; + beforeAll(async () => { + page = await program.reLaunch('/pages/component/web-view-local/web-view-local'); + await page.waitFor(1000); + }); + + it('check_load_url', async () => { + expect(await page.data('loadError')).toBe(false) + }); +}); diff --git a/pages/component/web-view-local/web-view-local.uvue b/pages/component/web-view-local/web-view-local.uvue index 684353ff163544c40b97d6b7f74b24ad6009bd42..4cc848026555e1848c8a7ff745baaa5127dac5a8 100644 --- a/pages/component/web-view-local/web-view-local.uvue +++ b/pages/component/web-view-local/web-view-local.uvue @@ -10,6 +10,7 @@ export default { data() { return { + loadError: false } }, methods: { @@ -21,6 +22,7 @@ }); }, error(event : WebViewErrorEvent) { + this.loadError = true console.log(JSON.stringify(event.detail)); }, loading(event : WebViewLoadingEvent) { diff --git a/pages/component/web-view/web-view.test.js b/pages/component/web-view/web-view.test.js new file mode 100644 index 0000000000000000000000000000000000000000..bca16763be3d8ac30c0270a59d10513198af5cc7 --- /dev/null +++ b/pages/component/web-view/web-view.test.js @@ -0,0 +1,14 @@ +// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/ + +describe('component-native-web-view', () => { + + let page; + beforeAll(async () => { + page = await program.reLaunch('/pages/component/web-view/web-view'); + await page.waitFor(3000); + }); + + it('check_load_url', async () => { + expect(await page.data('loadError')).toBe(false) + }); +}); diff --git a/pages/component/web-view/web-view.uvue b/pages/component/web-view/web-view.uvue index fa6b517a656960b9eebdc3251a33fdb44cf1a4f4..04c5eb85c15d8aafaac092d27403e1fa1575c0a5 100644 --- a/pages/component/web-view/web-view.uvue +++ b/pages/component/web-view/web-view.uvue @@ -34,13 +34,14 @@ export default { data() { return { - src: 'https://www.baidu.com', + src: 'https://www.dcloud.io', webview_styles: { progress: { color: '#FF3333' } }, - webviewContext: null as WebviewContext | null + webviewContext: null as WebviewContext | null, + loadError: false } }, onReady() { @@ -66,6 +67,7 @@ console.log(JSON.stringify(event.detail)); }, error(event : WebViewErrorEvent) { + this.loadError = true console.log(JSON.stringify(event.detail)); }, loading(event : WebViewLoadingEvent) { @@ -94,4 +96,4 @@ .uni-btn-ml { margin-left: 10rpx; } - \ No newline at end of file + diff --git a/pages/pages.test.js b/pages/pages.test.js new file mode 100755 index 0000000000000000000000000000000000000000..1041af21d6f893d6fc49260ccc02db62dda385b0 --- /dev/null +++ b/pages/pages.test.js @@ -0,0 +1,147 @@ +let pageIndex = 0 +const pages = [ + // component + '/pages/component/button/button', + '/pages/component/checkbox/checkbox', + '/pages/component/general-attribute/general-attribute', + '/pages/component/general-event/general-event', + '/pages/component/image/image-format', + // '/pages/component/image/image-large', // 截图过大 + '/pages/component/image/image-mode', + '/pages/component/image/image-path', + '/pages/component/image/image', + '/pages/component/input/input', + '/pages/component/list-view/list-view', + '/pages/component/navigator/navigate', + '/pages/component/navigator/navigator', + '/pages/component/navigator/redirect', + // '/pages/component/picker-view/picker-view', //动态内容 + '/pages/component/progress/progress', + '/pages/component/radio/radio', + '/pages/component/rich-text/rich-text-complex', + '/pages/component/rich-text/rich-text-tags', + '/pages/component/rich-text/rich-text', + '/pages/component/scroll-view/scroll-view-custom-refresher-props', + '/pages/component/scroll-view/scroll-view-props', + '/pages/component/scroll-view/scroll-view-refresher-props', + '/pages/component/scroll-view/scroll-view-refresher', + '/pages/component/scroll-view/scroll-view', + '/pages/component/slider/slider', + '/pages/component/slider-100/slider-100', + '/pages/component/swiper/swiper', + '/pages/component/switch/switch', + '/pages/component/text/text-props', + '/pages/component/text/text', + '/pages/component/textarea/textarea', + // '/pages/component/video/video', + '/pages/component/view/view-draw', + '/pages/component/view/view', + // '/pages/component/web-view/web-view', // 动态内容 + '/pages/component/web-view-local/web-view-local', + + // CSS + '/pages/CSS/background/background-color', + '/pages/CSS/background/background-image', + '/pages/CSS/border/complex-border/complex-border', + '/pages/CSS/border/border-bottom', + '/pages/CSS/border/border-color', + '/pages/CSS/border/border-left', + '/pages/CSS/border/border-radius', + '/pages/CSS/border/border-right', + '/pages/CSS/border/border-style', + '/pages/CSS/border/border-top', + '/pages/CSS/border/border-width', + '/pages/CSS/border/border', + // '/pages/CSS/box-shadow/box-shadow', + '/pages/CSS/display/flex', + '/pages/CSS/display/none', + '/pages/CSS/flex/align-content', + '/pages/CSS/flex/align-items', + '/pages/CSS/flex/flex-basis', + '/pages/CSS/flex/flex-direction', + '/pages/CSS/flex/flex-flow', + '/pages/CSS/flex/flex-grow', + '/pages/CSS/flex/flex-shrink', + '/pages/CSS/flex/flex', + '/pages/CSS/flex/justify-content', + '/pages/CSS/layout/height', + '/pages/CSS/layout/max-height', + '/pages/CSS/layout/max-width', + '/pages/CSS/layout/min-height', + '/pages/CSS/layout/min-width', + '/pages/CSS/layout/position', + '/pages/CSS/layout/visibility', + '/pages/CSS/layout/width', + '/pages/CSS/layout/z-index', + '/pages/CSS/margin/margin-bottom', + '/pages/CSS/margin/margin-left', + '/pages/CSS/margin/margin-right', + '/pages/CSS/margin/margin-top', + '/pages/CSS/margin/margin', + '/pages/CSS/padding/padding-bottom', + '/pages/CSS/padding/padding-left', + '/pages/CSS/padding/padding-right', + '/pages/CSS/padding/padding-top', + '/pages/CSS/padding/padding', + '/pages/CSS/text/color', + '/pages/CSS/text/font-family', + '/pages/CSS/text/font-size', + '/pages/CSS/text/font-style', + '/pages/CSS/text/font-weight', + '/pages/CSS/text/letter-spacing', + '/pages/CSS/text/line-height', + '/pages/CSS/text/text-align', + '/pages/CSS/text/text-decoration-line', + '/pages/CSS/text/text-overflow', + '/pages/CSS/transform/rotate', + '/pages/CSS/transform/scale', + '/pages/CSS/transform/translate', + '/pages/CSS/transition/transition', + + // tabBar + '/pages/tabBar/API', + '/pages/tabBar/component', + '/pages/tabBar/CSS', + '/pages/tabBar/template', + + // template + // '/pages/template/calendar/calendar', // 动态内容 + '/pages/template/custom-refresher/custom-refresher', + '/pages/template/custom-tab-bar/custom-tab-bar', + // '/pages/template/drop-card/drop-card', + '/pages/template/half-screen/half-screen', + '/pages/template/list-news/list-news', + '/pages/template/list-news/detail/detail', + // '/pages/template/long-list/long-list', // 动态内容 + '/pages/template/navbar-lite/navbar-lite', + '/pages/template/pull-zoom-image/pull-zoom-image', + '/pages/template/scroll-fold-nav/scroll-fold-nav', + '/pages/template/scroll-sticky/scroll-sticky', + '/pages/template/swiper-list/swiper-list', + '/pages/template/swiper-list2/swiper-list2', + // '/pages/template/swiper-vertical-video/swiper-vertical-video' +] + +let page; +describe('page screenshot test', () => { + beforeAll(async () => { + console.log("page screenshot test start"); + }); + beforeEach(async () => { + page = await program.reLaunch(pages[pageIndex]); + await page.waitFor(1000); + }); + afterEach(() => { + pageIndex++; + }); + afterAll(() => { + console.log("page screenshot test finish"); + }); + test.each(pages)('%s', async () => { + const image = await program.screenshot({ + fullPage: true + }); + expect(image).toMatchImageSnapshot(); + await page.waitFor(500); + }) +}) diff --git a/pages/tabBar/API.uvue b/pages/tabBar/API.uvue index e3f45999ad98714491fdb3123c76e1b8440f6116..02b5b58871d6fb874541fe6e06a5ba82b3a2038d 100644 --- a/pages/tabBar/API.uvue +++ b/pages/tabBar/API.uvue @@ -47,7 +47,6 @@ type ListItem = { id : string name : string - open : boolean pages : Page[] url ?: string enable ?: boolean @@ -59,7 +58,6 @@ { id: 'global', name: '全局', - open: false, pages: [ { name: 'getApp', @@ -74,7 +72,6 @@ { id: 'base', name: '基础', - open: false, pages: [ { name: '事件总线event-bus', @@ -94,7 +91,6 @@ { id: 'page', name: '页面和路由', - open: false, pages: [ { name: '页面跳转', @@ -127,42 +123,9 @@ }, ] as Page[], }, - { - id: 'network', - name: '网络', - pages: [ - { - name: '发起请求request', - url: 'request', - }, - { - name: '上传文件', - url: 'upload-file', - }, - { - name: '下载文件', - url: 'download-file', - }, - { - name: '获取设备网络状态', - url: 'get-network-type', - }, - { - name: 'socketTask', - url: 'websocket-socketTask', - api: [""] //它不是uni.的api - }, - { - name: '全局websocket', - url: 'websocket-global', - api: ["connectSocket", "onSocketOpen", "onSocketError", "sendSocketMessage", "onSocketMessage", "closeSocket", "onSocketClose"] - }, - ] as Page[], - }, { id: 'ui', name: '界面', - open: false, pages: [ /* { name: "创建动画", @@ -178,40 +141,76 @@ name: "节点布局交互状态", url: "intersection-observer", enable: false - }, */ + }, */ + { + name: 'element元素', + url: 'get-element-by-id', + api: ["getElementById"] + }, { - name: '节点信息', + name: 'node节点', url: 'nodes-info', api: ["createSelectorQuery"] }, { - name: '显示操作菜单', + name: '动态加载字体', + url: 'load-font-face', + }, + { + name: 'actionSheet操作菜单', url: 'action-sheet', }, { - name: '显示模态弹窗', + name: 'showModal模态弹窗', url: 'modal', api: ["showModal"] }, { - name: '显示加载提示框', - url: 'show-loading', + name: 'showLoading等待框', + url: 'loading', }, { - name: '显示消息提示框', + name: 'showToast轻提示框', url: 'toast', api: ["showToast"] - }, - { - name: '动态加载字体', - url: 'load-font-face', - }, + } ] as Page[], + }, + { + id: 'network', + name: '网络', + pages: [ + { + name: '发起请求request', + url: 'request', + }, + { + name: '上传文件', + url: 'upload-file', + }, + { + name: '下载文件', + url: 'download-file', + }, + { + name: '获取设备网络状态', + url: 'get-network-type', + }, + { + name: 'socketTask', + url: 'websocket-socketTask', + api: [""] //它不是uni.的api + }, + { + name: '全局websocket', + url: 'websocket-global', + api: ["connectSocket", "onSocketOpen", "onSocketError", "sendSocketMessage", "onSocketMessage", "closeSocket", "onSocketClose"] + }, + ] as Page[], }, { id: 'device', name: '设备', - open: false, pages: [ { name: '获取系统信息', @@ -298,16 +297,19 @@ { id: 'media', name: '媒体', - open: false, - pages: [ + pages: [ + { + name: "拍照和相册选择", + url: 'choose-image' + }, { - name: '图片选择和预览', + name: '图片预览', url: 'preview-image', - api: ["previewImage", "closePreviewImage", "chooseImage"] + api: ["previewImage", "closePreviewImage"] }, { name: "保存图片到相册", - url: 'save-image-to-album' + url: 'save-image-to-photos-album' } /* { name: "图片选择和拍照", @@ -383,7 +385,19 @@ pages: [ { name: '云函数', - url: 'call-function', + url: 'unicloud-call-function', + }, + { + name: '云对象', + url: 'unicloud-import-object', + }, + { + name: '云存储', + url: 'unicloud-file-api', + }, + { + name: 'clientDB', + url: 'unicloud-database', }, ] as Page[], }, @@ -391,7 +405,6 @@ id: "rewarded-video-ad", url: "rewarded-video-ad", name: "激励视频广告", - open: false, enable: false, pages: [] as Page[] }, @@ -399,14 +412,12 @@ id: "full-screen-video-ad", url: "full-screen-video-ad", name: "全屏视频广告", - open: false, enable: false, pages: [] as Page[] }, { id: "login", name: "登录", - open: false, pages: [ { name: "登录", @@ -421,7 +432,6 @@ { id: "share", name: "分享", - open: false, pages: [ { name: "分享", @@ -432,7 +442,6 @@ { id: "payment", name: "支付", - open: false, pages: [ { name: "发起支付", @@ -443,7 +452,6 @@ { id: "speech", name: "语音", - open: false, pages: [ { name: "语音识别", @@ -454,7 +462,6 @@ { id: "push", name: "推送", - open: false, pages: [ { name: "推送", @@ -469,24 +476,6 @@ } }, methods: { - triggerCollapse(index ?: number, item : ListItem) { - if (item.pages.length == 0) { - const page : Page = { - name: item.name, - enable: item.enable, - url: item.url!, - } - this.goDetailPage(page) - return - } - for (var i = 0; i < this.list.length; ++i) { - if (index == i) { - this.list[i].open = !this.list[i].open - } else { - this.list[i].open = false - } - } - }, goDetailPage(e : Page) { if (e.enable == false) { uni.showToast({ @@ -506,10 +495,10 @@ }) }, showPop: function () { - (this.$refs["pop"] as INode).style.setProperty("display", "flex") + (this.$refs["pop"] as Element).style.setProperty("display", "flex") }, hidePop: function () { - (this.$refs["pop"] as INode).style.setProperty("display", "none") + (this.$refs["pop"] as Element).style.setProperty("display", "none") }, stopClickPop: function (e : MouseEvent) { e.stopPropagation() //点击到pop的非灰色区域,拦截点击事件 diff --git a/pages/tabBar/CSS.uvue b/pages/tabBar/CSS.uvue index 514b50adbc100911756d6f2a2418783649f0925b..291bc1280cb33d856ce8a38d9e6b8a66c3d62124 100644 --- a/pages/tabBar/CSS.uvue +++ b/pages/tabBar/CSS.uvue @@ -38,7 +38,6 @@ type ListItem = { id : string name : string - open : boolean pages : Page[] url ?: string enable ?: boolean @@ -50,7 +49,6 @@ { id: 'background', name: 'background', - open: false, pages: [ { name: 'background-color', @@ -65,7 +63,6 @@ { id: 'border', name: 'border', - open: false, pages: [ { name: 'border', @@ -86,6 +83,22 @@ { name: 'border-radius', url: '/pages/CSS/border/border-radius', + }, + { + name: 'border-top', + url: '/pages/CSS/border/border-top', + }, + { + name: 'border-bottom', + url: '/pages/CSS/border/border-bottom', + }, + { + name: 'border-left', + url: '/pages/CSS/border/border-left', + }, + { + name: 'border-right', + url: '/pages/CSS/border/border-right', }, { name: 'border属性复合示例', @@ -96,7 +109,6 @@ { id: 'box-shadow', name: 'box-shadow', - open: false, pages: [ { name: 'box-shadow', @@ -107,7 +119,6 @@ { id: 'display', name: 'display', - open: false, pages: [ { name: 'flex', @@ -122,7 +133,6 @@ { id: 'flex', name: 'flex', - open: false, pages: [ { name: 'align-content', @@ -165,7 +175,6 @@ { id: 'layout', name: 'layout', - open: false, pages: [ { name: 'height', @@ -208,7 +217,6 @@ { id: 'margin', name: 'margin', - open: false, pages: [ { name: 'margin-bottom', @@ -235,7 +243,6 @@ { id: 'padding', name: 'padding', - open: false, pages: [ { name: 'padding-bottom', @@ -262,7 +269,6 @@ { id: 'text', name: 'text', - open: false, pages: [ { name: 'color', @@ -309,7 +315,6 @@ { id: 'transform', name: 'transform', - open: false, pages: [ { name: 'translate', @@ -328,7 +333,6 @@ { id: 'transition', name: 'transition', - open: false, pages: [ { name: 'transition', @@ -343,24 +347,6 @@ } }, methods: { - triggerCollapse(index ?: number, item : ListItem) { - if (item.pages.length == 0) { - const page : Page = { - name: item.name, - enable: item.enable, - url: item.url, - } - this.goDetailPage(page) - return - } - for (var i = 0; i < this.list.length; ++i) { - if (index == i) { - this.list[i].open = !this.list[i].open - } else { - this.list[i].open = false - } - } - }, goDetailPage(e : Page) { if (e.enable == false) { uni.showToast({ @@ -384,4 +370,4 @@ .item { margin-bottom: 12px; } - \ No newline at end of file + diff --git a/pages/tabBar/component.uvue b/pages/tabBar/component.uvue index 1466446cf946b24387adc214a28b41ac7d19c60d..6e94ad1e922d92bc4a4ac23d45cc9d19f036029c 100644 --- a/pages/tabBar/component.uvue +++ b/pages/tabBar/component.uvue @@ -54,7 +54,6 @@ type Page = { type ListItem = { id : string name : string - open : boolean pages : Page[] url ?: string enable ?: boolean @@ -66,7 +65,6 @@ export default { { id: 'view', name: '视图容器', - open: false, pages: [ { name: 'view', @@ -95,7 +93,6 @@ export default { { id: 'content', name: '基础内容', - open: false, pages: [ { name: 'text', @@ -112,7 +109,6 @@ export default { { id: 'form', name: '表单组件', - open: false, pages: [ { name: 'button', @@ -162,7 +158,6 @@ export default { { id: 'nav', name: '导航', - open: false, pages: [{ name: 'navigator', enable: true @@ -171,7 +166,6 @@ export default { { id: 'media', name: '媒体组件', - open: false, pages: [ { name: 'image', @@ -191,7 +185,6 @@ export default { { id: 'map', name: '地图', - open: false, pages: [ { name: 'map', @@ -202,7 +195,6 @@ export default { { id: 'canvas', name: '画布', - open: false, pages: [ { name: 'canvas' @@ -213,7 +205,6 @@ export default { { id: 'web-view', name: '网页', - open: false, pages: [ { name: '网络网页', @@ -233,14 +224,12 @@ export default { url: 'ad', name: 'AD组件', enable: false, - open: false, pages: [] as Page[] } */ { id: 'general-attr-event', name: '通用属性和事件', - open: false, pages: [ { name: '通用属性', @@ -261,24 +250,6 @@ export default { } }, methods: { - triggerCollapse(index ?: number, item : ListItem) { - if (item.pages.length == 0) { - const page : Page = { - name: item.name, - enable: item.enable, - url: item.url, - } - this.goDetailPage(page) - return - } - for (var i = 0; i < this.list.length; ++i) { - if (index == i) { - this.list[i].open = !this.list[i].open - } else { - this.list[i].open = false - } - } - }, goDetailPage(e : Page) { if (e.enable == false) { uni.showToast({ diff --git a/pages/tabBar/template.uvue b/pages/tabBar/template.uvue index 75eee77393ca9217dc10e5be3d60acf12895b9f2..bee81fdd60315b8c83f86ff1ff79528cef5e927c 100644 --- a/pages/tabBar/template.uvue +++ b/pages/tabBar/template.uvue @@ -145,20 +145,35 @@ export default { open: false, pages: [] as Page[], }, - { - id: 'half-screen', - url: 'half-screen', - name: '半屏弹窗', - open: false, - enable: false, - pages: [] as Page[], - }, + // { + // id: 'half-screen', + // url: 'half-screen', + // name: '半屏弹窗', + // open: false, + // enable: false, + // pages: [] as Page[], + // }, { id: 'drop-card', url: 'drop-card', name: '划走式卡片', open: false, pages: [] as Page[], + }, + { + id: 'navbar-lite', + url: 'navbar-lite', + name: '自定义导航栏', + open: false, + pages: [] as Page[], + }, + { + id: 'custom-tab-bar', + url: 'custom-tab-bar', + name: '自定义TabBar', + open: false, + enable: true, + pages: [] as Page[], }, { id: 'calendar', @@ -174,7 +189,7 @@ export default { } }, methods: { - triggerCollapse(index?: number, item: ListItem) { + triggerCollapse(index: number, item: ListItem) { if (item.pages.length == 0) { const page: Page = { name: item.name, diff --git a/pages/template/calendar/calendar.uts b/pages/template/calendar/calendar.uts index 0950683b88c73d73fa3b19373a39f363cc014b8f..765be1a0f94c2301f4f1d3968362194c8a47364c 100644 --- a/pages/template/calendar/calendar.uts +++ b/pages/template/calendar/calendar.uts @@ -125,7 +125,7 @@ export class Lunar { * 返回农历y年闰月是哪个月;若y年没有闰月 则返回0 * @param lunar Year * @return Number (0-12) - * @eg:let leapMonth = calendar.leapMonth(1987) ;//leapMonth=6 + * @eg:let leapMonth = calendar.leapMonth(1987) ;//leapMonth=6 */ leapMonth(year : number) : number { return lunarYears[year - 1900] & 0xF; @@ -146,7 +146,7 @@ export class Lunar { // 某年份农历各月天数 lunarMonthDays(year : number) : number[] { - + let monthDays = this.lunarMonthDaysMap.get(year) if (monthDays != null) { return monthDays @@ -164,7 +164,7 @@ export class Lunar { // 添加闰月 let leapM = this.leapMonth(year); - if (leapM > 0) monthDays.splice(leapM, 0, leapDays(year)); + if (leapM > 0) monthDays.splice(leapM, 0, this.leapDays(year)); this.lunarMonthDaysMap.set(year, monthDays) return monthDays; @@ -265,7 +265,7 @@ export class Lunar { } else { // 补偿公历1901年2月的农历信息 if (offset == -23) { - const info : InfoType = { + let info : InfoType = { lunarY: i, lunarM: 12, lunarD: 8, @@ -294,4 +294,4 @@ export class Lunar { return info } -} \ No newline at end of file +} diff --git a/pages/template/calendar/calendar.uvue b/pages/template/calendar/calendar.uvue index f786b99b7db0e396f614b5536b5c5dc3732b9078..05359064050ac98dd421bdb679a1678871e567e3 100644 --- a/pages/template/calendar/calendar.uvue +++ b/pages/template/calendar/calendar.uvue @@ -65,7 +65,7 @@ // 触发整个日历的点击事件,需要计算点击位置 select(event : TouchEvent) { - const refs = this.$refs['draw-weeks'] as INode + const refs = this.$refs['draw-weeks'] as Element const rect = refs.getBoundingClientRect(); const dom_x = rect.left; // 元素左上角相对于视口的 X 坐标 const dom_y = rect.top; // 元素左上角相对于视口的 Y 坐标 @@ -139,8 +139,9 @@ // 绘制日历顶部信息 drawHeader() { - const refs = this.$refs['draw-header'] as INode - let ctx = refs.getDrawableContext() + const refs = this.$refs['draw-header'] as Element + let ctx = refs.getDrawableContext() + if (ctx == null) return const date_header_map = ['一', '二', '三', '四', '五', '六', '日'] const width = refs.getBoundingClientRect().width @@ -166,8 +167,9 @@ // 绘制日历主体 drawWeek(weeks : Array>, time : string) { const start_time = Date.now() - const refs = this.$refs['draw-weeks'] as INode + const refs = this.$refs['draw-weeks'] as Element let ctx = refs.getDrawableContext() + if (ctx == null) return const dom = refs.getBoundingClientRect() const width = dom.width const height = dom.height @@ -283,4 +285,4 @@ justify-content: space-between; margin: 20px 0; } - \ No newline at end of file + diff --git a/pages/template/custom-refresher/custom-refresher.uvue b/pages/template/custom-refresher/custom-refresher.uvue index 02df00cf085946dbc871c34519a381fe3943ca88..e8c5d068bab4fa779de616105fe45a09d95634fe 100644 --- a/pages/template/custom-refresher/custom-refresher.uvue +++ b/pages/template/custom-refresher/custom-refresher.uvue @@ -15,7 +15,6 @@ + + \ No newline at end of file diff --git a/pages/template/custom-tab-bar/custom-tab-bar-tab2.uvue b/pages/template/custom-tab-bar/custom-tab-bar-tab2.uvue new file mode 100644 index 0000000000000000000000000000000000000000..063e1fbabf8fde88d5cb3c1a30fb1eed03989441 --- /dev/null +++ b/pages/template/custom-tab-bar/custom-tab-bar-tab2.uvue @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/pages/template/custom-tab-bar/custom-tab-bar.uvue b/pages/template/custom-tab-bar/custom-tab-bar.uvue new file mode 100644 index 0000000000000000000000000000000000000000..7c04890f89952579f100fdc043cc78ebbfd3b156 --- /dev/null +++ b/pages/template/custom-tab-bar/custom-tab-bar.uvue @@ -0,0 +1,200 @@ + + + + + \ 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 6eda7ee0232886fcc9c063291d3b24a8cf7b8837..56e15b81a640d286ec7559e8ceb5d79b89a1f80b 100644 --- a/pages/template/drop-card/card/card.uvue +++ b/pages/template/drop-card/card/card.uvue @@ -21,7 +21,7 @@ export default { data() { return { - $nodeMap:new Map(), + $elementMap:new Map(), x: 0 as number, y: 0 as number, // 飘走的卡片计数 @@ -59,8 +59,8 @@ // TODO 需要延迟设置才能生效 setTimeout(()=>{ - this.setINodeStyle('card','height', screenHeight * 0.7 + 'px'); - this.setINodeStyle('card-img','height', screenHeight * 0.7 + 'px'); + this.setElementStyle('card','height', screenHeight * 0.7 + 'px'); + this.setElementStyle('card-img','height', screenHeight * 0.7 + 'px'); this.initCardStyle() },200) @@ -74,20 +74,20 @@ initCardStyle(){ let _index = (this.cardIndex + this.floatCount)%3 // console.log('~~~~~~_index:'+_index + ' cardIndex:'+this.cardIndex+' floatCount:'+this.floatCount); - this.setINodeStyle('card','z-index', _index) - this.setINodeStyle('card','margin-top', screenHeight * 0.15 - 30 * _index + 'px'); - this.setINodeStyle('card','transform', 'scale('+(0.9 + 0.05 * _index)+')') + this.setElementStyle('card','z-index', _index) + this.setElementStyle('card','margin-top', screenHeight * 0.15 - 30 * _index + 'px'); + this.setElementStyle('card','transform', 'scale('+(0.9 + 0.05 * _index)+')') }, - // 工具方法,用于快速设置 INode 的 style - setINodeStyle(refName:string,propertyName : string, propertyStyle : any) : void { - let node : INode | null = this.$nodeMap.get(refName) - if(node == null){ - node = this.$refs.get(refName) as INode; - this.$nodeMap.set(refName,node) + // 工具方法,用于快速设置 Element 的 style + setElementStyle(refName:string,propertyName : string, propertyStyle : any) : void { + let element : Element | null = this.$elementMap.get(refName) + if(element == null){ + element = this.$refs[refName] as Element; + this.$elementMap.set(refName,element) }else{ // console.log('直接拿'); } - node?.style?.setProperty(propertyName, propertyStyle); + element?.style?.setProperty(propertyName, propertyStyle); }, touchstart(e : TouchEvent) { // console.log('touchstart') @@ -160,13 +160,13 @@ if(k.toInt() != 0){ cardTo(k * screenWidth * 1.3, this.y * 3,()=>{ // 状态图标变回透明 - this.setINodeStyle("state-icon-like",'opacity', 0) - this.setINodeStyle("state-icon-dislike",'opacity', 0) + this.setElementStyle("state-icon-like",'opacity', 0) + this.setElementStyle("state-icon-dislike",'opacity', 0) // 设置为透明,防止飘回时因为 margin-top 太高,露出来 - this.setINodeStyle("card",'opacity', 0) + this.setElementStyle("card",'opacity', 0) setTimeout(()=>{ - this.setINodeStyle("card",'opacity', 1) + this.setElementStyle("card",'opacity', 1) },300) // 执行卡片飘动后事件,注意uni.$emit是全局事件。其他卡片也会执行 @@ -185,12 +185,12 @@ } }, moveCard() { - this.setINodeStyle("card", + this.setElementStyle("card", 'transform', `translate(${this.x}px,${this.y}px) rotate(${this.x/-30}deg) scale(1)` ) - this.setINodeStyle("state-icon-like",'opacity', this.x < 0 ? 0 : movePercent * 10) - this.setINodeStyle("state-icon-dislike",'opacity', this.x > 0 ? 0 : movePercent * 10) + this.setElementStyle("state-icon-like",'opacity', this.x < 0 ? 0 : this.movePercent * 10) + this.setElementStyle("state-icon-dislike",'opacity', this.x > 0 ? 0 : this.movePercent * 10) } } } diff --git a/pages/template/half-screen/half-screen.uvue b/pages/template/half-screen/half-screen.uvue index 4dbb4ad7938ae977c91c1655dee5778cae07b093..840b8e66dd7788598f6c2a54ed1a8b80c1e2f2ea 100644 --- a/pages/template/half-screen/half-screen.uvue +++ b/pages/template/half-screen/half-screen.uvue @@ -26,8 +26,8 @@ lastY: 0, //上次 lastY2: 0, // bAnimation: false, //是否动画 - halfNode: null as INode | null, - scrollNode: null as INode | null + halfNode: null as Element | null, + scrollNode: null as Element | null } }, methods: { @@ -75,9 +75,9 @@ bHide = (this.lastY-this.lastY2)>3; //向下滑动计算加速度判断是否关闭,简单处理未考虑时间 } if(bHide){ - switchHalfScreen(false); + this.switchHalfScreen(false); }else{ - resumeHalfScreen(); + this.resumeHalfScreen(); } }, onScroll(_: ScrollEvent) { @@ -131,9 +131,9 @@ } }, onReady() { - this.halfNode = this.$refs['halfScreen'] as INode; + this.halfNode = this.$refs['halfScreen'] as Element; this.halfHeight = this.halfNode!.getBoundingClientRect().height; - this.scrollNode = this.$refs['halfScroll'] as INode; + this.scrollNode = this.$refs['halfScroll'] as Element; this.totalHeight = uni.getWindowInfo().windowHeight; this.halfNode?.style?.setProperty('top', this.totalHeight.toString()); diff --git a/pages/template/list-news/detail/detail.uvue b/pages/template/list-news/detail/detail.uvue index 09f151e7de0eecaddd97f0dee6ef8e9d36e3dcac..0d1ef04a3fb5fe053a517fd321241bfc843e6b3b 100644 --- a/pages/template/list-news/detail/detail.uvue +++ b/pages/template/list-news/detail/detail.uvue @@ -23,10 +23,11 @@ } }, onLoad(event) { - // console.log(event); - this.post_id = event["post_id"] ?? ""; - this.cover = event["cover"] ?? ""; - this.title = event["title"] ?? ""; + if (event != null) { + this.post_id = event["post_id"] ?? ""; + this.cover = event["cover"] ?? ""; + this.title = event["title"] ?? ""; + } this.getDetail(); }, methods: { diff --git a/pages/template/long-list/long-list-page.uvue b/pages/template/long-list/long-list-page.uvue index f6eeb9a953eeea6b12036af8124fe842e51dc800..bf7f90aef3e72865fe4fba5cd80f9fa5ba17f2ad 100644 --- a/pages/template/long-list/long-list-page.uvue +++ b/pages/template/long-list/long-list-page.uvue @@ -224,7 +224,7 @@ } .tag-item { - font-size: 14px; + font-size: 12px; background-color: #EFF9F0; color: #639069; border-radius: 20px; diff --git a/pages/template/long-list/long-list.uvue b/pages/template/long-list/long-list.uvue index 9efae74407e31aaa0a121587a14dec6b5ac7d28c..97f1c131ec88c53eeefec3f304803992d53fb87d 100644 --- a/pages/template/long-list/long-list.uvue +++ b/pages/template/long-list/long-list.uvue @@ -25,6 +25,7 @@ + + diff --git a/pages/template/pull-zoom-image/pull-zoom-image.uvue b/pages/template/pull-zoom-image/pull-zoom-image.uvue index 3ccf595d9499a9039dc347acd6e73291e87732cf..88d679ae5e00742fac3cb6430c69ebf7473ae218 100644 --- a/pages/template/pull-zoom-image/pull-zoom-image.uvue +++ b/pages/template/pull-zoom-image/pull-zoom-image.uvue @@ -25,7 +25,7 @@ - + @@ -36,7 +36,7 @@ export default { data() { return { - $INodeMap: new Map() + $elementMap: new Map() } }, methods: { @@ -51,23 +51,23 @@ s = 0.7 } let x : number = (1 - s) * -100 - this.setINodeStyle("user-info", "transform", `translate(${x},${y + (s-1)* -50}px) scale(${s})`) - this.setINodeStyle("head-img-box-2", "transform", `translateY(${y}px)`) + this.setElementStyle("user-info", "transform", `translate(${x},${y + (s-1)* -50}px) scale(${s})`) + this.setElementStyle("head-img-box-2", "transform", `translateY(${y}px)`) }, onRefresherpulling(e : RefresherEvent) { // console.log('onRefresherpulling',e.detail.dy) let pullingDistance : number = e.detail.dy - this.setINodeStyle("head-img-1", 'transform', `scale(${pullingDistance / 200 + 1})`) - this.setINodeStyle("head-img-2", 'transform', `scale(${pullingDistance / 200 + 1})`) + this.setElementStyle("head-img-1", 'transform', `scale(${pullingDistance / 200 + 1})`) + this.setElementStyle("head-img-2", 'transform', `scale(${pullingDistance / 200 + 1})`) }, - // 工具方法,用于快速设置 INode 的 style - setINodeStyle(refName : string, propertyName : string, propertyStyle : any) : void { - let iNode : INode | null = this.$INodeMap.get(refName) - if (iNode == null) { - iNode = this.$refs.get(refName) as INode; - this.$INodeMap.set(refName, iNode) + // 工具方法,用于快速设置 Element 的 style + 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; + this.$elementMap.set(refName, element) } - iNode.style.setProperty(propertyName, propertyStyle); + element.style.setProperty(propertyName, propertyStyle); }, back() { uni.navigateBack({ diff --git a/pages/template/scroll-fold-nav/scroll-fold-nav.uvue b/pages/template/scroll-fold-nav/scroll-fold-nav.uvue index 5dc83f133c5bbf43f74152f287b8013e336e411d..30659e13c217b70d9c6218b8afd28db3aefbd9ed 100644 --- a/pages/template/scroll-fold-nav/scroll-fold-nav.uvue +++ b/pages/template/scroll-fold-nav/scroll-fold-nav.uvue @@ -41,17 +41,17 @@ statusBarHeight: 35, scrollTop: 0, searchWidth: 700, - searchNode: null as INode | null, - boxNode: null as INode | null, - navNode: null as INode | null + searchNode: null as Element | null, + boxNode: null as Element | null, + navNode: null as Element | null } }, onLoad() { }, onReady() { this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight ?? 35; - this.searchNode = this.$refs['search'] as INode; - this.boxNode = this.$refs['top-box'] as INode; - this.navNode = this.$refs['scroll-fold-nav'] as INode; + this.searchNode = this.$refs['search'] as Element; + this.boxNode = this.$refs['top-box'] as Element; + this.navNode = this.$refs['scroll-fold-nav'] as Element; }, methods: { onScroll(e : ScrollEvent) { @@ -150,7 +150,7 @@ .nav-back { position: absolute; - top: 44px; + top: 46px; left: 8px; } diff --git a/pages/template/scroll-sticky/scroll-sticky.uvue b/pages/template/scroll-sticky/scroll-sticky.uvue index bc0680d6b7a39264399c6813c680ff6c60e82948..782ae1da7279f62642dc17b0b201b855edfa0d80 100644 --- a/pages/template/scroll-sticky/scroll-sticky.uvue +++ b/pages/template/scroll-sticky/scroll-sticky.uvue @@ -1,5 +1,5 @@