fix(接口测试): 修复启用禁用不生效问题

--bug=1009405 --user=赵勇 [github #8973]在接口自动化功能项,场景步骤里面的禁用按钮,点击禁用之后,状态无法保存。 https://www.tapd.cn/55049933/s/1091784
This commit is contained in:
fit2-zhao 2022-01-14 11:28:41 +08:00 committed by fit2-zhao
parent 57db8ebd02
commit 3744109fbf
2 changed files with 11 additions and 0 deletions

View File

@ -663,11 +663,15 @@ public class ApiAutomationService {
if (element != null && StringUtils.equalsIgnoreCase(element.getString("type"), "scenario")) { if (element != null && StringUtils.equalsIgnoreCase(element.getString("type"), "scenario")) {
ApiScenarioWithBLOBs scenarioWithBLOBs = apiScenarioMapper.selectByPrimaryKey(element.getString("id")); ApiScenarioWithBLOBs scenarioWithBLOBs = apiScenarioMapper.selectByPrimaryKey(element.getString("id"));
if (scenarioWithBLOBs != null && StringUtils.isNotEmpty(scenarioWithBLOBs.getScenarioDefinition())) { if (scenarioWithBLOBs != null && StringUtils.isNotEmpty(scenarioWithBLOBs.getScenarioDefinition())) {
boolean enable = element.getBoolean("enable");
boolean environmentEnable = element.getBoolean("environmentEnable");
if (StringUtils.equalsIgnoreCase(element.getString("referenced"), "REF")) { if (StringUtils.equalsIgnoreCase(element.getString("referenced"), "REF")) {
element = JSON.parseObject(scenarioWithBLOBs.getScenarioDefinition()); element = JSON.parseObject(scenarioWithBLOBs.getScenarioDefinition());
element.put("referenced", "REF"); element.put("referenced", "REF");
} }
element.put("num", scenarioWithBLOBs.getNum()); element.put("num", scenarioWithBLOBs.getNum());
element.put("enable", enable);
element.put("environmentEnable", environmentEnable);
hashTree.set(i, element); hashTree.set(i, element);
} }
} }
@ -682,10 +686,14 @@ public class ApiAutomationService {
if (element != null && StringUtils.equalsIgnoreCase(element.getString("type"), "scenario")) { if (element != null && StringUtils.equalsIgnoreCase(element.getString("type"), "scenario")) {
ApiScenarioWithBLOBs scenarioWithBLOBs = apiScenarioMapper.selectByPrimaryKey(element.getString("id")); ApiScenarioWithBLOBs scenarioWithBLOBs = apiScenarioMapper.selectByPrimaryKey(element.getString("id"));
if (scenarioWithBLOBs != null && StringUtils.isNotEmpty(scenarioWithBLOBs.getScenarioDefinition())) { if (scenarioWithBLOBs != null && StringUtils.isNotEmpty(scenarioWithBLOBs.getScenarioDefinition())) {
boolean enable = element.getBoolean("enable");
boolean environmentEnable = element.getBoolean("environmentEnable");
if (StringUtils.equalsIgnoreCase(element.getString("referenced"), "REF")) { if (StringUtils.equalsIgnoreCase(element.getString("referenced"), "REF")) {
element = JSON.parseObject(scenarioWithBLOBs.getScenarioDefinition()); element = JSON.parseObject(scenarioWithBLOBs.getScenarioDefinition());
element.put("referenced", "REF"); element.put("referenced", "REF");
} }
element.put("enable", enable);
element.put("environmentEnable", environmentEnable);
element.put("num", scenarioWithBLOBs.getNum()); element.put("num", scenarioWithBLOBs.getNum());
} }
} }

View File

@ -115,6 +115,9 @@ export default {
if (!this.scenario.projectId) { if (!this.scenario.projectId) {
this.scenario.projectId = getCurrentProjectID(); this.scenario.projectId = getCurrentProjectID();
} }
if (this.scenario.id && this.scenario.referenced === 'REF' && !this.scenario.loaded && this.scenario.hashTree) {
this.setDisabled(this.scenario.hashTree, this.scenario.projectId);
}
}, },
components: {ApiBaseComponent, MsSqlBasisParameters, MsTcpBasisParameters, MsDubboBasisParameters, MsApiRequestForm}, components: {ApiBaseComponent, MsSqlBasisParameters, MsTcpBasisParameters, MsDubboBasisParameters, MsApiRequestForm},
data() { data() {