From 3a6e84b1d3ff66c25a6008d2e9a7b328b7fdc250 Mon Sep 17 00:00:00 2001 From: wangyaqi Date: Thu, 25 Jan 2024 21:17:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=BE=8B=E5=85=BC=E5=AE=B9web=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/download-file/download-file.test.js | 77 ++++++++------- pages/API/download-file/download-file.uvue | 4 +- pages/API/upload-file/upload-file.test.js | 94 ++++++++++--------- 3 files changed, 93 insertions(+), 82 deletions(-) diff --git a/pages/API/download-file/download-file.test.js b/pages/API/download-file/download-file.test.js index 8de4823d..afe512d0 100644 --- a/pages/API/download-file/download-file.test.js +++ b/pages/API/download-file/download-file.test.js @@ -2,47 +2,52 @@ const PAGE_PATH = '/pages/API/download-file/download-file' describe('ExtApi-DownloadFile', () => { - let page; + let page; let res; beforeAll(async () => { page = await program.reLaunch(PAGE_PATH) - await page.waitFor(600); - await page.callMethod('jest_downloadFile'); - await page.waitFor(1000); - res = await page.data('jest_result'); - }); - - beforeEach(async () => { - await page.setData({ - jest_result: false - }) + await page.waitFor(600); + await page.callMethod('jest_downloadFile'); + await page.waitFor(1000); + res = await page.data('jest_result'); + }); + + beforeEach(async () => { + await page.setData({ + jest_result: false + }) }); it('Check ', async () => { - expect(res).toBe(true); - }); - it('Check Set Cookie', async () => { - if (process.env.uniTestPlatformInfo.startsWith('android')) { - let version = process.env.uniTestPlatformInfo - version = version.split(" ")[1] - if(version > 9){ - res = await page.callMethod('jest_set_cookie') - await page.waitFor(1000); - res = await page.data('jest_result'); - expect(res).toBe(true) - } - } - }); - it('Check Delete Cookie', async () => { - if (process.env.uniTestPlatformInfo.startsWith('android')) { - let version = process.env.uniTestPlatformInfo - version = version.split(" ")[1] - if(version > 9){ - res = await page.callMethod('jest_delete_cookie') - await page.waitFor(1000); - res = await page.data('jest_result'); - expect(res).toBe(true) - } - } + expect(res).toBe(true); + }); + + let shouldTestCookie = false + if (process.env.uniTestPlatformInfo.startsWith('android')) { + let version = process.env.uniTestPlatformInfo + version = version.split(" ")[1] + shouldTestCookie = version > 9 + } else if (process.env.uniTestPlatformInfo.startsWith('web')) { + // TODO 测试网址调整后放开此测试 + shouldTestCookie = false + } + + it('Check Set Cookie', async () => { + if (!shouldTestCookie) { + return + } + res = await page.callMethod('jest_set_cookie') + await page.waitFor(1000); + res = await page.data('jest_result'); + expect(res).toBe(true) + }); + it('Check Delete Cookie', async () => { + if (!shouldTestCookie) { + return + } + res = await page.callMethod('jest_delete_cookie') + await page.waitFor(1000); + res = await page.data('jest_result'); + expect(res).toBe(true) }); }); diff --git a/pages/API/download-file/download-file.uvue b/pages/API/download-file/download-file.uvue index 54ef9253..55a0b9c3 100644 --- a/pages/API/download-file/download-file.uvue +++ b/pages/API/download-file/download-file.uvue @@ -77,7 +77,7 @@ method: "GET", timeout: 6000, sslVerify: false, - withCredentials: false, + withCredentials: true, firstIpv4: false, success: () => { this.jest_cookie_download(true) @@ -94,7 +94,7 @@ method: "GET", timeout: 6000, sslVerify: false, - withCredentials: false, + withCredentials: true, firstIpv4: false, success: () => { this.jest_cookie_download(false) diff --git a/pages/API/upload-file/upload-file.test.js b/pages/API/upload-file/upload-file.test.js index f7cd5b91..308239d3 100644 --- a/pages/API/upload-file/upload-file.test.js +++ b/pages/API/upload-file/upload-file.test.js @@ -1,55 +1,61 @@ const PAGE_PATH = '/pages/API/upload-file/upload-file' describe('ExtApi-UploadFile', () => { + if(process.env.uniTestPlatformInfo.startsWith('web')){ + // TODO: web 端暂不支持测试 + it('web', async () => { + expect(1).toBe(1) + }) + } - let page; + let page; let res; beforeAll(async () => { page = await program.reLaunch(PAGE_PATH) - await page.waitFor(600); - await page.callMethod('jest_uploadFile'); - await page.waitFor(1000); - res = await page.data('jest_result'); - }); - - beforeEach(async () => { - await page.setData({ - jest_result: false - }) + await page.waitFor(600); + await page.callMethod('jest_uploadFile'); + await page.waitFor(1000); + res = await page.data('jest_result'); + }); + + beforeEach(async () => { + await page.setData({ + jest_result: false + }) }); it('Check ', async () => { - expect(res).toBe(true); - }); - - it('Check Set Cookie', async () => { - if (process.env.uniTestPlatformInfo.startsWith('android')) { - let version = process.env.uniTestPlatformInfo - version = version.split(" ")[1] - if(version > 9){ - res = await page.callMethod('jest_set_cookie') - await page.waitFor(1000); - res = await page.data('jest_result'); - expect(res).toBe(true) - } - } - }); - it('Check Delete Cookie', async () => { - if (process.env.uniTestPlatformInfo.startsWith('android')) { - let version = process.env.uniTestPlatformInfo - version = version.split(" ")[1] - if(version > 9){ - res = await page.callMethod('jest_delete_cookie') - await page.waitFor(1000); - res = await page.data('jest_result'); - expect(res).toBe(true) - } - } - }); - it('Check files upload', async () => { - res = await page.callMethod('jest_files_upload') - await page.waitFor(1000); - res = await page.data('jest_result'); - expect(res).toBe(true) + expect(res).toBe(true); + }); + + it('Check Set Cookie', async () => { + if (process.env.uniTestPlatformInfo.startsWith('android')) { + let version = process.env.uniTestPlatformInfo + version = version.split(" ")[1] + if(version > 9){ + res = await page.callMethod('jest_set_cookie') + await page.waitFor(1000); + res = await page.data('jest_result'); + expect(res).toBe(true) + } + } + }); + it('Check Delete Cookie', async () => { + if (process.env.uniTestPlatformInfo.startsWith('android')) { + let version = process.env.uniTestPlatformInfo + version = version.split(" ")[1] + if(version > 9){ + res = await page.callMethod('jest_delete_cookie') + await page.waitFor(1000); + res = await page.data('jest_result'); + expect(res).toBe(true) + } + } + }); + it('Check files upload', async () => { + res = await page.callMethod('jest_files_upload') + await page.waitFor(1000); + res = await page.data('jest_result'); + expect(res).toBe(true) }); -}); +}); -- GitLab