diff --git a/pages/API/request/request.test.js b/pages/API/request/request.test.js index 336d8ac3a108585815789a26c412a6d33ec73801..0b709f9d696b8a86f20cdf6bbb4ccd26b3149c43 100644 --- a/pages/API/request/request.test.js +++ b/pages/API/request/request.test.js @@ -117,7 +117,28 @@ describe('ExtApi-Request', () => { await page.waitFor(2000); res = await page.data('jest_result'); expect(res).toBe(true) - }); + }); + it('Check Set Cookie Expires', async () => { + await page.callMethod('jest_set_cookie_expires') + await page.waitFor(2000); + res = await page.data('jest_result_data'); + console.log("request expires cookie data :", res); + res = await page.data('jest_result'); + expect(res).toBe(true) + await page.setData({ + jest_result: false, + jest_result_data: "", + data: null, + header: null + }) + await page.waitFor(5000); + await page.callMethod('jest_cookie_request', false) + await page.waitFor(2000); + res = await page.data('jest_result_data'); + console.log("verify request data :", res); + res = await page.data('jest_result'); + expect(res).toBe(true) + }); it('Check Get With Data', async () => { res = await page.callMethod('jest_get_with_data') await page.waitFor(2000); diff --git a/pages/API/request/request.uvue b/pages/API/request/request.uvue index 190cec7e39789f49d20d6d0b2bab157d1ccdf8a4..65b26d92ab8cf3b0fbcbb50a41cd5f7381e32bc6 100644 --- a/pages/API/request/request.uvue +++ b/pages/API/request/request.uvue @@ -141,7 +141,8 @@ "/api/http/contentType/xWwwFormUrlencoded", ], //自动化测试例专用 - jest_result: false + jest_result: false, + jest_result_data: "" } }, onLoad() { @@ -257,6 +258,22 @@ this.jest_result = false; }, }); + }, + jest_set_cookie_expires(){ + uni.request({ + url: this.host + "/api/http/header/setCookie?expires=5", + method: "GET", + timeout: 6000, + sslVerify: false, + withCredentials: false, + firstIpv4: false, + success: () => { + this.jest_cookie_request(true) + }, + fail: () => { + this.jest_result = false; + }, + }); }, jest_delete_cookie() { uni.request({ @@ -284,7 +301,8 @@ firstIpv4: false, success: (res) => { const requestCookie = (res.data as UTSJSONObject).getJSON("data")?.getAny("requestCookie") - console.log("requestCookie ", requestCookie); + console.log("requestCookie ", requestCookie); + this.jest_result_data = JSON.stringify(requestCookie) if (requestCookie instanceof Array) { this.jest_result = needCookie ? requestCookie.length > 0 : requestCookie.length == 0 } else {