fix(接口测试): 修复测试计划全选UI用例环境数据丢失问题

--bug=1029146 --user=郭雨琦
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001029146
This commit is contained in:
guoyuqi 2023-08-22 11:37:09 +08:00 committed by 刘瑞斌
parent 5123e14315
commit e9e2f1e5ce
2 changed files with 44 additions and 28 deletions

View File

@ -125,7 +125,10 @@ import {TEST_PLAN_RELEVANCE_UI_SCENARIO_CONFIGS} from "metersphere-frontend/src/
import {ENV_TYPE} from "metersphere-frontend/src/utils/constants";
import MsTable from "metersphere-frontend/src/components/table/MsTable";
import {getOwnerProjects, getVersionFilters} from "@/business/utils/sdk-utils";
import {testPlanUiScenarioRelevanceList} from "@/api/remote/ui/test-plan-ui-scenario-case";
import {
testPlanUiScenarioRelevanceList,
testPlanUiScenarioRelevanceListIds
} from "@/api/remote/ui/test-plan-ui-scenario-case";
import {getCustomTableWidth} from "metersphere-frontend/src/utils/tableUtils";
import MsTableColumn from "metersphere-frontend/src/components/table/MsTableColumn";
import EnvGroupPopover from "@/business/plan/env/EnvGroupPopover";
@ -165,6 +168,7 @@ export default {
currentScenario: {},
schedule: {},
selectAll: false,
selectAllIds: [],
tableData: [],
currentPage: 1,
pageSize: 10,
@ -290,25 +294,46 @@ export default {
},
selectCountChange(data) {
this.selectRows = this.$refs.scenarioTable.selectRows;
this.selectAll = this.$refs.scenarioTable.showSelectAll;
this.$emit("selectCountChange", data);
this.initProjectIds();
},
showReport() {
},
initProjectIds() {
async initProjectIds() {
this.projectIds.clear();
this.map.clear();
this.selectRows.forEach((row) => {
getUiScenarioEnvByProjectId(row.id).then((res) => {
let data = res.data;
data.projectIds.forEach((d) => this.projectIds.add(d));
this.map.set(row.id, data.projectIds);
if (!this.selectAll) {
this.selectRows.forEach((row) => {
getUiScenarioEnvByProjectId(row.id).then((res) => {
let data = res.data;
data.projectIds.forEach((d) => this.projectIds.add(d));
this.map.set(row.id, data.projectIds);
});
});
} else {
this.selectAllIds = await this.getAllId(this.condition);
this.selectAllIds.forEach((row) => {
getUiScenarioEnvByProjectId(row).then((res) => {
let data = res.data;
data.projectIds.forEach((d) => this.projectIds.add(d));
this.map.set(row, data.projectIds);
});
});
}
},
getAllId(param) {
return new Promise((resolve) => {
testPlanUiScenarioRelevanceListIds(param).then((r) => {
resolve(r.data);
});
});
},
closeEnv(){
this.$refs.envPopover.close();
closeEnv() {
if (this.$refs.envPopover) {
this.$refs.envPopover.close();
}
}
}
};

View File

@ -38,7 +38,6 @@ import {strMapToObj} from "metersphere-frontend/src/utils";
import {ENV_TYPE} from "metersphere-frontend/src/utils/constants";
import RelevanceUiScenarioList from "@/business/plan/view/comonents/ui/RelevanceUiScenarioList";
import {testPlanAutoCheck} from "@/api/remote/plan/test-plan";
import {testPlanUiScenarioRelevanceListIds} from "@/api/remote/ui/test-plan-ui-scenario-case";
import UiScenarioModule from "@/business/plan/view/comonents/ui/UiScenarioModule";
import {uiAutomationRelevance} from "@/api/remote/ui/api-scenario";
@ -139,14 +138,8 @@ export default {
this.$refs.baseRelevance.close();
});
},
getAllId(param) {
return new Promise((resolve) => {
testPlanUiScenarioRelevanceListIds(param).then((r) => {
resolve(r.data);
});
});
},
async saveCaseRelevance() {
saveCaseRelevance() {
this.isSaving = true;
let selectIds = [];
let selectRows = this.$refs.apiScenarioList.selectRows;
@ -154,9 +147,14 @@ export default {
let map = this.$refs.apiScenarioList.map;
let envGroupId = this.$refs.apiScenarioList.envGroupId;
selectRows.forEach((row) => {
selectIds.push(row.id);
});
if (!this.$refs.apiScenarioList.selectAll) {
selectRows.forEach((row) => {
selectIds.push(row.id);
});
} else {
selectIds = this.$refs.apiScenarioList.selectAllIds;
}
if (selectIds.length < 1) {
this.isSaving = false;
this.$warning(this.$t("test_track.plan_view.please_choose_test_case"));
@ -169,13 +167,6 @@ export default {
param.envMap = strMapToObj(envMap);
param.envGroupId = envGroupId;
param.selectIds = selectIds;
//
let params = this.$refs.apiScenarioList.condition;
if (params.selectAll) {
let result = await this.getAllId(params);
param.selectIds = result;
}
this.loading = true;
uiAutomationRelevance(param)
.then(() => {