fix(接口测试): 解决场景对比数据没回显全的问题

--bug=1009769--user=郭雨琦 解决场景对比数据没回显全的问题
This commit is contained in:
guoyuqi 2022-01-26 17:47:10 +08:00 committed by song-tianyang
parent 555793c747
commit c2e342792e
2 changed files with 67 additions and 37 deletions

View File

@ -356,6 +356,10 @@
:new-scenario-definition="newScenarioDefinition" :new-scenario-definition="newScenarioDefinition"
:project-env-map="projectEnvMap" :project-env-map="projectEnvMap"
:new-project-env-map="newProjectEnvMap" :new-project-env-map="newProjectEnvMap"
:old-enable-cookie-share="enableCookieShare"
:new-enable-cookie-share="newEnableCookieShare"
:old-on-sample-error="onSampleError"
:new-on-sample-error="newOnSampleError"
:project-list="projectList" :project-list="projectList"
:type ="type" :type ="type"
></scenario-diff> ></scenario-diff>
@ -427,6 +431,7 @@ export default {
data() { data() {
return { return {
onSampleError: true, onSampleError: true,
newOnSampleError: true,
showConfigButtonWithOutPermission: false, showConfigButtonWithOutPermission: false,
props: { props: {
label: "label", label: "label",
@ -474,6 +479,7 @@ export default {
debugData: {}, debugData: {},
reportId: "", reportId: "",
enableCookieShare: false, enableCookieShare: false,
newEnableCookieShare: false,
globalOptions: { globalOptions: {
spacing: 30 spacing: 30
}, },
@ -1767,6 +1773,12 @@ export default {
obj.hashTree[i].requestResult = [{responseResult: {}}]; obj.hashTree[i].requestResult = [{responseResult: {}}];
} }
} }
this.newEnableCookieShare = obj.enableCookieShare;
if (obj.onSampleError === undefined) {
this.newOnSampleError = true;
} else {
this.newOnSampleError = obj.onSampleError;
}
} }
for (let i = 0; i < this.scenarioDefinition.length; i++) { for (let i = 0; i < this.scenarioDefinition.length; i++) {
this.scenarioDefinition[i].disabled = true; this.scenarioDefinition[i].disabled = true;

View File

@ -115,7 +115,7 @@
<el-col :span="3" class="ms-col-one ms-font"> <el-col :span="3" class="ms-col-one ms-font">
<el-link class="head">{{ $t('api_test.automation.scenario_total') }} <el-link class="head">{{ $t('api_test.automation.scenario_total') }}
</el-link> </el-link>
{{ oldVariableSize }} {{ getOldVariableSize() }}
</el-col> </el-col>
<el-col :span="3" class="ms-col-one ms-font"> <el-col :span="3" class="ms-col-one ms-font">
<el-checkbox v-model="oldEnableCookieShare"><span style="font-size: 13px;">{{ $t('api_test.scenario.share_cookie') }}</span></el-checkbox> <el-checkbox v-model="oldEnableCookieShare"><span style="font-size: 13px;">{{ $t('api_test.scenario.share_cookie') }}</span></el-checkbox>
@ -269,7 +269,7 @@
<el-col :span="3" class="ms-col-one ms-font"> <el-col :span="3" class="ms-col-one ms-font">
<el-link class="head" >{{ $t('api_test.automation.scenario_total') }} <el-link class="head" >{{ $t('api_test.automation.scenario_total') }}
</el-link> </el-link>
{{ newVariableSize }} {{ getNewVariableSize() }}
</el-col> </el-col>
<el-col :span="3" class="ms-col-one ms-font"> <el-col :span="3" class="ms-col-one ms-font">
<el-checkbox v-model="newEnableCookieShare"><span style="font-size: 13px;">{{ $t('api_test.scenario.share_cookie') }}</span></el-checkbox> <el-checkbox v-model="newEnableCookieShare"><span style="font-size: 13px;">{{ $t('api_test.scenario.share_cookie') }}</span></el-checkbox>
@ -459,19 +459,19 @@ export default{
newColor:"" newColor:""
} }
}, },
methods:{ methods: {
getDiff(){ getDiff() {
let oldVnode = this.$refs.old let oldVnode = this.$refs.old
let vnode = this.$refs.new let vnode = this.$refs.new
//oldVnode.style.backgroundColor = "rgb(241,200,196)"; //oldVnode.style.backgroundColor = "rgb(241,200,196)";
if(this.oldData.createTime>this.newData.createTime){ if (this.oldData.createTime > this.newData.createTime) {
this.oldColor = "rgb(121, 225, 153,0.3)"; this.oldColor = "rgb(121, 225, 153,0.3)";
this.newColor = "rgb(241,200,196,0.45)" this.newColor = "rgb(241,200,196,0.45)"
}else{ } else {
this.oldColor = "rgb(241,200,196,0.45)" this.oldColor = "rgb(241,200,196,0.45)"
this.newColor = "rgb(121, 225, 153,0.3)"; this.newColor = "rgb(121, 225, 153,0.3)";
} }
diff(oldVnode,vnode,this.oldColor,this.newColor); diff(oldVnode, vnode, this.oldColor, this.newColor);
this.isReloadData = false this.isReloadData = false
}, },
showAll() { showAll() {
@ -482,7 +482,7 @@ export default{
this.$store.state.selectStep = undefined; this.$store.state.selectStep = undefined;
} }
}, },
oldShowPopover(){ oldShowPopover() {
let definition = JSON.parse(JSON.stringify(this.oldData)); let definition = JSON.parse(JSON.stringify(this.oldData));
definition.hashTree = this.oldScenarioDefinition; definition.hashTree = this.oldScenarioDefinition;
this.oldEnvResult.loading = true; this.oldEnvResult.loading = true;
@ -491,7 +491,7 @@ export default{
this.oldEnvResult.loading = false; this.oldEnvResult.loading = false;
}) })
}, },
newShowPopover(){ newShowPopover() {
let definition = JSON.parse(JSON.stringify(this.newData)); let definition = JSON.parse(JSON.stringify(this.newData));
definition.hashTree = this.newScenarioDefinition; definition.hashTree = this.newScenarioDefinition;
this.newEnvResult.loading = true; this.newEnvResult.loading = true;
@ -500,13 +500,13 @@ export default{
this.newEnvResult.loading = false; this.newEnvResult.loading = false;
}) })
}, },
changeNodeStatus(nodes,source) { changeNodeStatus(nodes, source) {
for (let i in nodes) { for (let i in nodes) {
if (nodes[i]) { if (nodes[i]) {
if (this.expandedStatus) { if (this.expandedStatus) {
if(source==="new"){ if (source === "new") {
this.newExpandedNode.push(nodes[i].resourceId); this.newExpandedNode.push(nodes[i].resourceId);
}else { } else {
this.oldExpandedNode.push(nodes[i].resourceId); this.oldExpandedNode.push(nodes[i].resourceId);
} }
} }
@ -515,7 +515,7 @@ export default{
nodes[i].active = false; nodes[i].active = false;
} }
if (nodes[i].hashTree !== undefined && nodes[i].hashTree.length > 0) { if (nodes[i].hashTree !== undefined && nodes[i].hashTree.length > 0) {
this.changeNodeStatus(nodes[i].hashTree,source); this.changeNodeStatus(nodes[i].hashTree, source);
} }
} }
} }
@ -524,10 +524,10 @@ export default{
this.newExpandedNode = []; this.newExpandedNode = [];
this.oldExpandedNode = []; this.oldExpandedNode = [];
this.expandedStatus = true; this.expandedStatus = true;
if(source==="new"){ if (source === "new") {
this.changeNodeStatus(this.newScenarioDefinition,source); this.changeNodeStatus(this.newScenarioDefinition, source);
}else { } else {
this.changeNodeStatus(this.oldScenarioDefinition,source); this.changeNodeStatus(this.oldScenarioDefinition, source);
} }
}, },
@ -535,10 +535,10 @@ export default{
this.expandedStatus = false; this.expandedStatus = false;
this.newExpandedNode = []; this.newExpandedNode = [];
this.oldExpandedNode = []; this.oldExpandedNode = [];
if(source==="new"){ if (source === "new") {
this.changeNodeStatus( this.newScenarioDefinition,source); this.changeNodeStatus(this.newScenarioDefinition, source);
}else { } else {
this.changeNodeStatus( this.oldScenarioDefinition,source); this.changeNodeStatus(this.oldScenarioDefinition, source);
} }
this.showHide(); this.showHide();
}, },
@ -561,9 +561,9 @@ export default{
enableAll(source) { enableAll(source) {
this.stepEnable = true; this.stepEnable = true;
let scenarioDefinition; let scenarioDefinition;
if(source==="new"){ if (source === "new") {
scenarioDefinition = this.newScenarioDefinition; scenarioDefinition = this.newScenarioDefinition;
}else { } else {
scenarioDefinition = this.oldScenarioDefinition; scenarioDefinition = this.oldScenarioDefinition;
} }
this.stepStatus(scenarioDefinition); this.stepStatus(scenarioDefinition);
@ -571,59 +571,77 @@ export default{
disableAll(source) { disableAll(source) {
this.stepEnable = false; this.stepEnable = false;
let scenarioDefinition; let scenarioDefinition;
if(source==="new"){ if (source === "new") {
scenarioDefinition = this.newScenarioDefinition; scenarioDefinition = this.newScenarioDefinition;
}else { } else {
scenarioDefinition = this.oldScenarioDefinition; scenarioDefinition = this.oldScenarioDefinition;
} }
this.stepStatus(scenarioDefinition); this.stepStatus(scenarioDefinition);
}, },
nodeExpand(data, node,source) { nodeExpand(data, node, source) {
if(source==="new"){ if (source === "new") {
if (data && data.resourceId && this.newExpandedNode.indexOf(data.resourceId) === -1) { if (data && data.resourceId && this.newExpandedNode.indexOf(data.resourceId) === -1) {
this.newExpandedNode.push(data.resourceId); this.newExpandedNode.push(data.resourceId);
} }
}else{ } else {
if (data && data.resourceId && this.oldExpandedNode.indexOf(data.resourceId) === -1) { if (data && data.resourceId && this.oldExpandedNode.indexOf(data.resourceId) === -1) {
this.oldExpandedNode.push(data.resourceId); this.oldExpandedNode.push(data.resourceId);
} }
} }
}, },
nodeCollapse(data, node,source) { nodeCollapse(data, node, source) {
if (data && data.resourceId) { if (data && data.resourceId) {
if(source==="new"){ if (source === "new") {
this.newExpandedNode.splice(this.newExpandedNode.indexOf(data.resourceId), 1); this.newExpandedNode.splice(this.newExpandedNode.indexOf(data.resourceId), 1);
}else { } else {
this.oldExpandedNode.splice(this.oldExpandedNode.indexOf(data.resourceId), 1); this.oldExpandedNode.splice(this.oldExpandedNode.indexOf(data.resourceId), 1);
} }
} }
}, },
nodeClick(data, node,source) { nodeClick(data, node, source) {
this.$store.state.selectStep = data; this.$store.state.selectStep = data;
this.rightChildData = data; this.rightChildData = data;
this.rightChildNode = node this.rightChildNode = node
this.rightChildVnode = source this.rightChildVnode = source
this.currentRightChild = source; this.currentRightChild = source;
console.log(this.rightChildVnode) console.log(this.rightChildVnode)
if(this.currentLeftChild){ if (this.currentLeftChild) {
this.dialogVisible = true; this.dialogVisible = true;
} }
}, },
oldNodeClick(data, node,source) { oldNodeClick(data, node, source) {
this.$store.state.selectStep = data; this.$store.state.selectStep = data;
this.leftChildData = data; this.leftChildData = data;
this.leftChildNode = node this.leftChildNode = node
this.leftChildVnode = source this.leftChildVnode = source
this.currentLeftChild = source; this.currentLeftChild = source;
if(this.currentRightChild){ if (this.currentRightChild) {
this.dialogVisible = true; this.dialogVisible = true;
} }
}, },
getOldVariableSize() {
let size = 0;
if (this.oldData.variables) {
size += this.oldData.variables.length;
}
if (this.oldData.headers && this.oldData.headers.length > 1) {
size += this.oldData.headers.length - 1;
}
return size;
},
getNewVariableSize(){
let size = 0;
if (this.newData.variables) {
size += this.newData.variables.length;
}
if (this.newData.headers && this.newData.headers.length > 1) {
size += this.newData.headers.length - 1;
}
return size;
}
}, },
created() { created() {
}, },
mounted() { mounted() {
this.$nextTick(function () { this.$nextTick(function () {