feat(测试跟踪): 测试计划保存的运行环境回显,并且作为当前计划下所有用例的环境的默认值

--user=郭雨琦
--story=1008894

https://www.tapd.cn/55049933/prong/stories/view/1155049933001008894

--story=1008895

https://www.tapd.cn/55049933/prong/stories/view/1155049933001008895
This commit is contained in:
guoyuqi 2022-08-01 17:34:39 +08:00 committed by xiaomeinvG
parent 623f8bfedf
commit 39012deca8
8 changed files with 291 additions and 210 deletions

View File

@ -1,7 +1,6 @@
package io.metersphere.track.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.api.dto.datacount.request.ScheduleInfoRequest;
@ -18,7 +17,7 @@ import io.metersphere.track.dto.*;
import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest;
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
import io.metersphere.track.request.testplan.AddTestPlanRequest;
import io.metersphere.track.request.testplan.TestplanRunRequest;
import io.metersphere.track.request.testplan.TestPlanRunRequest;
import io.metersphere.track.request.testplancase.TestCaseRelevanceRequest;
import io.metersphere.track.service.TestPlanProjectService;
import io.metersphere.track.service.TestPlanService;
@ -206,18 +205,18 @@ public class TestPlanController {
@PostMapping("/edit/runModeConfig")
public void updateRunModeConfig(@RequestBody TestplanRunRequest testplanRunRequest) {
testPlanService.updateRunModeConfig(testplanRunRequest);
public void updateRunModeConfig(@RequestBody TestPlanRunRequest testplanRunRequest) {
testPlanService.updateRunModeConfig(testplanRunRequest);
}
@PostMapping("/run")
public String run(@RequestBody TestplanRunRequest testplanRunRequest) {
public String run(@RequestBody TestPlanRunRequest testplanRunRequest) {
return testPlanService.runPlan(testplanRunRequest);
}
@PostMapping(value = "/run/batch")
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanService.class)
public void runBatch(@RequestBody TestplanRunRequest request) {
@MsAuditLog(module = OperLogModule.TRACK_TEST_PLAN, type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.testPlanIds)", msClass = TestPlanService.class)
public void runBatch(@RequestBody TestPlanRunRequest request) {
request.setTriggerMode(TriggerMode.BATCH.name());
testPlanService.runBatch(request);
}

View File

@ -9,22 +9,22 @@ import java.util.Map;
@Getter
@Setter
public class TestplanRunRequest {
public class TestPlanRunRequest {
private String testPlanId;
private String projectId;
private String userId;
private String triggerMode;//触发方式
private String mode;//运行模式
private String reportType;//报告展示方式
private String onSampleError;//是否失败停止
private String runWithinResourcePool;//是否选择资源池
private boolean onSampleError;//是否失败停止
private boolean runWithinResourcePool;//是否选择资源池
private String resourcePoolId;//资源池Id
private Map<String, String> envMap;
private String environmentType;
private String environmentGroupId;
private List<String> testPlanIds;
private Boolean isAll;
private String reportId;
private String reportId;
private QueryTestPlanRequest queryTestPlanRequest;
}

View File

@ -23,7 +23,8 @@ import io.metersphere.track.request.report.QueryTestPlanReportRequest;
import io.metersphere.track.request.report.TestPlanReportSaveRequest;
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
import io.metersphere.track.request.testplan.LoadCaseRequest;
import io.metersphere.track.request.testplan.TestplanRunRequest;
import io.metersphere.track.request.testplan.TestPlanRunRequest;
import io.metersphere.track.service.utils.TestPlanRequestUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
@ -496,7 +497,8 @@ public class TestPlanReportService {
TestPlanExecutionQueue testPlanExecutionQueue = planExecutionQueueList.get(0);
TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(testPlanExecutionQueue.getTestPlanId());
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRunModeConfig());
TestplanRunRequest runRequest = JSON.toJavaObject(jsonObject, TestplanRunRequest.class);
TestPlanRequestUtil.changeStringToBoolean(jsonObject);
TestPlanRunRequest runRequest = JSON.toJavaObject(jsonObject, TestPlanRunRequest.class);
runRequest.setReportId(testPlanExecutionQueue.getReportId());
testPlanService.runPlan(runRequest);
}

View File

@ -43,8 +43,9 @@ import io.metersphere.track.request.testcase.QueryTestPlanRequest;
import io.metersphere.track.request.testplan.AddTestPlanRequest;
import io.metersphere.track.request.testplan.LoadCaseReportRequest;
import io.metersphere.track.request.testplan.LoadCaseRequest;
import io.metersphere.track.request.testplan.TestplanRunRequest;
import io.metersphere.track.request.testplan.TestPlanRunRequest;
import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest;
import io.metersphere.track.service.utils.TestPlanRequestUtil;
import io.metersphere.utils.LoggerUtil;
import org.apache.commons.beanutils.BeanMap;
import org.apache.commons.collections.CollectionUtils;
@ -966,11 +967,27 @@ public class TestPlanService {
LogUtil.error(e);
}
if (runModeConfig == null) {
runModeConfig = new RunModeConfigDTO();
runModeConfig.setMode(RunModeConstants.SERIAL.name());
runModeConfig.setReportType("iddReport");
runModeConfig.setEnvMap(new HashMap<>());
runModeConfig.setOnSampleError(false);
TestPlanWithBLOBs testPlanWithBLOBs = testPlanMapper.selectByPrimaryKey(testPlanID);
if (StringUtils.isNotEmpty(testPlanWithBLOBs.getRunModeConfig())) {
JSONObject json = JSONObject.parseObject(testPlanWithBLOBs.getRunModeConfig());
TestPlanRequestUtil.changeStringToBoolean(json);
TestPlanRunRequest testPlanRunRequest = JSON.toJavaObject(json, TestPlanRunRequest.class);
if (StringUtils.equals("GROUP", testPlanRunRequest.getEnvironmentType()) && StringUtils.isBlank(testPlanRunRequest.getEnvironmentGroupId())) {
runModeConfig = buildRunModeConfigDTO();
} else {
runModeConfig = new RunModeConfigDTO();
runModeConfig.setMode(testPlanRunRequest.getMode());
runModeConfig.setReportType(testPlanRunRequest.getReportType());
if (testPlanRunRequest.getEnvMap() == null) {
runModeConfig.setEnvMap(new HashMap<>());
} else {
runModeConfig.setEnvMap(testPlanRunRequest.getEnvMap());
}
runModeConfig.setOnSampleError(testPlanRunRequest.isOnSampleError());
}
} else {
runModeConfig = buildRunModeConfigDTO();
}
} else {
if (runModeConfig.getEnvMap() == null) {
runModeConfig.setEnvMap(new HashMap<>());
@ -1014,6 +1031,15 @@ public class TestPlanService {
return planReportId;
}
private RunModeConfigDTO buildRunModeConfigDTO() {
RunModeConfigDTO runModeConfig = new RunModeConfigDTO();
runModeConfig.setMode(RunModeConstants.SERIAL.name());
runModeConfig.setReportType("iddReport");
runModeConfig.setEnvMap(new HashMap<>());
runModeConfig.setOnSampleError(false);
return runModeConfig;
}
private Map<String, String> executeApiTestCase(String triggerMode, String planReportId, String userId, List<String> planCaseIds, RunModeConfigDTO runModeConfig) {
BatchRunDefinitionRequest request = new BatchRunDefinitionRequest();
request.setTriggerMode(triggerMode);
@ -1117,6 +1143,24 @@ public class TestPlanService {
return loadCaseReportMap;
}
public String getLogDetails(List<String> ids) {
if (CollectionUtils.isNotEmpty(ids)) {
TestPlanExample testPlanExample = new TestPlanExample();
testPlanExample.createCriteria().andIdIn(ids);
List<TestPlan> planList = testPlanMapper.selectByExample(testPlanExample);
if (CollectionUtils.isNotEmpty(planList)) {
List<OperatingLogDetails> detailsList = new ArrayList<>();
for (TestPlan plan : planList) {
List<DetailColumn> columns = ReflexObjectUtil.getColumns(planList.get(0), TestPlanReference.testPlanColumns);
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(plan.getId()), plan.getProjectId(), plan.getName(), plan.getCreator(), columns);
detailsList.add(details);
}
return JSON.toJSONString(detailsList);
}
}
return null;
}
public String getLogDetails(String id) {
TestPlan plan = testPlanMapper.selectByPrimaryKey(id);
if (plan != null) {
@ -1925,7 +1969,7 @@ public class TestPlanService {
return envMap;
}
public String runPlan(TestplanRunRequest testplanRunRequest) {
public String runPlan(TestPlanRunRequest testplanRunRequest) {
//检查是否有可以执行的用例
if (!haveExecCase(testplanRunRequest.getTestPlanId())) {
MSException.throwException(Translator.get("plan_warning"));
@ -1942,7 +1986,7 @@ public class TestPlanService {
}
private RunModeConfigDTO getRunModeConfigDTO(TestplanRunRequest testplanRunRequest, String envType, Map<String, String> envMap, String environmentGroupId, String testPlanId) {
private RunModeConfigDTO getRunModeConfigDTO(TestPlanRunRequest testplanRunRequest, String envType, Map<String, String> envMap, String environmentGroupId, String testPlanId) {
RunModeConfigDTO runModeConfig = new RunModeConfigDTO();
runModeConfig.setEnvironmentType(testplanRunRequest.getEnvironmentType());
if (StringUtils.equals(envType, EnvironmentType.JSON.name()) && !envMap.isEmpty()) {
@ -1954,7 +1998,7 @@ public class TestPlanService {
}
runModeConfig.setMode(testplanRunRequest.getMode());
runModeConfig.setResourcePoolId(testplanRunRequest.getResourcePoolId());
runModeConfig.setOnSampleError(Boolean.parseBoolean(testplanRunRequest.getOnSampleError()));
runModeConfig.setOnSampleError(testplanRunRequest.isOnSampleError());
if (StringUtils.isBlank(testplanRunRequest.getReportType())) {
runModeConfig.setReportType("iddReport");
} else {
@ -1963,7 +2007,7 @@ public class TestPlanService {
return runModeConfig;
}
private void updatePlan(TestplanRunRequest testplanRunRequest, String testPlanId) {
private void updatePlan(TestPlanRunRequest testplanRunRequest, String testPlanId) {
String request = JSON.toJSONString(testplanRunRequest);
TestPlanWithBLOBs testPlanWithBLOBs = testPlanMapper.selectByPrimaryKey(testPlanId);
if (testPlanWithBLOBs.getRunModeConfig() == null || !(StringUtils.equals(request, testPlanWithBLOBs.getRunModeConfig()))) {
@ -2136,7 +2180,7 @@ public class TestPlanService {
return extTestPlanMapper.list(request);
}
public void runBatch(TestplanRunRequest request) {
public void runBatch(TestPlanRunRequest request) {
List<String> ids = request.getTestPlanIds();
if (CollectionUtils.isEmpty(ids) && !request.getIsAll()) {
return;
@ -2201,7 +2245,7 @@ public class TestPlanService {
}
private List<TestPlanExecutionQueue> getTestPlanExecutionQueues(TestplanRunRequest request, Map<String, String> executeQueue) {
private List<TestPlanExecutionQueue> getTestPlanExecutionQueues(TestPlanRunRequest request, Map<String, String> executeQueue) {
List<TestPlanExecutionQueue> planExecutionQueues = new ArrayList<>();
String resourceId = UUID.randomUUID().toString();
final int[] nextNum = {testPlanExecutionQueueService.getNextNum(resourceId)};
@ -2220,7 +2264,7 @@ public class TestPlanService {
return planExecutionQueues;
}
private void runByMode(TestplanRunRequest request, Map<String, TestPlanWithBLOBs> testPlanMap, List<TestPlanExecutionQueue> planExecutionQueues) {
private void runByMode(TestPlanRunRequest request, Map<String, TestPlanWithBLOBs> testPlanMap, List<TestPlanExecutionQueue> planExecutionQueues) {
if (CollectionUtils.isNotEmpty(planExecutionQueues)) {
Thread thread = new Thread(new Runnable() {
@Override
@ -2230,14 +2274,16 @@ public class TestPlanService {
TestPlanExecutionQueue planExecutionQueue = planExecutionQueues.get(0);
TestPlanWithBLOBs testPlan = testPlanMap.get(planExecutionQueue.getTestPlanId());
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRunModeConfig());
TestplanRunRequest runRequest = JSON.toJavaObject(jsonObject, TestplanRunRequest.class);
TestPlanRequestUtil.changeStringToBoolean(jsonObject);
TestPlanRunRequest runRequest = JSON.toJavaObject(jsonObject, TestPlanRunRequest.class);
runRequest.setReportId(planExecutionQueue.getReportId());
runPlan(runRequest);
} else {
for (TestPlanExecutionQueue planExecutionQueue : planExecutionQueues) {
TestPlanWithBLOBs testPlan = testPlanMap.get(planExecutionQueue.getTestPlanId());
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRunModeConfig());
TestplanRunRequest runRequest = JSON.toJavaObject(jsonObject, TestplanRunRequest.class);
TestPlanRequestUtil.changeStringToBoolean(jsonObject);
TestPlanRunRequest runRequest = JSON.toJavaObject(jsonObject, TestPlanRunRequest.class);
runRequest.setReportId(planExecutionQueue.getReportId());
runPlan(runRequest);
}
@ -2248,7 +2294,7 @@ public class TestPlanService {
}
}
public void updateRunModeConfig(TestplanRunRequest testplanRunRequest) {
public void updateRunModeConfig(TestPlanRunRequest testplanRunRequest) {
String testPlanId = testplanRunRequest.getTestPlanId();
updatePlan(testplanRunRequest, testPlanId);
}

View File

@ -0,0 +1,24 @@
package io.metersphere.track.service.utils;
import com.alibaba.fastjson.JSONObject;
public class TestPlanRequestUtil {
private static final String ON_SAMPLE_ERROR = "onSampleError";
private static final String RUN_WITHIN_RESOURCE_POOL = "runWithinResourcePool";
public static void changeStringToBoolean(JSONObject runModeConfig) {
if (runModeConfig != null) {
if (runModeConfig.get(ON_SAMPLE_ERROR).equals("true") || runModeConfig.get(ON_SAMPLE_ERROR).equals(true)) {
runModeConfig.put(ON_SAMPLE_ERROR, true);
} else {
runModeConfig.put(ON_SAMPLE_ERROR, false);
}
if (runModeConfig.get(RUN_WITHIN_RESOURCE_POOL).equals("true") || runModeConfig.get(RUN_WITHIN_RESOURCE_POOL).equals(true)) {
runModeConfig.put(RUN_WITHIN_RESOURCE_POOL, true);
} else {
runModeConfig.put(RUN_WITHIN_RESOURCE_POOL, false);
}
}
}
}

View File

@ -76,14 +76,14 @@
</div>
<template v-slot:footer>
<div class="dialog-footer" v-if="showSave">
<el-button @click="close">{{$t('commons.cancel')}}</el-button>
<el-button @click="close">{{ $t('commons.cancel') }}</el-button>
<el-dropdown @command="handleCommand" style="margin-left: 5px">
<el-button type="primary">
{{$t('load_test.save_and_run')}}<i class="el-icon-arrow-down el-icon--right"></i>
{{ $t('load_test.save_and_run') }}<i class="el-icon-arrow-down el-icon--right"></i>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="run">{{$t('load_test.save_and_run')}}</el-dropdown-item>
<el-dropdown-item command="save">{{$t('commons.save')}}</el-dropdown-item>
<el-dropdown-item command="run">{{ $t('load_test.save_and_run') }}</el-dropdown-item>
<el-dropdown-item command="save">{{ $t('commons.save') }}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
@ -93,158 +93,162 @@
</template>
<script>
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
import EnvPopover from "@/business/components/api/automation/scenario/EnvPopover";
import {strMapToObj} from "@/common/js/utils";
import {ENV_TYPE} from "@/common/js/constants";
import {hasLicense} from "@/common/js/utils";
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
import EnvPopover from "@/business/components/api/automation/scenario/EnvPopover";
import {hasLicense, strMapToObj} from "@/common/js/utils";
import {ENV_TYPE} from "@/common/js/constants";
export default {
name: "MsPlanRunModeWithEnv",
components: {EnvPopover, MsDialogFooter},
data() {
return {
runModeVisible: false,
testType: null,
resourcePools: [],
runConfig: {
mode: "serial",
reportType: "iddReport",
onSampleError: false,
runWithinResourcePool: false,
resourcePoolId: null,
envMap: new Map(),
environmentGroupId: "",
environmentType: ENV_TYPE.JSON,
},
isHasLicense: hasLicense(),
projectEnvListMap: {},
projectList: [],
projectIds: new Set(),
options: [{
value: 'confirmAndRun',
label: this.$t('load_test.save_and_run')
}, {
value: 'save',
label: this.$t('commons.save')
}],
value: 'confirmAndRun'
};
export default {
name: "MsPlanRunModeWithEnv",
components: {EnvPopover, MsDialogFooter},
data() {
return {
runModeVisible: false,
testType: null,
resourcePools: [],
runConfig: {
mode: "serial",
reportType: "iddReport",
onSampleError: false,
runWithinResourcePool: false,
resourcePoolId: null,
envMap: new Map(),
environmentGroupId: "",
environmentType: ENV_TYPE.JSON,
},
isHasLicense: hasLicense(),
projectEnvListMap: {},
projectList: [],
projectIds: new Set(),
options: [{
value: 'confirmAndRun',
label: this.$t('load_test.save_and_run')
}, {
value: 'save',
label: this.$t('commons.save')
}],
value: 'confirmAndRun'
};
},
props: {
planCaseIds: {
type: Array,
},
props: {
planCaseIds: {
type: Array,
},
type: String,
planId: String,
showSave: {
type: Boolean,
default: false
},
type: String,
planId: String,
showSave: {
type: Boolean,
default: false
},
methods: {
open(testType) {
this.runModeVisible = true;
this.testType = testType;
this.getResourcePools();
this.getWsProjects();
},
changeMode() {
this.runConfig.onSampleError = false;
this.runConfig.runWithinResourcePool = false;
this.runConfig.resourcePoolId = null;
},
close() {
this.runConfig = {
mode: "serial",
reportType: "iddReport",
onSampleError: false,
runWithinResourcePool: false,
resourcePoolId: null,
envMap: new Map(),
environmentGroupId: "",
environmentType: ENV_TYPE.JSON
};
this.runModeVisible = false;
this.$emit('close');
},
handleRunBatch() {
this.$emit("handleRunBatch", this.runConfig);
this.close();
},
getResourcePools() {
this.result = this.$get('/testresourcepool/list/quota/valid', response => {
this.resourcePools = response.data;
});
},
setProjectEnvMap(projectEnvMap) {
this.runConfig.envMap = strMapToObj(projectEnvMap);
},
setEnvGroup(id) {
this.runConfig.environmentGroupId = id;
},
getWsProjects() {
this.$get("/project/getOwnerProjects", res => {
this.projectList = res.data;
})
},
showPopover() {
this.projectIds.clear();
let param = undefined;
let url = "";
if (this.type === 'apiCase') {
url = '/test/plan/api/case/env';
param = this.planCaseIds;
} else if (this.type === 'apiScenario') {
url = '/test/plan/api/scenario/env';
param = this.planCaseIds;
} else if (this.type === 'plan') {
url = '/test/plan/case/env';
param = {id: this.planId};
}
this.$post(url, param, res => {
let data = res.data;
if (data) {
this.projectEnvListMap = data;
for (let d in data) {
this.projectIds.add(d);
}
}
this.$refs.envPopover.openEnvSelect();
});
},
handleCommand(command) {
if (this.runConfig.runWithinResourcePool && this.runConfig.resourcePoolId == null) {
this.$warning(this.$t('workspace.env_group.please_select_run_within_resource_pool'));
return;
}
if (command === 'run') {
this.runConfig.isRun = true
this.handleRunBatch();
} else {
this.runConfig.isRun = false
this.handleRunBatch();
}
},
methods: {
open(testType, runModeConfig) {
if (runModeConfig) {
this.runConfig = JSON.parse(runModeConfig);
this.runConfig.onSampleError = this.runConfig.onSampleError === 'true' || this.runConfig.onSampleError === true;
this.runConfig.runWithinResourcePool = this.runConfig.runWithinResourcePool === 'true' || this.runConfig.runWithinResourcePool === true;
}
this.runModeVisible = true;
this.testType = testType;
this.getResourcePools();
this.getWsProjects();
},
};
changeMode() {
this.runConfig.onSampleError = false;
this.runConfig.runWithinResourcePool = false;
this.runConfig.resourcePoolId = null;
},
close() {
this.runConfig = {
mode: "serial",
reportType: "iddReport",
onSampleError: false,
runWithinResourcePool: false,
resourcePoolId: null,
envMap: new Map(),
environmentGroupId: "",
environmentType: ENV_TYPE.JSON
};
this.runModeVisible = false;
this.$emit('close');
},
handleRunBatch() {
this.$emit("handleRunBatch", this.runConfig);
this.close();
},
getResourcePools() {
this.result = this.$get('/testresourcepool/list/quota/valid', response => {
this.resourcePools = response.data;
});
},
setProjectEnvMap(projectEnvMap) {
this.runConfig.envMap = strMapToObj(projectEnvMap);
},
setEnvGroup(id) {
this.runConfig.environmentGroupId = id;
},
getWsProjects() {
this.$get("/project/getOwnerProjects", res => {
this.projectList = res.data;
})
},
showPopover() {
this.projectIds.clear();
let param = undefined;
let url = "";
if (this.type === 'apiCase') {
url = '/test/plan/api/case/env';
param = this.planCaseIds;
} else if (this.type === 'apiScenario') {
url = '/test/plan/api/scenario/env';
param = this.planCaseIds;
} else if (this.type === 'plan') {
url = '/test/plan/case/env';
param = {id: this.planId};
}
this.$post(url, param, res => {
let data = res.data;
if (data) {
this.projectEnvListMap = data;
for (let d in data) {
this.projectIds.add(d);
}
}
this.$refs.envPopover.openEnvSelect();
});
},
handleCommand(command) {
if (this.runConfig.runWithinResourcePool && this.runConfig.resourcePoolId == null) {
this.$warning(this.$t('workspace.env_group.please_select_run_within_resource_pool'));
return;
}
if (command === 'run') {
this.runConfig.isRun = true
this.handleRunBatch();
} else {
this.runConfig.isRun = false
this.handleRunBatch();
}
}
},
};
</script>
<style scoped>
.ms-mode-span {
margin-right: 10px;
}
.ms-mode-span {
margin-right: 10px;
}
.ms-mode-div {
margin-top: 20px;
}
.ms-mode-div {
margin-top: 20px;
}
.ms-failure-div {
margin-top: 10px;
}
.ms-failure-div {
margin-top: 10px;
}
.ms-failure-div-right {
padding-right: 10px;
}
.ms-failure-div-right {
padding-right: 10px;
}
</style>

View File

@ -266,11 +266,14 @@
</ms-table-column>
</span>
<template v-slot:opt-before="scope">
<ms-table-operator-button :tip="$t('api_test.run')" icon="el-icon-video-play" :class="[scope.row.status==='Archived'?'disable-run':'run-button']" :disabled="scope.row.status === 'Archived'"
<ms-table-operator-button :tip="$t('api_test.run')" icon="el-icon-video-play"
:class="[scope.row.status==='Archived'?'disable-run':'run-button']"
:disabled="scope.row.status === 'Archived'"
@exec="handleRun(scope.row)" v-permission="['PROJECT_TRACK_PLAN:READ+RUN']"
/>
/>
<ms-table-operator-button :tip="$t('commons.edit')" icon="el-icon-edit"
@exec="handleEdit(scope.row)" v-permission="['PROJECT_TRACK_PLAN:READ+EDIT']" :disabled="scope.row.status === 'Archived'"
@exec="handleEdit(scope.row)" v-permission="['PROJECT_TRACK_PLAN:READ+EDIT']"
:disabled="scope.row.status === 'Archived'"
style="margin-right: 10px"/>
</template>
<template v-slot:opt-behind="scope">
@ -290,10 +293,11 @@
<el-icon class="el-icon-more"></el-icon>
</el-link>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="delete" v-permission="['PROJECT_TRACK_PLAN:READ+DELETE']" >
<el-dropdown-item command="delete" v-permission="['PROJECT_TRACK_PLAN:READ+DELETE']">
{{ $t('commons.delete') }}
</el-dropdown-item>
<el-dropdown-item command="schedule_task" v-permission="['PROJECT_TRACK_PLAN:READ+SCHEDULE']" :disabled="scope.row.status === 'Archived'" >
<el-dropdown-item command="schedule_task" v-permission="['PROJECT_TRACK_PLAN:READ+SCHEDULE']"
:disabled="scope.row.status === 'Archived'">
{{ $t('commons.trigger_mode.schedule') }}
</el-dropdown-item>
</el-dropdown-menu>
@ -325,7 +329,8 @@
<el-radio label="serial">{{ $t("run_mode.serial") }}</el-radio>
<el-radio label="parallel">{{ $t("run_mode.parallel") }}</el-radio>
</el-radio-group>
</div><br/>
</div>
<br/>
<span>运行模式仅对测试计划间有效</span>
<template v-slot:footer>
<ms-dialog-footer @cancel="closeExecute" @confirm="handleRunBatch"/>
@ -347,7 +352,9 @@ import {TEST_PLAN_CONFIGS} from "../../../common/components/search/search-compon
import {
_filter,
_sort,
deepClone, getCustomTableHeader, getCustomTableWidth,
deepClone,
getCustomTableHeader,
getCustomTableWidth,
getLastTableSortField,
saveLastTableSortField
} from "@/common/js/tableUtils";
@ -356,12 +363,7 @@ import HeaderCustom from "@/business/components/common/head/HeaderCustom";
import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate";
import MsTag from "@/business/components/common/components/MsTag";
import MsTestPlanScheduleMaintain from "@/business/components/track/plan/components/ScheduleMaintain";
import {
getCurrentProjectID,
getCurrentUser,
getCurrentUserId,
hasPermission
} from "@/common/js/utils";
import {getCurrentProjectID, getCurrentUser, getCurrentUserId, hasPermission} from "@/common/js/utils";
import PlanRunModeWithEnv from "@/business/components/track/plan/common/PlanRunModeWithEnv";
import TestPlanReportReview from "@/business/components/track/report/components/TestPlanReportReview";
import MsTaskCenter from "@/business/components/task/TaskCenter";
@ -397,7 +399,7 @@ export default {
result: {},
cardResult: {},
enableDeleteTip: false,
showExecute:false,
showExecute: false,
queryPath: "/test/plan/list",
deletePath: "/test/plan/delete",
condition: {
@ -459,7 +461,7 @@ export default {
permission: ['PROJECT_TRACK_PLAN:READ+EDIT']
},
],
batchExecuteType:"serial"
batchExecuteType: "serial"
};
},
watch: {
@ -525,7 +527,7 @@ export default {
data.listObject.forEach(item => {
if (item.tags) {
item.tags = JSON.parse(item.tags);
if(item.tags.length===0){
if (item.tags.length === 0) {
item.tags = null;
}
}
@ -571,7 +573,7 @@ export default {
this.$set(item, "showFollow", showFollow);
})
});
this.tableData =data.listObject;
this.tableData = data.listObject;
});
},
copyData(status) {
@ -613,10 +615,10 @@ export default {
this.$refs.scheduleBatchSwitch.open(param, size, this.condition.selectAll, this.condition);
}
},
handleBatchExecute(){
handleBatchExecute() {
this.showExecute = true;
},
handleRunBatch(){
handleRunBatch() {
this.showExecute = false;
let mode = this.batchExecuteType;
let param = {mode};
@ -624,8 +626,7 @@ export default {
if (this.condition.selectAll) {
param.isAll = true;
param.queryTestPlanRequest = this.condition
}
else {
} else {
this.$refs.testPlanLitTable.selectRows.forEach((item) => {
ids.push(item.id)
});
@ -642,7 +643,7 @@ export default {
// this.$error(error.message);
});
},
closeExecute(){
closeExecute() {
this.showExecute = false;
},
statusChange(data) {
@ -760,7 +761,7 @@ export default {
this.$get("/test/plan/have/exec/case/" + row.id, res => {
const haveExecCase = res.data;
if (haveExecCase) {
this.$refs.runMode.open('API');
this.$refs.runMode.open('API', row.runModeConfig);
} else {
this.$router.push('/track/plan/view/' + row.id);
}
@ -775,7 +776,7 @@ export default {
resourcePoolId,
envMap,
environmentType,
environmentGroupId
environmentGroupId,
} = config;
let param = {mode, reportType, onSampleError, runWithinResourcePool, resourcePoolId, envMap};
param.testPlanId = this.currentPlanId;
@ -785,17 +786,17 @@ export default {
param.environmentType = environmentType;
param.environmentGroupId = environmentGroupId;
param.requestOriginator = "TEST_PLAN";
if(config.isRun === true){
if (config.isRun === true) {
this.$refs.taskCenter.open();
this.result = this.$post('test/plan/run/', param, () => {
this.$success(this.$t('commons.run_success'));
});
}else{
} else {
this.result = this.$post('test/plan/edit/runModeConfig', param, () => {
this.$success(this.$t('commons.save_success'));
});
}
this.initTableData();
},
saveFollow(row) {
if (row.showFollow) {

View File

@ -1,12 +1,14 @@
<template>
<div>
<el-row >
<el-row>
<el-col :span="12" v-if="caseCharData && caseCharData.length > 0">
<ms-doughnut-pie-chart style="margin-right: 200px" :name="$t('api_test.home_page.detail_card.single_case')" :data="caseCharData" ref="functionChar"/>
<ms-doughnut-pie-chart style="margin-right: 200px" :name="$t('api_test.home_page.detail_card.single_case')"
:data="caseCharData" ref="functionChar"/>
</el-col>
<el-col :span="12" v-if="scenarioCharData && scenarioCharData.length > 0">
<api-scenario-char-result :name="$t('test_track.plan.test_plan_api_scenario_count')" :data="scenarioCharData"/>
<api-scenario-char-result style="margin-top: -50px;" :name="$t('test_track.plan.test_plan_component_case_count')" :data="stepCharData"/>
<api-scenario-char-result style="margin-top: -50px;"
:name="$t('test_track.plan.test_plan_component_case_count')" :data="stepCharData"/>
</el-col>
</el-row>
</div>
@ -18,6 +20,7 @@ import MsPieChart from "@/business/components/common/components/MsPieChart";
import MsDoughnutPieChart from "@/business/components/common/components/MsDoughnutPieChart";
import ApiScenarioCharResult
from "@/business/components/track/plan/view/comonents/report/detail/component/ApiScenarioCharResult";
export default {
name: "ApiResult",
components: {ApiScenarioCharResult, MsDoughnutPieChart, MsPieChart},
@ -82,11 +85,13 @@ export default {
}
let stepCharData = [];
for (let i = 0; i < this.apiResult.apiScenarioStepData.length; i++) {
let stepItem = this.apiResult.apiScenarioStepData[i];
let data = this.getDataByStatus(stepItem.status);
data.value = stepItem.count;
stepCharData.push(data);
if (this.apiResult.apiScenarioStepData && this.apiResult.apiScenarioStepData.length > 0) {
for (let i = 0; i < this.apiResult.apiScenarioStepData.length; i++) {
let stepItem = this.apiResult.apiScenarioStepData[i];
let data = this.getDataByStatus(stepItem.status);
data.value = stepItem.count;
stepCharData.push(data);
}
}
this.scenarioCharData = apiScenarioData;