fix(接口测试): 修复多层事物控制器执行结果显示问题

--bug=1014984 --user=赵勇 [接口测试]github#15873]事务控制器下添加事务控制器,场景调试内层事务控制器下步骤调试一直测试中,测试报告显示未执行 https://www.tapd.cn/55049933/s/1207610
This commit is contained in:
fit2-zhao 2022-07-22 17:03:21 +08:00 committed by f2c-ci-robot[bot]
parent f045a061c4
commit fe1f78918d
2 changed files with 73 additions and 69 deletions

View File

@ -5,28 +5,28 @@
<section class="report-container"> <section class="report-container">
<div style="margin-top: 10px"> <div style="margin-top: 10px">
<ms-api-report-view-header <ms-api-report-view-header
:show-cancel-button="false" :show-cancel-button="false"
:debug="debug" :debug="debug"
:export-flag="exportFlag" :export-flag="exportFlag"
:report="report" :report="report"
@reportExport="handleExport" @reportExport="handleExport"
@reportSave="handleSave"/> @reportSave="handleSave"/>
</div> </div>
<main> <main>
<ms-metric-chart <ms-metric-chart
:content="content" :content="content"
:totalTime="totalTime" :totalTime="totalTime"
:report="report" :report="report"
v-if="!loading"/> v-if="!loading"/>
<div> <div>
<el-tabs v-model="activeName" @tab-click="handleClick"> <el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane :label="$t('api_report.total')" name="total"> <el-tab-pane :label="$t('api_report.total')" name="total">
<ms-scenario-results <ms-scenario-results
:treeData="fullTreeNodes" :treeData="fullTreeNodes"
:report="report" :report="report"
:default-expand="true" :default-expand="true"
:console="content.console" :console="content.console"
v-on:requestResult="requestResult" v-on:requestResult="requestResult"
/> />
</el-tab-pane> </el-tab-pane>
<el-tab-pane name="fail"> <el-tab-pane name="fail">
@ -36,11 +36,11 @@
</span> </span>
</template> </template>
<ms-scenario-results <ms-scenario-results
:console="content.console" :console="content.console"
:report="report" :report="report"
:treeData="fullTreeNodes" :treeData="fullTreeNodes"
v-on:requestResult="requestResult" v-on:requestResult="requestResult"
ref="failsTree" ref="failsTree"
/> />
</el-tab-pane> </el-tab-pane>
<el-tab-pane name="errorReport" v-if="content.errorCode > 0"> <el-tab-pane name="errorReport" v-if="content.errorCode > 0">
@ -69,11 +69,11 @@
</el-tabs> </el-tabs>
</div> </div>
<ms-api-report-export <ms-api-report-export
:title="report.testName" :title="report.testName"
:content="content" :content="content"
:total-time="totalTime" :total-time="totalTime"
id="apiTestReport" id="apiTestReport"
v-if="reportExportVisible" v-if="reportExportVisible"
/> />
</main> </main>
</section> </section>
@ -184,6 +184,18 @@ export default {
} }
return type; return type;
}, },
margeTransaction(item, arr) {
arr.forEach(subItem => {
if (item.resId === subItem.resourceId) {
item.value = subItem;
item.testing = false;
item.debug = true;
}
if (subItem.subRequestResults && subItem.subRequestResults.length > 0) {
this.margeTransaction(item, subItem.subRequestResults);
}
})
},
formatContent(hashTree, tree, fullPath, pid) { formatContent(hashTree, tree, fullPath, pid) {
if (hashTree) { if (hashTree) {
hashTree.forEach(item => { hashTree.forEach(item => {
@ -309,7 +321,7 @@ export default {
this.initHeartBeat(); this.initHeartBeat();
} }
this.messageWebSocket.onmessage = this.onMessage; this.messageWebSocket.onmessage = this.onMessage;
this.messageWebSocket.onerror = this.cleanHeartBeat; this.messageWebSocket.onerror = this.cleanHeartBeat;
}, },
getReport() { getReport() {
let url = "/api/scenario/report/get/" + this.reportId; let url = "/api/scenario/report/get/" + this.reportId;
@ -325,16 +337,16 @@ export default {
this.content.success = (this.content.total - this.content.error - this.content.errorCode - this.content.unExecute); this.content.success = (this.content.total - this.content.error - this.content.errorCode - this.content.unExecute);
this.totalTime = this.content.totalTime; this.totalTime = this.content.totalTime;
this.resetLabel(this.content.steps); this.resetLabel(this.content.steps);
if(this.report.reportType === "UI_INDEPENDENT"){ if (this.report.reportType === "UI_INDEPENDENT") {
this.tempResult = this.content.steps; this.tempResult = this.content.steps;
// //
try{ try {
this.checkOrder(this.tempResult); this.checkOrder(this.tempResult);
this.fullTreeNodes = this.tempResult; this.fullTreeNodes = this.tempResult;
}catch(e){ } catch (e) {
this.fullTreeNodes = this.content.steps; this.fullTreeNodes = this.content.steps;
} }
}else{ } else {
this.fullTreeNodes = this.content.steps; this.fullTreeNodes = this.content.steps;
} }
this.recursiveSorting(this.fullTreeNodes); this.recursiveSorting(this.fullTreeNodes);
@ -345,31 +357,31 @@ export default {
} }
}); });
}, },
checkOrder(origin){ checkOrder(origin) {
if(!origin){ if (!origin) {
return; return;
} }
if(Array.isArray(origin)){ if (Array.isArray(origin)) {
this.sortChildren(origin); this.sortChildren(origin);
origin.forEach(v => { origin.forEach(v => {
if(v.children){ if (v.children) {
this.checkOrder(v.children) this.checkOrder(v.children)
} }
}) })
} }
}, },
sortChildren(source){ sortChildren(source) {
if(!source){ if (!source) {
return; return;
} }
source.forEach( item =>{ source.forEach(item => {
let children = item.children; let children = item.children;
if(children && children.length > 0){ if (children && children.length > 0) {
let tempArr = new Array(children.length); let tempArr = new Array(children.length);
let tempMap = new Map(); let tempMap = new Map();
for(let i = 0; i < children.length; i++){ for (let i = 0; i < children.length; i++) {
if(!children[i].value || !children[i].value.startTime || children[i].value.startTime === 0){ if (!children[i].value || !children[i].value.startTime || children[i].value.startTime === 0) {
//valuestep //valuestep
tempArr[i] = children[i]; tempArr[i] = children[i];
// //
@ -386,8 +398,8 @@ export default {
}); });
//arr() tempArr //arr() tempArr
for(let j = 0, i = 0; j < tempArr.length; j++){ for (let j = 0, i = 0; j < tempArr.length; j++) {
if(!tempArr[j]){ if (!tempArr[j]) {
// //
tempArr[j] = arr[i]; tempArr[j] = arr[i];
i++; i++;
@ -408,13 +420,7 @@ export default {
} else if (resourceId && resourceId.startsWith("result_")) { } else if (resourceId && resourceId.startsWith("result_")) {
let data = JSON.parse(resourceId.substring(7)); let data = JSON.parse(resourceId.substring(7));
if (data.method === 'Request' && data.subRequestResults && data.subRequestResults.length > 0) { if (data.method === 'Request' && data.subRequestResults && data.subRequestResults.length > 0) {
data.subRequestResults.forEach(subItem => { this.margeTransaction(item, data.subRequestResults);
if (item.resId === subItem.resourceId) {
item.value = subItem;
item.testing = false;
item.debug = true;
}
})
} else if (item.resId === data.resourceId) { } else if (item.resId === data.resourceId) {
if (item.value && item.value.id && !item.mark) { if (item.value && item.value.id && !item.mark) {
let newItem = JSON.parse(JSON.stringify(item)); let newItem = JSON.parse(JSON.stringify(item));
@ -505,7 +511,7 @@ export default {
} }
} }
}, },
websocketKey(){ websocketKey() {
return "ui_ws_" + this.reportId; return "ui_ws_" + this.reportId;
}, },
initHeartBeat() { initHeartBeat() {

View File

@ -932,21 +932,27 @@ export default {
this.runningEditParent(node.parent); this.runningEditParent(node.parent);
} }
}, },
margeTransaction(item, console, arr) {
arr.forEach(sub => {
if (item.data && item.data.id + "_" + item.data.parentIndex === sub.resourceId) {
sub.responseResult.console = console;
item.data.requestResult.push(sub);
//
this.resultEvaluation(sub.resourceId, sub.success);
item.data.testing = false;
item.data.debug = true;
}
if (sub.subRequestResults && sub.subRequestResults.length > 0) {
this.margeTransaction(item, console, sub.subRequestResults);
}
})
},
runningNodeChild(arr, resultData) { runningNodeChild(arr, resultData) {
arr.forEach(item => { arr.forEach(item => {
if (resultData && resultData.startsWith("result_")) { if (resultData && resultData.startsWith("result_")) {
let data = JSON.parse(resultData.substring(7)); let data = JSON.parse(resultData.substring(7));
if (data.method === 'Request' && data.subRequestResults && data.subRequestResults.length > 0) { if (data.method === 'Request' && data.subRequestResults && data.subRequestResults.length > 0) {
data.subRequestResults.forEach(subItem => { this.margeTransaction(item, data.responseResult.console, data.subRequestResults);
if (item.data && item.data.id + "_" + item.data.parentIndex === subItem.resourceId) {
subItem.responseResult.console = data.responseResult.console;
item.data.requestResult.push(subItem);
//
this.resultEvaluation(subItem.resourceId, subItem.success);
item.data.testing = false;
item.data.debug = true;
}
})
} else if ((item.data && item.data.id + "_" + item.data.parentIndex === data.resourceId) } else if ((item.data && item.data.id + "_" + item.data.parentIndex === data.resourceId)
|| (item.data && item.data.resourceId + "_" + item.data.parentIndex === data.resourceId)) { || (item.data && item.data.resourceId + "_" + item.data.parentIndex === data.resourceId)) {
if (item.data.requestResult) { if (item.data.requestResult) {
@ -976,15 +982,7 @@ export default {
} else if (resultData && resultData.startsWith("result_")) { } else if (resultData && resultData.startsWith("result_")) {
let data = JSON.parse(resultData.substring(7)); let data = JSON.parse(resultData.substring(7));
if (data.method === 'Request' && data.subRequestResults && data.subRequestResults.length > 0) { if (data.method === 'Request' && data.subRequestResults && data.subRequestResults.length > 0) {
data.subRequestResults.forEach(subItem => { this.margeTransaction(item, data.responseResult.console, data.subRequestResults);
if (item.data && item.data.id + "_" + item.data.parentIndex === subItem.resourceId) {
item.data.requestResult.push(subItem);
//
this.resultEvaluation(subItem.resourceId, subItem.success);
item.data.testing = false;
item.data.debug = true;
}
})
} else if (item.data && item.data.id + "_" + item.data.parentIndex === data.resourceId } else if (item.data && item.data.id + "_" + item.data.parentIndex === data.resourceId
|| (item.data && item.data.resourceId + "_" + item.data.parentIndex === data.resourceId)) { || (item.data && item.data.resourceId + "_" + item.data.parentIndex === data.resourceId)) {
item.data.requestResult.push(data); item.data.requestResult.push(data);