This commit is contained in:
fit2-zhao 2021-03-23 11:11:24 +08:00
commit 4978b9381f
58 changed files with 838 additions and 449 deletions

View File

@ -153,8 +153,18 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</exclusion>
<exclusion>
<artifactId>xstream</artifactId>
<groupId>com.thoughtworks.xstream</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- 排除jmeter中的 xstream 解决bug -->
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.16</version>
</dependency>
<dependency>
<groupId>org.python</groupId>

View File

@ -64,7 +64,6 @@ public class ApiAutomationController {
public void update(@RequestPart("request") SaveApiScenarioRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
apiAutomationService.update(request, bodyFiles);
}
@GetMapping("/delete/{id}")
public void delete(@PathVariable String id) {
apiAutomationService.delete(id);
@ -109,8 +108,16 @@ public class ApiAutomationController {
return apiAutomationService.run(request);
}
@PostMapping(value = "/run/jenkins")
public String runByJenkins(@RequestBody RunScenarioRequest request) {
request.setExecuteType(ExecuteType.Saved.name());
request.setTriggerMode(ApiRunMode.SCENARIO.name());
request.setRunMode(ApiRunMode.SCENARIO.name());
return apiAutomationService.run(request);
}
@PostMapping(value = "/run/batch")
public String runBatch(@RequestBody RunScenarioRequest request) {
public String runBatcah(@RequestBody RunScenarioRequest request) {
request.setExecuteType(ExecuteType.Saved.name());
request.setTriggerMode(ApiRunMode.SCENARIO.name());
request.setRunMode(ApiRunMode.SCENARIO.name());

View File

@ -12,6 +12,7 @@ import io.metersphere.api.dto.definition.request.ScheduleInfoSwaggerUrlRequest;
import io.metersphere.api.dto.swaggerurl.SwaggerTaskResult;
import io.metersphere.api.dto.swaggerurl.SwaggerUrlRequest;
import io.metersphere.api.service.ApiDefinitionService;
import io.metersphere.api.service.EsbApiParamService;
import io.metersphere.base.domain.ApiDefinition;
import io.metersphere.base.domain.Schedule;
import io.metersphere.commons.constants.RoleConstants;
@ -24,6 +25,7 @@ import io.metersphere.controller.request.ScheduleRequest;
import io.metersphere.service.CheckPermissionService;
import io.metersphere.service.ScheduleService;
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*;
@ -45,6 +47,8 @@ public class ApiDefinitionController {
private ApiDefinitionService apiDefinitionService;
@Resource
private CheckPermissionService checkPermissionService;
@Resource
private EsbApiParamService esbApiParamService;
@PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<ApiDefinitionResult>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiDefinitionRequest request) {
@ -97,6 +101,15 @@ public class ApiDefinitionController {
apiDefinitionService.deleteBatch(ids);
}
@PostMapping(value = "/updateEsbRequest")
public SaveApiDefinitionRequest updateEsbRequest(@RequestBody SaveApiDefinitionRequest request) {
if(StringUtils.equals(request.getMethod(),"ESB")){
//ESB的接口类型数据采用TCP方式去发送并将方法类型改为TCP 并修改发送数据
request = esbApiParamService.updateEsbRequest(request);
}
return request;
}
@PostMapping("/deleteBatchByParams")
public void deleteBatchByParams(@RequestBody ApiBatchRequest request) {
apiDefinitionService.deleteByParams(request);

View File

@ -58,6 +58,7 @@ public class Swagger2Parser extends SwaggerAbstractParser {
ApiModule parentNode = ApiDefinitionImportUtil.getSelectModule(importRequest.getModuleId());
String basePath = swagger.getBasePath();
for (String pathName : pathNames) {
Path path = paths.get(pathName);
Map<HttpMethod, Operation> operationMap = path.getOperationMap();
@ -68,6 +69,10 @@ public class Swagger2Parser extends SwaggerAbstractParser {
ApiDefinitionWithBLOBs apiDefinition = buildApiDefinition(request.getId(), operation, pathName, method.name(),importRequest);
parseParameters(operation, request);
addBodyHeader(request);
if (StringUtils.isNotBlank(basePath)) {
apiDefinition.setPath(basePath + apiDefinition.getPath());
request.setPath(basePath + request.getPath());
}
apiDefinition.setRequest(JSON.toJSONString(request));
apiDefinition.setResponse(JSON.toJSONString(parseResponse(operation, operation.getResponses())));
buildModule(parentNode, apiDefinition, operation.getTags());

View File

@ -236,7 +236,7 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
testPlanTestCaseService.updateTestCaseStates(ids, TestPlanTestCaseStatus.Failure.name());
}
} catch (Exception e) {
LogUtil.error(e.getMessage(), e);
}
}
sendTask(report, reportUrl, testResult);

View File

@ -145,7 +145,9 @@ public class ApiTestCaseService {
}
public ApiTestCaseWithBLOBs get(String id) {
return apiTestCaseMapper.selectByPrimaryKey(id);
ApiTestCaseWithBLOBs returnBlobs = apiTestCaseMapper.selectByPrimaryKey(id);
esbApiParamService.handleApiEsbParams(returnBlobs);
return returnBlobs;
}
public ApiTestCase create(SaveApiTestCaseRequest request, List<MultipartFile> bodyFiles) {
@ -435,6 +437,9 @@ public class ApiTestCaseService {
public Map<String, String> getRequest(ApiTestCaseRequest request) {
List<ApiTestCaseWithBLOBs> list = extApiTestCaseMapper.getRequest(request);
for (ApiTestCaseWithBLOBs model : list) {
esbApiParamService.handleApiEsbParams(model);
}
return list.stream().collect(Collectors.toMap(ApiTestCaseWithBLOBs::getId, ApiTestCaseWithBLOBs::getRequest));
}

View File

@ -10,6 +10,7 @@ import io.metersphere.api.dto.definition.SaveApiDefinitionRequest;
import io.metersphere.api.dto.definition.SaveApiTestCaseRequest;
import io.metersphere.api.dto.definition.request.sampler.MsTCPSampler;
import io.metersphere.api.dto.scenario.KeyValue;
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
import io.metersphere.base.domain.EsbApiParamsExample;
import io.metersphere.base.domain.EsbApiParamsWithBLOBs;
import io.metersphere.base.mapper.EsbApiParamsMapper;
@ -110,25 +111,76 @@ public class EsbApiParamService {
if (esbParamBlobs == null) {
return;
}
try {
if (StringUtils.isNotEmpty(res.getRequest())) {
JSONObject jsonObj = JSONObject.parseObject(res.getRequest());
JSONArray esbDataArray = JSONArray.parseArray(esbParamBlobs.getDataStruct());
jsonObj.put("esbDataStruct", esbDataArray);
JSONArray responseDataArray = JSONArray.parseArray(esbParamBlobs.getResponseDataStruct());
jsonObj.put("backEsbDataStruct", responseDataArray);
JSONObject backedScriptObj = JSONObject.parseObject(esbParamBlobs.getBackedScript());
jsonObj.put("backScript", backedScriptObj);
jsonObj.put("esbFrontedScript", esbParamBlobs.getFrontedScript());
if (StringUtils.isNotEmpty(res.getRequest())) {
JSONObject jsonObj = this.addEsbInfoToJsonString(esbParamBlobs, res.getRequest());
if (jsonObj != null) {
res.setRequest(jsonObj.toJSONString());
}
} catch (Exception e) {
}
// try {
// if (StringUtils.isNotEmpty(res.getRequest())) {
// JSONObject jsonObj = JSONObject.parseObject(res.getRequest());
//
// JSONArray esbDataArray = JSONArray.parseArray(esbParamBlobs.getDataStruct());
// jsonObj.put("esbDataStruct", esbDataArray);
//
// JSONArray responseDataArray = JSONArray.parseArray(esbParamBlobs.getResponseDataStruct());
// jsonObj.put("backEsbDataStruct", responseDataArray);
//
// JSONObject backedScriptObj = JSONObject.parseObject(esbParamBlobs.getBackedScript());
// jsonObj.put("backScript", backedScriptObj);
//
// jsonObj.put("esbFrontedScript", esbParamBlobs.getFrontedScript());
//
// res.setRequest(jsonObj.toJSONString());
// }
// } catch (Exception e) {
// }
}
public void handleApiEsbParams(ApiTestCaseWithBLOBs res) {
EsbApiParamsWithBLOBs esbParamBlobs = this.getEsbParamBLOBsByResourceID(res.getId());
if (esbParamBlobs == null) {
return;
}
if (StringUtils.isNotEmpty(res.getRequest())) {
JSONObject jsonObj = this.addEsbInfoToJsonString(esbParamBlobs, res.getRequest());
if (jsonObj != null) {
res.setRequest(jsonObj.toJSONString());
}
}
}
private JSONObject addEsbInfoToJsonString(EsbApiParamsWithBLOBs esbParamBlobs, String requestString) {
JSONObject returnObj = null;
try {
returnObj = JSONObject.parseObject(requestString);
JSONArray esbDataArray = JSONArray.parseArray(esbParamBlobs.getDataStruct());
if (esbDataArray == null) {
returnObj.put("esbDataStruct", "");
} else {
returnObj.put("esbDataStruct", esbDataArray);
}
JSONArray responseDataArray = JSONArray.parseArray(esbParamBlobs.getResponseDataStruct());
if (responseDataArray == null) {
returnObj.put("backEsbDataStruct", "");
} else {
returnObj.put("backEsbDataStruct", responseDataArray);
}
returnObj.put("esbFrontedScript", esbParamBlobs.getFrontedScript());
JSONObject backedScriptObj = JSONObject.parseObject(esbParamBlobs.getBackedScript());
returnObj.put("backScript", backedScriptObj);
} catch (Exception e) {
}
return returnObj;
}
public void handleApiEsbParams(ApiTestCaseResult res) {
@ -136,23 +188,30 @@ public class EsbApiParamService {
if (esbParamBlobs == null) {
return;
}
try {
if (StringUtils.isNotEmpty(res.getRequest())) {
JSONObject jsonObj = JSONObject.parseObject(res.getRequest());
JSONArray esbDataArray = JSONArray.parseArray(esbParamBlobs.getDataStruct());
jsonObj.put("esbDataStruct", esbDataArray);
jsonObj.put("esbFrontedScript", esbParamBlobs.getFrontedScript());
JSONArray responseDataArray = JSONArray.parseArray(esbParamBlobs.getResponseDataStruct());
jsonObj.put("backEsbDataStruct", responseDataArray);
if (StringUtils.isNotEmpty(res.getRequest())) {
JSONObject jsonObj = this.addEsbInfoToJsonString(esbParamBlobs, res.getRequest());
if (jsonObj != null) {
res.setRequest(jsonObj.toJSONString());
}
} catch (Exception e) {
}
// try {
// if (StringUtils.isNotEmpty(res.getRequest())) {
// JSONObject jsonObj = JSONObject.parseObject(res.getRequest());
// JSONArray esbDataArray = JSONArray.parseArray(esbParamBlobs.getDataStruct());
// jsonObj.put("esbDataStruct", esbDataArray);
// jsonObj.put("esbFrontedScript", esbParamBlobs.getFrontedScript());
//
// JSONArray responseDataArray = JSONArray.parseArray(esbParamBlobs.getResponseDataStruct());
// jsonObj.put("backEsbDataStruct", responseDataArray);
//
// res.setRequest(jsonObj.toJSONString());
// }
// } catch (Exception e) {
// }
}
public SaveApiDefinitionRequest handleEsbRequest(SaveApiDefinitionRequest request) {
public SaveApiDefinitionRequest updateEsbRequest(SaveApiDefinitionRequest request) {
try {
//修改reqeust.parameters
//用户交互感受ESB的发送数据以报文模板为主框架同时前端不再有key-value的表格数据填充
@ -162,8 +221,27 @@ public class EsbApiParamService {
MsTCPSampler tcpSampler = (MsTCPSampler) request.getRequest();
List<KeyValue> keyValueList = this.genKeyValueListByDataStruct(tcpSampler, request.getEsbDataStruct());
tcpSampler.setParameters(keyValueList);
request.setRequest(tcpSampler);
}
//更新EsbApiParams类
// EsbApiParamsWithBLOBs esbApiParams = this.createEsbApiParam(request.getId(), request.getEsbDataStruct(), request.getBackEsbDataStruct(), request.getBackScript());
} catch (Exception e) {
e.printStackTrace();
}
return request;
}
public SaveApiDefinitionRequest handleEsbRequest(SaveApiDefinitionRequest request) {
try {
//修改reqeust.parameters
//用户交互感受ESB的发送数据以报文模板为主框架同时前端不再有key-value的表格数据填充
//业务逻辑 发送ESB接口数据时使用报文模板中的数据同时报文模板中的${取值}目的是为了拼接数据结构(比如xml的子节点)
//代码实现: 此处打算解析前端传来的EsbDataStruct数据结构将数据结构按照报文模板中的${取值}为最高优先级组装keyValue对象这样Jmeter会自动拼装为合适的xml
if (StringUtils.isNotEmpty(request.getEsbDataStruct())) {
MsTCPSampler tcpSampler = (MsTCPSampler) request.getRequest();
tcpSampler.setProtocol("ESB");
List<KeyValue> keyValueList = this.genKeyValueListByDataStruct(tcpSampler, request.getEsbDataStruct());
tcpSampler.setParameters(keyValueList);
}
//更新EsbApiParams类
EsbApiParamsWithBLOBs esbApiParams = this.createEsbApiParam(request.getId(), request.getEsbDataStruct(), request.getBackEsbDataStruct(), request.getBackScript());
} catch (Exception e) {
@ -172,6 +250,43 @@ public class EsbApiParamService {
return request;
}
// public RunDefinitionRequest handleEsbRequest(RunDefinitionRequest request) {
// try {
// //修改reqeust.parameters
// //用户交互感受ESB的发送数据以报文模板为主框架同时前端不再有key-value的表格数据填充
// //业务逻辑 发送ESB接口数据时使用报文模板中的数据同时报文模板中的${取值}目的是为了拼接数据结构(比如xml的子节点)
// //代码实现: 此处打算解析前端传来的EsbDataStruct数据结构将数据结构按照报文模板中的${取值}为最高优先级组装keyValue对象这样Jmeter会自动拼装为合适的xml
// if (StringUtils.isNotEmpty(request.getEsbDataStruct())) {
// if(request.getTestElement() instanceof MsTestPlan){
// MsTestPlan testPlan = (MsTestPlan)request.getTestElement();
// for (MsTestElement testElement: testPlan.getHashTree()) {
// if(testElement instanceof MsThreadGroup){
// MsThreadGroup group = (MsThreadGroup)testElement;
// for (MsTestElement groupElement: testPlan.getHashTree()) {
// if(groupElement instanceof MsScenario){
// MsScenario scenario = (MsScenario)groupElement;
// for (MsTestElement scenarioElement: scenario.getHashTree()) {
// if(scenarioElement instanceof MsTCPSampler){
// MsTCPSampler tcpSampler = (MsTCPSampler) scenarioElement;
// List<KeyValue> keyValueList = this.genKeyValueListByDataStruct(tcpSampler, request.getEsbDataStruct());
// tcpSampler.setParameters(keyValueList);
// }
// }
// }
// }
// }
// }
// }
// }
//
// //更新EsbApiParams类
// EsbApiParamsWithBLOBs esbApiParams = this.createEsbApiParam(request.getId(), request.getEsbDataStruct(), request.getBackEsbDataStruct(), request.getBackScript());
// } catch (Exception e) {
// e.printStackTrace();
// }
// return request;
// }
//通过esb数据结构生成keyValue集合以及发送参数
private List<KeyValue> genKeyValueListByDataStruct(MsTCPSampler tcpSampler, String esbDataStruct) {
List<KeyValue> keyValueList = new ArrayList<>();

View File

@ -1,18 +1,19 @@
package io.metersphere.base.domain;
import lombok.Data;
import java.io.Serializable;
import lombok.Data;
@Data
public class TestCaseTest implements Serializable {
private String id;
private String testCaseId;
private String testId;
private String testType;
private Long createTime;
private Long updateTime;
private static final long serialVersionUID = 1L;
}

View File

@ -104,76 +104,6 @@ public class TestCaseTestExample {
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(String value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(String value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(String value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(String value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(String value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(String value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdLike(String value) {
addCriterion("id like", value, "id");
return (Criteria) this;
}
public Criteria andIdNotLike(String value) {
addCriterion("id not like", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<String> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<String> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(String value1, String value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(String value1, String value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andTestCaseIdIsNull() {
addCriterion("test_case_id is null");
return (Criteria) this;
@ -383,6 +313,126 @@ public class TestCaseTestExample {
addCriterion("test_type not between", value1, value2, "testType");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Long value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Long value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Long value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Long value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Long value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Long> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Long> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Long value1, Long value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Long value1, Long value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Long value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Long value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Long value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Long value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Long value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Long value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Long> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Long> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Long value1, Long value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Long value1, Long value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -2,30 +2,21 @@ package io.metersphere.base.mapper;
import io.metersphere.base.domain.TestCaseTest;
import io.metersphere.base.domain.TestCaseTestExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TestCaseTestMapper {
long countByExample(TestCaseTestExample example);
int deleteByExample(TestCaseTestExample example);
int deleteByPrimaryKey(String id);
int insert(TestCaseTest record);
int insertSelective(TestCaseTest record);
List<TestCaseTest> selectByExample(TestCaseTestExample example);
TestCaseTest selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") TestCaseTest record, @Param("example") TestCaseTestExample example);
int updateByExample(@Param("record") TestCaseTest record, @Param("example") TestCaseTestExample example);
int updateByPrimaryKeySelective(TestCaseTest record);
int updateByPrimaryKey(TestCaseTest record);
}

View File

@ -1,201 +1,175 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.base.mapper.TestCaseTestMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.TestCaseTest">
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="test_case_id" jdbcType="VARCHAR" property="testCaseId"/>
<result column="test_id" jdbcType="VARCHAR" property="testId"/>
<result column="test_type" jdbcType="VARCHAR" property="testType"/>
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.TestCaseTest">
<result column="test_case_id" jdbcType="VARCHAR" property="testCaseId" />
<result column="test_id" jdbcType="VARCHAR" property="testId" />
<result column="test_type" jdbcType="VARCHAR" property="testType" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, test_case_id, test_id, test_type
</sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.TestCaseTestExample"
resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</trim>
</if>
<include refid="Base_Column_List"/>
from test_case_test
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from test_case_test
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete
from test_case_test
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.TestCaseTestExample">
delete from test_case_test
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.TestCaseTest">
insert into test_case_test (id, test_case_id, test_id,
test_type)
values (#{id,jdbcType=VARCHAR}, #{testCaseId,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR},
#{testType,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestCaseTest">
insert into test_case_test
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="testCaseId != null">
test_case_id,
</if>
<if test="testId != null">
test_id,
</if>
<if test="testType != null">
test_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="testCaseId != null">
#{testCaseId,jdbcType=VARCHAR},
</if>
<if test="testId != null">
#{testId,jdbcType=VARCHAR},
</if>
<if test="testType != null">
#{testType,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.TestCaseTestExample"
resultType="java.lang.Long">
select count(*) from test_case_test
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update test_case_test
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.testCaseId != null">
test_case_id = #{record.testCaseId,jdbcType=VARCHAR},
</if>
<if test="record.testId != null">
test_id = #{record.testId,jdbcType=VARCHAR},
</if>
<if test="record.testType != null">
test_type = #{record.testType,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByExample" parameterType="map">
update test_case_test
set id = #{record.id,jdbcType=VARCHAR},
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
test_case_id, test_id, test_type, create_time, update_time
</sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.TestCaseTestExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from test_case_test
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.TestCaseTestExample">
delete from test_case_test
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.TestCaseTest">
insert into test_case_test (test_case_id, test_id, test_type,
create_time, update_time)
values (#{testCaseId,jdbcType=VARCHAR}, #{testId,jdbcType=VARCHAR}, #{testType,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.TestCaseTest">
insert into test_case_test
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="testCaseId != null">
test_case_id,
</if>
<if test="testId != null">
test_id,
</if>
<if test="testType != null">
test_type,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="testCaseId != null">
#{testCaseId,jdbcType=VARCHAR},
</if>
<if test="testId != null">
#{testId,jdbcType=VARCHAR},
</if>
<if test="testType != null">
#{testType,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=BIGINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.TestCaseTestExample" resultType="java.lang.Long">
select count(*) from test_case_test
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update test_case_test
<set>
<if test="record.testCaseId != null">
test_case_id = #{record.testCaseId,jdbcType=VARCHAR},
</if>
<if test="record.testId != null">
test_id = #{record.testId,jdbcType=VARCHAR},
test_type = #{record.testType,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.TestCaseTest">
update test_case_test
<set>
<if test="testCaseId != null">
test_case_id = #{testCaseId,jdbcType=VARCHAR},
</if>
<if test="testId != null">
test_id = #{testId,jdbcType=VARCHAR},
</if>
<if test="testType != null">
test_type = #{testType,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.TestCaseTest">
update test_case_test
set test_case_id = #{testCaseId,jdbcType=VARCHAR},
test_id = #{testId,jdbcType=VARCHAR},
test_type = #{testType,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</if>
<if test="record.testType != null">
test_type = #{record.testType,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=BIGINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update test_case_test
set test_case_id = #{record.testCaseId,jdbcType=VARCHAR},
test_id = #{record.testId,jdbcType=VARCHAR},
test_type = #{record.testType,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
</mapper>

View File

@ -65,7 +65,7 @@ public interface ExtTestCaseMapper {
long countRelevanceCreatedThisWeek(@Param("projectId") String projectId,@Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp);
List<TrackCountResult> countCoverage(@Param("projectId") String projectId);
int countCoverage(@Param("projectId") String projectId);
List<TrackCountResult> countFuncMaintainer(@Param("projectId") String projectId);

View File

@ -307,7 +307,7 @@
or test_case.tags like CONCAT('%', #{request.name},'%'))
</if>
<if test="request.createTime >0">
AND test_case.create_time >= #{request.createTime}
and test_case.id in (select test_case_id from test_case_test where test_case_test.create_time >= #{request.createTime})
</if>
<if test="request.nodeIds != null and request.nodeIds.size() > 0">
and test_case.node_id in
@ -320,10 +320,10 @@
</if>
<include refid="filters"/>
<if test="request.caseCoverage == 'uncoverage' ">
and test_case.test_id is null and test_case.type != 'functional'
and test_case.id not in (select distinct test_case_test.test_case_id from test_case_test)
</if>
<if test="request.caseCoverage == 'coverage' ">
and test_case.test_id is not null and test_case.type != 'functional'
and test_case.id in (select distinct test_case_test.test_case_id from test_case_test)
</if>
</where>
</sql>
@ -343,17 +343,19 @@
</select>
<select id="countRelevance" resultType="io.metersphere.track.response.TrackCountResult">
SELECT type AS groupField, count(id) AS countNumber FROM test_case WHERE test_case.project_id = #{projectId} GROUP BY test_case.type
SELECT test_case_test.test_type AS groupField, count(test_case_test.test_case_id) AS countNumber
FROM test_case join test_case_test on test_case.id = test_case_test.test_case_id
WHERE test_case.project_id = #{projectId} GROUP BY test_case_test.test_type
</select>
<select id="countRelevanceCreatedThisWeek" resultType="java.lang.Long">
SELECT count(id) AS countNumber FROM test_case WHERE test_case.project_id = #{projectId}
AND create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
SELECT count(distinct test_case_test.test_case_id) AS countNumber FROM test_case join test_case_test on test_case.id = test_case_test.test_case_id
WHERE test_case.project_id = #{projectId}
AND test_case_test.create_time BETWEEN #{firstDayTimestamp} AND #{lastDayTimestamp}
</select>
<select id="countCoverage" resultType="io.metersphere.track.response.TrackCountResult">
SELECT count(test_case.id) AS countNumber,
if(test_case.test_id is null,"uncoverage","coverage") AS groupField
FROM test_case WHERE test_case.project_id=#{projectId} and test_case.type != 'functional' GROUP BY groupField
<select id="countCoverage" resultType="int">
select count(test_case.id) from test_case where test_case.project_id = #{projectId}
and test_case.id in (select distinct test_case_test.test_case_id from test_case_test)
</select>
<select id="countFuncMaintainer" resultType="io.metersphere.track.response.TrackCountResult">
select count(tc.id) as countNumber, user.name as groupField from test_case tc right join user on tc.maintainer = user.id
@ -362,7 +364,7 @@
</select>
<select id="countRelevanceMaintainer" resultType="io.metersphere.track.response.TrackCountResult">
select count(tc.id) as countNumber, user.name as groupField from test_case tc right join user on tc.maintainer = user.id
where tc.project_id = #{projectId} and tc.test_id is not null
where tc.project_id = #{projectId} and tc.id in (select distinct test_case_test.test_case_id from test_case_test)
group by tc.maintainer
</select>
<select id="getTestPlanBug" resultType="int">

View File

@ -75,6 +75,7 @@
<include refid="condition">
<property name="object" value="${condition}.type"/>
</include>
test_case_review_users
</if>
<if test="${condition}.updateTime != null">
and test_case.update_time
@ -136,7 +137,7 @@
<select id="list" resultType="io.metersphere.track.dto.TestPlanCaseDTO">
select test_plan_test_case.id as id, test_case.id as caseId, test_case.name, test_case.priority,
test_case.type,test_case.test_id as testId,test_case.node_id, test_case.tags,
test_case.type,test_case.test_id as testId,test_case.node_id, test_case.tags, test_case.maintainer,
test_case.node_path, test_case.method, test_case.num, test_plan_test_case.executor, test_plan_test_case.status,
test_plan_test_case.update_time, test_case_node.name as model, project.name as projectName,
test_plan_test_case.plan_id as planId
@ -199,6 +200,12 @@
#{value}
</foreach>
</when>
<when test="key=='maintainer'">
and test_case.maintainer in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<when test="key=='executor'">
and test_plan_test_case.executor in
<foreach collection="values" item="value" separator="," open="(" close=")">
@ -368,7 +375,7 @@
</if>
</where>
UNION ALL
SELECT test_plan_api_scenario.id as reportId,test_plan_api_scenario.api_scenario_id as id,"scenario" as
SELECT test_plan_api_scenario.api_scenario_id as testId,test_plan_api_scenario.id as id,"scenario" as
type,api_scenario.name,test_plan_api_scenario.status
from test_plan_api_scenario
left join

View File

@ -52,6 +52,7 @@ public class ShiroUtils {
filterChainDefinitionMap.put("/", "apikey, authc"); // 跳转到 / 不用校验 csrf
filterChainDefinitionMap.put("/language", "apikey, authc");// 跳转到 /language 不用校验 csrf
filterChainDefinitionMap.put("/document", "apikey, authc"); // 跳转到 /document 不用校验 csrf
filterChainDefinitionMap.put("/test/case/file/preview/**", "apikey, authc"); // 预览测试用例附件 不用校验 csrf
}
public static Cookie getSessionIdCookie(){

View File

@ -25,6 +25,6 @@ public class IndexController {
@GetMapping(value = "/document")
public String document() {
return "document:/";
return "document.html";
}
}

View File

@ -7,6 +7,7 @@ import io.metersphere.commons.utils.SessionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.ExpiredCredentialsException;
import org.apache.shiro.web.filter.authc.AnonymousFilter;
import org.apache.shiro.web.util.WebUtils;
import org.springframework.core.env.Environment;
@ -41,7 +42,12 @@ public class CsrfFilter extends AnonymousFilter {
// 请求头取出的token value
String csrfToken = httpServletRequest.getHeader(TOKEN_NAME);
// 校验 token
validateToken(csrfToken);
try {
validateToken(csrfToken);
} catch (ExpiredCredentialsException e) {
((HttpServletResponse) response).setHeader("Authentication-Status", "invalid");
return true;
}
// 校验 referer
validateReferer(httpServletRequest);
return true;
@ -84,7 +90,7 @@ public class CsrfFilter extends AnonymousFilter {
Environment env = CommonBeanFactory.getBean(Environment.class);
long timeout = env.getProperty("session.timeout", Long.class, 43200L);
if (Math.abs(System.currentTimeMillis() - signatureTime) > timeout * 1000) {
throw new RuntimeException("expired token");
throw new ExpiredCredentialsException("expired token");
}
if (!StringUtils.equals(SessionUtils.getUserId(), signatureArray[0])) {
throw new RuntimeException("Please check csrf token.");

View File

@ -74,6 +74,7 @@ public class TestResourcePoolService {
if (StringUtils.isNotBlank(testResourcePoolDTO.getId())) {
criteria.andIdNotEqualTo(testResourcePoolDTO.getId());
}
criteria.andStatusNotEqualTo(DELETE.name());
if (testResourcePoolMapper.countByExample(example) > 0) {
MSException.throwException(Translator.get("test_resource_pool_name_already_exists"));

View File

@ -3,6 +3,7 @@ package io.metersphere.track.controller;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.api.dto.automation.*;
import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
@ -55,6 +56,14 @@ public class TestPlanScenarioCaseController {
return testPlanScenarioCaseService.run(request);
}
@PostMapping(value = "/jenkins/run")
public String runByRun(@RequestBody RunScenarioRequest request) {
request.setExecuteType(ExecuteType.Saved.name());
request.setTriggerMode(ApiRunMode.SCENARIO.name());
request.setRunMode(ApiRunMode.SCENARIO.name());
return testPlanScenarioCaseService.run(request);
}
@PostMapping("/batch/update/env")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void batchUpdateEnv(@RequestBody RelevanceScenarioRequest request) {

View File

@ -1,11 +1,13 @@
package io.metersphere.track.controller;
import io.metersphere.base.domain.TestCase;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.performance.base.ChartsData;
import io.metersphere.track.response.BugStatustics;
import io.metersphere.track.response.TrackCountResult;
import io.metersphere.track.response.TrackStatisticsDTO;
import io.metersphere.track.service.TestCaseService;
import io.metersphere.track.service.TrackService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
@ -25,6 +27,8 @@ public class TrackController {
@Resource
private TrackService trackService;
@Resource
private TestCaseService testCaseService;
@GetMapping("/count/{projectId}")
public TrackStatisticsDTO getTrackCount(@PathVariable String projectId) {
@ -63,10 +67,11 @@ public class TrackController {
long size = trackService.countRelevanceCreatedThisWeek(projectId);
statistics.setThisWeekAddedCount(size);
List<TrackCountResult> coverageResults = trackService.countCoverage(projectId);
statistics.countCoverage(coverageResults);
long total = statistics.getUncoverageCount() + statistics.getCoverageCount();
List<TestCase> list = testCaseService.getTestCaseByProjectId(projectId);
long total = list.size();
int coverage = trackService.countCoverage(projectId);
statistics.setCoverageCount(coverage);
statistics.setUncoverageCount(total - coverage);
if (total != 0) {
float coverageRageNumber = (float) statistics.getCoverageCount() * 100 / total;

View File

@ -4,6 +4,8 @@ import io.metersphere.base.domain.TestCaseWithBLOBs;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class TestReviewCaseDTO extends TestCaseWithBLOBs {
@ -16,4 +18,5 @@ public class TestReviewCaseDTO extends TestCaseWithBLOBs {
private String issues;
private String model;
private String projectName;
private List<TestCaseTestDTO> list;
}

View File

@ -10,5 +10,6 @@ import java.util.List;
@Setter
public class TestCaseMinderEditRequest {
private String projectId;
private List<String> ids;
List<TestCaseWithBLOBs> data;
}

View File

@ -6,7 +6,7 @@ public class TrackCount {
public static final String P2 = "P2";
public static final String P3 = "P3";
public static final String API = "api";
public static final String TESTCASE = "testcase";
public static final String PERFORMANCE = "performance";
public static final String AUTOMATION = "automation";
}

View File

@ -145,7 +145,7 @@ public class TrackStatisticsDTO {
public void countRelevance(List<TrackCountResult> relevanceResults) {
for (TrackCountResult countResult : relevanceResults) {
switch (countResult.getGroupField()){
case TrackCount.API:
case TrackCount.TESTCASE:
this.apiCaseCount += countResult.getCountNumber();
this.allRelevanceCaseCount += countResult.getCountNumber();
break;

View File

@ -664,8 +664,9 @@ public class TestCaseService {
selecteds.forEach(id -> {
test.setTestType(id.get(0));
test.setTestId(id.get(1));
test.setId(UUID.randomUUID().toString());
test.setTestCaseId(request.getId());
test.setCreateTime(System.currentTimeMillis());
test.setUpdateTime(System.currentTimeMillis());
testCaseTestMapper.insert(test);
});
}
@ -707,7 +708,8 @@ public class TestCaseService {
selecteds.forEach(id -> {
test.setTestType(id.get(0));
test.setTestId(id.get(1));
test.setId(UUID.randomUUID().toString());
test.setCreateTime(System.currentTimeMillis());
test.setUpdateTime(System.currentTimeMillis());
test.setTestCaseId(request.getId());
testCaseTestMapper.insert(test);
});
@ -778,5 +780,17 @@ public class TestCaseService {
editTestCase(item);
}
});
List<String> ids = request.getIds();
if (CollectionUtils.isNotEmpty(ids)) {
TestCaseBatchRequest deleteRequest = new TestCaseBatchRequest();
deleteRequest.setIds(ids);
deleteTestCaseBath(deleteRequest);
}
}
public List<TestCase> getTestCaseByProjectId(String projectId) {
TestCaseExample example = new TestCaseExample();
example.createCriteria().andProjectIdEqualTo(projectId);
return testCaseMapper.selectByExample(example);
}
}

View File

@ -1,16 +1,16 @@
package io.metersphere.track.service;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.TestCaseMapper;
import io.metersphere.base.mapper.TestCaseReviewMapper;
import io.metersphere.base.mapper.TestCaseReviewTestCaseMapper;
import io.metersphere.base.mapper.TestCaseReviewUsersMapper;
import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestReviewCaseMapper;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.ServiceUtils;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.member.QueryMemberRequest;
import io.metersphere.service.UserService;
import io.metersphere.track.dto.TestCaseTestDTO;
import io.metersphere.track.dto.TestPlanCaseDTO;
import io.metersphere.track.dto.TestReviewCaseDTO;
import io.metersphere.track.request.testplancase.TestReviewCaseBatchRequest;
import io.metersphere.track.request.testreview.DeleteRelevanceRequest;
@ -29,7 +29,14 @@ import java.util.stream.Collectors;
@Service
@Transactional(rollbackFor = Exception.class)
public class TestReviewTestCaseService {
@Resource
private TestCaseTestMapper testCaseTestMapper;
@Resource
private LoadTestMapper loadTestMapper;
@Resource
private ApiTestCaseMapper apiTestCaseMapper;
@Resource
private ApiScenarioMapper apiScenarioMapper;
@Resource
ExtTestReviewCaseMapper extTestReviewCaseMapper;
@Resource
@ -44,6 +51,8 @@ public class TestReviewTestCaseService {
TestCaseReviewService testCaseReviewService;
@Resource
TestCaseMapper testCaseMapper;
@Resource
ExtTestPlanTestCaseMapper extTestPlanTestCaseMapper;
public List<TestReviewCaseDTO> list(QueryCaseReviewRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
@ -128,7 +137,40 @@ public class TestReviewTestCaseService {
}
public TestReviewCaseDTO get(String reviewId) {
return extTestReviewCaseMapper.get(reviewId);
TestReviewCaseDTO testReviewCaseDTO=extTestReviewCaseMapper.get(reviewId);
List<TestCaseTestDTO> testCaseTestDTOS = extTestPlanTestCaseMapper.listTestCaseTest(testReviewCaseDTO.getCaseId());
testCaseTestDTOS.forEach(dto -> {
setTestName(dto);
});
testReviewCaseDTO.setList(testCaseTestDTOS);
return testReviewCaseDTO;
}
private void setTestName(TestCaseTestDTO dto) {
String type = dto.getTestType();
String id = dto.getTestId();
switch (type) {
case "performance":
LoadTest loadTest = loadTestMapper.selectByPrimaryKey(id);
if (loadTest != null) {
dto.setTestName(loadTest.getName());
}
break;
case "testcase":
ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = apiTestCaseMapper.selectByPrimaryKey(id);
if (apiTestCaseWithBLOBs != null) {
dto.setTestName(apiTestCaseWithBLOBs.getName());
}
break;
case "automation":
ApiScenarioWithBLOBs apiScenarioWithBLOBs = apiScenarioMapper.selectByPrimaryKey(id);
if (apiScenarioWithBLOBs != null) {
dto.setTestName(apiScenarioWithBLOBs.getName());
}
break;
default:
break;
}
}
public void editTestCaseBatchStatus(TestReviewCaseBatchRequest request) {

View File

@ -80,7 +80,7 @@ public class TrackService {
}
}
public List<TrackCountResult> countCoverage(String projectId) {
public int countCoverage(String projectId) {
return extTestCaseMapper.countCoverage(projectId);
}

View File

@ -179,15 +179,16 @@ alter table test_plan
alter table test_case
modify method varchar(15) null comment 'Test case method type';
-- add test_case_test
create table test_case_test
CREATE TABLE IF NOT EXISTS test_case_test
(
id varchar(70) null,
test_case_id varchar(70) null,
test_id varchar(70) null,
test_type varchar(70) null,
constraint test_case_test_pk
primary key (id)
test_case_id varchar(50) null,
test_id varchar(50) null,
test_type varchar(50) null,
create_time bigint(13) null,
update_time bigint(13) null,
UNIQUE KEY test_case_test_unique_key (test_case_id, test_id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
DEFAULT CHARSET = utf8mb4 COMMENT ='测试用例和关联用例的关系表';
alter table test_case
modify test_id varchar(2000) null;

View File

@ -49,7 +49,7 @@
"xml-js": "^1.6.11",
"yan-progress": "^1.0.3",
"jsonpath": "^1.1.0",
"vue-minder-editor-plus": "^1.0.18",
"vue-minder-editor-plus": "^1.0.19",
"jsencrypt": "^3.1.0"
},
"devDependencies": {

View File

@ -244,7 +244,7 @@
return {
type: API_SCENARIO_LIST,
headerItems: Api_Scenario_List,
tableLabel: [],
tableLabel: Api_Scenario_List,
loading: false,
screenHeight: document.documentElement.clientHeight - 280,//,
condition: {
@ -419,6 +419,9 @@
});
this.loading = false;
this.unSelection = data.listObject.map(s => s.id);
if (this.$refs.scenarioTable) {
this.$refs.scenarioTable.doLayout()
}
});
}
getLabel(this, API_SCENARIO_LIST);

View File

@ -50,6 +50,7 @@ import MsMainContainer from "../../../../common/components/MsMainContainer";
import ScenarioRelevanceApiList from "./RelevanceApiList";
import RelevanceDialog from "../../../../track/plan/view/comonents/base/RelevanceDialog";
import TestCaseRelevanceBase from "@/business/components/track/plan/view/comonents/base/TestCaseRelevanceBase";
import {getUUID} from "@/common/js/utils";
export default {
name: "ApiRelevance",
@ -97,6 +98,29 @@ export default {
apiCases.forEach((item) => {
item.request = response.data[item.id];
item.projectId = this.projectId;
let requestObj = JSON.parse(item.request);
if(requestObj.esbDataStruct != null ){
//ESB
let param = {};
param.request = requestObj;
param.method = "ESB";
param.esbDataStruct = JSON.stringify(requestObj.esbDataStruct);
if(requestObj.backEsbDataStruct != null){
param.backEsbDataStruct = JSON.stringify(requestObj.backEsbDataStruct);
}else{
param.backEsbDataStruct = "";
}
this.$post("/api/definition/updateEsbRequest", param, response => {
if(response.data!=null){
if(response.data.request!=null){
item.request = JSON.stringify(response.data.request);
param.method = "TCP";
}
}
})
}
});
this.$emit('save', apiCases, 'CASE', reference);
this.$refs.baseRelevance.close();

View File

@ -32,7 +32,9 @@
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
<ms-api-request-form :isShowEnable="true" :referenced="true" :headers="request.headers " :request="request"
v-if="request.protocol==='HTTP' || request.type==='HTTPSamplerProxy'"/>
<ms-tcp-basis-parameters :request="request" v-if="request.protocol==='TCP'|| request.type==='TCPSampler'" :showScript="false"/>
<esb-definition v-xpack :request="request" :showScript="false" v-if="this.showXpackCompnent&&request.esbDataStruct!=null" ref="esbDefinition"/>
<ms-tcp-basis-parameters :request="request" v-if="(request.protocol==='TCP'|| request.type==='TCPSampler')&&request.esbDataStruct==null " :showScript="false"/>
<ms-sql-basis-parameters :request="request" v-if="request.protocol==='SQL'|| request.type==='JDBCSampler'"
:showScript="false"/>
<ms-dubbo-basis-parameters :request="request"
@ -49,7 +51,13 @@
</el-tab-pane>
</el-tabs>
</div>
<api-response-component :currentProtocol="request.protocol" :result="request.requestResult" v-else/>
<div v-else-if="showXpackCompnent&&request.backEsbDataStruct != null">
<esb-definition-response :currentProtocol="request.protocol" :request="request" :is-api-component="false"
:show-options-button="false" :show-header="true" :result="request.requestResult"/>
</div>
<div v-else>
<api-response-component :currentProtocol="request.protocol" :result="request.requestResult"/>
</div>
<!-- 保存操作 -->
<el-button type="primary" size="small" class="ms-btn-flot" @click="saveTestCase(item)"
@ -75,6 +83,9 @@
import ApiBaseComponent from "../common/ApiBaseComponent";
import ApiResponseComponent from "./ApiResponseComponent";
import CustomizeReqInfo from "@/business/components/api/automation/scenario/common/CustomizeReqInfo";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const esbDefinition = (requireComponent!=null&&requireComponent.keys().length) > 0 ? requireComponent("./apiDefinition/EsbDefinition.vue") : {};
const esbDefinitionResponse = (requireComponent!=null&&requireComponent.keys().length) > 0 ? requireComponent("./apiDefinition/EsbDefinitionResponse.vue") : {};
export default {
name: "MsApiComponent",
@ -101,7 +112,9 @@
components: {
CustomizeReqInfo,
ApiBaseComponent, ApiResponseComponent,
MsSqlBasisParameters, MsTcpBasisParameters, MsDubboBasisParameters, MsApiRequestForm, MsRequestResultTail, MsRun
MsSqlBasisParameters, MsTcpBasisParameters, MsDubboBasisParameters, MsApiRequestForm, MsRequestResultTail, MsRun,
"esbDefinition": esbDefinition.default,
"esbDefinitionResponse": esbDefinitionResponse.default
},
data() {
return {
@ -109,6 +122,7 @@
reportId: "",
runData: [],
isShowInput: false,
showXpackCompnent:false,
}
},
created() {
@ -121,6 +135,7 @@
}
//
this.getApiInfo();
console.log(JSON.stringify(this.request));
if (this.request.protocol === 'HTTP') {
this.setUrl(this.request.url);
this.setUrl(this.request.path);
@ -134,6 +149,9 @@
}
}
}
if (requireComponent != null && JSON.stringify(esbDefinition) != '{}'&& JSON.stringify(esbDefinitionResponse) != '{}') {
this.showXpackCompnent = true;
}
},
computed: {
displayColor() {
@ -284,7 +302,7 @@
let debugData = {
id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario",
variables: this.currentScenario.variables, referenced: 'Created', headers: this.currentScenario.headers,
enableCookieShare: this.enableCookieShare, environmentId: this.currentEnvironmentId, hashTree: [this.request]
enableCookieShare: this.enableCookieShare, environmentId: this.currentEnvironmentId, hashTree: [this.request],
};
this.runData.push(debugData);
/*触发执行操作*/

View File

@ -101,7 +101,7 @@
getComponent(type) {
if (type === ELEMENT_TYPE.JSR223PreProcessor) {
this.title = this.$t('api_test.definition.request.pre_script');
this.titleColor = "#B8741A";
this.titleColor = "#b8741a";
this.backgroundColor = "#F9F1EA";
return "MsJsr233Processor";
} else if (type === ELEMENT_TYPE.JSR223PostProcessor) {

View File

@ -131,8 +131,6 @@ export default {
if(this.request.backScript != null){
this.basisData.backScript = JSON.stringify(this.request.backScript);
}
}
this.$emit('saveApi', this.basisData);
}

View File

@ -186,7 +186,7 @@ export default {
return {
type: API_CASE_LIST,
headerItems: Api_Case_List,
tableLabel: [],
tableLabel: Api_Case_List,
condition: {
components: API_CASE_CONFIGS
},
@ -260,6 +260,10 @@ export default {
},
created: function () {
this.initTable();
this.$nextTick(() => {
this.$refs.caseTable.bodyWrapper.scrollTop = 5
})
},
watch: {
selectNodeIds() {
@ -277,24 +281,24 @@ export default {
this.initTable();
}
},
computed: {
computed: {
//
isApiModel() {
return this.model === 'api'
},
//
isApiModel() {
return this.model === 'api'
},
methods: {
customHeader() {
getLabel(this, API_CASE_LIST);
this.$refs.headerCustom.open(this.tableLabel)
},
initTable() {
},
methods: {
customHeader() {
getLabel(this, API_CASE_LIST);
this.$refs.headerCustom.open(this.tableLabel)
},
initTable() {
this.selectRows = new Set();
this.condition.status = "";
this.condition.moduleIds = this.selectNodeIds;
if (this.trashEnable) {
this.selectRows = new Set();
this.condition.status = "";
this.condition.moduleIds = this.selectNodeIds;
if (this.trashEnable) {
this.condition.status = "Trash";
this.condition.moduleIds = [];
}
@ -331,9 +335,13 @@ export default {
item.tags = JSON.parse(item.tags);
}
})
if (this.$refs.caseTable) {
this.$refs.caseTable.doLayout()
}
});
}
getLabel(this, API_CASE_LIST);
},
open() {
this.$refs.searchBar.open();
@ -636,4 +644,7 @@ export default {
top: -2px;
}
/deep/ .el-table__fixed {
height: 100% !important;
}
</style>

View File

@ -272,7 +272,7 @@
return {
type: API_LIST,
headerItems: Api_List,
tableLabel: [],
tableLabel: Api_List,
condition: {
components: API_DEFINITION_CONFIGS
},
@ -442,6 +442,10 @@
item.tags = JSON.parse(item.tags);
}
})
if (this.$refs.apiDefinitionTable) {
this.$refs.apiDefinitionTable.doLayout()
}
});
}
getLabel(this, API_LIST);

View File

@ -73,7 +73,6 @@ export const API_STATUS = [
]
export const TEST = [
{id: 'performance', name: '性能测试'},
{id: 'api', name: '接口测试'},
{id: 'testcase', name: '测试用例'},
{id: 'automation', name: '场景测试'}
]

View File

@ -47,18 +47,14 @@ export default {
},
open(items) {
this.defaultCheckedKeys = []
this.dialogTableVisible = true
this.fieldSelected = items
if (items.size <= 0) {
this.optionalField = this.optionalFields
} else {
items.forEach(i => {
this.defaultCheckedKeys.push(i.id)
}
)
}
items.forEach(i => {
this.defaultCheckedKeys.push(i.id)
}
)
console.log(this.defaultCheckedKeys)
console.log(this.optionalFields)
console.log(this.fieldSelected)
},
saveHeader() {
@ -83,7 +79,6 @@ export default {
},
// 穿transfer addressList
// changeMode() {
// if (this.mode == "transfer") {

View File

@ -109,6 +109,7 @@ export const Test_Plan_Function_Test_Case = [
{id: 'executorName', label: i18n.t('test_track.plan_view.executor')},
{id: 'status', label: i18n.t('test_track.plan_view.execute_result')},
{id: 'updateTime', label: i18n.t('commons.update_time')},
{id: 'maintainer', label: i18n.t('api_test.definition.request.responsible')}
]
//测试计划-api用例
export const Test_Plan_Api_Case = [

View File

@ -105,13 +105,12 @@ export default {
this.testCaseForm.projectId = getCurrentProjectID();
this.testCaseForm.type = "";
this.testCaseForm.priority = "P0";
this.testCaseForm.method = "manual";
if(this.currentModule!==undefined){
if (this.currentModule !== undefined || this.currentModule !== null || this.currentModule !== 0 || this.currentModule !== "") {
this.testCaseForm.nodePath = this.currentModule.path;
this.testCaseForm.nodeId = this.currentModule.id;
}else{
this.testCaseForm.nodePath="/全部用例"
this.testCaseForm.nodeId="root"
} else {
this.testCaseForm.nodePath = "/全部用例"
this.testCaseForm.nodeId = "root"
}
this.result = this.$post(path, this.testCaseForm, response => {
this.testCaseForm.id=response.data.id

View File

@ -83,7 +83,6 @@
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
@ -98,17 +97,12 @@
</el-select>
</el-form-item>
</el-col>
<el-col :span="7">
<el-form-item :label="$t('test_track.case.relate_test')" :label-width="formLabelWidth" prop="testId">
<el-cascader show-all-levels v-model="form.selected" :props="props" ></el-cascader>
</el-form-item>
</el-col>
<!-- <el-col :span="7" v-if="form.testId=='other'">
<el-form-item :label="$t('test_track.case.test_name')" :label-width="formLabelWidth" prop="testId">
<el-input v-model="form.otherTestName" :placeholder="$t('test_track.case.input_test_case')"></el-input>
<el-col :span="14">
<el-form-item :label="$t('test_track.case.relate_test')" :label-width="formLabelWidth">
<el-cascader filterable placeholder="请选择要关联的测试" show-all-levels v-model="form.selected" :props="props"
class="ms-case"></el-cascader>
</el-form-item>
</el-col>-->
</el-col>
</el-row>
<el-row>
@ -126,8 +120,9 @@
</el-form-item>
</el-col>
<el-col :span="10">
<el-form-item label="需求名称" :label-width="formLabelWidth" prop="demandName" v-if="form.demandId=='other'">
<el-col :span="10" :offset="1">
<el-form-item label="需求ID/名称" :label-width="formLabelWidth" prop="demandName"
v-if="form.demandId=='other'">
<el-input v-model="form.demandName"></el-input>
</el-form-item>
</el-col>
@ -341,7 +336,6 @@ export default {
}
if (this.projectId && this.form.type != '' && this.form.type != 'undefined') {
this.$get(url, response => {
response.data.unshift({id: 'other', name: this.$t('test_track.case.other')})
const nodes = response.data
.map(item => ({
value: item.id,
@ -377,7 +371,7 @@ export default {
desc: '',
result: ''
}],
selected:[],
selected: [],
remark: '',
tags: [],
demandId: '',
@ -497,6 +491,8 @@ export default {
this.$nextTick(() => (this.isStepTableAlive = true));
},
open(testCase) {
console.log("测试用例")
console.log(testCase)
this.projectId = getCurrentProjectID();
if (window.history && window.history.pushState) {
history.pushState(null, null, document.URL);
@ -580,7 +576,10 @@ export default {
}
Object.assign(this.form, tmp);
this.form.module = testCase.nodeId;
this.form.testId=testCase.testId
/*
this.form.testId=testCase.selected
*/
console.log(this.form.selected)
this.getFileMetaData(testCase);
},
setTestCaseExtInfo(testCase) {
@ -776,7 +775,6 @@ export default {
});
},
getTestOptions(val) {
console.log(val)
this.projectId = getCurrentProjectID()
this.testOptions = [];
let url = '';
@ -996,6 +994,10 @@ export default {
width: 100%;
}
.ms-case {
width: 100%;
}
/deep/ .el-button-group > .el-button:first-child {
border-top-right-radius: 0;
border-bottom-right-radius: 0;

View File

@ -29,6 +29,7 @@ export default {
},
methods: {
open(file) {
console.log(file)
this.file = file;
this.dialogVisible = true;
},

View File

@ -259,7 +259,7 @@ export default {
return {
type: TEST_CASE_LIST,
headerItems: Track_Test_Case,
tableLabel: [],
tableLabel: Track_Test_Case,
result: {},
deletePath: "/test/case/delete",
condition: {
@ -443,6 +443,10 @@ export default {
item.tags = JSON.parse(item.tags);
}
})
if (this.$refs.table) {
this.$refs.table.doLayout()
}
});
}
},

View File

@ -4,6 +4,7 @@
:tree-nodes="treeNodes"
:data-map="dataMap"
:tags="tags"
:distinct-tags="tags"
@save="save"
/>
</template>
@ -48,23 +49,29 @@ name: "TestCaseMinder",
},
save(data) {
let saveCases = [];
this.buildSaveCase(data.root, saveCases, undefined);
let deleteCases = [];
this.buildSaveCase(data.root, saveCases, deleteCases, undefined);
let param = {
projectId: this.projectId,
data: saveCases
data: saveCases,
ids: deleteCases.map(item => item.id)
}
this.result = this.$post('/test/case/minder/edit', param, () => {
this.$success(this.$t('commons.save_success'));
});
},
buildSaveCase(root, saveCases, parent) {
buildSaveCase(root, saveCases, deleteCases, parent) {
let data = root.data;
if (data.resource && data.resource.indexOf(this.$t('api_test.definition.request.case')) > -1) {
this._buildSaveCase(root, saveCases, parent);
} else {
let deleteChild = data.deleteChild;
if (deleteChild && deleteChild.length > 0) {
deleteCases.push(...deleteChild);
}
if (root.children) {
root.children.forEach((childNode) => {
this.buildSaveCase(childNode, saveCases, root.data);
this.buildSaveCase(childNode, saveCases, deleteCases, root.data);
})
}
}
@ -83,7 +90,7 @@ name: "TestCaseMinder",
type: data.type ? data.type : 'functional',
method: data.method ? data.method: 'manual',
maintainer: data.maintainer,
priority: 'P' + (data.priority ? data.priority : 0),
priority: 'P' + (data.priority ? data.priority - 1 : 0),
};
if (data.changed) isChange = true;
let steps = [];
@ -117,6 +124,11 @@ name: "TestCaseMinder",
if (isChange) {
saveCases.push(testCase);
}
if (testCase.nodeId.length < 15) {
let tip = this.$t('test_track.case.create_case') + "'" + testCase.name + "'" + this.$t('test_track.case.minder_create_tip');
this.$error(tip)
throw new Error(tip);
}
},
}

View File

@ -10,7 +10,7 @@ export function getTestCaseDataMap(testCase, isDisable, setParamCallback) {
data: {
id: item.id,
text: item.name,
priority: Number.parseInt(item.priority.substring(item.priority.length - 1 )),
priority: Number.parseInt(item.priority.substring(item.priority.length - 1 )) + 1,
resource: ["用例"],
type: item.type,
method: item.method,

View File

@ -188,7 +188,7 @@ export default {
},
redirectPage(page,dataType,selectType){
//test_plan
this.$router.push('/track/plan/view/'+selectType);
// this.$router.push('/track/plan/view/'+selectType);
switch (page){
case "case":
this.$router.push({name:'testCase',params:{dataType:dataType,dataSelectRange:selectType, projectId: getCurrentProjectID()}});

View File

@ -248,7 +248,7 @@ export default {
return {
type: TEST_PLAN_LIST,
headerItems: Test_Plan_List,
tableLabel: [],
tableLabel: Test_Plan_List,
result: {},
enableDeleteTip: false,
queryPath: "/test/plan/list",

View File

@ -192,7 +192,7 @@ export default {
return {
type: TEST_PLAN_API_CASE,
headerItems: Test_Plan_Api_Case,
tableLabel: [],
tableLabel: Test_Plan_Api_Case,
condition: {},
selectCase: {},
result: {},

View File

@ -148,7 +148,7 @@ export default {
return {
type: TEST_PLAN_SCENARIO_CASE,
headerItems: Test_Plan_Scenario_Case,
tableLabel: [],
tableLabel: Test_Plan_Scenario_Case,
loading: false,
condition: {},
currentScenario: {},
@ -274,7 +274,7 @@ export default {
execute(row) {
this.infoDb = false;
let param = this.buildExecuteParam(row);
console.log(param)
if (this.planId) {
this.$post("/test/plan/scenario/case/run", param, response => {
this.runVisible = true;
@ -293,6 +293,7 @@ export default {
// param.id = row.id;
param.id = getUUID();
param.planScenarioId = row.id;
console.log(row.id)
param.projectId = row.projectId;
param.planCaseIds = [];
param.planCaseIds.push(row.id);

View File

@ -48,10 +48,8 @@
<span class="cast_item">{{ testCase.priority }}</span>
</el-col>
<el-col :span="5">
<span class="cast_label">{{ $t('test_track.case.case_type') }}</span>
<span class="cast_item" v-if="testCase.type === 'functional'">{{ $t('commons.functional') }}</span>
<span class="cast_item" v-if="testCase.type === 'performance'">{{ $t('commons.performance') }}</span>
<span class="cast_item" v-if="testCase.type === 'api'">{{ $t('commons.api') }}</span>
<span class="cast_label">{{ $t('test_track.case.module') }}</span>
<span class="cast_item">{{ testCase.nodePath }}</span>
</el-col>
<el-col :span="10">
<test-plan-test-case-status-button class="status-button"
@ -63,15 +61,6 @@
</el-row>
<el-row>
<el-col :span="4" :offset="1">
<span class="cast_label">{{ $t('test_track.case.method') }}</span>
<span v-if="testCase.method === 'manual'">{{ $t('test_track.case.manual') }}</span>
<span v-if="testCase.method === 'auto'">{{ $t('test_track.case.auto') }}</span>
</el-col>
<el-col :span="5">
<span class="cast_label">{{ $t('test_track.case.module') }}</span>
<span class="cast_item">{{ testCase.nodePath }}</span>
</el-col>
<el-col :span="4" :offset="1">
<span class="cast_label">{{ $t('test_track.plan.plan_project') }}</span>
<span class="cast_item">{{ testCase.projectName }}</span>

View File

@ -4,9 +4,12 @@
<!-- <template v-slot:header>-->
<ms-table-header :is-tester-permission="true" :condition.sync="condition" @search="initTableData"
:show-create="false" :tip="$t('commons.search_by_id_name_tag')">
<!-- 不显示 全部用例 标题,使标题为空 -->
<template v-slot:title>
<node-breadcrumb class="table-title" :nodes="selectParentNodes" @refresh="breadcrumbRefresh"/>
<span></span>
</template>
<template v-slot:button>
<ms-table-button :is-tester-permission="true" v-if="!showMyTestCase" icon="el-icon-s-custom"
:content="$t('test_track.plan_view.my_case')" @click="searchMyTestCase"/>
@ -15,8 +18,11 @@
<ms-table-button :is-tester-permission="true" icon="el-icon-connection"
:content="$t('test_track.plan_view.relevance_test_case')"
@click="$emit('openTestCaseRelevanceDialog')"/>
<ms-table-button :is-tester-permission="true" icon="el-icon-document-remove"
:content="$t('test_track.plan_view.cancel_all_relevance')" @click="handleDeleteBatch"/>
<!-- 删除 取消全部关联 按钮-->
<!-- <ms-table-button :is-tester-permission="true" icon="el-icon-document-remove"-->
<!-- :content="$t('test_track.plan_view.cancel_all_relevance')" @click="handleDeleteBatch"/>-->
</template>
</ms-table-header>
<!-- </template>-->
@ -27,6 +33,7 @@
:select-ids="new Set(Array.from(this.selectRows).map(row => row.id))" @refresh="initTableData"/>
<el-table
ref="table"
class="adjust-table"
border
@select-all="handleSelectAll"
@ -173,6 +180,16 @@
column-key="executor"
:label="$t('test_track.plan_view.executor')">
</el-table-column>
<!-- 责任人(创建该用例时所关联的责任人) -->
<el-table-column
v-if="item.id == 'maintainer'"
prop="maintainer"
:filters="maintainerFilters"
min-width="100px"
:key="index"
column-key="maintainer"
:label="$t('api_test.definition.request.responsible')">
</el-table-column>
<el-table-column
v-if="item.id == 'status'"
@ -312,7 +329,7 @@ export default {
return {
type: TEST_PLAN_FUNCTION_TEST_CASE,
headerItems: Test_Plan_Function_Test_Case,
tableLabel: [],
tableLabel: Test_Plan_Function_Test_Case,
result: {},
deletePath: "/test/case/delete",
condition: {
@ -352,6 +369,7 @@ export default {
{text: this.$t('test_track.plan.plan_status_running'), value: 'Underway'},
],
executorFilters: [],
maintainerFilters: [],
showMore: false,
buttons: [
{
@ -462,6 +480,9 @@ export default {
}
}
this.selectRows.clear();
if (this.$refs.table) {
this.$refs.table.doLayout()
}
});
}
getLabel(this, TEST_PLAN_FUNCTION_TEST_CASE);
@ -665,6 +686,9 @@ export default {
this.executorFilters = response.data.map(u => {
return {text: u.name, value: u.id}
});
this.maintainerFilters = response.data.map(u => {
return {text: u.id + '(' + u.name + ')', value: u.id};
});
});
}
}

View File

@ -154,7 +154,7 @@ export default {
return {
type: TEST_PLAN_LOAD_CASE,
headerItems: Test_Plan_Load_Case,
tableLabel: [],
tableLabel: Test_Plan_Load_Case,
condition: {},
result: {},
tableData: [],

View File

@ -74,8 +74,12 @@
</el-row>
<el-row>
<el-col :offset="1">
<span class="cast_label">{{ $t('test_track.plan_view.relevance_test_case') }}</span>
<span class="cast_item">{{ testCase.prerequisite }}</span>
<span class="cast_label">关联测试</span>
<span v-for="(item,index) in testCase.list" :key="index">
<el-button @click="openTest(item)" type="text" style="margin-left: 7px;">{{
item.testName
}}</el-button>
</span>
</el-col>
</el-row>
<el-row>
@ -241,7 +245,7 @@ import PerformanceTestDetail from "../../../plan/view/comonents/test/Performance
import ApiTestResult from "../../../plan/view/comonents/test/ApiTestResult";
import ApiTestDetail from "../../../plan/view/comonents/test/ApiTestDetail";
import TestPlanTestCaseStatusButton from "../../../plan/common/TestPlanTestCaseStatusButton";
import {getCurrentProjectID, listenGoBack, removeGoBackListener} from "@/common/js/utils";
import {getCurrentProjectID, getUUID, listenGoBack, removeGoBackListener} from "@/common/js/utils";
import ReviewComment from "../../commom/ReviewComment";
import TestCaseAttachment from "@/business/components/track/case/components/TestCaseAttachment";
import ApiCaseItem from "@/business/components/api/definition/components/case/ApiCaseItem";
@ -295,6 +299,35 @@ export default {
}
},
methods: {
openTest(item) {
const type = item.testType;
const id = item.testId;
switch (type) {
case "performance": {
let performanceData = this.$router.resolve({
path: '/performance/test/edit/' + id,
})
window.open(performanceData.href, '_blank');
break;
}
case "testcase": {
let caseData = this.$router.resolve({
name: 'ApiDefinition',
params: {redirectID: getUUID(), dataType: "apiTestCase", dataSelectRange: 'single:' + id}
});
window.open(caseData.href, '_blank');
break;
}
case "automation": {
let automationData = this.$router.resolve({
name: 'ApiAutomation',
params: {redirectID: getUUID(), dataType: "scenario", dataSelectRange: 'edit:' + id}
});
window.open(automationData.href, '_blank');
break;
}
}
},
handleClose() {
removeGoBackListener(this.handleClose);
this.showDialog = false;
@ -354,6 +387,7 @@ export default {
item.steptResults.push(item.steps[i]);
}
this.testCase = item;
console.log(this.testCase)
this.getRelatedTest();
this.getComments(item);
/* this.initTest();*/

@ -1 +1 @@
Subproject commit f63ebb68ebad78de42fd711f17e2671e34577a86
Subproject commit 3571feccf7c2bc68e4b619f6c367ac47d37c6723

View File

@ -69,6 +69,10 @@ html,body {
border-right-color: white !important;
}
.adjust-table.ms-select-all-fixed th:first-child.el-table-column--selection {
border-right-color: #DCDFE6 !important;
}
.adjust-table {
border-color: white !important;
}

View File

@ -945,9 +945,9 @@ export default {
export_tip: "Export Tip",
ms_tip: "Support for MeterSphere JSON format",
ms_export_tip: "Export jSON-formatted files via MeterSphere website or browser plug-ins",
har_export_tip: "Export Har files by browser dev-tool",
har_export_tip: "Export HAR files by browser dev-tool",
swagger_tip: "Swagger 2.0 and 3.0 json files are supported",
har_tip: "Only Har files are supported",
har_tip: "Only HAR files are supported",
postman_tip: "Only Postman Collection V2.1 json files are supported",
postman_export_tip: "Export the test collection by Postman",
swagger_export_tip: "Export jSON-formatted files via Swagger website",
@ -1128,6 +1128,7 @@ export default {
case: {
list: "List",
minder: "Minder",
minder_create_tip: "failed, unable to create its parent module in minder",
check_select: "Please check the case",
export_all_cases: 'Are you sure you want to export all use cases?',
input_test_case: 'Please enter the associated case name',

View File

@ -948,10 +948,10 @@ export default {
export_tip: "导出方法",
ms_tip: "支持 MeterSphere json 格式",
ms_export_tip: "通过 MeterSphere 接口测试页面或者浏览器插件导出 json 格式文件",
har_export_tip: "通过 浏览器的开发者工具 导出 Har 格式文件",
har_export_tip: "通过 浏览器的开发者工具 导出 HAR 格式文件",
postman_tip: "只支持 Postman Collection v2.1 格式的 json 文件",
swagger_tip: "支持 Swagger 2.0 与 3.0 版本的 json 文件",
har_tip: "只支持 Har 文件",
har_tip: "只支持 HAR 文件",
post_export_tip: "通过 Postman 导出测试集合",
swagger_export_tip: "通过 Swagger 页面导出",
jmeter_export_tip: "通过 JMeter 生成JMX文件",
@ -1132,6 +1132,7 @@ export default {
case: {
list: "列表",
minder: "脑图",
minder_create_tip: "失败, 无法在脑图创建其父模块",
check_select: "请勾选用例",
export_all_cases: '确定要导出全部用例吗?',
input_test_case: '请输入关联用例名称',

View File

@ -947,10 +947,10 @@ export default {
export_tip: "導出方法",
ms_tip: "支持 MeterSphere json 格式",
ms_export_tip: "通過 MeterSphere 接口測試頁面或者瀏覽器插件導出 json 格式文件",
har_export_tip: "通过 瀏覽器到開發者工具 导出 Har 格式文件",
har_export_tip: "通过 瀏覽器到開發者工具 导出 HAR 格式文件",
postman_tip: "只支持 Postman Collection v2.1 格式的 json 文件",
swagger_tip: "支持 Swagger 2.0 與 3.0 版本的 json 文件",
har_tip: "只支持 Har 文件",
har_tip: "只支持 HAR 文件",
post_export_tip: "通過 Postman 導出測試集合",
swagger_export_tip: "通過 Swagger 頁面導出",
jmeter_export_tip: "通過 JMeter 生成JMX文件",
@ -1130,6 +1130,7 @@ export default {
case: {
list: "列表",
minder: "腦圖",
minder_create_tip: "失敗, 無法在腦圖創建其父模塊",
check_select: "請勾選用例",
export_all_cases: '確定要導出全部用例嗎?',
input_test_case: '請輸入關聯用例名稱',