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-07-29 19:10:40 +08:00 committed by xiaomeinvG
parent 337d2dbf0d
commit e799f64805
8 changed files with 170 additions and 74 deletions

View File

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

View File

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

View File

@ -30,7 +30,8 @@ import io.metersphere.track.request.report.QueryTestPlanReportRequest;
import io.metersphere.track.request.report.TestPlanReportSaveRequest; import io.metersphere.track.request.report.TestPlanReportSaveRequest;
import io.metersphere.track.request.testcase.QueryTestPlanRequest; import io.metersphere.track.request.testcase.QueryTestPlanRequest;
import io.metersphere.track.request.testplan.LoadCaseRequest; 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.CollectionUtils;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -584,7 +585,8 @@ public class TestPlanReportService {
TestPlanExecutionQueue testPlanExecutionQueue = planExecutionQueueList.get(0); TestPlanExecutionQueue testPlanExecutionQueue = planExecutionQueueList.get(0);
TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(testPlanExecutionQueue.getTestPlanId()); TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(testPlanExecutionQueue.getTestPlanId());
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRunModeConfig()); 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()); runRequest.setReportId(testPlanExecutionQueue.getReportId());
testPlanService.runPlan(runRequest); testPlanService.runPlan(runRequest);
} }

View File

@ -44,8 +44,9 @@ import io.metersphere.track.request.testcase.QueryTestPlanRequest;
import io.metersphere.track.request.testplan.AddTestPlanRequest; import io.metersphere.track.request.testplan.AddTestPlanRequest;
import io.metersphere.track.request.testplan.LoadCaseReportRequest; import io.metersphere.track.request.testplan.LoadCaseReportRequest;
import io.metersphere.track.request.testplan.LoadCaseRequest; 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.request.testplancase.QueryTestPlanCaseRequest;
import io.metersphere.track.service.utils.TestPlanRequestUtil;
import io.metersphere.utils.LoggerUtil; import io.metersphere.utils.LoggerUtil;
import org.apache.commons.beanutils.BeanMap; import org.apache.commons.beanutils.BeanMap;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
@ -974,11 +975,27 @@ public class TestPlanService {
LogUtil.error(e); LogUtil.error(e);
} }
if (runModeConfig == null) { if (runModeConfig == null) {
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 = new RunModeConfigDTO();
runModeConfig.setMode(RunModeConstants.SERIAL.name()); runModeConfig.setMode(testPlanRunRequest.getMode());
runModeConfig.setReportType("iddReport"); runModeConfig.setReportType(testPlanRunRequest.getReportType());
if (testPlanRunRequest.getEnvMap() == null) {
runModeConfig.setEnvMap(new HashMap<>()); runModeConfig.setEnvMap(new HashMap<>());
runModeConfig.setOnSampleError(false); } else {
runModeConfig.setEnvMap(testPlanRunRequest.getEnvMap());
}
runModeConfig.setOnSampleError(testPlanRunRequest.isOnSampleError());
}
} else {
runModeConfig = buildRunModeConfigDTO();
}
} else { } else {
if (runModeConfig.getEnvMap() == null) { if (runModeConfig.getEnvMap() == null) {
runModeConfig.setEnvMap(new HashMap<>()); runModeConfig.setEnvMap(new HashMap<>());
@ -1029,6 +1046,15 @@ public class TestPlanService {
return planReportId; 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) { private Map<String, String> executeApiTestCase(String triggerMode, String planReportId, String userId, List<String> planCaseIds, RunModeConfigDTO runModeConfig) {
BatchRunDefinitionRequest request = new BatchRunDefinitionRequest(); BatchRunDefinitionRequest request = new BatchRunDefinitionRequest();
request.setTriggerMode(triggerMode); request.setTriggerMode(triggerMode);
@ -1118,6 +1144,24 @@ public class TestPlanService {
return returnMap; return returnMap;
} }
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) { public String getLogDetails(String id) {
TestPlan plan = testPlanMapper.selectByPrimaryKey(id); TestPlan plan = testPlanMapper.selectByPrimaryKey(id);
if (plan != null) { if (plan != null) {
@ -2074,7 +2118,7 @@ public class TestPlanService {
return envMap; return envMap;
} }
public String runPlan(TestplanRunRequest testplanRunRequest) { public String runPlan(TestPlanRunRequest testplanRunRequest) {
//检查测试计划下有没有可以执行的用例 //检查测试计划下有没有可以执行的用例
if (!haveExecCase(testplanRunRequest.getTestPlanId()) && !haveUiCase(testplanRunRequest.getTestPlanId())) { if (!haveExecCase(testplanRunRequest.getTestPlanId()) && !haveUiCase(testplanRunRequest.getTestPlanId())) {
MSException.throwException(Translator.get("plan_warning")); MSException.throwException(Translator.get("plan_warning"));
@ -2091,7 +2135,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(); RunModeConfigDTO runModeConfig = new RunModeConfigDTO();
runModeConfig.setEnvironmentType(testplanRunRequest.getEnvironmentType()); runModeConfig.setEnvironmentType(testplanRunRequest.getEnvironmentType());
if (StringUtils.equals(envType, EnvironmentType.JSON.name()) && !envMap.isEmpty()) { if (StringUtils.equals(envType, EnvironmentType.JSON.name()) && !envMap.isEmpty()) {
@ -2103,7 +2147,7 @@ public class TestPlanService {
} }
runModeConfig.setMode(testplanRunRequest.getMode()); runModeConfig.setMode(testplanRunRequest.getMode());
runModeConfig.setResourcePoolId(testplanRunRequest.getResourcePoolId()); runModeConfig.setResourcePoolId(testplanRunRequest.getResourcePoolId());
runModeConfig.setOnSampleError(Boolean.parseBoolean(testplanRunRequest.getOnSampleError())); runModeConfig.setOnSampleError(testplanRunRequest.isOnSampleError());
if (StringUtils.isBlank(testplanRunRequest.getReportType())) { if (StringUtils.isBlank(testplanRunRequest.getReportType())) {
runModeConfig.setReportType("iddReport"); runModeConfig.setReportType("iddReport");
} else { } else {
@ -2116,7 +2160,7 @@ public class TestPlanService {
return runModeConfig; return runModeConfig;
} }
private void updatePlan(TestplanRunRequest testplanRunRequest, String testPlanId) { private void updatePlan(TestPlanRunRequest testplanRunRequest, String testPlanId) {
String request = JSON.toJSONString(testplanRunRequest); String request = JSON.toJSONString(testplanRunRequest);
TestPlanWithBLOBs testPlanWithBLOBs = testPlanMapper.selectByPrimaryKey(testPlanId); TestPlanWithBLOBs testPlanWithBLOBs = testPlanMapper.selectByPrimaryKey(testPlanId);
if (testPlanWithBLOBs.getRunModeConfig() == null || !(StringUtils.equals(request, testPlanWithBLOBs.getRunModeConfig()))) { if (testPlanWithBLOBs.getRunModeConfig() == null || !(StringUtils.equals(request, testPlanWithBLOBs.getRunModeConfig()))) {
@ -2293,7 +2337,7 @@ public class TestPlanService {
return extTestPlanMapper.list(request); return extTestPlanMapper.list(request);
} }
public void runBatch(TestplanRunRequest request) { public void runBatch(TestPlanRunRequest request) {
List<String> ids = request.getTestPlanIds(); List<String> ids = request.getTestPlanIds();
if (CollectionUtils.isEmpty(ids) && !request.getIsAll()) { if (CollectionUtils.isEmpty(ids) && !request.getIsAll()) {
return; return;
@ -2360,7 +2404,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<>(); List<TestPlanExecutionQueue> planExecutionQueues = new ArrayList<>();
String resourceId = UUID.randomUUID().toString(); String resourceId = UUID.randomUUID().toString();
final int[] nextNum = {testPlanExecutionQueueService.getNextNum(resourceId)}; final int[] nextNum = {testPlanExecutionQueueService.getNextNum(resourceId)};
@ -2379,7 +2423,7 @@ public class TestPlanService {
return planExecutionQueues; 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)) { if (CollectionUtils.isNotEmpty(planExecutionQueues)) {
Thread thread = new Thread(new Runnable() { Thread thread = new Thread(new Runnable() {
@Override @Override
@ -2389,14 +2433,16 @@ public class TestPlanService {
TestPlanExecutionQueue planExecutionQueue = planExecutionQueues.get(0); TestPlanExecutionQueue planExecutionQueue = planExecutionQueues.get(0);
TestPlanWithBLOBs testPlan = testPlanMap.get(planExecutionQueue.getTestPlanId()); TestPlanWithBLOBs testPlan = testPlanMap.get(planExecutionQueue.getTestPlanId());
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRunModeConfig()); 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()); runRequest.setReportId(planExecutionQueue.getReportId());
runPlan(runRequest); runPlan(runRequest);
} else { } else {
for (TestPlanExecutionQueue planExecutionQueue : planExecutionQueues) { for (TestPlanExecutionQueue planExecutionQueue : planExecutionQueues) {
TestPlanWithBLOBs testPlan = testPlanMap.get(planExecutionQueue.getTestPlanId()); TestPlanWithBLOBs testPlan = testPlanMap.get(planExecutionQueue.getTestPlanId());
JSONObject jsonObject = JSONObject.parseObject(testPlan.getRunModeConfig()); 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()); runRequest.setReportId(planExecutionQueue.getReportId());
runPlan(runRequest); runPlan(runRequest);
} }
@ -2407,7 +2453,7 @@ public class TestPlanService {
} }
} }
public void updateRunModeConfig(TestplanRunRequest testplanRunRequest) { public void updateRunModeConfig(TestPlanRunRequest testplanRunRequest) {
String testPlanId = testplanRunRequest.getTestPlanId(); String testPlanId = testplanRunRequest.getTestPlanId();
updatePlan(testplanRunRequest, testPlanId); 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

@ -146,7 +146,8 @@
<div class="mode-row" v-if="runConfig.mode === 'serial'"> <div class="mode-row" v-if="runConfig.mode === 'serial'">
<el-checkbox v-model="runConfig.onSampleError">{{ <el-checkbox v-model="runConfig.onSampleError">{{
$t("api_test.fail_to_stop") $t("api_test.fail_to_stop")
}}</el-checkbox> }}
</el-checkbox>
</div> </div>
<div class="mode-row" v-if="haveUICase"> <div class="mode-row" v-if="haveUICase">
@ -163,16 +164,19 @@
<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-dropdown @command="handleCommand" style="margin-left: 5px">
<el-button type="primary"> <el-button type="primary">
{{ $t("load_test.save_and_run") {{
$t("load_test.save_and_run")
}}<i class="el-icon-arrow-down el-icon--right"></i> }}<i class="el-icon-arrow-down el-icon--right"></i>
</el-button> </el-button>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="run">{{ <el-dropdown-item command="run">{{
$t("load_test.save_and_run") $t("load_test.save_and_run")
}}</el-dropdown-item> }}
</el-dropdown-item>
<el-dropdown-item command="save">{{ <el-dropdown-item command="save">{{
$t("commons.save") $t("commons.save")
}}</el-dropdown-item> }}
</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</div> </div>
@ -184,9 +188,8 @@
<script> <script>
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter"; import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
import EnvPopover from "@/business/components/api/automation/scenario/EnvPopover"; import EnvPopover from "@/business/components/api/automation/scenario/EnvPopover";
import { strMapToObj } from "@/common/js/utils"; import {hasLicense, strMapToObj} from "@/common/js/utils";
import {ENV_TYPE} from "@/common/js/constants"; import {ENV_TYPE} from "@/common/js/constants";
import { hasLicense } from "@/common/js/utils";
export default { export default {
name: "MsPlanRunModeWithEnv", name: "MsPlanRunModeWithEnv",
@ -256,7 +259,12 @@ export default {
}, },
}, },
methods: { methods: {
open(testType) { 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.runModeVisible = true;
this.testType = testType; this.testType = testType;
this.getResourcePools(); this.getResourcePools();
@ -359,6 +367,7 @@ export default {
text-align: right; text-align: right;
padding-right: 10px; padding-right: 10px;
} }
.env-container .content { .env-container .content {
width: 163px; width: 163px;
} }
@ -382,6 +391,7 @@ export default {
margin-top: 25px; margin-top: 25px;
align-items: flex-start; align-items: flex-start;
} }
.other-content { .other-content {
height: 100%; height: 100%;
} }

View File

@ -267,11 +267,14 @@
</ms-table-column> </ms-table-column>
</span> </span>
<template v-slot:opt-before="scope"> <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']" @exec="handleRun(scope.row)" v-permission="['PROJECT_TRACK_PLAN:READ+RUN']"
/> />
<ms-table-operator-button :tip="$t('commons.edit')" icon="el-icon-edit" <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"/> style="margin-right: 10px"/>
</template> </template>
<template v-slot:opt-behind="scope"> <template v-slot:opt-behind="scope">
@ -294,7 +297,8 @@
<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') }} {{ $t('commons.delete') }}
</el-dropdown-item> </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') }} {{ $t('commons.trigger_mode.schedule') }}
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
@ -326,7 +330,8 @@
<el-radio label="serial">{{ $t("run_mode.serial") }}</el-radio> <el-radio label="serial">{{ $t("run_mode.serial") }}</el-radio>
<el-radio label="parallel">{{ $t("run_mode.parallel") }}</el-radio> <el-radio label="parallel">{{ $t("run_mode.parallel") }}</el-radio>
</el-radio-group> </el-radio-group>
</div><br/> </div>
<br/>
<span>运行模式仅对测试计划间有效</span> <span>运行模式仅对测试计划间有效</span>
<template v-slot:footer> <template v-slot:footer>
<ms-dialog-footer @cancel="closeExecute" @confirm="handleRunBatch"/> <ms-dialog-footer @cancel="closeExecute" @confirm="handleRunBatch"/>
@ -348,7 +353,9 @@ import {TEST_PLAN_CONFIGS} from "../../../common/components/search/search-compon
import { import {
_filter, _filter,
_sort, _sort,
deepClone, getCustomTableHeader, getCustomTableWidth, deepClone,
getCustomTableHeader,
getCustomTableWidth,
getLastTableSortField, getLastTableSortField,
saveLastTableSortField saveLastTableSortField
} from "@/common/js/tableUtils"; } from "@/common/js/tableUtils";
@ -361,7 +368,8 @@ import {
getCurrentProjectID, getCurrentProjectID,
getCurrentUser, getCurrentUser,
getCurrentUserId, getCurrentUserId,
hasPermission, operationConfirm hasPermission,
operationConfirm
} from "@/common/js/utils"; } from "@/common/js/utils";
import PlanRunModeWithEnv from "@/business/components/track/plan/common/PlanRunModeWithEnv"; import PlanRunModeWithEnv from "@/business/components/track/plan/common/PlanRunModeWithEnv";
import TestPlanReportReview from "@/business/components/track/report/components/TestPlanReportReview"; import TestPlanReportReview from "@/business/components/track/report/components/TestPlanReportReview";
@ -633,8 +641,7 @@ export default {
if (this.condition.selectAll) { if (this.condition.selectAll) {
param.isAll = true; param.isAll = true;
param.queryTestPlanRequest = this.condition param.queryTestPlanRequest = this.condition
} } else {
else {
this.$refs.testPlanLitTable.selectRows.forEach((item) => { this.$refs.testPlanLitTable.selectRows.forEach((item) => {
ids.push(item.id) ids.push(item.id)
}); });
@ -771,7 +778,7 @@ export default {
let r = await this.haveUIScenario(); let r = await this.haveUIScenario();
this.haveUICase = r.data.data; this.haveUICase = r.data.data;
if (haveExecCase || this.haveUICase) { if (haveExecCase || this.haveUICase) {
this.$refs.runMode.open('API'); this.$refs.runMode.open('API', row.runModeConfig);
} else { } else {
this.$router.push('/track/plan/view/' + row.id); this.$router.push('/track/plan/view/' + row.id);
} }
@ -788,7 +795,10 @@ export default {
environmentType, environmentType,
environmentGroupId, environmentGroupId,
browser, browser,
headlessEnabled headlessEnabled,
retryEnable,
retryNum,
triggerMode
} = config; } = config;
let param = {mode, reportType, onSampleError, runWithinResourcePool, resourcePoolId, envMap}; let param = {mode, reportType, onSampleError, runWithinResourcePool, resourcePoolId, envMap};
param.testPlanId = this.currentPlanId; param.testPlanId = this.currentPlanId;
@ -812,7 +822,7 @@ export default {
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
}); });
} }
this.initTableData();
}, },
saveFollow(row) { saveFollow(row) {
if (row.showFollow) { if (row.showFollow) {

View File

@ -2,11 +2,13 @@
<div> <div>
<el-row> <el-row>
<el-col :span="12" v-if="caseCharData && caseCharData.length > 0"> <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>
<el-col :span="12" v-if="scenarioCharData && scenarioCharData.length > 0"> <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 :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-col>
</el-row> </el-row>
</div> </div>
@ -18,6 +20,7 @@ import MsPieChart from "@/business/components/common/components/MsPieChart";
import MsDoughnutPieChart from "@/business/components/common/components/MsDoughnutPieChart"; import MsDoughnutPieChart from "@/business/components/common/components/MsDoughnutPieChart";
import ApiScenarioCharResult import ApiScenarioCharResult
from "@/business/components/track/plan/view/comonents/report/detail/component/ApiScenarioCharResult"; from "@/business/components/track/plan/view/comonents/report/detail/component/ApiScenarioCharResult";
export default { export default {
name: "ApiResult", name: "ApiResult",
components: {ApiScenarioCharResult, MsDoughnutPieChart, MsPieChart}, components: {ApiScenarioCharResult, MsDoughnutPieChart, MsPieChart},
@ -82,12 +85,14 @@ export default {
} }
let stepCharData = []; let stepCharData = [];
if (this.apiResult.apiScenarioStepData && this.apiResult.apiScenarioStepData.length > 0) {
for (let i = 0; i < this.apiResult.apiScenarioStepData.length; i++) { for (let i = 0; i < this.apiResult.apiScenarioStepData.length; i++) {
let stepItem = this.apiResult.apiScenarioStepData[i]; let stepItem = this.apiResult.apiScenarioStepData[i];
let data = this.getDataByStatus(stepItem.status); let data = this.getDataByStatus(stepItem.status);
data.value = stepItem.count; data.value = stepItem.count;
stepCharData.push(data); stepCharData.push(data);
} }
}
this.scenarioCharData = apiScenarioData; this.scenarioCharData = apiScenarioData;
this.stepCharData = stepCharData; this.stepCharData = stepCharData;