fix(接口测试): 场景不能引用没有步骤的场景
--bug=1014432 --user=宋天阳 【接口测试】场景中复制/引用空场景-生成报告空场景步骤统计为未执行 https://www.tapd.cn/55049933/s/1203448
This commit is contained in:
parent
ac350d3b27
commit
cb344fed5d
|
@ -1362,10 +1362,29 @@ export default {
|
|||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
const parent = node.parent
|
||||
const hashTree = parent.data.hashTree || parent.data;
|
||||
const index = hashTree.findIndex(d => d.resourceId !== undefined && row.resourceId !== undefined && d.resourceId === row.resourceId)
|
||||
let parent = node.parent
|
||||
let hashTree = parent.data.hashTree || parent.data;
|
||||
let index = hashTree.findIndex(d => d.resourceId !== undefined && row.resourceId !== undefined && d.resourceId === row.resourceId)
|
||||
hashTree.splice(index, 1);
|
||||
//删除空步骤
|
||||
while (
|
||||
parent &&
|
||||
parent.data &&
|
||||
parent.data.hashTree &&
|
||||
parent.data.hashTree.length <= 0 &&
|
||||
parent.data.type === "scenario"
|
||||
) {
|
||||
parent = parent.parent;
|
||||
if (!parent) {
|
||||
break;
|
||||
}
|
||||
hashTree = parent.data.hashTree || parent.data;
|
||||
index = hashTree.findIndex(
|
||||
(d) =>
|
||||
d.id != undefined && row.id != undefined && d.id === row.id
|
||||
);
|
||||
hashTree.splice(index, 1);
|
||||
}
|
||||
this.sort();
|
||||
this.forceRerender();
|
||||
}
|
||||
|
|
|
@ -108,27 +108,38 @@ export default {
|
|||
this.buttonIsWorking = false;
|
||||
},
|
||||
createScenarioDefinition(scenarios, data, referenced) {
|
||||
let emptyStepScenarios = "";
|
||||
data.forEach(item => {
|
||||
let scenarioDefinition = JSON.parse(item.scenarioDefinition);
|
||||
if (scenarioDefinition && scenarioDefinition.hashTree) {
|
||||
let obj = {
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
type: "scenario",
|
||||
headers: scenarioDefinition.headers,
|
||||
variables: scenarioDefinition.variables,
|
||||
environmentMap: scenarioDefinition.environmentMap,
|
||||
referenced: referenced,
|
||||
resourceId: getUUID(),
|
||||
hashTree: scenarioDefinition.hashTree,
|
||||
projectId: item.projectId,
|
||||
num: item.num,
|
||||
versionName: item.versionName,
|
||||
versionEnable: item.versionEnable
|
||||
};
|
||||
scenarios.push(obj);
|
||||
if (!item.stepTotal || item.stepTotal == 0) {
|
||||
emptyStepScenarios += item.name + ",";
|
||||
} else {
|
||||
let scenarioDefinition = JSON.parse(item.scenarioDefinition);
|
||||
if (scenarioDefinition && scenarioDefinition.hashTree) {
|
||||
let obj = {
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
type: "scenario",
|
||||
headers: scenarioDefinition.headers,
|
||||
variables: scenarioDefinition.variables,
|
||||
environmentMap: scenarioDefinition.environmentMap,
|
||||
referenced: referenced,
|
||||
resourceId: getUUID(),
|
||||
hashTree: scenarioDefinition.hashTree,
|
||||
projectId: item.projectId,
|
||||
num: item.num,
|
||||
versionName: item.versionName,
|
||||
versionEnable: item.versionEnable
|
||||
};
|
||||
scenarios.push(obj);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (emptyStepScenarios !== "") {
|
||||
if (emptyStepScenarios.endsWith(",")) {
|
||||
emptyStepScenarios = emptyStepScenarios.substring(0, emptyStepScenarios.length - 1);
|
||||
this.$error(this.$t('api_test.scenario.scenario_step_is_empty', [emptyStepScenarios]));
|
||||
}
|
||||
}
|
||||
},
|
||||
getScenarioDefinition(referenced) {
|
||||
this.buttonIsWorking = true;
|
||||
|
|
|
@ -41,6 +41,10 @@
|
|||
}}
|
||||
</el-tag>
|
||||
<span class="ms-tag ms-step-name-api">{{ getProjectName(scenario.projectId) }}</span>
|
||||
<el-tooltip v-if="(!scenario.hashTree || scenario.hashTree.length === 0) && scenario.referenced==='REF'"
|
||||
class="ms-num" effect="dark" :content="$t('api_test.scenario.base_scenario_step_is_empty')" placement="top" style="margin-left: 5px">
|
||||
<i class="el-icon-warning"/>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
<template v-slot:debugStepCode>
|
||||
<span v-if="node.data.testing" class="ms-test-running">
|
||||
|
|
|
@ -1501,6 +1501,8 @@ export default {
|
|||
name: "Scenario Name",
|
||||
base_url: "Base URL",
|
||||
base_url_description: "Base URL as URL prefix for all requests",
|
||||
scenario_step_is_empty: "Scenario: {0} has none step!",
|
||||
base_scenario_step_is_empty:"Scenario step is empty!",
|
||||
url_invalid: "Invalid URL",
|
||||
variables: "Variables",
|
||||
headers: "Headers",
|
||||
|
|
|
@ -1509,6 +1509,8 @@ export default {
|
|||
name: "场景名称",
|
||||
base_url: "基础URL",
|
||||
base_url_description: "基础URL作为所有请求的URL前缀",
|
||||
scenario_step_is_empty: "场景: {0} 的步骤为空,无法导入",
|
||||
base_scenario_step_is_empty:"原场景步骤为空",
|
||||
variables: "自定义变量",
|
||||
headers: "请求头",
|
||||
kv_description: "所有请求可以使用自定义变量",
|
||||
|
|
|
@ -1506,6 +1506,8 @@ export default {
|
|||
name: "場景名稱",
|
||||
base_url: "基礎URL",
|
||||
base_url_description: "基礎URL作為所有請求的URL前綴",
|
||||
scenario_step_is_empty: "場景: {0} 的步驟為空,無法導入",
|
||||
base_scenario_step_is_empty:"原場景步驟為空",
|
||||
variables: "自定義變量",
|
||||
headers: "請求頭",
|
||||
kv_description: "所有請求可以使用自定義變量",
|
||||
|
|
Loading…
Reference in New Issue