refactor(接口测试): 场景中生成报告优化
--bug=1011491 --user=赵勇 【接口测试】场景-编辑-点击生成报告到弹出报告页面时间较长 https://www.tapd.cn/55049933/s/1122486
This commit is contained in:
parent
06fa5d28f4
commit
ef8374bb2b
|
@ -347,6 +347,8 @@ public class ApiScenarioExecuteService {
|
|||
String reportType = request.getConfig() != null ? request.getConfig().getReportType() : null;
|
||||
if (scenario != null) {
|
||||
report.setVersionId(scenario.getVersionId());
|
||||
String scenarioDefinition = JSON.toJSONString(request.getTestElement().getHashTree().get(0).getHashTree().get(0));
|
||||
scenario.setScenarioDefinition(scenarioDefinition);
|
||||
reportStructureService.save(scenario, report.getId(), reportType);
|
||||
} else {
|
||||
if (request.getTestElement() != null && CollectionUtils.isNotEmpty(request.getTestElement().getHashTree())) {
|
||||
|
|
|
@ -403,8 +403,12 @@ export default {
|
|||
scenarioDefinition: t.currentScenario.scenarioDefinition
|
||||
};
|
||||
let v3 = JSON.parse(JSON.stringify(v2));
|
||||
this.deleteResourceIds(v1.scenarioDefinition);
|
||||
this.deleteResourceIds(v3.scenarioDefinition);
|
||||
if (v1.scenarioDefinition) {
|
||||
this.deleteResourceIds(v1.scenarioDefinition);
|
||||
}
|
||||
if (v3.scenarioDefinition) {
|
||||
this.deleteResourceIds(v3.scenarioDefinition);
|
||||
}
|
||||
let delta = jsondiffpatch.diff(JSON.parse(JSON.stringify(v1)), JSON.parse(JSON.stringify(v3)));
|
||||
if (delta) {
|
||||
this.isSave = true;
|
||||
|
@ -560,7 +564,9 @@ export default {
|
|||
}
|
||||
},
|
||||
refresh(data) {
|
||||
this.setTabTitle(data);
|
||||
if (data) {
|
||||
this.setTabTitle(data);
|
||||
}
|
||||
this.isSave = true;
|
||||
},
|
||||
refreshTree() {
|
||||
|
|
|
@ -128,12 +128,17 @@ export default {
|
|||
this.isRequestResult = false;
|
||||
},
|
||||
created() {
|
||||
if (this.scenario && this.scenario.scenarioDefinition) {
|
||||
this.content.scenarioStepTotal = this.scenario.scenarioDefinition.hashTree.length;
|
||||
this.initTree();
|
||||
this.initMessageSocket();
|
||||
this.clearDebug();
|
||||
}
|
||||
|
||||
},
|
||||
mounted() {
|
||||
this.$nextTick(() => {
|
||||
if (this.scenario && this.scenario.scenarioDefinition) {
|
||||
this.content.scenarioStepTotal = this.scenario.scenarioDefinition.hashTree.length;
|
||||
this.initTree();
|
||||
this.initMessageSocket();
|
||||
this.clearDebug();
|
||||
}
|
||||
});
|
||||
},
|
||||
props: {
|
||||
reportId: String,
|
||||
|
@ -208,7 +213,7 @@ export default {
|
|||
this.$refs.failsTree.filter(index);
|
||||
} else if (this.activeName === "errorReport") {
|
||||
this.$refs.errorReportTree.filter("errorReport");
|
||||
} else if(this.activeName === "unExecute"){
|
||||
} else if (this.activeName === "unExecute") {
|
||||
this.$refs.unExecuteTree.filter("unexecute");
|
||||
}
|
||||
},
|
||||
|
|
|
@ -972,18 +972,18 @@ export default {
|
|||
}
|
||||
/*触发执行操作*/
|
||||
this.$refs['currentScenario'].validate(async (valid) => {
|
||||
if (valid) {
|
||||
this.debugLoading = true;
|
||||
let definition = JSON.parse(JSON.stringify(this.currentScenario));
|
||||
definition.hashTree = this.scenarioDefinition;
|
||||
await this.getEnv(JSON.stringify(definition));
|
||||
await this.$refs.envPopover.initEnv();
|
||||
const sign = await this.$refs.envPopover.checkEnv(this.isFullUrl);
|
||||
if (!sign) {
|
||||
this.debugLoading = false;
|
||||
return;
|
||||
}
|
||||
this.editScenario().then(() => {
|
||||
if (valid) {
|
||||
this.debugLoading = true;
|
||||
let definition = JSON.parse(JSON.stringify(this.currentScenario));
|
||||
definition.hashTree = this.scenarioDefinition;
|
||||
await this.getEnv(JSON.stringify(definition));
|
||||
await this.$refs.envPopover.initEnv();
|
||||
const sign = await this.$refs.envPopover.checkEnv(this.isFullUrl);
|
||||
if (!sign) {
|
||||
this.debugLoading = false;
|
||||
return;
|
||||
}
|
||||
this.initParameter();
|
||||
this.debugData = {
|
||||
id: this.currentScenario.id,
|
||||
name: this.currentScenario.name,
|
||||
|
@ -999,9 +999,10 @@ export default {
|
|||
this.reportId = getUUID().substring(0, 8);
|
||||
this.debugLoading = false;
|
||||
this.pluginDelStep = false;
|
||||
})
|
||||
this.$emit('refresh');
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
},
|
||||
validatePluginData(steps) {
|
||||
steps.forEach(step => {
|
||||
|
@ -1621,7 +1622,7 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
async setParameter() {
|
||||
initParameter() {
|
||||
this.currentScenario.stepTotal = this.scenarioDefinition.length;
|
||||
if (!this.currentScenario.projectId) {
|
||||
this.currentScenario.projectId = this.projectId;
|
||||
|
@ -1646,11 +1647,6 @@ export default {
|
|||
this.formatData(scenario.hashTree);
|
||||
}
|
||||
this.currentScenario.environmentType = this.environmentType;
|
||||
let definition = JSON.parse(JSON.stringify(this.currentScenario));
|
||||
definition.hashTree = this.scenarioDefinition;
|
||||
await this.getEnv(JSON.stringify(definition));
|
||||
// 保存时同步所需要的项目环境
|
||||
savePreciseEnvProjectIds(this.projectIds, this.projectEnvMap);
|
||||
this.currentScenario.environmentJson = JSON.stringify(strMapToObj(this.projectEnvMap));
|
||||
this.currentScenario.environmentGroupId = this.envGroupId;
|
||||
this.currentScenario.scenarioDefinition = scenario;
|
||||
|
@ -1662,6 +1658,14 @@ export default {
|
|||
this.currentScenario.apiScenarioModuleId = this.currentModule.id;
|
||||
}
|
||||
},
|
||||
async setParameter() {
|
||||
this.initParameter();
|
||||
let definition = JSON.parse(JSON.stringify(this.currentScenario));
|
||||
definition.hashTree = this.scenarioDefinition;
|
||||
await this.getEnv(JSON.stringify(definition));
|
||||
// 保存时同步所需要的项目环境
|
||||
savePreciseEnvProjectIds(this.projectIds, this.projectEnvMap);
|
||||
},
|
||||
runRefresh() {
|
||||
if (!this.debug) {
|
||||
this.debugVisible = true;
|
||||
|
@ -1679,6 +1683,7 @@ export default {
|
|||
this.runScenario = undefined;
|
||||
this.message = "stop";
|
||||
this.clearMessage = getUUID().substring(0, 8);
|
||||
this.debugData = {};
|
||||
},
|
||||
showScenarioParameters() {
|
||||
this.$refs.scenarioParameters.open(this.currentScenario.variables, this.currentScenario.headers);
|
||||
|
@ -1726,6 +1731,7 @@ export default {
|
|||
},
|
||||
detailRefresh(result) {
|
||||
// 把执行结果分发给各个请求
|
||||
this.debugData = {};
|
||||
},
|
||||
fullScreen() {
|
||||
this.drawer = true;
|
||||
|
|
Loading…
Reference in New Issue