From 17bdadc11d208ee1504569e667847498a01702b5 Mon Sep 17 00:00:00 2001 From: Rick <1450685+LinuxSuRen@users.noreply.github.com> Date: Tue, 18 Jul 2023 09:07:32 +0800 Subject: [PATCH] fix: the createFilter func is incorrect (#132) * fix: the createFilter func is incorrect * feat: format the JSON payload automatically --- console/atest-ui/src/views/TestCase.vue | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/console/atest-ui/src/views/TestCase.vue b/console/atest-ui/src/views/TestCase.vue index 1a1f0bf..7dc697c 100644 --- a/console/atest-ui/src/views/TestCase.vue +++ b/console/atest-ui/src/views/TestCase.vue @@ -76,7 +76,7 @@ const queryBodyFields = (queryString: string, cb: any) => { } as Pair) }) - const results = queryString ? pairs.filter(createFilter(queryString)) : pairs + const results = queryString ? pairs.filter(CreateFilter(queryString)) : pairs // call callback function to return suggestions cb(results) } @@ -311,6 +311,18 @@ function bodyTypeChange(e: number) { } } +function jsonForamt() { + if (bodyType.value !== 5) { + return + } + + try { + testCaseWithSuite.value.data.request.body = JSON.stringify(JSON.parse(testCaseWithSuite.value.data.request.body), null, 4) + } catch (e) { + console.log(e) + } +} + function insertOrUpdateIntoMap(pair: Pair, pairs: Pair[]) { const index = pairs.findIndex((e) => e.key === pair.key) if (index === -1) { @@ -459,6 +471,7 @@ function flattenObject(obj: any): any { :autosize="{ minRows: 4, maxRows: 8 }" type="textarea" placeholder="Please input" + @change="jsonForamt" />