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')"
|
||||
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 导入 -->
|
||||
<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"/>
|
||||
|
@ -319,7 +319,8 @@
|
|||
enableCookieShare: false,
|
||||
globalOptions: {
|
||||
spacing: 30
|
||||
}
|
||||
},
|
||||
response: {}
|
||||
}
|
||||
}
|
||||
,
|
||||
|
@ -530,6 +531,12 @@
|
|||
this.selectedTreeNode = e;
|
||||
}
|
||||
,
|
||||
suggestClick(node) {
|
||||
this.response = {};
|
||||
if (node.parent && node.parent.data.requestResult) {
|
||||
this.response = node.parent.data.requestResult;
|
||||
}
|
||||
},
|
||||
showAll() {
|
||||
this.operatingElements = ELEMENTS.get("ALL");
|
||||
this.selectedTreeNode = undefined;
|
||||
|
|
|
@ -176,7 +176,7 @@
|
|||
},
|
||||
initTable() {
|
||||
this.selectRows = new Set();
|
||||
this.condition.filters = ["Prepare", "Underway", "Completed"];
|
||||
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
|
||||
this.condition.moduleIds = this.selectNodeIds;
|
||||
if (this.trashEnable) {
|
||||
this.condition.filters = ["Trash"];
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
</el-collapse-transition>
|
||||
</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>
|
||||
</template>
|
||||
|
||||
|
@ -111,7 +111,6 @@
|
|||
type: "",
|
||||
loading: false,
|
||||
reloadData: "",
|
||||
suggestData: {}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -125,17 +124,14 @@
|
|||
this.$emit('copyRow', this.assertions, this.node);
|
||||
},
|
||||
suggestJsonOpen() {
|
||||
if (!this.response || !this.response.responseResult || !this.response.responseResult.body) {
|
||||
this.$message(this.$t('api_test.request.assertions.debug_first'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.suggestData = JSON.parse(this.response.responseResult.body);
|
||||
} catch (e) {
|
||||
this.$error(this.$t('api_test.request.assertions.json_path_err'));
|
||||
return;
|
||||
}
|
||||
this.$refs.jsonpathSuggest.open();
|
||||
this.$emit('suggestClick');
|
||||
this.$nextTick(() => {
|
||||
if (!this.response || !this.response.responseResult || !this.response.responseResult.body) {
|
||||
this.$message(this.$t('api_test.request.assertions.debug_first'));
|
||||
return;
|
||||
}
|
||||
this.$refs.jsonpathSuggest.open(this.response.responseResult.body);
|
||||
})
|
||||
},
|
||||
reload() {
|
||||
this.loading = true
|
||||
|
|
|
@ -19,22 +19,34 @@
|
|||
return {
|
||||
visible: false,
|
||||
isCheckAll: false,
|
||||
data: {},
|
||||
};
|
||||
},
|
||||
props: {
|
||||
data: {},
|
||||
tip: {
|
||||
type: String,
|
||||
default() {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
close() {
|
||||
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;
|
||||
},
|
||||
pathChangeHandler(data) {
|
||||
|
@ -64,8 +76,8 @@
|
|||
if (index === params.length - 1) {
|
||||
if (childObj instanceof Object) {
|
||||
childObj = JSON.stringify(childObj);
|
||||
} else if (childObj == null) {
|
||||
childObj = "null";
|
||||
} else {
|
||||
childObj = childObj + "";
|
||||
}
|
||||
return {
|
||||
key: param,
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
</div>
|
||||
</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>
|
||||
</div>
|
||||
|
@ -91,7 +91,6 @@
|
|||
type: "",
|
||||
reloadData: "",
|
||||
loading: false,
|
||||
suggestData: {}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -117,17 +116,14 @@
|
|||
this.reload();
|
||||
},
|
||||
suggestJsonOpen() {
|
||||
if (!this.response || !this.response.responseResult || !this.response.responseResult.body) {
|
||||
this.$message(this.$t('api_test.request.assertions.debug_first'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.suggestData = JSON.parse(this.response.responseResult.body);
|
||||
} catch (e) {
|
||||
this.$error(this.$t('api_test.request.assertions.json_path_err'));
|
||||
return;
|
||||
}
|
||||
this.$refs.jsonpathSuggest.open();
|
||||
this.$emit('suggestClick');
|
||||
this.$nextTick(() => {
|
||||
if (!this.response || !this.response.responseResult || !this.response.responseResult.body) {
|
||||
this.$message(this.$t('api_test.request.assertions.debug_first'));
|
||||
return;
|
||||
}
|
||||
this.$refs.jsonpathSuggest.open(this.response.responseResult.body);
|
||||
})
|
||||
},
|
||||
addJsonPathSuggest(data) {
|
||||
let option = {};
|
||||
|
|
Loading…
Reference in New Issue