fix(接口测试): 修复场景报告跳转到场景编辑页面模块下拉内容不显示问题

--bug=1013398 --user=王孝刚 【接口测试】github#13809. 切换项目后,从报告中点击场景用例link进入场景用例页面,页面显示模块信息丢失 https://www.tapd.cn/55049933/s/1176599
This commit is contained in:
fit2-zhao 2022-06-08 17:10:25 +08:00 committed by f2c-ci-robot[bot]
parent 59b821f9a0
commit f4d8413ef3
3 changed files with 55 additions and 45 deletions

View File

@ -37,7 +37,7 @@ public class MsExtract extends MsTestElement {
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
ParameterConfig config = (ParameterConfig) msParameter;
// 非导出操作且不是启用状态则跳过执行
if (!config.isOperating() && !this.isEnable()) {
if (!this.isEnable()) {
return;
}
addRequestExtractors(tree, config);

View File

@ -107,6 +107,7 @@
import {getCurrentProjectID, getCurrentUser, getCurrentWorkspaceId, getUUID, hasPermission} from "@/common/js/utils";
import {PROJECT_ID, WORKSPACE_ID} from "@/common/js/constants";
import {buildTree} from "@/business/components/api/definition/model/NodeTree";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {};
@ -212,34 +213,46 @@ export default {
exportJmx() {
this.$refs.apiScenarioList.exportJmx();
},
checkRedirectEditPage(redirectParam) {
if (redirectParam != null) {
let selectParamArr = redirectParam.split("edit:");
if (selectParamArr.length == 2) {
let scenarioId = selectParamArr[1];
//
let url = "/api/automation/list/" + 1 + "/" + 1;
this.$post(url, {id: scenarioId}, async response => {
let data = response.data;
if (data != null) {
//
if (this.moduleOptions && this.moduleOptions.length === 0) {
await this.$refs.nodeTree.list();
}
if (data.listObject && data.listObject.length > 0) {
let row = data.listObject[0];
if (row != null && row.tags != 'null' && row.tags != '' && row.tags != undefined) {
if (Object.prototype.toString.call(row.tags).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'object'
&& Object.prototype.toString.call(row.tags).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'array') {
row.tags = JSON.parse(row.tags);
}
}
this.editScenario(row);
}
}
});
}
checkRedirectEditPage(params) {
if (!params) {
return;
}
let paramArr = params.split("edit:");
if (paramArr.length !== 2) {
return;
}
let scenarioId = paramArr[1];
//
this.$post("/api/automation/list/1/1", {id: scenarioId}, response => {
let data = response.data;
if (data && data.listObject && data.listObject.length > 0) {
let row = data.listObject[0];
let checks = ["array", "object"];
if (row && row.tags && (checks.indexOf(Object.prototype.toString.call(row.tags)
.match(/\[object (\w+)\]/)[1].toLowerCase()) !== -1)) {
row.tags = JSON.parse(row.tags);
}
//
if (this.moduleOptions && this.moduleOptions.length === 0) {
let projectId = data.projectId ? data.projectId : this.projectId;
this.initModules(row, projectId);
} else {
this.editScenario(row);
}
}
});
},
initModules(row, projectId) {
this.$get("/api/automation/module/list/" + projectId, response => {
if (response.data) {
response.data.forEach(node => {
node.name = node.name === '未规划场景' ? this.$t('api_test.automation.unplanned_scenario') : node.name
buildTree(node, {path: ''});
});
this.moduleOptions = response.data;
}
this.editScenario(row);
});
},
changeRedirectParam(redirectIDParam) {
this.redirectID = redirectIDParam;
@ -609,7 +622,7 @@ export default {
}
},
editScenario(row) {
if(!row) {
if (!row) {
this.activeName === 'default'
this.$error("跳转的应场景已经删除!");
return;

View File

@ -182,23 +182,20 @@
return;
}
}
return new Promise((resolve) => {
this.result = this.$get(url, response => {
if (response.data != undefined && response.data != null) {
this.data = response.data;
this.data.forEach(node => {
node.name = node.name === '未规划场景' ? this.$t('api_test.automation.unplanned_scenario') : node.name
buildTree(node, {path: ''});
});
this.$emit('setModuleOptions', this.data);
this.$emit('setNodeTree', this.data);
if (this.$refs.nodeTree) {
this.$refs.nodeTree.filter(this.condition.filterText);
}
this.result = this.$get(url, response => {
if (response.data != undefined && response.data != null) {
this.data = response.data;
this.data.forEach(node => {
node.name = node.name === '未规划场景' ? this.$t('api_test.automation.unplanned_scenario') : node.name
buildTree(node, {path: ''});
});
this.$emit('setModuleOptions', this.data);
this.$emit('setNodeTree', this.data);
if (this.$refs.nodeTree) {
this.$refs.nodeTree.filter(this.condition.filterText);
}
});
resolve();
})
}
});
},
edit(param) {
param.projectId = this.projectId;