fix(接口测试): 【【接口测试】github#27933,【接口自动化】当场景有很多自定义请求时,点击调试后,点击推荐jsonpath提取,会出现"请先执行调试获取响应结果"的提示,以及出现了jsonpath提取内容与响应内容不对应的问题】

--bug=1033563 --user=白奇 【接口测试】github#27933,【接口自动化】当场景有很多自定义请求时,点击调试后,点击推荐jsonpath提取,会出现"请先执行调试获取响应结果"的提示,以及出现了jsonpath提取内容与响应内容不对应的问题 https://www.tapd.cn/55049933/s/1443650
This commit is contained in:
baiqi 2023-12-13 18:18:32 +08:00 committed by Craftsman
parent dc7e258719
commit 80d964fcd3
2 changed files with 70 additions and 55 deletions

View File

@ -251,7 +251,7 @@
</div> </div>
</div> </div>
<div class="card-content white-space" > <div class="card-content white-space">
<!-- 场景步骤--> <!-- 场景步骤-->
<div v-loading="loading"> <div v-loading="loading">
<el-row> <el-row>
@ -1515,14 +1515,17 @@ export default {
this.showAll(); this.showAll();
this.buttonData = buttons(this); this.buttonData = buttons(this);
this.initPlugins(); this.initPlugins();
if (e && e.target.className && e.target.className.split(" ")[1] === "white--space") { if (e && e.target.className && e.target.className.split(' ')[1] === 'white--space') {
this.selectedTreeNode = undefined; this.selectedTreeNode = undefined;
this.selectedNode = undefined; this.selectedNode = undefined;
} }
}, },
fabClick() { fabClick() {
if (this.operatingElements && this.operatingElements.length < 1) { if (this.operatingElements && this.operatingElements.length < 1) {
if ((this.selectedTreeNode && this.selectedTreeNode.referenced === 'REF') || (this.selectedNode.disabled && this.selectedTreeNode.disabled)) { if (
(this.selectedTreeNode && this.selectedTreeNode.referenced === 'REF') ||
(this.selectedNode.disabled && this.selectedTreeNode.disabled)
) {
this.$warning(this.$t('api_test.scenario.scenario_warning')); this.$warning(this.$t('api_test.scenario.scenario_warning'));
} else { } else {
this.$warning(this.$t('api_test.scenario.scenario_step_warning')); this.$warning(this.$t('api_test.scenario.scenario_step_warning'));
@ -2016,6 +2019,7 @@ export default {
} }
} }
if (this.scenarioDefinition !== null) { if (this.scenarioDefinition !== null) {
this.stepCount = 0;
this.dataProcessing(this.scenarioDefinition); this.dataProcessing(this.scenarioDefinition);
} }
// //

View File

@ -256,60 +256,15 @@ export default {
}; };
}, },
created() { created() {
this.request.protocol = this.request.protocol === 'ESB' ? 'TCP' : this.request.protocol; this.init();
//
if (!this.request.requestResult) {
this.request.requestResult = [{ responseResult: {} }];
} else if (
this.request.requestResult &&
Object.prototype.toString.call(this.request.requestResult) !== '[object Array]'
) {
let obj = JSON.parse(JSON.stringify(this.request.requestResult));
this.request.requestResult = [obj];
}
// IDID
if (!this.request.projectId) {
this.request.projectId = getCurrentProjectID();
}
this.request.customizeReq = this.isCustomizeReq;
if (this.request.customizeReq) {
if (this.node.parent && this.node.parent.data && this.node.parent.data.length > 1) {
this.request.projectId = getCurrentProjectID();
} else {
this.request.projectId =
this.node.parent.data instanceof Array ? this.node.parent.data[0].projectId : this.node.parent.data.projectId;
}
}
if (this.currentScenario) {
this.request.currentScenarioId = this.currentScenario.id;
}
// ID
if (this.request.hashTree) {
this.setOwnEnvironment(this.request.hashTree);
}
if (this.request.id && this.request.referenced === 'REF') {
this.request.disabled = true;
this.request.root = this.node.parent.parent ? false : true;
this.request.showExtend =
this.node.parent && this.node.parent.data && this.node.parent.data.disabled ? false : true;
}
this.isShowNum = this.request.num ? true : false;
if (this.request.protocol === 'HTTP') {
// auth
if (this.request.hashTree) {
for (let index in this.request.hashTree) {
if (this.request.hashTree[index].type == 'AuthManager') {
this.request.authManager = this.request.hashTree[index];
this.request.hashTree.splice(index, 1);
}
}
}
}
if (this.request.requestResult && this.request.requestResult.length > 0) {
this.response = this.request.requestResult[0];
}
}, },
watch: { watch: {
request: {
handler() {
this.init();
},
deep: true,
},
message() { message() {
this.forStatus(); this.forStatus();
this.reload(); this.reload();
@ -374,6 +329,62 @@ export default {
}, },
}, },
methods: { methods: {
init() {
this.request.protocol = this.request.protocol === 'ESB' ? 'TCP' : this.request.protocol;
//
if (!this.request.requestResult) {
this.request.requestResult = [{ responseResult: {} }];
} else if (
this.request.requestResult &&
Object.prototype.toString.call(this.request.requestResult) !== '[object Array]'
) {
let obj = JSON.parse(JSON.stringify(this.request.requestResult));
this.request.requestResult = [obj];
}
// IDID
if (!this.request.projectId) {
this.request.projectId = getCurrentProjectID();
}
this.request.customizeReq = this.isCustomizeReq;
if (this.request.customizeReq) {
if (this.node.parent && this.node.parent.data && this.node.parent.data.length > 1) {
this.request.projectId = getCurrentProjectID();
} else {
this.request.projectId =
this.node.parent.data instanceof Array
? this.node.parent.data[0].projectId
: this.node.parent.data.projectId;
}
}
if (this.currentScenario) {
this.request.currentScenarioId = this.currentScenario.id;
}
// ID
if (this.request.hashTree) {
this.setOwnEnvironment(this.request.hashTree);
}
if (this.request.id && this.request.referenced === 'REF') {
this.request.disabled = true;
this.request.root = this.node.parent.parent ? false : true;
this.request.showExtend =
this.node.parent && this.node.parent.data && this.node.parent.data.disabled ? false : true;
}
this.isShowNum = this.request.num ? true : false;
if (this.request.protocol === 'HTTP') {
// auth
if (this.request.hashTree) {
for (let index in this.request.hashTree) {
if (this.request.hashTree[index].type == 'AuthManager') {
this.request.authManager = this.request.hashTree[index];
this.request.hashTree.splice(index, 1);
}
}
}
}
if (this.request.requestResult && this.request.requestResult.length > 0) {
this.response = this.request.requestResult[0];
}
},
setOwnEnvironment(scenarioDefinition) { setOwnEnvironment(scenarioDefinition) {
for (let i in scenarioDefinition) { for (let i in scenarioDefinition) {
let typeArray = ['JDBCPostProcessor', 'JDBCSampler', 'JDBCPreProcessor']; let typeArray = ['JDBCPostProcessor', 'JDBCSampler', 'JDBCPreProcessor'];