fix(接口测试): 修复场景多数据源切换执行提示错误问题
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001012622
This commit is contained in:
parent
0b60824853
commit
d3587bd4c9
|
@ -345,6 +345,8 @@ export default {
|
||||||
this.tabs = [];
|
this.tabs = [];
|
||||||
this.activeName = "default";
|
this.activeName = "default";
|
||||||
this.isSave = false;
|
this.isSave = false;
|
||||||
|
// 清除vuex中缓存的环境
|
||||||
|
this.$store.state.scenarioEnvMap = new Map();
|
||||||
} else {
|
} else {
|
||||||
this.isSave = false;
|
this.isSave = false;
|
||||||
}
|
}
|
||||||
|
@ -384,7 +386,6 @@ export default {
|
||||||
},
|
},
|
||||||
diff(t) {
|
diff(t) {
|
||||||
if (t.currentScenario.type !== "add") {
|
if (t.currentScenario.type !== "add") {
|
||||||
|
|
||||||
let v1 = t.currentScenario.scenarioDefinitionOrg;
|
let v1 = t.currentScenario.scenarioDefinitionOrg;
|
||||||
let v2 = {
|
let v2 = {
|
||||||
apiScenarioModuleId: t.currentScenario.apiScenarioModuleId,
|
apiScenarioModuleId: t.currentScenario.apiScenarioModuleId,
|
||||||
|
@ -506,11 +507,6 @@ export default {
|
||||||
if (tab && this.isSave) {
|
if (tab && this.isSave) {
|
||||||
message += tab.currentScenario.name + ",";
|
message += tab.currentScenario.name + ",";
|
||||||
}
|
}
|
||||||
if (tab) {
|
|
||||||
let index = this.tabs.filter(t => t === tab);
|
|
||||||
index.splice(0, 1);
|
|
||||||
tab = undefined;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (message !== "") {
|
if (message !== "") {
|
||||||
|
@ -535,6 +531,22 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
removeTab(targetName) {
|
removeTab(targetName) {
|
||||||
|
let index = this.tabs.findIndex(item => item.name === targetName);
|
||||||
|
if (index !== -1) {
|
||||||
|
// 清除vuex中缓存的环境
|
||||||
|
let tab = this.tabs[index];
|
||||||
|
if (tab && tab.currentScenario && this.$store.state.scenarioEnvMap && this.$store.state.scenarioEnvMap instanceof Map) {
|
||||||
|
this.$store.state.scenarioEnvMap.forEach((v, k) => {
|
||||||
|
if (k.indexOf(tab.currentScenario.id) !== -1) {
|
||||||
|
this.$store.state.scenarioEnvMap.delete(k);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.tabs.splice(index, 1);
|
||||||
|
if (tab) {
|
||||||
|
tab = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
this.tabs = this.tabs.filter(tab => tab.name !== targetName);
|
this.tabs = this.tabs.filter(tab => tab.name !== targetName);
|
||||||
if (this.tabs.length > 0) {
|
if (this.tabs.length > 0) {
|
||||||
this.activeName = this.tabs[this.tabs.length - 1].name;
|
this.activeName = this.tabs[this.tabs.length - 1].name;
|
||||||
|
@ -542,10 +554,6 @@ export default {
|
||||||
} else {
|
} else {
|
||||||
this.activeName = "default";
|
this.activeName = "default";
|
||||||
}
|
}
|
||||||
let index = this.tabs.findIndex(item => item.name === targetName);
|
|
||||||
if (index !== -1) {
|
|
||||||
this.tabs.splice(index, 1);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
setTabLabel(data) {
|
setTabLabel(data) {
|
||||||
for (const tab of this.tabs) {
|
for (const tab of this.tabs) {
|
||||||
|
|
|
@ -1583,7 +1583,12 @@ export default {
|
||||||
// 兼容历史数据
|
// 兼容历史数据
|
||||||
this.projectEnvMap.set(this.projectId, obj.environmentId);
|
this.projectEnvMap.set(this.projectId, obj.environmentId);
|
||||||
}
|
}
|
||||||
this.$store.state.scenarioEnvMap = this.projectEnvMap;
|
if (!this.$store.state.scenarioEnvMap || !(this.$store.state.scenarioEnvMap instanceof Map)) {
|
||||||
|
this.$store.state.scenarioEnvMap = new Map();
|
||||||
|
}
|
||||||
|
this.projectEnvMap.forEach((v, k) => {
|
||||||
|
this.$store.state.scenarioEnvMap.set(this.currentScenario.id + "_" + k, v);
|
||||||
|
})
|
||||||
this.envGroupId = response.data.environmentGroupId;
|
this.envGroupId = response.data.environmentGroupId;
|
||||||
if (response.data.environmentType) {
|
if (response.data.environmentType) {
|
||||||
this.environmentType = response.data.environmentType;
|
this.environmentType = response.data.environmentType;
|
||||||
|
@ -1777,7 +1782,15 @@ export default {
|
||||||
},
|
},
|
||||||
setProjectEnvMap(projectEnvMap) {
|
setProjectEnvMap(projectEnvMap) {
|
||||||
this.projectEnvMap = projectEnvMap;
|
this.projectEnvMap = projectEnvMap;
|
||||||
this.$store.state.scenarioEnvMap = projectEnvMap;
|
if (!this.$store.state.scenarioEnvMap) {
|
||||||
|
this.$store.state.scenarioEnvMap = new Map();
|
||||||
|
}
|
||||||
|
let map = objToStrMap(JSON.parse(JSON.stringify(this.$store.state.scenarioEnvMap)));
|
||||||
|
this.projectEnvMap.forEach((v, k) => {
|
||||||
|
let key = this.currentScenario.id + "_" + k;
|
||||||
|
map.set(key, v);
|
||||||
|
});
|
||||||
|
this.$store.state.scenarioEnvMap = map;
|
||||||
this.setDomain(true);
|
this.setDomain(true);
|
||||||
},
|
},
|
||||||
setEnvGroup(id) {
|
setEnvGroup(id) {
|
||||||
|
|
|
@ -99,10 +99,7 @@ export default {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
isScenario: {
|
isScenario: String,
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
isReadOnly: {
|
isReadOnly: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
@ -189,9 +186,10 @@ export default {
|
||||||
getEnvironments() {
|
getEnvironments() {
|
||||||
let envId = "";
|
let envId = "";
|
||||||
let id = this.request.projectId ? this.request.projectId : this.projectId;
|
let id = this.request.projectId ? this.request.projectId : this.projectId;
|
||||||
|
let scenarioEnvId = this.isScenario ? (this.isScenario + "_" + id) : id;
|
||||||
if (this.$store.state.scenarioEnvMap && this.$store.state.scenarioEnvMap instanceof Map
|
if (this.$store.state.scenarioEnvMap && this.$store.state.scenarioEnvMap instanceof Map
|
||||||
&& this.$store.state.scenarioEnvMap.has(id)) {
|
&& this.$store.state.scenarioEnvMap.has(scenarioEnvId)) {
|
||||||
envId = this.$store.state.scenarioEnvMap.get(id);
|
envId = this.$store.state.scenarioEnvMap.get(scenarioEnvId);
|
||||||
}
|
}
|
||||||
if (this.request.referenced === 'Created' && this.isScenario && !this.request.isRefEnvironment) {
|
if (this.request.referenced === 'Created' && this.isScenario && !this.request.isRefEnvironment) {
|
||||||
this.itselfEnvironment();
|
this.itselfEnvironment();
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
:isShowEnable="true"
|
:isShowEnable="true"
|
||||||
:response="response"
|
:response="response"
|
||||||
:referenced="true"
|
:referenced="true"
|
||||||
:isScenario="true"
|
:isScenario="currentScenario.id"
|
||||||
:headers="request.headers "
|
:headers="request.headers "
|
||||||
:is-read-only="isCompReadOnly"
|
:is-read-only="isCompReadOnly"
|
||||||
:request="request"/>
|
:request="request"/>
|
||||||
|
@ -101,21 +101,21 @@
|
||||||
:is-read-only="isCompReadOnly"
|
:is-read-only="isCompReadOnly"
|
||||||
:response="response"
|
:response="response"
|
||||||
:show-pre-script="true"
|
:show-pre-script="true"
|
||||||
:isScenario="true"
|
:isScenario="currentScenario.id"
|
||||||
:show-script="true" :request="request"/>
|
:show-script="true" :request="request"/>
|
||||||
|
|
||||||
<ms-sql-basis-parameters
|
<ms-sql-basis-parameters
|
||||||
v-if="request.protocol==='SQL'|| request.type==='JDBCSampler'"
|
v-if="request.protocol==='SQL'|| request.type==='JDBCSampler'"
|
||||||
:request="request"
|
:request="request"
|
||||||
:response="response"
|
:response="response"
|
||||||
:isScenario="true"
|
:isScenario="currentScenario.id"
|
||||||
:is-read-only="isCompReadOnly"
|
:is-read-only="isCompReadOnly"
|
||||||
:showScript="true"/>
|
:showScript="true"/>
|
||||||
|
|
||||||
<ms-dubbo-basis-parameters
|
<ms-dubbo-basis-parameters
|
||||||
v-if="request.protocol==='DUBBO' || request.protocol==='dubbo://'|| request.type==='DubboSampler'"
|
v-if="request.protocol==='DUBBO' || request.protocol==='dubbo://'|| request.type==='DubboSampler'"
|
||||||
:request="request"
|
:request="request"
|
||||||
:isScenario="true"
|
:isScenario="currentScenario.id"
|
||||||
:response="response"
|
:response="response"
|
||||||
:is-read-only="isCompReadOnly"
|
:is-read-only="isCompReadOnly"
|
||||||
:showScript="true"/>
|
:showScript="true"/>
|
||||||
|
@ -252,7 +252,11 @@ export default {
|
||||||
this.request.projectId = getCurrentProjectID();
|
this.request.projectId = getCurrentProjectID();
|
||||||
}
|
}
|
||||||
this.request.customizeReq = this.isCustomizeReq;
|
this.request.customizeReq = this.isCustomizeReq;
|
||||||
|
this.request.currentScenarioId = this.currentScenario.id;
|
||||||
|
// 传递场景ID
|
||||||
|
if (this.request.hashTree) {
|
||||||
|
this.setOwnEnvironment(this.request.hashTree);
|
||||||
|
}
|
||||||
if (this.request.num) {
|
if (this.request.num) {
|
||||||
this.isShowNum = true;
|
this.isShowNum = true;
|
||||||
this.request.root = true;
|
this.request.root = true;
|
||||||
|
@ -357,6 +361,17 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
setOwnEnvironment(scenarioDefinition) {
|
||||||
|
for (let i in scenarioDefinition) {
|
||||||
|
let typeArray = ["JDBCPostProcessor", "JDBCSampler", "JDBCPreProcessor"]
|
||||||
|
if (typeArray.indexOf(scenarioDefinition[i].type) !== -1) {
|
||||||
|
scenarioDefinition[i].currentScenarioId = this.currentScenario.id;
|
||||||
|
}
|
||||||
|
if (scenarioDefinition[i].hashTree !== undefined && scenarioDefinition[i].hashTree.length > 0) {
|
||||||
|
this.setOwnEnvironment(scenarioDefinition[i].hashTree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
forStatus() {
|
forStatus() {
|
||||||
this.reqSuccess = true;
|
this.reqSuccess = true;
|
||||||
if (this.request.result && this.request.result.length > 0) {
|
if (this.request.result && this.request.result.length > 0) {
|
||||||
|
|
|
@ -35,10 +35,7 @@ export default {
|
||||||
ApiBaseComponent, MsDropdown, MsInstructionsIcon, MsCodeEdit
|
ApiBaseComponent, MsDropdown, MsInstructionsIcon, MsCodeEdit
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
isScenario: {
|
isScenario: String,
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
draggable: {
|
draggable: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
|
|
|
@ -149,10 +149,7 @@ export default {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
isScenario: {
|
isScenario: String,
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
isReadOnly: {
|
isReadOnly: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
@ -279,9 +276,10 @@ export default {
|
||||||
getEnvironments() {
|
getEnvironments() {
|
||||||
let envId = "";
|
let envId = "";
|
||||||
let id = this.request.projectId ? this.request.projectId : this.projectId;
|
let id = this.request.projectId ? this.request.projectId : this.projectId;
|
||||||
|
let scenarioEnvId = this.request.currentScenarioId ? (this.request.currentScenarioId + "_" + id) : id;
|
||||||
if (this.$store.state.scenarioEnvMap && this.$store.state.scenarioEnvMap instanceof Map
|
if (this.$store.state.scenarioEnvMap && this.$store.state.scenarioEnvMap instanceof Map
|
||||||
&& this.$store.state.scenarioEnvMap.has(id)) {
|
&& this.$store.state.scenarioEnvMap.has(scenarioEnvId)) {
|
||||||
envId = this.$store.state.scenarioEnvMap.get(id);
|
envId = this.$store.state.scenarioEnvMap.get(scenarioEnvId);
|
||||||
}
|
}
|
||||||
if (this.request.referenced === 'Created' && this.isScenario && !this.request.isRefEnvironment) {
|
if (this.request.referenced === 'Created' && this.isScenario && !this.request.isRefEnvironment) {
|
||||||
this.itselfEnvironment();
|
this.itselfEnvironment();
|
||||||
|
|
|
@ -116,10 +116,7 @@ export default {
|
||||||
MsJmxStep
|
MsJmxStep
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
isScenario: {
|
isScenario: String,
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
request: {},
|
request: {},
|
||||||
basisData: {},
|
basisData: {},
|
||||||
moduleOptions: Array,
|
moduleOptions: Array,
|
||||||
|
|
|
@ -210,10 +210,7 @@ export default {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isScenario: {
|
isScenario: String,
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
showScript: {
|
showScript: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
|
|
|
@ -202,10 +202,7 @@ export default {
|
||||||
MsJmxStep
|
MsJmxStep
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
isScenario: {
|
isScenario: String,
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
request: {},
|
request: {},
|
||||||
basisData: {},
|
basisData: {},
|
||||||
response: {},
|
response: {},
|
||||||
|
|
|
@ -139,10 +139,7 @@ export default {
|
||||||
tabType: String,
|
tabType: String,
|
||||||
response: {},
|
response: {},
|
||||||
apiId: String,
|
apiId: String,
|
||||||
isScenario: {
|
isScenario: String,
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
showScript: {
|
showScript: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
|
|
Loading…
Reference in New Issue