fix(接口测试): 修复无权限的case执行时提示未选择环境的缺陷

--bug=1019502 --user=王孝刚 【接口测试】导入的场景-编辑保存运行环境后,列表中执行仍提示未选择运行环境
https://www.tapd.cn/55049933/s/1292309
This commit is contained in:
wxg0103 2022-11-08 16:36:40 +08:00 committed by fit2-zhao
parent 1186418eef
commit 8ba7b8b704
4 changed files with 70 additions and 54 deletions

View File

@ -495,64 +495,71 @@ export default {
run() {
this.currentScenarioData = undefined;
this.getParentVariables(this.node);
let selectEnvId;
//
if (this.isApiImport || this.request.isRefEnvironment) {
if (this.request.type && (this.request.type === "HTTPSamplerProxy" || this.request.type === "JDBCSampler" || this.request.type === "TCPSampler")) {
if (store.scenarioEnvMap && store.scenarioEnvMap instanceof Map
&& store.scenarioEnvMap.has((this.currentScenario.id + "_" + this.request.projectId))) {
selectEnvId = store.scenarioEnvMap.get((this.currentScenario.id + "_" + this.request.projectId));
this.environmentMap = this.envMap;
getOwnerProjectIds().then(res => {
const project = res.data.find(p => p === resource.projectId);
if (!project) {
this.$warning(this.$t('automation.project_no_permission'));
} else {
let selectEnvId;
//
if (this.isApiImport || this.request.isRefEnvironment) {
if (this.request.type && (this.request.type === "HTTPSamplerProxy" || this.request.type === "JDBCSampler" || this.request.type === "TCPSampler")) {
if (store.scenarioEnvMap && store.scenarioEnvMap instanceof Map
&& store.scenarioEnvMap.has((this.currentScenario.id + "_" + this.request.projectId))) {
selectEnvId = store.scenarioEnvMap.get((this.currentScenario.id + "_" + this.request.projectId));
this.environmentMap = this.envMap;
}
if (!selectEnvId) {
this.$warning(this.$t('api_test.automation.env_message'));
return false;
}
}
}
if (!selectEnvId) {
this.$warning(this.$t('api_test.automation.env_message'));
if (!this.request.enable) {
this.$warning(this.$t('api_test.automation.debug_message'));
return false;
}
this.request.debug = true;
this.request.active = true;
this.loading = true;
this.runData = [];
if (selectEnvId) {
this.request.useEnvironment = selectEnvId;
this.request.environmentId = selectEnvId;
}
this.request.customizeReq = this.isCustomizeReq;
//
let variables = [];
if (this.currentScenario && this.currentScenario.variables) {
variables = JSON.parse(JSON.stringify(this.currentScenario.variables));
}
let debugData = {
id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario",
variables: variables, referenced: 'Created', headers: this.currentScenario.headers,
enableCookieShare: this.enableCookieShare, environmentId: selectEnvId, hashTree: [this.request],
};
//
if (this.currentScenarioData && this.currentScenarioData.variableEnable && this.currentScenarioData.variables) {
if (!debugData.variables || debugData.variables.length === 0) {
debugData.variables = this.currentScenarioData.variables;
} else if (this.currentScenarioData.variables) {
//
debugData.variables.forEach(data => {
this.currentScenarioData.variables.forEach(item => {
if (data.type === item.type && data.name === item.name) {
Object.assign(data, item);
}
})
});
}
}
this.runData.push(debugData);
this.request.requestResult = [];
this.request.result = undefined;
/*触发执行操作*/
this.reportId = getUUID();
}
}
if (!this.request.enable) {
this.$warning(this.$t('api_test.automation.debug_message'));
return false;
}
this.request.debug = true;
this.request.active = true;
this.loading = true;
this.runData = [];
if (selectEnvId) {
this.request.useEnvironment = selectEnvId;
this.request.environmentId = selectEnvId;
}
this.request.customizeReq = this.isCustomizeReq;
//
let variables = [];
if (this.currentScenario && this.currentScenario.variables) {
variables = JSON.parse(JSON.stringify(this.currentScenario.variables));
}
let debugData = {
id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario",
variables: variables, referenced: 'Created', headers: this.currentScenario.headers,
enableCookieShare: this.enableCookieShare, environmentId: selectEnvId, hashTree: [this.request],
};
//
if (this.currentScenarioData && this.currentScenarioData.variableEnable && this.currentScenarioData.variables) {
if (!debugData.variables || debugData.variables.length === 0) {
debugData.variables = this.currentScenarioData.variables;
} else if (this.currentScenarioData.variables) {
//
debugData.variables.forEach(data => {
this.currentScenarioData.variables.forEach(item => {
if (data.type === item.type && data.name === item.name) {
Object.assign(data, item);
}
})
});
}
}
this.runData.push(debugData);
this.request.requestResult = [];
this.request.result = undefined;
/*触发执行操作*/
this.reportId = getUUID();
})
},
getParentVariables(node) {
if (!this.currentScenarioData) {

View File

@ -48,6 +48,9 @@ const message = {
relation_case: "Relation CASE",
relation_scenario: "Relation Scenario"
},
},
automation:{
project_no_permission: "The current person does not have the operation permission for this step",
}
}
export default {

View File

@ -48,6 +48,9 @@ const message = {
relation_case: "关联CASE",
relation_scenario: "关联场景"
},
},
automation:{
project_no_permission: "当前操作人无此步骤的操作权限",
}
}

View File

@ -48,6 +48,9 @@ const message = {
relation_case: "關聯CASE",
relation_scenario: "關聯場景"
},
},
automation:{
project_no_permission: "當前人操作無此步驟的操作權限",
}
}