feat: 场景添加jsonpath功能
This commit is contained in:
parent
a7bc099305
commit
5465d9cf64
|
@ -164,9 +164,9 @@
|
||||||
<ms-jsr233-processor v-if="data.type==='JSR223PostProcessor'" @remove="remove" @copyRow="copyRow" :title="$t('api_test.definition.request.post_script')"
|
<ms-jsr233-processor v-if="data.type==='JSR223PostProcessor'" @remove="remove" @copyRow="copyRow" :title="$t('api_test.definition.request.post_script')"
|
||||||
style-type="color: #783887;background-color: #F2ECF3" :jsr223-processor="data" :node="node"/>
|
style-type="color: #783887;background-color: #F2ECF3" :jsr223-processor="data" :node="node"/>
|
||||||
<!--断言规则-->
|
<!--断言规则-->
|
||||||
<ms-api-assertions v-if="data.type==='Assertions'" @remove="remove" @copyRow="copyRow" customizeStyle="margin-top: 0px" :assertions="data" :node="node"/>
|
<ms-api-assertions @suggestClick="suggestClick(node)" :response="response" v-if="data.type==='Assertions'" @remove="remove" @copyRow="copyRow" customizeStyle="margin-top: 0px" :assertions="data" :node="node"/>
|
||||||
<!--提取规则-->
|
<!--提取规则-->
|
||||||
<ms-api-extract @remove="remove" @copyRow="copyRow" v-if="data.type==='Extract'" customizeStyle="margin-top: 0px" :extract="data" :node="node"/>
|
<ms-api-extract @suggestClick="suggestClick(node)" :response="response" @remove="remove" @copyRow="copyRow" v-if="data.type==='Extract'" customizeStyle="margin-top: 0px" :extract="data" :node="node"/>
|
||||||
<!--API 导入 -->
|
<!--API 导入 -->
|
||||||
<ms-api-component :request="data" :currentScenario="currentScenario" :currentEnvironmentId="currentEnvironmentId" @remove="remove" @copyRow="copyRow"
|
<ms-api-component :request="data" :currentScenario="currentScenario" :currentEnvironmentId="currentEnvironmentId" @remove="remove" @copyRow="copyRow"
|
||||||
v-if="data.type==='HTTPSamplerProxy'||data.type==='DubboSampler'||data.type==='JDBCSampler'||data.type==='TCPSampler'" :node="node"/>
|
v-if="data.type==='HTTPSamplerProxy'||data.type==='DubboSampler'||data.type==='JDBCSampler'||data.type==='TCPSampler'" :node="node"/>
|
||||||
|
@ -319,7 +319,8 @@
|
||||||
enableCookieShare: false,
|
enableCookieShare: false,
|
||||||
globalOptions: {
|
globalOptions: {
|
||||||
spacing: 30
|
spacing: 30
|
||||||
}
|
},
|
||||||
|
response: {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
|
@ -530,6 +531,12 @@
|
||||||
this.selectedTreeNode = e;
|
this.selectedTreeNode = e;
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
|
suggestClick(node) {
|
||||||
|
this.response = {};
|
||||||
|
if (node.parent && node.parent.data.requestResult) {
|
||||||
|
this.response = node.parent.data.requestResult;
|
||||||
|
}
|
||||||
|
},
|
||||||
showAll() {
|
showAll() {
|
||||||
this.operatingElements = ELEMENTS.get("ALL");
|
this.operatingElements = ELEMENTS.get("ALL");
|
||||||
this.selectedTreeNode = undefined;
|
this.selectedTreeNode = undefined;
|
||||||
|
|
|
@ -176,7 +176,7 @@
|
||||||
},
|
},
|
||||||
initTable() {
|
initTable() {
|
||||||
this.selectRows = new Set();
|
this.selectRows = new Set();
|
||||||
this.condition.filters = ["Prepare", "Underway", "Completed"];
|
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
|
||||||
this.condition.moduleIds = this.selectNodeIds;
|
this.condition.moduleIds = this.selectNodeIds;
|
||||||
if (this.trashEnable) {
|
if (this.trashEnable) {
|
||||||
this.condition.filters = ["Trash"];
|
this.condition.filters = ["Trash"];
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
</el-collapse-transition>
|
</el-collapse-transition>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<ms-api-jsonpath-suggest :tip="$t('api_test.request.extract.suggest_tip')" @addSuggest="addJsonPathSuggest" :data="suggestData" ref="jsonpathSuggest"/>
|
<ms-api-jsonpath-suggest :tip="$t('api_test.request.extract.suggest_tip')" @addSuggest="addJsonPathSuggest" ref="jsonpathSuggest"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -111,7 +111,6 @@
|
||||||
type: "",
|
type: "",
|
||||||
loading: false,
|
loading: false,
|
||||||
reloadData: "",
|
reloadData: "",
|
||||||
suggestData: {}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -125,17 +124,14 @@
|
||||||
this.$emit('copyRow', this.assertions, this.node);
|
this.$emit('copyRow', this.assertions, this.node);
|
||||||
},
|
},
|
||||||
suggestJsonOpen() {
|
suggestJsonOpen() {
|
||||||
if (!this.response || !this.response.responseResult || !this.response.responseResult.body) {
|
this.$emit('suggestClick');
|
||||||
this.$message(this.$t('api_test.request.assertions.debug_first'));
|
this.$nextTick(() => {
|
||||||
return;
|
if (!this.response || !this.response.responseResult || !this.response.responseResult.body) {
|
||||||
}
|
this.$message(this.$t('api_test.request.assertions.debug_first'));
|
||||||
try {
|
return;
|
||||||
this.suggestData = JSON.parse(this.response.responseResult.body);
|
}
|
||||||
} catch (e) {
|
this.$refs.jsonpathSuggest.open(this.response.responseResult.body);
|
||||||
this.$error(this.$t('api_test.request.assertions.json_path_err'));
|
})
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$refs.jsonpathSuggest.open();
|
|
||||||
},
|
},
|
||||||
reload() {
|
reload() {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
|
|
|
@ -19,22 +19,34 @@
|
||||||
return {
|
return {
|
||||||
visible: false,
|
visible: false,
|
||||||
isCheckAll: false,
|
isCheckAll: false,
|
||||||
|
data: {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
data: {},
|
|
||||||
tip: {
|
tip: {
|
||||||
type: String,
|
type: String,
|
||||||
default() {
|
default() {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
close() {
|
close() {
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
},
|
},
|
||||||
open() {
|
open(objStr) {
|
||||||
|
this.data = {};
|
||||||
|
try {
|
||||||
|
let param = JSON.parse(objStr);
|
||||||
|
if (param instanceof Array) {
|
||||||
|
this.$warning(this.$t('api_test.request.assertions.json_path_err'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.data = param;
|
||||||
|
} catch (e) {
|
||||||
|
this.$warning(this.$t('api_test.request.assertions.json_path_err'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
},
|
},
|
||||||
pathChangeHandler(data) {
|
pathChangeHandler(data) {
|
||||||
|
@ -64,8 +76,8 @@
|
||||||
if (index === params.length - 1) {
|
if (index === params.length - 1) {
|
||||||
if (childObj instanceof Object) {
|
if (childObj instanceof Object) {
|
||||||
childObj = JSON.stringify(childObj);
|
childObj = JSON.stringify(childObj);
|
||||||
} else if (childObj == null) {
|
} else {
|
||||||
childObj = "null";
|
childObj = childObj + "";
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
key: param,
|
key: param,
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
</div>
|
</div>
|
||||||
</el-collapse-transition>
|
</el-collapse-transition>
|
||||||
|
|
||||||
<ms-api-jsonpath-suggest :tip="$t('api_test.request.extract.suggest_tip')" @addSuggest="addJsonPathSuggest" :data="suggestData" ref="jsonpathSuggest"/>
|
<ms-api-jsonpath-suggest :tip="$t('api_test.request.extract.suggest_tip')" @addSuggest="addJsonPathSuggest" ref="jsonpathSuggest"/>
|
||||||
|
|
||||||
</el-card>
|
</el-card>
|
||||||
</div>
|
</div>
|
||||||
|
@ -91,7 +91,6 @@
|
||||||
type: "",
|
type: "",
|
||||||
reloadData: "",
|
reloadData: "",
|
||||||
loading: false,
|
loading: false,
|
||||||
suggestData: {}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -117,17 +116,14 @@
|
||||||
this.reload();
|
this.reload();
|
||||||
},
|
},
|
||||||
suggestJsonOpen() {
|
suggestJsonOpen() {
|
||||||
if (!this.response || !this.response.responseResult || !this.response.responseResult.body) {
|
this.$emit('suggestClick');
|
||||||
this.$message(this.$t('api_test.request.assertions.debug_first'));
|
this.$nextTick(() => {
|
||||||
return;
|
if (!this.response || !this.response.responseResult || !this.response.responseResult.body) {
|
||||||
}
|
this.$message(this.$t('api_test.request.assertions.debug_first'));
|
||||||
try {
|
return;
|
||||||
this.suggestData = JSON.parse(this.response.responseResult.body);
|
}
|
||||||
} catch (e) {
|
this.$refs.jsonpathSuggest.open(this.response.responseResult.body);
|
||||||
this.$error(this.$t('api_test.request.assertions.json_path_err'));
|
})
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$refs.jsonpathSuggest.open();
|
|
||||||
},
|
},
|
||||||
addJsonPathSuggest(data) {
|
addJsonPathSuggest(data) {
|
||||||
let option = {};
|
let option = {};
|
||||||
|
|
Loading…
Reference in New Issue