diff --git a/pages/API/download-file/download-file.test.js b/pages/API/download-file/download-file.test.js index 8de4823d1db1198440ae737f79056371f6e3437f..afe512d0c887e490a2abf71a8f977f2f55db6472 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 54ef92535160be74c1010591c604c61809556f5e..55a0b9c395e08aa8bde9a6ee8361de64387800b6 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 f7cd5b91b9cff5c0b8c6d0cfb0b3e26966b87abd..308239d3ccd6acb8cd4defdba3dd08caa29b09e0 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) }); -}); +});