Merge remote-tracking branch 'origin/master'

# Conflicts:
#	frontend/src/business/components/api/definition/components/module/ApiModuleHeader.vue
#	frontend/src/i18n/en-US.js
#	frontend/src/i18n/zh-CN.js
#	frontend/src/i18n/zh-TW.js
This commit is contained in:
song.tianyang 2021-03-23 17:28:07 +08:00
commit dc1ef10180
76 changed files with 619 additions and 376 deletions

View File

@ -80,8 +80,8 @@ public class ApiAutomationController {
} }
@PostMapping("/reduction") @PostMapping("/reduction")
public void reduction(@RequestBody List<SaveApiScenarioRequest> requests) { public void reduction(@RequestBody List<String> ids) {
apiAutomationService.reduction(requests); apiAutomationService.reduction(ids);
} }
@GetMapping("/getApiScenario/{id}") @GetMapping("/getApiScenario/{id}")

View File

@ -133,8 +133,8 @@ public class ApiDefinitionController {
} }
@PostMapping("/reduction") @PostMapping("/reduction")
public void reduction(@RequestBody List<SaveApiDefinitionRequest> requests) { public void reduction(@RequestBody ApiBatchRequest request) {
apiDefinitionService.reduction(requests); apiDefinitionService.reduction(request);
} }
@GetMapping("/get/{id}") @GetMapping("/get/{id}")

View File

@ -40,4 +40,7 @@ public class ApiTestBatchRequest extends ApiTestCaseWithBLOBs {
private String protocol; private String protocol;
private String status; private String status;
private String envId;
} }

View File

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

View File

@ -17,6 +17,8 @@ import org.apache.jmeter.control.LoopController;
import org.apache.jmeter.control.RunTime; import org.apache.jmeter.control.RunTime;
import org.apache.jmeter.control.WhileController; import org.apache.jmeter.control.WhileController;
import org.apache.jmeter.modifiers.CounterConfig; import org.apache.jmeter.modifiers.CounterConfig;
import org.apache.jmeter.modifiers.JSR223PreProcessor;
import org.apache.jmeter.protocol.java.sampler.JSR223Sampler;
import org.apache.jmeter.reporters.ResultAction; import org.apache.jmeter.reporters.ResultAction;
import org.apache.jmeter.save.SaveService; import org.apache.jmeter.save.SaveService;
import org.apache.jmeter.testelement.TestElement; import org.apache.jmeter.testelement.TestElement;
@ -24,6 +26,7 @@ import org.apache.jmeter.timers.ConstantTimer;
import org.apache.jorphan.collections.HashTree; import org.apache.jorphan.collections.HashTree;
import java.util.List; import java.util.List;
import java.util.UUID;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ -42,6 +45,9 @@ public class MsLoopController extends MsTestElement {
@JSONField(ordinal = 23) @JSONField(ordinal = 23)
private MsWhileController whileController; private MsWhileController whileController;
private String ms_current_timer = UUID.randomUUID().toString();
@Override @Override
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) { public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
// 非导出操作且不是启用状态则跳过执行 // 非导出操作且不是启用状态则跳过执行
@ -122,7 +128,8 @@ public class MsLoopController extends MsTestElement {
operator = ""; operator = "";
value = ""; value = "";
} }
return "${__jexl3(" + variable + operator + value + ")}"; ms_current_timer = UUID.randomUUID().toString();
return "${__jexl3(" + variable + operator + value + " && \"${" + ms_current_timer + "}\" !=\"stop\")}";
} }
private WhileController initWhileController() { private WhileController initWhileController() {
@ -151,6 +158,32 @@ public class MsLoopController extends MsTestElement {
return controller; return controller;
} }
private String script() {
String script = "\n" +
"import java.util.*;\n" +
"import java.text.SimpleDateFormat;\n" +
"import org.apache.jmeter.threads.JMeterContextService;\n" +
"\n" +
"// 循环控制器超时后结束循环\n" +
"try{\n" +
"\tString ms_current_timer = vars.get(\"" + ms_current_timer + "\");\n" +
"\tlong _nowTime = System.currentTimeMillis(); \n" +
"\tif(ms_current_timer == null ){\n" +
"\t\tvars.put(\"" + ms_current_timer + "\",_nowTime.toString());\n" +
"\t}\n" +
"\tlong time = Long.parseLong(vars.get(\"" + ms_current_timer + "\"));\n" +
"\t if((_nowTime - time) > " + this.whileController.getTimeout() + " ){\n" +
"\t \tvars.put(\"" + ms_current_timer + "\", \"stop\");\n" +
"\t \tlog.info( \"结束循环\");\n" +
"\t }\n" +
"}catch (Exception e){\n" +
"\tlog.info( e.getMessage());\n" +
"\tvars.put(\"" + ms_current_timer + "\", \"stop\");\n" +
"}\n";
return script;
}
private HashTree controller(HashTree tree) { private HashTree controller(HashTree tree) {
if (StringUtils.equals(this.loopType, LoopConstants.WHILE.name()) && this.whileController != null) { if (StringUtils.equals(this.loopType, LoopConstants.WHILE.name()) && this.whileController != null) {
RunTime runTime = new RunTime(); RunTime runTime = new RunTime();
@ -162,9 +195,17 @@ public class MsLoopController extends MsTestElement {
timeout = 1; timeout = 1;
} }
runTime.setRuntime(timeout); runTime.setRuntime(timeout);
HashTree hashTree = tree.add(initWhileController());
// 添加超时处理防止死循环 // 添加超时处理防止死循环
HashTree hashTree = tree.add(runTime); JSR223PreProcessor jsr223PreProcessor = new JSR223PreProcessor();
return hashTree.add(initWhileController()); jsr223PreProcessor.setName("循环超时处理");
jsr223PreProcessor.setProperty(TestElement.TEST_CLASS, JSR223Sampler.class.getName());
jsr223PreProcessor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI"));
jsr223PreProcessor.setProperty("cacheKey", "true");
jsr223PreProcessor.setProperty("scriptLanguage", "beanshell");
jsr223PreProcessor.setProperty("script", script());
hashTree.add(jsr223PreProcessor);
return hashTree;
} }
if (StringUtils.equals(this.loopType, LoopConstants.FOREACH.name()) && this.forEachController != null) { if (StringUtils.equals(this.loopType, LoopConstants.FOREACH.name()) && this.forEachController != null) {
return tree.add(initForeachController()); return tree.add(initForeachController());

View File

@ -34,10 +34,10 @@ public class MsExtract extends MsTestElement {
if (!config.isOperating() && !this.isEnable()) { if (!config.isOperating() && !this.isEnable()) {
return; return;
} }
addRequestExtractors(tree); addRequestExtractors(tree, config);
} }
private void addRequestExtractors(HashTree samplerHashTree) { private void addRequestExtractors(HashTree samplerHashTree, ParameterConfig config) {
StringJoiner extract = new StringJoiner(";"); StringJoiner extract = new StringJoiner(";");
if (CollectionUtils.isNotEmpty(this.getRegex())) { if (CollectionUtils.isNotEmpty(this.getRegex())) {
@ -55,7 +55,7 @@ public class MsExtract extends MsTestElement {
samplerHashTree.add(jsonPostProcessor(extractJSONPath, extract)) samplerHashTree.add(jsonPostProcessor(extractJSONPath, extract))
); );
} }
if (Optional.ofNullable(extract).orElse(extract).length() > 0) { if (Optional.ofNullable(extract).orElse(extract).length() > 0 && !config.isOperating()) {
JSR223PostProcessor shell = new JSR223PostProcessor(); JSR223PostProcessor shell = new JSR223PostProcessor();
shell.setEnabled(true); shell.setEnabled(true);
shell.setName(StringUtils.isEmpty(this.getName()) ? "JSR223PostProcessor" : this.getName()); shell.setName(StringUtils.isEmpty(this.getName()) ? "JSR223PostProcessor" : this.getName());

View File

@ -114,10 +114,14 @@ public class ApiAutomationService {
Map<String, String> map = d.getEnvironmentMap(); Map<String, String> map = d.getEnvironmentMap();
if (map != null) { if (map != null) {
if (map.isEmpty()) { if (map.isEmpty()) {
try {
List<String> ids = (List<String>) JSONPath.read(definition, "$..projectId"); List<String> ids = (List<String>) JSONPath.read(definition, "$..projectId");
if (CollectionUtils.isNotEmpty(ids)) { if (CollectionUtils.isNotEmpty(ids)) {
idList.addAll(new HashSet<>(ids)); idList.addAll(new HashSet<>(ids));
} }
} catch (Exception e) {
LogUtil.error("JSONPath.read projectId fail.");
}
} else { } else {
Set<String> set = d.getEnvironmentMap().keySet(); Set<String> set = d.getEnvironmentMap().keySet();
idList = new ArrayList<>(set); idList = new ArrayList<>(set);
@ -316,13 +320,8 @@ public class ApiAutomationService {
} }
} }
public void reduction(List<SaveApiScenarioRequest> requests) { public void reduction(List<String> ids) {
List<String> apiIds = new ArrayList<>(); extApiScenarioMapper.reduction(ids);
requests.forEach(item -> {
checkNameExist(item);
apiIds.add(item.getId());
});
extApiScenarioMapper.reduction(apiIds);
} }
private void checkNameExist(SaveApiScenarioRequest request) { private void checkNameExist(SaveApiScenarioRequest request) {

View File

@ -137,10 +137,11 @@ public class ApiDefinitionService {
public ApiDefinitionWithBLOBs getBLOBs(String id) { public ApiDefinitionWithBLOBs getBLOBs(String id) {
return apiDefinitionMapper.selectByPrimaryKey(id); return apiDefinitionMapper.selectByPrimaryKey(id);
} }
public List<ApiDefinitionWithBLOBs> getBLOBs(List<String> idList) { public List<ApiDefinitionWithBLOBs> getBLOBs(List<String> idList) {
if(idList == null || idList.isEmpty()){ if (idList == null || idList.isEmpty()) {
return new ArrayList<>(0); return new ArrayList<>(0);
}else{ } else {
ApiDefinitionExample example = new ApiDefinitionExample(); ApiDefinitionExample example = new ApiDefinitionExample();
example.createCriteria().andIdIn(idList); example.createCriteria().andIdIn(idList);
example.setOrderByClause("create_time DESC "); example.setOrderByClause("create_time DESC ");
@ -190,13 +191,8 @@ public class ApiDefinitionService {
extApiDefinitionMapper.removeToGc(apiIds); extApiDefinitionMapper.removeToGc(apiIds);
} }
public void reduction(List<SaveApiDefinitionRequest> requests) { public void reduction(ApiBatchRequest request) {
List<String> apiIds = new ArrayList<>(); extApiDefinitionMapper.reduction(request.getIds());
requests.forEach(item -> {
checkNameExist(item);
apiIds.add(item.getId());
});
extApiDefinitionMapper.reduction(apiIds);
} }
public void deleteBodyFiles(String apiId) { public void deleteBodyFiles(String apiId) {
@ -244,7 +240,7 @@ public class ApiDefinitionService {
private ApiDefinition updateTest(SaveApiDefinitionRequest request) { private ApiDefinition updateTest(SaveApiDefinitionRequest request) {
checkNameExist(request); checkNameExist(request);
if(StringUtils.equals(request.getMethod(),"ESB")){ if (StringUtils.equals(request.getMethod(), "ESB")) {
//ESB的接口类型数据采用TCP方式去发送并将方法类型改为TCP 并修改发送数据 //ESB的接口类型数据采用TCP方式去发送并将方法类型改为TCP 并修改发送数据
request = esbApiParamService.handleEsbRequest(request); request = esbApiParamService.handleEsbRequest(request);
} }
@ -273,7 +269,7 @@ public class ApiDefinitionService {
private ApiDefinition createTest(SaveApiDefinitionRequest request) { private ApiDefinition createTest(SaveApiDefinitionRequest request) {
checkNameExist(request); checkNameExist(request);
if(StringUtils.equals(request.getMethod(),"ESB")){ if (StringUtils.equals(request.getMethod(), "ESB")) {
//ESB的接口类型数据采用TCP方式去发送并将方法类型改为TCP 并修改发送数据 //ESB的接口类型数据采用TCP方式去发送并将方法类型改为TCP 并修改发送数据
request = esbApiParamService.handleEsbRequest(request); request = esbApiParamService.handleEsbRequest(request);
} }
@ -764,6 +760,7 @@ public class ApiDefinitionService {
calculateResult(resList); calculateResult(resList);
return resList; return resList;
} }
public List<ApiDefinitionResult> listRelevanceReview(ApiDefinitionRequest request) { public List<ApiDefinitionResult> listRelevanceReview(ApiDefinitionRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
List<ApiDefinitionResult> resList = extApiDefinitionMapper.listRelevanceReview(request); List<ApiDefinitionResult> resList = extApiDefinitionMapper.listRelevanceReview(request);
@ -795,7 +792,7 @@ public class ApiDefinitionService {
res.setCaseStatus("-"); res.setCaseStatus("-");
} }
if(StringUtils.equals("ESB",res.getMethod())){ if (StringUtils.equals("ESB", res.getMethod())) {
esbApiParamService.handleApiEsbParams(res); esbApiParamService.handleApiEsbParams(res);
} }
} }
@ -882,8 +879,7 @@ public class ApiDefinitionService {
((MsApiExportResult) apiExportResult).setProtocol(request.getProtocol()); ((MsApiExportResult) apiExportResult).setProtocol(request.getProtocol());
((MsApiExportResult) apiExportResult).setProjectId(request.getProjectId()); ((MsApiExportResult) apiExportResult).setProjectId(request.getProjectId());
((MsApiExportResult) apiExportResult).setVersion(System.getenv("MS_VERSION")); ((MsApiExportResult) apiExportResult).setVersion(System.getenv("MS_VERSION"));
} } else { // 导出为 Swagger 格式
else { // 导出为 Swagger 格式
Swagger3Parser swagger3Parser = new Swagger3Parser(); Swagger3Parser swagger3Parser = new Swagger3Parser();
System.out.println(apiDefinitionMapper.selectByExampleWithBLOBs(example)); System.out.println(apiDefinitionMapper.selectByExampleWithBLOBs(example));
apiExportResult = swagger3Parser.swagger3Export(apiDefinitionMapper.selectByExampleWithBLOBs(example)); apiExportResult = swagger3Parser.swagger3Export(apiDefinitionMapper.selectByExampleWithBLOBs(example));

View File

@ -230,7 +230,7 @@ public class ApiTestCaseService {
private ApiTestCase updateTest(SaveApiTestCaseRequest request) { private ApiTestCase updateTest(SaveApiTestCaseRequest request) {
checkNameExist(request); checkNameExist(request);
if(StringUtils.isNotEmpty(request.getEsbDataStruct())){ if (StringUtils.isNotEmpty(request.getEsbDataStruct())) {
request = esbApiParamService.handleEsbRequest(request); request = esbApiParamService.handleEsbRequest(request);
} }
@ -253,7 +253,7 @@ public class ApiTestCaseService {
request.setId(UUID.randomUUID().toString()); request.setId(UUID.randomUUID().toString());
checkNameExist(request); checkNameExist(request);
if(StringUtils.isNotEmpty(request.getEsbDataStruct())||StringUtils.isNotEmpty(request.getBackEsbDataStruct())){ if (StringUtils.isNotEmpty(request.getEsbDataStruct()) || StringUtils.isNotEmpty(request.getBackEsbDataStruct())) {
request = esbApiParamService.handleEsbRequest(request); request = esbApiParamService.handleEsbRequest(request);
} }
@ -332,7 +332,8 @@ public class ApiTestCaseService {
List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(example); List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(example);
relevance(apiTestCases, request); relevance(apiTestCases, request);
} }
public void relevanceByApiByReview(ApiCaseRelevanceRequest request){
public void relevanceByApiByReview(ApiCaseRelevanceRequest request) {
List<String> ids = request.getSelectIds(); List<String> ids = request.getSelectIds();
if (CollectionUtils.isEmpty(ids)) { if (CollectionUtils.isEmpty(ids)) {
return; return;
@ -342,6 +343,7 @@ public class ApiTestCaseService {
List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(example); List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(example);
relevanceByReview(apiTestCases, request); relevanceByReview(apiTestCases, request);
} }
public void relevanceByCase(ApiCaseRelevanceRequest request) { public void relevanceByCase(ApiCaseRelevanceRequest request) {
List<String> ids = request.getSelectIds(); List<String> ids = request.getSelectIds();
if (CollectionUtils.isEmpty(ids)) { if (CollectionUtils.isEmpty(ids)) {
@ -391,7 +393,7 @@ public class ApiTestCaseService {
TestCaseReviewApiCase.setUpdateTime(System.currentTimeMillis()); TestCaseReviewApiCase.setUpdateTime(System.currentTimeMillis());
batchMapper.insertIfNotExists(TestCaseReviewApiCase); batchMapper.insertIfNotExists(TestCaseReviewApiCase);
}); });
TestCaseReview testCaseReview=testCaseReviewMapper.selectByPrimaryKey(request.getReviewId()); TestCaseReview testCaseReview = testCaseReviewMapper.selectByPrimaryKey(request.getReviewId());
if (StringUtils.equals(testCaseReview.getStatus(), TestPlanStatus.Prepare.name()) if (StringUtils.equals(testCaseReview.getStatus(), TestPlanStatus.Prepare.name())
|| StringUtils.equals(testCaseReview.getStatus(), TestPlanStatus.Completed.name())) { || StringUtils.equals(testCaseReview.getStatus(), TestPlanStatus.Completed.name())) {
testCaseReview.setStatus(TestPlanStatus.Underway.name()); testCaseReview.setStatus(TestPlanStatus.Underway.name());
@ -399,11 +401,13 @@ public class ApiTestCaseService {
} }
sqlSession.flushStatements(); sqlSession.flushStatements();
} }
public List<String> selectIdsNotExistsInPlan(String projectId, String planId) { public List<String> selectIdsNotExistsInPlan(String projectId, String planId) {
return extApiTestCaseMapper.selectIdsNotExistsInPlan(projectId, planId); return extApiTestCaseMapper.selectIdsNotExistsInPlan(projectId, planId);
} }
public List<String> selectIdsNotExistsInReview(String projectId,String reviewId){
return extApiTestCaseMapper.selectIdsNotExistsInReview(projectId,reviewId); public List<String> selectIdsNotExistsInReview(String projectId, String reviewId) {
return extApiTestCaseMapper.selectIdsNotExistsInReview(projectId, reviewId);
} }
public List<ApiDataCountResult> countProtocolByProjectID(String projectId) { public List<ApiDataCountResult> countProtocolByProjectID(String projectId) {
@ -497,7 +501,22 @@ public class ApiTestCaseService {
sqlSession.flushStatements(); sqlSession.flushStatements();
} }
if (StringUtils.isNotEmpty(request.getEnvId())) {
List<ApiTestCaseWithBLOBs> bloBs = apiTestCaseMapper.selectByExampleWithBLOBs(apiDefinitionExample);
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
ApiTestCaseMapper batchMapper = sqlSession.getMapper(ApiTestCaseMapper.class);
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
bloBs.forEach(apiTestCase -> {
JSONObject req = JSON.parseObject(apiTestCase.getRequest());
req.put("useEnvironment", request.getEnvId());
String requestStr = JSON.toJSONString(req);
apiTestCase.setRequest(requestStr);
batchMapper.updateByPrimaryKeySelective(apiTestCase);
});
sqlSession.flushStatements();
}
} }
private List<String> getAllApiCaseIdsByFontedSelect(Map<String, List<String>> filters, List<String> moduleIds, String name, String projectId, String protocol, List<String> unSelectIds, String status) { private List<String> getAllApiCaseIdsByFontedSelect(Map<String, List<String>> filters, List<String> moduleIds, String name, String projectId, String protocol, List<String> unSelectIds, String status) {

View File

@ -306,9 +306,12 @@
or test_case.num like CONCAT('%', #{request.name},'%') or test_case.num like CONCAT('%', #{request.name},'%')
or test_case.tags like CONCAT('%', #{request.name},'%')) or test_case.tags like CONCAT('%', #{request.name},'%'))
</if> </if>
<if test="request.createTime >0"> <if test="request.relevanceCreateTime >0">
and test_case.id in (select test_case_id from test_case_test where test_case_test.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>
<if test="request.createTime >0">
and test_case.create_time >= #{request.createTime}
</if>
<if test="request.nodeIds != null and request.nodeIds.size() > 0"> <if test="request.nodeIds != null and request.nodeIds.size() > 0">
and test_case.node_id in and test_case.node_id in
<foreach collection="request.nodeIds" item="nodeId" separator="," open="(" close=")"> <foreach collection="request.nodeIds" item="nodeId" separator="," open="(" close=")">

View File

@ -137,7 +137,7 @@
<select id="list" resultType="io.metersphere.track.dto.TestPlanCaseDTO"> <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, 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_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.update_time, test_case_node.name as model, project.name as projectName,
test_plan_test_case.plan_id as planId test_plan_test_case.plan_id as planId
@ -200,6 +200,12 @@
#{value} #{value}
</foreach> </foreach>
</when> </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'"> <when test="key=='executor'">
and test_plan_test_case.executor in and test_plan_test_case.executor in
<foreach collection="values" item="value" separator="," open="(" close=")"> <foreach collection="values" item="value" separator="," open="(" close=")">

View File

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

View File

@ -7,7 +7,6 @@ import io.metersphere.commons.utils.SessionUtils;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.ExpiredCredentialsException;
import org.apache.shiro.web.filter.authc.AnonymousFilter; import org.apache.shiro.web.filter.authc.AnonymousFilter;
import org.apache.shiro.web.util.WebUtils; import org.apache.shiro.web.util.WebUtils;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
@ -75,18 +74,6 @@ public class CsrfFilter extends AnonymousFilter {
if (signatureArray.length != 3) { if (signatureArray.length != 3) {
throw new RuntimeException("invalid token"); throw new RuntimeException("invalid token");
} }
long signatureTime;
try {
signatureTime = Long.parseLong(signatureArray[2]);
} catch (Exception e) {
throw new RuntimeException(e);
}
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 ExpiredCredentialsException("expired token");
}
if (!StringUtils.equals(SessionUtils.getUserId(), signatureArray[0])) { if (!StringUtils.equals(SessionUtils.getUserId(), signatureArray[0])) {
throw new RuntimeException("Please check csrf token."); throw new RuntimeException("Please check csrf token.");
} }

View File

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

View File

@ -23,7 +23,8 @@ public class ReportFailureAdvanceResultComponent extends ReportComponent {
@Override @Override
public void readRecord(TestPlanCaseDTO testCase) { public void readRecord(TestPlanCaseDTO testCase) {
if (StringUtils.equals(testCase.getStatus(), TestPlanTestCaseStatus.Failure.name())) { if (StringUtils.equals(testCase.getStatus(), TestPlanTestCaseStatus.Failure.name()) ||
StringUtils.equals(testCase.getStatus(), TestPlanTestCaseStatus.Blocking.name())) {
this.functionalTestCases.add(testCase); this.functionalTestCases.add(testCase);
} }
} }

View File

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

View File

@ -24,8 +24,10 @@ public class QueryTestCaseRequest extends BaseQueryRequest {
private String reviewId; private String reviewId;
private boolean isSelectThisWeedData = false; private boolean isSelectThisWeedData = false;
private boolean isSelectThisWeedRelevanceData = false;
private String caseCoverage; private String caseCoverage;
private long createTime = 0; private long createTime = 0;
private long relevanceCreateTime = 0;
} }

View File

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

View File

@ -6,7 +6,7 @@ public class TrackCount {
public static final String P2 = "P2"; public static final String P2 = "P2";
public static final String P3 = "P3"; 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 PERFORMANCE = "performance";
public static final String AUTOMATION = "automation"; public static final String AUTOMATION = "automation";
} }

View File

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

View File

@ -210,13 +210,19 @@ public class TestCaseService {
*/ */
private void initRequest(QueryTestCaseRequest request, boolean checkThisWeekData) { private void initRequest(QueryTestCaseRequest request, boolean checkThisWeekData) {
if (checkThisWeekData) { if (checkThisWeekData) {
if (request.isSelectThisWeedData()) {
Map<String, Date> weekFirstTimeAndLastTime = DateUtils.getWeedFirstTimeAndLastTime(new Date()); Map<String, Date> weekFirstTimeAndLastTime = DateUtils.getWeedFirstTimeAndLastTime(new Date());
Date weekFirstTime = weekFirstTimeAndLastTime.get("firstTime"); Date weekFirstTime = weekFirstTimeAndLastTime.get("firstTime");
if (request.isSelectThisWeedData()) {
if (weekFirstTime != null) { if (weekFirstTime != null) {
request.setCreateTime(weekFirstTime.getTime()); request.setCreateTime(weekFirstTime.getTime());
} }
} }
if (request.isSelectThisWeedRelevanceData()) {
if (weekFirstTime != null) {
request.setRelevanceCreateTime(weekFirstTime.getTime());
}
}
} }
} }
@ -780,6 +786,12 @@ public class TestCaseService {
editTestCase(item); 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) { public List<TestCase> getTestCaseByProjectId(String projectId) {

View File

@ -206,7 +206,7 @@ public class TestPlanService {
} }
else { // 有修改字段的调用为保证将某些时间置null的情况使用updateByPrimaryKey else { // 有修改字段的调用为保证将某些时间置null的情况使用updateByPrimaryKey
extScheduleMapper.updateNameByResourceID(testPlan.getId(), testPlan.getName());// 同步更新该测试的定时任务的name extScheduleMapper.updateNameByResourceID(testPlan.getId(), testPlan.getName());// 同步更新该测试的定时任务的name
i = testPlanMapper.updateByPrimaryKey(testPlan); // 更新 i = testPlanMapper.updateByPrimaryKeyWithBLOBs(testPlan); // 更新
} }
if (!StringUtils.isBlank(testPlan.getStatus())) { if (!StringUtils.isBlank(testPlan.getStatus())) {
BeanUtils.copyBean(testPlans, getTestPlan(testPlan.getId())); BeanUtils.copyBean(testPlans, getTestPlan(testPlan.getId()));

View File

@ -1,16 +1,16 @@
package io.metersphere.track.service; package io.metersphere.track.service;
import io.metersphere.base.domain.*; import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.TestCaseMapper; import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.TestCaseReviewMapper; import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper;
import io.metersphere.base.mapper.TestCaseReviewTestCaseMapper;
import io.metersphere.base.mapper.TestCaseReviewUsersMapper;
import io.metersphere.base.mapper.ext.ExtTestReviewCaseMapper; import io.metersphere.base.mapper.ext.ExtTestReviewCaseMapper;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.ServiceUtils; import io.metersphere.commons.utils.ServiceUtils;
import io.metersphere.commons.utils.SessionUtils; import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.member.QueryMemberRequest; import io.metersphere.controller.request.member.QueryMemberRequest;
import io.metersphere.service.UserService; 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.dto.TestReviewCaseDTO;
import io.metersphere.track.request.testplancase.TestReviewCaseBatchRequest; import io.metersphere.track.request.testplancase.TestReviewCaseBatchRequest;
import io.metersphere.track.request.testreview.DeleteRelevanceRequest; import io.metersphere.track.request.testreview.DeleteRelevanceRequest;
@ -29,7 +29,14 @@ import java.util.stream.Collectors;
@Service @Service
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public class TestReviewTestCaseService { public class TestReviewTestCaseService {
@Resource
private TestCaseTestMapper testCaseTestMapper;
@Resource
private LoadTestMapper loadTestMapper;
@Resource
private ApiTestCaseMapper apiTestCaseMapper;
@Resource
private ApiScenarioMapper apiScenarioMapper;
@Resource @Resource
ExtTestReviewCaseMapper extTestReviewCaseMapper; ExtTestReviewCaseMapper extTestReviewCaseMapper;
@Resource @Resource
@ -44,6 +51,8 @@ public class TestReviewTestCaseService {
TestCaseReviewService testCaseReviewService; TestCaseReviewService testCaseReviewService;
@Resource @Resource
TestCaseMapper testCaseMapper; TestCaseMapper testCaseMapper;
@Resource
ExtTestPlanTestCaseMapper extTestPlanTestCaseMapper;
public List<TestReviewCaseDTO> list(QueryCaseReviewRequest request) { public List<TestReviewCaseDTO> list(QueryCaseReviewRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
@ -128,7 +137,40 @@ public class TestReviewTestCaseService {
} }
public TestReviewCaseDTO get(String reviewId) { 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) { public void editTestCaseBatchStatus(TestReviewCaseBatchRequest request) {

View File

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

View File

@ -24,7 +24,7 @@
<el-table-column v-if="!referenced" width="30" min-width="30" :resizable="false" align="center"> <el-table-column v-if="!referenced" width="30" min-width="30" :resizable="false" align="center">
<template v-slot:default="scope"> <template v-slot:default="scope">
<show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectDataCounts" v-tester/> <show-more-btn :is-show="scope.row.showMore" :buttons="trashEnable ? trashButtons: buttons" :size="selectDataCounts" v-tester/>
</template> </template>
</el-table-column> </el-table-column>
<template v-for="(item, index) in tableLabel"> <template v-for="(item, index) in tableLabel">
@ -69,7 +69,7 @@
<el-table-column v-if="item.id == 'tags'" prop="tags" min-width="120px" <el-table-column v-if="item.id == 'tags'" prop="tags" min-width="120px"
:label="$t('api_test.automation.tag')" :key="index"> :label="$t('api_test.automation.tag')" :key="index">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :content="itemName" :show-tooltip="true" tooltip style="margin-left: 5px"/> <ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :content="itemName" :show-tooltip="true" tooltip style="margin-left: 0px; margin-right: 2px"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column v-if="item.id == 'userId'" prop="userId" min-width="120px" <el-table-column v-if="item.id == 'userId'" prop="userId" min-width="120px"
@ -244,7 +244,7 @@
return { return {
type: API_SCENARIO_LIST, type: API_SCENARIO_LIST,
headerItems: Api_Scenario_List, headerItems: Api_Scenario_List,
tableLabel: [], tableLabel: Api_Scenario_List,
loading: false, loading: false,
screenHeight: document.documentElement.clientHeight - 280,//, screenHeight: document.documentElement.clientHeight - 280,//,
condition: { condition: {
@ -286,6 +286,12 @@
{name: this.$t('api_test.definition.request.batch_delete'), handleClick: this.handleDeleteBatch}, {name: this.$t('api_test.definition.request.batch_delete'), handleClick: this.handleDeleteBatch},
], ],
trashButtons: [
{name: this.$t('api_test.definition.request.batch_delete'), handleClick: this.handleDeleteBatch},
{
name: "批量恢复", handleClick: this.handleBatchRestore
},
],
isSelectAllDate: false, isSelectAllDate: false,
selectRows: new Set(), selectRows: new Set(),
selectDataCounts: 0, selectDataCounts: 0,
@ -419,6 +425,9 @@
}); });
this.loading = false; this.loading = false;
this.unSelection = data.listObject.map(s => s.id); this.unSelection = data.listObject.map(s => s.id);
if (this.$refs.scenarioTable) {
this.$refs.scenarioTable.doLayout()
}
}); });
} }
getLabel(this, API_SCENARIO_LIST); getLabel(this, API_SCENARIO_LIST);
@ -589,10 +598,14 @@
this.$emit('edit', data); this.$emit('edit', data);
}, },
reductionApi(row) { reductionApi(row) {
row.scenarioDefinition = null; this.$post("/api/automation/reduction", [row.id], response => {
row.tags = null; this.$success(this.$t('commons.save_success'));
let rows = [row]; this.search();
this.$post("/api/automation/reduction", rows, response => { })
},
handleBatchRestore() {
let ids = Array.from(this.selectRows).map(row => row.id);
this.$post("/api/automation/reduction", ids, response => {
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
this.search(); this.search();
}) })

View File

@ -135,7 +135,6 @@
} }
// //
this.getApiInfo(); this.getApiInfo();
console.log(JSON.stringify(this.request));
if (this.request.protocol === 'HTTP') { if (this.request.protocol === 'HTTP') {
this.setUrl(this.request.url); this.setUrl(this.request.url);
this.setUrl(this.request.path); this.setUrl(this.request.path);

View File

@ -23,7 +23,7 @@
<el-button :disabled="scenarioDefinition.length < 1" size="mini" type="primary" v-prevent-re-click @click="runDebug">{{$t('api_test.request.debug')}}</el-button> <el-button :disabled="scenarioDefinition.length < 1" size="mini" type="primary" v-prevent-re-click @click="runDebug">{{$t('api_test.request.debug')}}</el-button>
<font-awesome-icon class="alt-ico" :icon="['fa', 'compress-alt']" size="lg" @click="unFullScreen"/> <font-awesome-icon class="ms-alt-ico" :icon="['fa', 'compress-alt']" size="lg" @click="unFullScreen"/>
<i class="el-icon-close alt-ico-close" @click="close"/> <i class="el-icon-close alt-ico-close" @click="close"/>
</div> </div>
@ -124,14 +124,12 @@
.ms-header-right { .ms-header-right {
float: right; float: right;
width: 420px;
margin-top: 2px; margin-top: 2px;
position: fixed;
right: 20px;
z-index: 1; z-index: 1;
} }
.alt-ico { .ms-alt-ico {
font-size: 16px; font-size: 16px;
margin: 10px 10px 0px; margin: 10px 10px 0px;
} }
@ -146,7 +144,7 @@
cursor: pointer; cursor: pointer;
} }
.alt-ico:hover { .ms-alt-ico:hover {
color: black; color: black;
cursor: pointer; cursor: pointer;
} }

View File

@ -140,7 +140,7 @@ import MsRunTestHttpPage from "./components/runtest/RunTestHTTPPage";
import MsRunTestTcpPage from "./components/runtest/RunTestTCPPage"; import MsRunTestTcpPage from "./components/runtest/RunTestTCPPage";
import MsRunTestSqlPage from "./components/runtest/RunTestSQLPage"; import MsRunTestSqlPage from "./components/runtest/RunTestSQLPage";
import MsRunTestDubboPage from "./components/runtest/RunTestDubboPage"; import MsRunTestDubboPage from "./components/runtest/RunTestDubboPage";
import {checkoutTestManagerOrTestUser, getCurrentProjectID, getCurrentUser, getUUID} from "@/common/js/utils"; import {checkoutTestManagerOrTestUser, getCurrentUser, getUUID} from "@/common/js/utils";
import MsApiModule from "./components/module/ApiModule"; import MsApiModule from "./components/module/ApiModule";
import ApiCaseSimpleList from "./components/list/ApiCaseSimpleList"; import ApiCaseSimpleList from "./components/list/ApiCaseSimpleList";
@ -159,7 +159,10 @@ import MsTabButton from "@/business/components/common/components/MsTabButton";
}, },
isReadOnly(){ isReadOnly(){
return !checkoutTestManagerOrTestUser(); return !checkoutTestManagerOrTestUser();
} },
projectId() {
return this.$store.state.projectId
},
}, },
components: { components: {
MsTabButton, MsTabButton,
@ -211,13 +214,9 @@ import MsTabButton from "@/business/components/common/components/MsTabButton";
}], }],
activeDom: "left", activeDom: "left",
syncTabs: [], syncTabs: [],
projectId: "",
nodeTree: [] nodeTree: []
} }
}, },
mounted() {
this.projectId = getCurrentProjectID();
},
watch: { watch: {
currentProtocol() { currentProtocol() {
this.handleCommand("CLOSE_ALL"); this.handleCommand("CLOSE_ALL");

View File

@ -59,7 +59,7 @@
import MsDialogFooter from "../../../../common/components/MsDialogFooter"; import MsDialogFooter from "../../../../common/components/MsDialogFooter";
import {WORKSPACE_ID} from '../../../../../../common/js/constants'; import {WORKSPACE_ID} from '../../../../../../common/js/constants';
import {REQ_METHOD} from "../../model/JsonData"; import {REQ_METHOD} from "../../model/JsonData";
import {getCurrentProjectID, getCurrentUser} from "../../../../../../common/js/utils"; import {getCurrentUser} from "../../../../../../common/js/utils";
import {createComponent, Request} from "../jmeter/components"; import {createComponent, Request} from "../jmeter/components";
export default { export default {
@ -94,8 +94,12 @@
value: REQ_METHOD[0].id, value: REQ_METHOD[0].id,
options: REQ_METHOD, options: REQ_METHOD,
} }
} },
, computed: {
projectId() {
return this.$store.state.projectId
},
},
methods: { methods: {
saveApi(saveAs) { saveApi(saveAs) {
this.$refs['httpForm'].validate((valid) => { this.$refs['httpForm'].validate((valid) => {
@ -137,7 +141,7 @@
break; break;
} }
this.httpForm.bodyUploadIds = []; this.httpForm.bodyUploadIds = [];
this.httpForm.projectId = getCurrentProjectID(); this.httpForm.projectId = this.projectId;
this.httpForm.id = this.httpForm.request.id; this.httpForm.id = this.httpForm.request.id;
this.httpForm.protocol = this.currentProtocol; this.httpForm.protocol = this.currentProtocol;

View File

@ -36,7 +36,6 @@
<script> <script>
import {listenGoBack, removeGoBackListener} from "@/common/js/utils"; import {listenGoBack, removeGoBackListener} from "@/common/js/utils";
import {parseEnvironment} from "@/business/components/api/test/model/EnvironmentModel"; import {parseEnvironment} from "@/business/components/api/test/model/EnvironmentModel";
import {getUUID, getCurrentProjectID} from "@/common/js/utils";
export default { export default {
name: "MsSetEnvironment", name: "MsSetEnvironment",
@ -64,6 +63,11 @@ export default {
this.environmentChange(this.environmentId); this.environmentChange(this.environmentId);
}, },
}, },
computed: {
projectId() {
return this.$store.state.projectId
},
},
methods: { methods: {
environmentChange(value) { environmentChange(value) {
for (let i in this.environments) { for (let i in this.environments) {
@ -74,7 +78,7 @@ export default {
} }
}, },
getEnvironments() { getEnvironments() {
let selectProjectId = getCurrentProjectID(); let selectProjectId = this.projectId;
if (selectProjectId) { if (selectProjectId) {
this.$get('/api/environment/list/' + selectProjectId, response => { this.$get('/api/environment/list/' + selectProjectId, response => {
this.environments = response.data; this.environments = response.data;

View File

@ -230,7 +230,8 @@
} }
data.message = true; data.message = true;
data.request.useEnvironment = this.environment; data.request.useEnvironment = this.environment;
this.saveTestCase(data); //this.saveTestCase(data);
this.$emit('singleRun', data); this.$emit('singleRun', data);
}, },
copyCase(data) { copyCase(data) {

View File

@ -50,7 +50,7 @@
import ApiCaseHeader from "./ApiCaseHeader"; import ApiCaseHeader from "./ApiCaseHeader";
import ApiCaseItem from "./ApiCaseItem"; import ApiCaseItem from "./ApiCaseItem";
import MsRun from "../Run"; import MsRun from "../Run";
import {getCurrentProjectID, getUUID} from "@/common/js/utils"; import {getUUID} from "@/common/js/utils";
import MsDrawer from "../../../../common/components/MsDrawer"; import MsDrawer from "../../../../common/components/MsDrawer";
import {CASE_ORDER} from "../../model/JsonData"; import {CASE_ORDER} from "../../model/JsonData";
import {API_CASE_CONFIGS} from "@/business/components/common/components/search/search-components"; import {API_CASE_CONFIGS} from "@/business/components/common/components/search/search-components";
@ -89,7 +89,6 @@
runData: [], runData: [],
selectdCases: [], selectdCases: [],
reportId: "", reportId: "",
projectId: "",
testCaseId: "", testCaseId: "",
checkedCases: new Set(), checkedCases: new Set(),
visible: false, visible: false,
@ -128,7 +127,6 @@
}, },
created() { created() {
this.api = this.currentApi; this.api = this.currentApi;
this.projectId = getCurrentProjectID();
if (this.createCase) { if (this.createCase) {
this.sysAddition(); this.sysAddition();
} }
@ -136,7 +134,10 @@
computed: { computed: {
isCaseEdit() { isCaseEdit() {
return this.testCaseId ? true : false; return this.testCaseId ? true : false;
} },
projectId() {
return this.$store.state.projectId
},
}, },
methods: { methods: {
open(api, testCaseId) { open(api, testCaseId) {
@ -181,7 +182,7 @@
this.visible = false; this.visible = false;
}, },
runRefresh(data) { runRefresh() {
this.batchLoadingIds = []; this.batchLoadingIds = [];
this.singleLoading = false; this.singleLoading = false;
this.singleRunId = ""; this.singleRunId = "";
@ -192,12 +193,9 @@
this.$set(item, 'selected', false); this.$set(item, 'selected', false);
}) })
} }
// //
let cases = this.apiCaseList[0]; let obj = {envId: this.environment, show: true};
cases.request.useEnvironment = this.environment; this.batchEdit(obj);
cases.message = true;
this.$refs.apiCaseItem[0].saveCase(cases);
this.refresh();
this.$success(this.$t('organization.integration.successful_operation')); this.$success(this.$t('organization.integration.successful_operation'));
}, },
@ -222,7 +220,7 @@
} }
this.result = this.$post("/api/testcase/list", this.condition, response => { this.result = this.$post("/api/testcase/list", this.condition, response => {
if(response.data){ if (response.data) {
this.apiCaseList = response.data; this.apiCaseList = response.data;
} }
this.apiCaseList.forEach(apiCase => { this.apiCaseList.forEach(apiCase => {
@ -260,7 +258,7 @@
if (!request.hashTree) { if (!request.hashTree) {
request.hashTree = []; request.hashTree = [];
} }
if(request.backScript != null){ if (request.backScript != null) {
request.hashTree.push(request.backScript); request.hashTree.push(request.backScript);
} }
let uuid = getUUID(); let uuid = getUUID();
@ -286,18 +284,17 @@
this.$warning(this.$t('api_test.environment.select_environment')); this.$warning(this.$t('api_test.environment.select_environment'));
return; return;
} }
this.selectdCases = [];
this.selectdCases.push(row.id);
this.runData = []; this.runData = [];
this.singleLoading = true; this.singleLoading = true;
this.singleRunId = row.id; this.singleRunId = row.id;
row.request.name = row.id; row.request.name = row.id;
this.$get('/api/definition/get/' + row.request.id, response => {
row.request.path = response.data.path; // pathpath
row.request.useEnvironment = this.environment; row.request.useEnvironment = this.environment;
row.request.projectId = getCurrentProjectID(); row.request.projectId = this.projectId;
this.runData.push(row.request); this.runData.push(row.request);
/*触发执行操作*/ /*触发执行操作*/
this.reportId = getUUID().substring(0, 8); this.reportId = getUUID().substring(0, 8);
});
}, },
batchRun() { batchRun() {
@ -307,6 +304,7 @@
} }
this.runData = []; this.runData = [];
this.batchLoadingIds = []; this.batchLoadingIds = [];
this.selectdCases = [];
if (this.apiCaseList.length > 0) { if (this.apiCaseList.length > 0) {
this.apiCaseList.forEach(item => { this.apiCaseList.forEach(item => {
if (item.selected && item.id) { if (item.selected && item.id) {
@ -314,6 +312,7 @@
item.request.useEnvironment = this.environment; item.request.useEnvironment = this.environment;
this.runData.push(item.request); this.runData.push(item.request);
this.batchLoadingIds.push(item.id); this.batchLoadingIds.push(item.id);
this.selectdCases.push(item.id);
} }
}) })
if (this.runData.length > 0) { if (this.runData.length > 0) {
@ -353,17 +352,22 @@
}, },
batchEdit(form) { batchEdit(form) {
let param = {}; let param = {};
if (form) {
param[form.type] = form.value; param[form.type] = form.value;
param.ids = this.selectdCases; param.ids = this.selectdCases;
param.projectId = getCurrentProjectID(); param.projectId = this.projectId;
param.envId = form.envId;
if (this.api) { if (this.api) {
param.protocol = this.api.protocol; param.protocol = this.api.protocol;
} }
param.selectAllDate = this.isSelectAllDate; param.selectAllDate = this.isSelectAllDate;
param.unSelectIds = this.unSelection; param.unSelectIds = this.unSelection;
param = Object.assign(param, this.condition); param = Object.assign(param, this.condition);
}
this.$post('/api/testcase/batch/editByParam', param, () => { this.$post('/api/testcase/batch/editByParam', param, () => {
if (!form.show) {
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
}
this.selectdCases = []; this.selectdCases = [];
this.getApiTest(); this.getApiTest();
}); });

View File

@ -100,7 +100,6 @@
<script> <script>
import MsDialogFooter from "../../../../common/components/MsDialogFooter"; import MsDialogFooter from "../../../../common/components/MsDialogFooter";
import {listenGoBack, removeGoBackListener} from "@/common/js/utils"; import {listenGoBack, removeGoBackListener} from "@/common/js/utils";
import {getCurrentProjectID} from "../../../../../../common/js/utils";
import ScheduleImport from "@/business/components/api/definition/components/import/ImportScheduleEdit"; import ScheduleImport from "@/business/components/api/definition/components/import/ImportScheduleEdit";
export default { export default {
@ -232,7 +231,10 @@ export default {
}, },
isScenarioModel() { isScenarioModel() {
return this.model === 'scenario'; return this.model === 'scenario';
} },
projectId() {
return this.$store.state.projectId
},
}, },
methods: { methods: {
scheduleEdit() { scheduleEdit() {
@ -318,7 +320,7 @@ export default {
}) })
param.modeId = this.formData.modeId param.modeId = this.formData.modeId
} }
param.projectId = getCurrentProjectID(); param.projectId = this.projectId;
if (!this.swaggerUrlEnable) { if (!this.swaggerUrlEnable) {
param.swaggerUrl = undefined; param.swaggerUrl = undefined;
} }

View File

@ -71,7 +71,7 @@
<el-table-column v-if="item.id=='tags'" prop="tags" min-width="120px" :label="$t('commons.tag')" <el-table-column v-if="item.id=='tags'" prop="tags" min-width="120px" :label="$t('commons.tag')"
:key="index"> :key="index">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :content="itemName" style="margin-left: 5px"/> <ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :content="itemName" style="margin-left: 0px; margin-right: 2px"/>
</template> </template>
</el-table-column> </el-table-column>
@ -143,7 +143,7 @@ import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn";
import MsBatchEdit from "../basis/BatchEdit"; import MsBatchEdit from "../basis/BatchEdit";
import {API_METHOD_COLOUR, CASE_PRIORITY, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData"; import {API_METHOD_COLOUR, CASE_PRIORITY, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData";
import {getBodyUploadFiles, getCurrentProjectID, getCurrentUser} from "@/common/js/utils"; import {getBodyUploadFiles} from "@/common/js/utils";
import PriorityTableItem from "../../../../track/common/tableItems/planview/PriorityTableItem"; import PriorityTableItem from "../../../../track/common/tableItems/planview/PriorityTableItem";
import MsApiCaseTableExtendBtns from "../reference/ApiCaseTableExtendBtns"; import MsApiCaseTableExtendBtns from "../reference/ApiCaseTableExtendBtns";
import MsReferenceView from "../reference/ReferenceView"; import MsReferenceView from "../reference/ReferenceView";
@ -186,7 +186,7 @@ export default {
return { return {
type: API_CASE_LIST, type: API_CASE_LIST,
headerItems: Api_Case_List, headerItems: Api_Case_List,
tableLabel: [], tableLabel: Api_Case_List,
condition: { condition: {
components: API_CASE_CONFIGS components: API_CASE_CONFIGS
}, },
@ -260,6 +260,10 @@ export default {
}, },
created: function () { created: function () {
this.initTable(); this.initTable();
this.$nextTick(() => {
this.$refs.caseTable.bodyWrapper.scrollTop = 5
})
}, },
watch: { watch: {
selectNodeIds() { selectNodeIds() {
@ -278,11 +282,13 @@ export default {
} }
}, },
computed: { computed: {
// //
isApiModel() { isApiModel() {
return this.model === 'api' return this.model === 'api'
}, },
projectId() {
return this.$store.state.projectId
},
}, },
methods: { methods: {
customHeader() { customHeader() {
@ -301,7 +307,7 @@ export default {
this.selectAll = false; this.selectAll = false;
this.unSelection = []; this.unSelection = [];
this.selectDataCounts = 0; this.selectDataCounts = 0;
this.condition.projectId = getCurrentProjectID(); this.condition.projectId = this.projectId;
if (this.currentProtocol != null) { if (this.currentProtocol != null) {
this.condition.protocol = this.currentProtocol; this.condition.protocol = this.currentProtocol;
@ -331,9 +337,13 @@ export default {
item.tags = JSON.parse(item.tags); item.tags = JSON.parse(item.tags);
} }
}) })
if (this.$refs.caseTable) {
this.$refs.caseTable.doLayout()
}
}); });
} }
getLabel(this, API_CASE_LIST); getLabel(this, API_CASE_LIST);
}, },
open() { open() {
this.$refs.searchBar.open(); this.$refs.searchBar.open();
@ -401,7 +411,7 @@ export default {
callback: (action) => { callback: (action) => {
if (action === 'confirm') { if (action === 'confirm') {
let obj = {}; let obj = {};
obj.projectId = getCurrentProjectID(); obj.projectId = this.projectId;
obj.selectAllDate = this.isSelectAllDate; obj.selectAllDate = this.isSelectAllDate;
obj.unSelectIds = this.unSelection; obj.unSelectIds = this.unSelection;
obj.ids = Array.from(this.selectRows).map(row => row.id); obj.ids = Array.from(this.selectRows).map(row => row.id);
@ -448,7 +458,7 @@ export default {
let param = {}; let param = {};
param[form.type] = form.value; param[form.type] = form.value;
param.ids = ids; param.ids = ids;
param.projectId = getCurrentProjectID(); param.projectId = this.projectId;
param.selectAllDate = this.isSelectAllDate; param.selectAllDate = this.isSelectAllDate;
param.unSelectIds = this.unSelection; param.unSelectIds = this.unSelection;
param = Object.assign(param, this.condition); param = Object.assign(param, this.condition);
@ -520,7 +530,7 @@ export default {
}, },
showEnvironment(row) { showEnvironment(row) {
let projectID = getCurrentProjectID(); let projectID = this.projectId;
if (this.projectId) { if (this.projectId) {
this.$get('/api/environment/list/' + this.projectId, response => { this.$get('/api/environment/list/' + this.projectId, response => {
this.environments = response.data; this.environments = response.data;
@ -572,7 +582,7 @@ export default {
id: row.id, id: row.id,
testElement: testPlan, testElement: testPlan,
name: row.name, name: row.name,
projectId: getCurrentProjectID(), projectId: this.projectId,
}; };
let bodyFiles = getBodyUploadFiles(reqObj, runData); let bodyFiles = getBodyUploadFiles(reqObj, runData);
reqObj.reportId = "run"; reqObj.reportId = "run";
@ -636,4 +646,7 @@ export default {
top: -2px; top: -2px;
} }
/deep/ .el-table__fixed {
height: 100% !important;
}
</style> </style>

View File

@ -28,7 +28,7 @@
<el-table-column width="30" :resizable="false" align="center"> <el-table-column width="30" :resizable="false" align="center">
<template v-slot:default="scope"> <template v-slot:default="scope">
<!-- 选中记录后浮现的按钮提供对记录的批量操作 --> <!-- 选中记录后浮现的按钮提供对记录的批量操作 -->
<show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectDataCounts" v-tester/> <show-more-btn :is-show="scope.row.showMore" :buttons="trashEnable ? trashButtons : buttons" :size="selectDataCounts" v-tester/>
</template> </template>
</el-table-column> </el-table-column>
<template v-for="(item, index) in tableLabel"> <template v-for="(item, index) in tableLabel">
@ -116,7 +116,7 @@
min-width="120px" min-width="120px"
:key="index"> :key="index">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :show-tooltip="true" :content="itemName" style="margin-left: 5px"/> <ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :show-tooltip="true" :content="itemName" style="margin-left: 0px; margin-right: 2px"/>
</template> </template>
</el-table-column> </el-table-column>
@ -225,7 +225,6 @@
import {API_METHOD_COLOUR, API_STATUS, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData"; import {API_METHOD_COLOUR, API_STATUS, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData";
import {checkoutTestManagerOrTestUser, downloadFile, getUUID} from "@/common/js/utils"; import {checkoutTestManagerOrTestUser, downloadFile, getUUID} from "@/common/js/utils";
import {PROJECT_NAME} from '@/common/js/constants'; import {PROJECT_NAME} from '@/common/js/constants';
import {getCurrentProjectID, getCurrentUser} from "@/common/js/utils";
import {API_LIST, TEST_CASE_LIST, WORKSPACE_ID} from '@/common/js/constants'; import {API_LIST, TEST_CASE_LIST, WORKSPACE_ID} from '@/common/js/constants';
import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover"; import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover";
import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus"; import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus";
@ -272,7 +271,7 @@
return { return {
type: API_LIST, type: API_LIST,
headerItems: Api_List, headerItems: Api_List,
tableLabel: [], tableLabel: Api_List,
condition: { condition: {
components: API_DEFINITION_CONFIGS components: API_DEFINITION_CONFIGS
}, },
@ -289,6 +288,12 @@
name: this.$t('api_test.definition.request.batch_move'), handleClick: this.handleBatchMove name: this.$t('api_test.definition.request.batch_move'), handleClick: this.handleBatchMove
} }
], ],
trashButtons: [
{name: this.$t('api_test.definition.request.batch_delete'), handleClick: this.handleDeleteBatch},
{
name: "批量恢复", handleClick: this.handleBatchRestore
},
],
typeArr: [ typeArr: [
{id: 'status', name: this.$t('api_test.definition.api_status')}, {id: 'status', name: this.$t('api_test.definition.api_status')},
{id: 'method', name: this.$t('api_test.definition.api_type')}, {id: 'method', name: this.$t('api_test.definition.api_type')},
@ -364,6 +369,11 @@
}, },
} }
}, },
computed: {
projectId() {
return this.$store.state.projectId
},
},
created: function () { created: function () {
if (this.trashEnable) { if (this.trashEnable) {
this.condition.filters = {status: ["Trash"]}; this.condition.filters = {status: ["Trash"]};
@ -403,7 +413,7 @@
initCondition(this.condition); initCondition(this.condition);
this.selectDataCounts = 0; this.selectDataCounts = 0;
this.condition.moduleIds = this.selectNodeIds; this.condition.moduleIds = this.selectNodeIds;
this.condition.projectId = getCurrentProjectID(); this.condition.projectId = this.projectId;
if (this.currentProtocol != null) { if (this.currentProtocol != null) {
this.condition.protocol = this.currentProtocol; this.condition.protocol = this.currentProtocol;
} }
@ -442,6 +452,10 @@
item.tags = JSON.parse(item.tags); item.tags = JSON.parse(item.tags);
} }
}) })
if (this.$refs.apiDefinitionTable) {
this.$refs.apiDefinitionTable.doLayout()
}
}); });
} }
getLabel(this, API_LIST); getLabel(this, API_LIST);
@ -560,17 +574,18 @@
}, },
reductionApi(row) { reductionApi(row) {
let tmp = JSON.parse(JSON.stringify(row)); let tmp = JSON.parse(JSON.stringify(row));
tmp.request = null; let rows = {ids: [tmp.id]};
tmp.response = null;
if (tmp.tags instanceof Array) {
tmp.tags = JSON.stringify(tmp.tags);
}
let rows = [tmp];
this.$post('/api/definition/reduction/', rows, () => { this.$post('/api/definition/reduction/', rows, () => {
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
this.search(); this.search();
}); });
}, },
handleBatchRestore() {
this.$post('/api/definition/reduction/', buildBatchParam(this), () => {
this.$success(this.$t('commons.save_success'));
this.search();
});
},
handleDeleteBatch() { handleDeleteBatch() {
if (this.trashEnable) { if (this.trashEnable) {
this.$alert(this.$t('api_test.definition.request.delete_confirm') + "", '', { this.$alert(this.$t('api_test.definition.request.delete_confirm') + "", '', {
@ -625,7 +640,7 @@
let arr = Array.from(this.selectRows); let arr = Array.from(this.selectRows);
let ids = arr.map(row => row.id); let ids = arr.map(row => row.id);
param.ids = ids; param.ids = ids;
param.projectId = getCurrentProjectID(); param.projectId = this.projectId;
param.moduleId = param.nodeId; param.moduleId = param.nodeId;
param.condition = this.condition; param.condition = this.condition;
param.selectAllDate = this.isSelectAllDate; param.selectAllDate = this.isSelectAllDate;

View File

@ -38,7 +38,6 @@ import MsAddBasisApi from "../basis/AddBasisApi";
import SelectMenu from "../../../../track/common/SelectMenu"; import SelectMenu from "../../../../track/common/SelectMenu";
import {OPTIONS} from "../../model/JsonData"; import {OPTIONS} from "../../model/JsonData";
import ApiImport from "../import/ApiImport"; import ApiImport from "../import/ApiImport";
import {getCurrentProjectID} from "@/common/js/utils";
import MsNodeTree from "../../../../track/common/NodeTree"; import MsNodeTree from "../../../../track/common/NodeTree";
import ApiModuleHeader from "./ApiModuleHeader"; import ApiModuleHeader from "./ApiModuleHeader";
import {buildNodePath} from "../../model/NodeTree"; import {buildNodePath} from "../../model/NodeTree";
@ -60,7 +59,6 @@ export default {
filterText: "", filterText: "",
trashEnable: false trashEnable: false
}, },
projectId: "",
data: [], data: [],
currentModule: {}, currentModule: {},
} }
@ -85,10 +83,12 @@ export default {
}, },
isReviewModel() { isReviewModel() {
return this.reviewId ? true : false; return this.reviewId ? true : false;
} },
projectId() {
return this.$store.state.projectId
},
}, },
mounted() { mounted() {
this.projectId = getCurrentProjectID();
this.$emit('protocolChange', this.condition.protocol); this.$emit('protocolChange', this.condition.protocol);
this.list(); this.list();
}, },

View File

@ -58,7 +58,6 @@ import {OPTIONS} from "../../model/JsonData";
import MsAddBasisApi from "../basis/AddBasisApi"; import MsAddBasisApi from "../basis/AddBasisApi";
import ApiImport from "../import/ApiImport"; import ApiImport from "../import/ApiImport";
import ModuleTrashButton from "./ModuleTrashButton"; import ModuleTrashButton from "./ModuleTrashButton";
import {getCurrentProjectID} from "../../../../../../common/js/utils";
import {buildNodePath} from "@/business/components/api/definition/model/NodeTree"; import {buildNodePath} from "@/business/components/api/definition/model/NodeTree";
import TemplateComponent from "../../../../track/plan/view/comonents/report/TemplateComponent/TemplateComponent"; import TemplateComponent from "../../../../track/plan/view/comonents/report/TemplateComponent/TemplateComponent";
@ -91,6 +90,11 @@ export default {
} }
}, },
}, },
computed: {
projectId() {
return this.$store.state.projectId
},
},
methods: { methods: {
handleCommand(e) { handleCommand(e) {
@ -104,12 +108,12 @@ export default {
case "add-module": case "add-module":
break; break;
case "import": case "import":
if (!getCurrentProjectID()) { if (!this.projectId) {
this.$warning(this.$t('commons.check_project_tip')); this.$warning(this.$t('commons.check_project_tip'));
return; return;
} }
// this.protocol = "HTTP"; this.protocol = "HTTP";
this.result = this.$get("/api/module/list/" + getCurrentProjectID() + "/" + this.condition.protocol, response => { this.result = this.$get("/api/module/list/" + this.projectId + "/" + this.condition.protocol, response => {
if (response.data != undefined && response.data != null) { if (response.data != undefined && response.data != null) {
this.data = response.data; this.data = response.data;
let moduleOptions = []; let moduleOptions = [];
@ -124,7 +128,7 @@ export default {
} }
}, },
chooseExportType(e) { chooseExportType(e) {
if (!getCurrentProjectID()) { if (!this.projectId) {
this.$warning(this.$t('commons.check_project_tip')); this.$warning(this.$t('commons.check_project_tip'));
return; return;
} }
@ -138,7 +142,7 @@ export default {
} }
}, },
addApi() { addApi() {
if (!getCurrentProjectID()) { if (!this.projectId) {
this.$warning(this.$t('commons.check_project_tip')); this.$warning(this.$t('commons.check_project_tip'));
return; return;
} }

View File

@ -5,26 +5,26 @@
<el-col :span="14"> <el-col :span="14">
<el-menu class="header-menu" :unique-opened="true" mode="horizontal" router :default-active='$route.path'> <el-menu class="header-menu" :unique-opened="true" mode="horizontal" router :default-active='$route.path'>
<el-menu-item v-show="$store.state.switch.value=='new'" :index="'/api/home'"> <el-menu-item v-show="isNewVersion" :index="'/api/home'">
{{ $t("i18n.home") }} {{ $t("i18n.home") }}
</el-menu-item> </el-menu-item>
<el-menu-item v-show="$store.state.switch.value=='old'" :index="'/api/home_obsolete'"> <el-menu-item v-show="isOldVersion" :index="'/api/home_obsolete'">
{{ $t("i18n.home") }} {{ $t("i18n.home") }}
</el-menu-item> </el-menu-item>
<el-menu-item v-show="$store.state.switch.value=='new'" :index="'/api/definition'"> <el-menu-item v-show="isNewVersion" :index="'/api/definition'">
{{ $t("i18n.definition") }} {{ $t("i18n.definition") }}
</el-menu-item> </el-menu-item>
<el-menu-item v-show="$store.state.switch.value=='new'" :index="'/api/automation'"> <el-menu-item v-show="isNewVersion" :index="'/api/automation'">
{{ $t("i18n.automation") }} {{ $t("i18n.automation") }}
</el-menu-item> </el-menu-item>
<el-menu-item v-show="$store.state.switch.value=='new'" :index="'/api/automation/report'"> <el-menu-item v-show="isNewVersion" :index="'/api/automation/report'">
{{ $t("i18n.report") }} {{ $t("i18n.report") }}
</el-menu-item> </el-menu-item>
<el-submenu v-show="$store.state.switch.value=='old'" <el-submenu v-show="isOldVersion"
v-permission="['test_manager','test_user','test_viewer']" index="4"> v-permission="['test_manager','test_user','test_viewer']" index="4">
<template v-slot:title>{{ $t('commons.test') }}</template> <template v-slot:title>{{ $t('commons.test') }}</template>
<ms-recent-list ref="testRecent" :options="testRecent"/> <ms-recent-list ref="testRecent" :options="testRecent"/>
@ -35,7 +35,7 @@
:title="$t('load_test.create')"/> :title="$t('load_test.create')"/>
</el-submenu> </el-submenu>
<el-submenu v-show="$store.state.switch.value=='old'" <el-submenu v-show="isOldVersion"
v-permission="['test_manager','test_user','test_viewer']" index="5"> v-permission="['test_manager','test_user','test_viewer']" index="5">
<template v-slot:title>{{ $t('commons.report') }}</template> <template v-slot:title>{{ $t('commons.report') }}</template>
<ms-recent-list ref="reportRecent" :options="reportRecent"/> <ms-recent-list ref="reportRecent" :options="reportRecent"/>
@ -44,7 +44,7 @@
</el-submenu> </el-submenu>
<el-menu-item v-show="$store.state.switch.value=='old'" <el-menu-item v-show="isOldVersion"
v-permission="['test_manager','test_user','test_viewer']" :index="'/api/monitor/view'"> v-permission="['test_manager','test_user','test_viewer']" :index="'/api/monitor/view'">
{{ $t('commons.monitor') }} {{ $t('commons.monitor') }}
</el-menu-item> </el-menu-item>
@ -64,6 +64,7 @@ import MsCreateTest from "../../common/head/CreateTest";
import {ApiEvent, LIST_CHANGE} from "@/business/components/common/head/ListEvent"; import {ApiEvent, LIST_CHANGE} from "@/business/components/common/head/ListEvent";
import SearchList from "@/business/components/common/head/SearchList"; import SearchList from "@/business/components/common/head/SearchList";
import ProjectChange from "@/business/components/common/head/ProjectSwitch"; import ProjectChange from "@/business/components/common/head/ProjectSwitch";
import {mapGetters} from "vuex";
export default { export default {
name: "MsApiHeaderMenus", name: "MsApiHeaderMenus",
@ -94,6 +95,12 @@ export default {
currentProject: '' currentProject: ''
} }
}, },
computed: {
...mapGetters([
'isNewVersion',
'isOldVersion',
])
},
methods: { methods: {
registerEvents() { registerEvents() {
ApiEvent.$on(LIST_CHANGE, () => { ApiEvent.$on(LIST_CHANGE, () => {

View File

@ -47,19 +47,12 @@ export default {
}, },
open(items) { open(items) {
this.defaultCheckedKeys = [] this.defaultCheckedKeys = []
this.dialogTableVisible = true this.dialogTableVisible = true
this.fieldSelected = items
if (items.size <= 0) {
this.optionalField = this.optionalFields
} else {
items.forEach(i => { items.forEach(i => {
this.defaultCheckedKeys.push(i.id) this.defaultCheckedKeys.push(i.id)
} }
) )
} this.fieldSelected = items;
console.log(this.defaultCheckedKeys)
}, },
saveHeader() { saveHeader() {
let param = { let param = {
@ -71,8 +64,8 @@ export default {
console.log(this.optionalFields) console.log(this.optionalFields)
console.log(this.fieldSelected) console.log(this.fieldSelected)
this.$success(this.$t("commons.save_success")); this.$success(this.$t("commons.save_success"));
this.dialogTableVisible = false
this.initTableData() this.initTableData()
this.close();
}) })
}, },
removeAt(idx) { removeAt(idx) {
@ -83,7 +76,6 @@ export default {
}, },
// 穿transfer addressList // 穿transfer addressList
// changeMode() { // changeMode() {
// if (this.mode == "transfer") { // if (this.mode == "transfer") {

View File

@ -30,6 +30,7 @@
<script> <script>
import {LicenseKey} from '@/common/js/constants'; import {LicenseKey} from '@/common/js/constants';
import {mapGetters} from "vuex";
const requireContext = require.context('@/business/components/xpack/', true, /router\.js$/) const requireContext = require.context('@/business/components/xpack/', true, /router\.js$/)
const report = requireContext.keys().map(key => requireContext(key).report); const report = requireContext.keys().map(key => requireContext(key).report);
@ -62,15 +63,21 @@
this.isReport = false; this.isReport = false;
} }
}, },
computed: {
...mapGetters([
'isNewVersion',
'isOldVersion',
])
},
methods: { methods: {
handleSelect(index) { handleSelect(index) {
this.activeIndex = index this.activeIndex = index
}, },
active() { active() {
if (this.activeIndex === '/api') { if (this.activeIndex === '/api') {
if (this.$store.state.switch.value == 'new') { if (this.isNewVersion) {
window.location.href = "/#/api/home"; window.location.href = "/#/api/home";
} else if (this.$store.state.switch.value == 'old') { } else if (this.isOldVersion) {
window.location.href = "/#/api/home_obsolete"; window.location.href = "/#/api/home_obsolete";
} }
} }

View File

@ -9,10 +9,10 @@
<el-dropdown-item command="about">{{ $t('commons.about_us') }} <i class="el-icon-info"/></el-dropdown-item> <el-dropdown-item command="about">{{ $t('commons.about_us') }} <i class="el-icon-info"/></el-dropdown-item>
<el-dropdown-item command="help">{{ $t('commons.help_documentation') }}</el-dropdown-item> <el-dropdown-item command="help">{{ $t('commons.help_documentation') }}</el-dropdown-item>
<el-dropdown-item command="ApiHelp">{{ $t('commons.api_help_documentation') }}</el-dropdown-item> <el-dropdown-item command="ApiHelp">{{ $t('commons.api_help_documentation') }}</el-dropdown-item>
<el-dropdown-item command="old" v-show=isReadOnly @click.native="changeBar('old')"> <el-dropdown-item command="old" v-show=isNewVersion @click.native="changeBar('old')">
{{ $t('commons.cut_back_old_version') }} {{ $t('commons.cut_back_old_version') }}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item command="new" v-show=!isReadOnly @click.native="changeBar('new')"> <el-dropdown-item command="new" v-show=isOldVersion @click.native="changeBar('new')">
{{ $t('commons.cut_back_new_version') }} {{ $t('commons.cut_back_new_version') }}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item command="logout">{{ $t('commons.exit_system') }}</el-dropdown-item> <el-dropdown-item command="logout">{{ $t('commons.exit_system') }}</el-dropdown-item>
@ -27,6 +27,7 @@
import {getCurrentUser} from "@/common/js/utils"; import {getCurrentUser} from "@/common/js/utils";
import AboutUs from "./AboutUs"; import AboutUs from "./AboutUs";
import axios from "axios"; import axios from "axios";
import {mapGetters} from "vuex";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/); const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const auth = requireComponent.keys().length > 0 ? requireComponent("./auth/Auth.vue") : {}; const auth = requireComponent.keys().length > 0 ? requireComponent("./auth/Auth.vue") : {};
@ -36,13 +37,16 @@ export default {
components: {AboutUs}, components: {AboutUs},
data() { data() {
return { return {
isReadOnly: this.$store.state.isReadOnly.flag
} }
}, },
computed: { computed: {
currentUser: () => { currentUser: () => {
return getCurrentUser(); return getCurrentUser();
} },
...mapGetters([
'isNewVersion',
'isOldVersion',
])
}, },
methods: { methods: {
logout: function () { logout: function () {
@ -79,9 +83,7 @@ export default {
} }
}, },
changeBar(item) { changeBar(item) {
this.isReadOnly = !this.isReadOnly this.$store.commit('setVersionSwitch', item);
this.$store.commit('setFlag', this.isReadOnly);
this.$store.commit('setValue', item);
if (item == "old") { if (item == "old") {
window.location.href = "/#/api/home_obsolete"; window.location.href = "/#/api/home_obsolete";
} else { } else {

View File

@ -28,6 +28,7 @@
<script> <script>
import {getCurrentProjectID, getCurrentUser, hasRoles} from "@/common/js/utils"; import {getCurrentProjectID, getCurrentUser, hasRoles} from "@/common/js/utils";
import {PROJECT_ID, ROLE_TEST_MANAGER, ROLE_TEST_USER, ROLE_TEST_VIEWER} from "@/common/js/constants"; import {PROJECT_ID, ROLE_TEST_MANAGER, ROLE_TEST_USER, ROLE_TEST_VIEWER} from "@/common/js/constants";
import {mapGetters} from "vuex";
export default { export default {
name: "SearchList", name: "SearchList",
@ -39,6 +40,10 @@ export default {
this.init(); this.init();
}, },
computed: { computed: {
...mapGetters([
'isNewVersion',
'isOldVersion',
]),
currentProjectId() { currentProjectId() {
return localStorage.getItem(PROJECT_ID) return localStorage.getItem(PROJECT_ID)
} }
@ -70,7 +75,10 @@ export default {
let projectId = localStorage.getItem(PROJECT_ID); let projectId = localStorage.getItem(PROJECT_ID);
if (!projectId || projectId != userLastProjectId) { if (!projectId || projectId != userLastProjectId) {
localStorage.setItem(PROJECT_ID, userLastProjectId); localStorage.setItem(PROJECT_ID, userLastProjectId);
this.$store.commit('setProjectId', userLastProjectId);
window.location.reload(); window.location.reload();
} else {
this.$store.commit('setProjectId', projectId);
} }
} }
} }
@ -104,11 +112,12 @@ export default {
} }
this.$post("/user/update/current", {id: this.userId, lastProjectId: projectId}, () => { this.$post("/user/update/current", {id: this.userId, lastProjectId: projectId}, () => {
localStorage.setItem(PROJECT_ID, projectId); localStorage.setItem(PROJECT_ID, projectId);
this.$store.commit('setProjectId', projectId);
let path = this.$route.matched[0].path ? this.$route.matched[0].path : '/'; let path = this.$route.matched[0].path ? this.$route.matched[0].path : '/';
if (path === '/api') { if (path === '/api') {
if (this.$store.state.switch.value === 'new') { if (this.isNewVersion) {
path = "/api/home"; path = "/api/home";
} else if (this.$store.state.switch.value === 'old') { } else if (this.isOldVersion) {
path = "/api/home_obsolete"; path = "/api/home_obsolete";
} else { } else {
path = '/'; path = '/';

View File

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

View File

@ -123,7 +123,7 @@ export default {
}, },
methods: { methods: {
importAPITest() { importAPITest() {
let apiTest = this.$store.state.api.test; let apiTest = this.$store.state.test;
if (apiTest && apiTest.name) { if (apiTest && apiTest.name) {
this.$set(this.test, "name", apiTest.name); this.$set(this.test, "name", apiTest.name);
let blob = new Blob([apiTest.jmx.xml], {type: "application/octet-stream"}); let blob = new Blob([apiTest.jmx.xml], {type: "application/octet-stream"});

View File

@ -215,7 +215,7 @@ export default {
// //
async function f() { async function f() {
return await axios.post('/performance/file/' + getCurrentProjectID() + '/getMetadataByName', {filename: file.name}) return await axios.post('/performance/file/' + getCurrentProjectID() + '/getMetadataByName', {name: file.name})
} }
await f().then(res => { await f().then(res => {

View File

@ -22,7 +22,7 @@
:label="$t('api_test.automation.tag')"> :label="$t('api_test.automation.tag')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :content="itemName" <ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :content="itemName"
style="margin-left: 5px"/> style="margin-left: 0px; margin-right: 2px"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column

View File

@ -26,6 +26,11 @@
row: Object, row: Object,
size: Number size: Number
}, },
created() {
if (this.trashEnable) {
this.buttons.splice(1, 1);
}
},
methods: { methods: {
click(btn) { click(btn) {
if (btn.handleClick instanceof Function) { if (btn.handleClick instanceof Function) {

View File

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

View File

@ -83,7 +83,6 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
@ -98,17 +97,12 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="7"> <el-col :span="14">
<el-form-item :label="$t('test_track.case.relate_test')" :label-width="formLabelWidth" prop="testId"> <el-form-item :label="$t('test_track.case.relate_test')" :label-width="formLabelWidth">
<el-cascader show-all-levels v-model="form.selected" :props="props" ></el-cascader> <el-cascader filterable placeholder="请选择要关联的测试" show-all-levels v-model="form.selected" :props="props"
class="ms-case"></el-cascader>
</el-form-item> </el-form-item>
</el-col> </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-form-item>
</el-col>-->
</el-row> </el-row>
<el-row> <el-row>
@ -126,8 +120,9 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="10"> <el-col :span="10" :offset="1">
<el-form-item label="需求名称" :label-width="formLabelWidth" prop="demandName" v-if="form.demandId=='other'"> <el-form-item label="需求ID/名称" :label-width="formLabelWidth" prop="demandName"
v-if="form.demandId=='other'">
<el-input v-model="form.demandName"></el-input> <el-input v-model="form.demandName"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -341,7 +336,6 @@ export default {
} }
if (this.projectId && this.form.type != '' && this.form.type != 'undefined') { if (this.projectId && this.form.type != '' && this.form.type != 'undefined') {
this.$get(url, response => { this.$get(url, response => {
response.data.unshift({id: 'other', name: this.$t('test_track.case.other')})
const nodes = response.data const nodes = response.data
.map(item => ({ .map(item => ({
value: item.id, value: item.id,
@ -445,6 +439,14 @@ export default {
if (this.type === 'edit' || this.type === 'copy') { if (this.type === 'edit' || this.type === 'copy') {
this.open(this.currentTestCaseInfo) this.open(this.currentTestCaseInfo)
} }
// Cascader : input
setInterval(function () {
document.querySelectorAll('.el-cascader-node__label').forEach(el => {
el.onclick = function () {
if (this.previousElementSibling) this.previousElementSibling.click();
};
});
}, 1000);
}, },
watch: { watch: {
treeNodes() { treeNodes() {
@ -582,8 +584,10 @@ export default {
} }
Object.assign(this.form, tmp); Object.assign(this.form, tmp);
this.form.module = testCase.nodeId; this.form.module = testCase.nodeId;
/*
this.form.testId=testCase.selected this.form.testId=testCase.selected
console.log(this.form.testId) */
console.log(this.form.selected)
this.getFileMetaData(testCase); this.getFileMetaData(testCase);
}, },
setTestCaseExtInfo(testCase) { setTestCaseExtInfo(testCase) {
@ -678,8 +682,6 @@ export default {
} }
this.dialogFormVisible = false; this.dialogFormVisible = false;
this.$emit("refresh"); this.$emit("refresh");
// 广 head
TrackEvent.$emit(LIST_CHANGE);
}); });
} }
} else { } else {
@ -779,7 +781,6 @@ export default {
}); });
}, },
getTestOptions(val) { getTestOptions(val) {
console.log(val)
this.projectId = getCurrentProjectID() this.projectId = getCurrentProjectID()
this.testOptions = []; this.testOptions = [];
let url = ''; let url = '';
@ -999,6 +1000,10 @@ export default {
width: 100%; width: 100%;
} }
.ms-case {
width: 100%;
}
/deep/ .el-button-group > .el-button:first-child { /deep/ .el-button-group > .el-button:first-child {
border-top-right-radius: 0; border-top-right-radius: 0;
border-bottom-right-radius: 0; border-bottom-right-radius: 0;

View File

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

View File

@ -131,7 +131,7 @@
<el-table-column v-if="item.id=='tags'" prop="tags" :label="$t('commons.tag')" :key="index"> <el-table-column v-if="item.id=='tags'" prop="tags" :label="$t('commons.tag')" :key="index">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" <ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain"
:content="itemName" style="margin-left: 5px"/> :content="itemName" style="margin-left: 0px; margin-right: 2px"/>
</template> </template>
</el-table-column> </el-table-column>
@ -259,7 +259,7 @@ export default {
return { return {
type: TEST_CASE_LIST, type: TEST_CASE_LIST,
headerItems: Track_Test_Case, headerItems: Track_Test_Case,
tableLabel: [], tableLabel: Track_Test_Case,
result: {}, result: {},
deletePath: "/test/case/delete", deletePath: "/test/case/delete",
condition: { condition: {
@ -409,11 +409,15 @@ export default {
getData() { getData() {
this.getSelectDataRange(); this.getSelectDataRange();
this.condition.selectThisWeedData = false; this.condition.selectThisWeedData = false;
this.condition.selectThisWeedRelevanceData = false;
this.condition.caseCoverage = null; this.condition.caseCoverage = null;
switch (this.selectDataRange) { switch (this.selectDataRange) {
case 'thisWeekCount': case 'thisWeekCount':
this.condition.selectThisWeedData = true; this.condition.selectThisWeedData = true;
break; break;
case 'thisWeekRelevanceCount':
this.condition.selectThisWeedRelevanceData = true;
break;
case 'uncoverage': case 'uncoverage':
this.condition.caseCoverage = 'uncoverage'; this.condition.caseCoverage = 'uncoverage';
break; break;
@ -443,6 +447,10 @@ export default {
item.tags = JSON.parse(item.tags); item.tags = JSON.parse(item.tags);
} }
}) })
if (this.$refs.table) {
this.$refs.table.doLayout()
}
}); });
} }
}, },

View File

@ -49,26 +49,29 @@ name: "TestCaseMinder",
}, },
save(data) { save(data) {
let saveCases = []; let saveCases = [];
this.buildSaveCase(data.root, saveCases, undefined); let deleteCases = [];
this.buildSaveCase(data.root, saveCases, deleteCases, undefined);
let param = { let param = {
projectId: this.projectId, projectId: this.projectId,
data: saveCases data: saveCases,
ids: deleteCases.map(item => item.id)
} }
this.result = this.$post('/test/case/minder/edit', param, () => { this.result = this.$post('/test/case/minder/edit', param, () => {
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
}); });
}, },
buildSaveCase(root, saveCases, parent) { buildSaveCase(root, saveCases, deleteCases, parent) {
let data = root.data; let data = root.data;
if (data.resource && data.resource.indexOf(this.$t('api_test.definition.request.case')) > -1) { if (data.resource && data.resource.indexOf(this.$t('api_test.definition.request.case')) > -1) {
if (root.parent) {
console.log(root.parent);
}
this._buildSaveCase(root, saveCases, parent); this._buildSaveCase(root, saveCases, parent);
} else { } else {
let deleteChild = data.deleteChild;
if (deleteChild && deleteChild.length > 0) {
deleteCases.push(...deleteChild);
}
if (root.children) { if (root.children) {
root.children.forEach((childNode) => { root.children.forEach((childNode) => {
this.buildSaveCase(childNode, saveCases, root.data); this.buildSaveCase(childNode, saveCases, deleteCases, root.data);
}) })
} }
} }

View File

@ -9,7 +9,10 @@
<el-menu-item :index="'/track/home'"> <el-menu-item :index="'/track/home'">
{{ $t("i18n.home") }} {{ $t("i18n.home") }}
</el-menu-item> </el-menu-item>
<el-menu-item :index="'/track/case/all'">
{{ $t("test_track.case.test_case") }}
</el-menu-item>
<!--
<el-submenu v-permission="['test_manager','test_user','test_viewer']" <el-submenu v-permission="['test_manager','test_user','test_viewer']"
index="6" popper-class="submenu"> index="6" popper-class="submenu">
<template v-slot:title>{{ $t('test_track.case.test_case') }}</template> <template v-slot:title>{{ $t('test_track.case.test_case') }}</template>
@ -21,6 +24,7 @@
<ms-create-button v-permission="['test_manager','test_user']" :index="'/track/case/create'" <ms-create-button v-permission="['test_manager','test_user']" :index="'/track/case/create'"
:title="$t('test_track.case.create_case')"/> :title="$t('test_track.case.create_case')"/>
</el-submenu> </el-submenu>
-->
<el-submenu v-permission="['test_manager','test_user','test_viewer']" <el-submenu v-permission="['test_manager','test_user','test_viewer']"
index="8" popper-class="submenu"> index="8" popper-class="submenu">

View File

@ -169,7 +169,7 @@ export default {
type: 'bar', type: 'bar',
itemStyle: { itemStyle: {
normal: { normal: {
color: this.$store.state.theme.theme ? this.$store.state.theme.theme : COUNT_NUMBER color: this.$store.state.theme ? this.$store.state.theme : COUNT_NUMBER
} }
} }
}, },
@ -179,7 +179,7 @@ export default {
type: 'bar', type: 'bar',
itemStyle: { itemStyle: {
normal: { normal: {
color: this.$store.state.theme.theme ? this.$store.state.theme.theme : COUNT_NUMBER_SHALLOW color: this.$store.state.theme ? this.$store.state.theme : COUNT_NUMBER_SHALLOW
} }
} }
}] }]

View File

@ -40,7 +40,7 @@
<el-row> <el-row>
<el-col> <el-col>
{{$t('api_test.home_page.api_details_card.this_week_add')}} {{$t('api_test.home_page.api_details_card.this_week_add')}}
<el-link type="info" @click="redirectPage('thisWeekCount')" target="_blank" style="color: #000000">{{relevanceCountData.thisWeekAddedCount}} <el-link type="info" @click="redirectPage('thisWeekRelevanceCount')" target="_blank" style="color: #000000">{{relevanceCountData.thisWeekAddedCount}}
</el-link> </el-link>
{{$t('api_test.home_page.unit_of_measurement')}} {{$t('api_test.home_page.unit_of_measurement')}}
</el-col> </el-col>

View File

@ -96,7 +96,7 @@
:label="$t('api_test.automation.tag')" :key="index"> :label="$t('api_test.automation.tag')" :key="index">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" <ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain"
:content="itemName" style="margin-left: 5px"></ms-tag> :content="itemName" style="margin-left: 0px; margin-right: 2px"></ms-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
@ -248,7 +248,7 @@ export default {
return { return {
type: TEST_PLAN_LIST, type: TEST_PLAN_LIST,
headerItems: Test_Plan_List, headerItems: Test_Plan_List,
tableLabel: [], tableLabel: Test_Plan_List,
result: {}, result: {},
enableDeleteTip: false, enableDeleteTip: false,
queryPath: "/test/plan/list", queryPath: "/test/plan/list",

View File

@ -31,7 +31,7 @@
</el-table-column> </el-table-column>
<el-table-column prop="tagNames" :label="$t('api_test.automation.tag')" min-width="120"> <el-table-column prop="tagNames" :label="$t('api_test.automation.tag')" min-width="120">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-tag v-for="itemName in scope.row.tags" :key="itemName" type="success" effect="plain" :content="itemName" style="margin-left: 5px"/> <ms-tag v-for="itemName in scope.row.tags" :key="itemName" type="success" effect="plain" :content="itemName" style="margin-left: 0px; margin-right: 2px"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="userId" :label="$t('api_test.automation.creator')" show-overflow-tooltip/> <el-table-column prop="userId" :label="$t('api_test.automation.creator')" show-overflow-tooltip/>

View File

@ -80,7 +80,7 @@
:label="$t('commons.tag')" :label="$t('commons.tag')"
:key="index"> :key="index">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :content="itemName" style="margin-left: 5px"/> <ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :content="itemName" style="margin-left: 0px; margin-right: 2px"/>
</template> </template>
</el-table-column> </el-table-column>
@ -192,7 +192,7 @@ export default {
return { return {
type: TEST_PLAN_API_CASE, type: TEST_PLAN_API_CASE,
headerItems: Test_Plan_Api_Case, headerItems: Test_Plan_Api_Case,
tableLabel: [], tableLabel: Test_Plan_Api_Case,
condition: {}, condition: {},
selectCase: {}, selectCase: {},
result: {}, result: {},
@ -453,15 +453,12 @@ export default {
this.initTable(); this.initTable();
}, },
singleRun(row) { singleRun(row) {
if (!row.environmentId) {
this.$warning(this.$t('api_test.environment.select_environment'));
return;
}
this.runData = []; this.runData = [];
this.rowLoading = row.id; this.rowLoading = row.id;
this.$get('/api/testcase/get/' + row.caseId, (response) => { this.$get('/api/testcase/get/' + row.caseId, (response) => {
console.log(response.data)
let apiCase = response.data; let apiCase = response.data;
let request = JSON.parse(apiCase.request); let request = JSON.parse(apiCase.request);
request.name = row.id; request.name = row.id;

View File

@ -38,7 +38,7 @@
width="200px" :key="index"> width="200px" :key="index">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" <ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain"
:content="itemName" style="margin-left: 5px"/> :content="itemName" style="margin-left: 0px; margin-right: 2px"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column v-if="item.id == 'userId'" prop="userId" :label="$t('api_test.automation.creator')" <el-table-column v-if="item.id == 'userId'" prop="userId" :label="$t('api_test.automation.creator')"
@ -148,7 +148,7 @@ export default {
return { return {
type: TEST_PLAN_SCENARIO_CASE, type: TEST_PLAN_SCENARIO_CASE,
headerItems: Test_Plan_Scenario_Case, headerItems: Test_Plan_Scenario_Case,
tableLabel: [], tableLabel: Test_Plan_Scenario_Case,
loading: false, loading: false,
condition: {}, condition: {},
currentScenario: {}, currentScenario: {},

View File

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

View File

@ -4,9 +4,12 @@
<!-- <template v-slot:header>--> <!-- <template v-slot:header>-->
<ms-table-header :is-tester-permission="true" :condition.sync="condition" @search="initTableData" <ms-table-header :is-tester-permission="true" :condition.sync="condition" @search="initTableData"
:show-create="false" :tip="$t('commons.search_by_id_name_tag')"> :show-create="false" :tip="$t('commons.search_by_id_name_tag')">
<!-- 不显示 全部用例 标题,使标题为空 -->
<template v-slot:title> <template v-slot:title>
<node-breadcrumb class="table-title" :nodes="selectParentNodes" @refresh="breadcrumbRefresh"/> <span></span>
</template> </template>
<template v-slot:button> <template v-slot:button>
<ms-table-button :is-tester-permission="true" v-if="!showMyTestCase" icon="el-icon-s-custom" <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"/> :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" <ms-table-button :is-tester-permission="true" icon="el-icon-connection"
:content="$t('test_track.plan_view.relevance_test_case')" :content="$t('test_track.plan_view.relevance_test_case')"
@click="$emit('openTestCaseRelevanceDialog')"/> @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> </template>
</ms-table-header> </ms-table-header>
<!-- </template>--> <!-- </template>-->
@ -27,6 +33,7 @@
:select-ids="new Set(Array.from(this.selectRows).map(row => row.id))" @refresh="initTableData"/> :select-ids="new Set(Array.from(this.selectRows).map(row => row.id))" @refresh="initTableData"/>
<el-table <el-table
ref="table"
class="adjust-table" class="adjust-table"
border border
@select-all="handleSelectAll" @select-all="handleSelectAll"
@ -173,6 +180,16 @@
column-key="executor" column-key="executor"
:label="$t('test_track.plan_view.executor')"> :label="$t('test_track.plan_view.executor')">
</el-table-column> </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 <el-table-column
v-if="item.id == 'status'" v-if="item.id == 'status'"
@ -312,7 +329,7 @@ export default {
return { return {
type: TEST_PLAN_FUNCTION_TEST_CASE, type: TEST_PLAN_FUNCTION_TEST_CASE,
headerItems: Test_Plan_Function_Test_Case, headerItems: Test_Plan_Function_Test_Case,
tableLabel: [], tableLabel: Test_Plan_Function_Test_Case,
result: {}, result: {},
deletePath: "/test/case/delete", deletePath: "/test/case/delete",
condition: { condition: {
@ -352,6 +369,7 @@ export default {
{text: this.$t('test_track.plan.plan_status_running'), value: 'Underway'}, {text: this.$t('test_track.plan.plan_status_running'), value: 'Underway'},
], ],
executorFilters: [], executorFilters: [],
maintainerFilters: [],
showMore: false, showMore: false,
buttons: [ buttons: [
{ {
@ -462,6 +480,9 @@ export default {
} }
} }
this.selectRows.clear(); this.selectRows.clear();
if (this.$refs.table) {
this.$refs.table.doLayout()
}
}); });
} }
getLabel(this, TEST_PLAN_FUNCTION_TEST_CASE); getLabel(this, TEST_PLAN_FUNCTION_TEST_CASE);
@ -665,6 +686,9 @@ export default {
this.executorFilters = response.data.map(u => { this.executorFilters = response.data.map(u => {
return {text: u.name, value: u.id} 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 { return {
type: TEST_PLAN_LOAD_CASE, type: TEST_PLAN_LOAD_CASE,
headerItems: Test_Plan_Load_Case, headerItems: Test_Plan_Load_Case,
tableLabel: [], tableLabel: Test_Plan_Load_Case,
condition: {}, condition: {},
result: {}, result: {},
tableData: [], tableData: [],

View File

@ -20,7 +20,7 @@
<el-table-column prop="tags" :label="$t('api_test.automation.tag')" width="200px"> <el-table-column prop="tags" :label="$t('api_test.automation.tag')" width="200px">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :content="itemName" style="margin-left: 5px"/> <ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :content="itemName" style="margin-left: 0px; margin-right: 2px"/>
</template> </template>
</el-table-column> </el-table-column>

View File

@ -62,7 +62,7 @@
:label="$t('api_test.automation.tag')" :key="index"> :label="$t('api_test.automation.tag')" :key="index">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" <ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain"
:content="itemName" style="margin-left: 5px"></ms-tag> :content="itemName" style="margin-left: 0px; margin-right: 2px"></ms-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column

View File

@ -74,8 +74,12 @@
</el-row> </el-row>
<el-row> <el-row>
<el-col :offset="1"> <el-col :offset="1">
<span class="cast_label">{{ $t('test_track.plan_view.relevance_test_case') }}</span> <span class="cast_label">关联测试</span>
<span class="cast_item">{{ testCase.prerequisite }}</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-col>
</el-row> </el-row>
<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 ApiTestResult from "../../../plan/view/comonents/test/ApiTestResult";
import ApiTestDetail from "../../../plan/view/comonents/test/ApiTestDetail"; import ApiTestDetail from "../../../plan/view/comonents/test/ApiTestDetail";
import TestPlanTestCaseStatusButton from "../../../plan/common/TestPlanTestCaseStatusButton"; 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 ReviewComment from "../../commom/ReviewComment";
import TestCaseAttachment from "@/business/components/track/case/components/TestCaseAttachment"; import TestCaseAttachment from "@/business/components/track/case/components/TestCaseAttachment";
import ApiCaseItem from "@/business/components/api/definition/components/case/ApiCaseItem"; import ApiCaseItem from "@/business/components/api/definition/components/case/ApiCaseItem";
@ -295,6 +299,35 @@ export default {
} }
}, },
methods: { 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() { handleClose() {
removeGoBackListener(this.handleClose); removeGoBackListener(this.handleClose);
this.showDialog = false; this.showDialog = false;
@ -354,6 +387,7 @@ export default {
item.steptResults.push(item.steps[i]); item.steptResults.push(item.steps[i]);
} }
this.testCase = item; this.testCase = item;
console.log(this.testCase)
this.getRelatedTest(); this.getRelatedTest();
this.getComments(item); this.getComments(item);
/* this.initTest();*/ /* this.initTest();*/

@ -1 +1 @@
Subproject commit f63ebb68ebad78de42fd711f17e2671e34577a86 Subproject commit bc5735a2eb796640bde400ae6cafca6229672905

View File

@ -10,7 +10,7 @@ import router from "./components/common/router/router";
import YanProgress from 'yan-progress'; import YanProgress from 'yan-progress';
import './permission' // permission control import './permission' // permission control
import i18n from "../i18n/i18n"; import i18n from "../i18n/i18n";
import store from "./store"; import store from "../store";
import {permission, roles, tester, xpack} from './permission' import {permission, roles, tester, xpack} from './permission'
import chart from "../common/js/chart"; import chart from "../common/js/chart";
import CalendarHeatmap from "../common/js/calendar-heatmap"; import CalendarHeatmap from "../common/js/calendar-heatmap";

View File

@ -1,72 +0,0 @@
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex);
const Common = {
state: {
projectId: ""
},
mutations: {
setProjectId(state, projectId) {
state.projectId = projectId;
}
}
}
const API = {
state: {
test: {}
},
mutations: {
setTest(state, test) {
state.test = test;
},
clearTest(state) {
state.test = {};
}
}
}
const Switch = {
state: {
value: "new"
},
mutations: {
setValue(state, value) {
state.value = value;
}
}
}
const IsReadOnly = {
state: {
flag: true
},
mutations: {
setFlag(state, value) {
state.flag = value;
}
}
}
const Theme = {
state: {
theme: undefined
},
mutations: {
setTheme(state, value) {
state.theme = value;
}
}
}
export default new Vuex.Store({
modules: {
api: API,
common: Common,
switch: Switch,
isReadOnly: IsReadOnly,
theme: Theme
}
})

View File

@ -69,6 +69,10 @@ html,body {
border-right-color: white !important; 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 { .adjust-table {
border-color: white !important; border-color: white !important;
} }

View File

@ -945,10 +945,10 @@ export default {
export_tip: "Export Tip", export_tip: "Export Tip",
ms_tip: "Support for MeterSphere JSON format", ms_tip: "Support for MeterSphere JSON format",
ms_export_tip: "Export jSON-formatted files via MeterSphere website or browser plug-ins", 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",
esb_export_tip: "Can not export esb files now", esb_export_tip: "Can not export esb files now",
swagger_tip: "Swagger 2.0 and 3.0 json files are supported", 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",
esb_tip: "Only ESB xlsx files are supported", esb_tip: "Only ESB xlsx files are supported",
postman_tip: "Only Postman Collection V2.1 json files are supported", postman_tip: "Only Postman Collection V2.1 json files are supported",
postman_export_tip: "Export the test collection by Postman", postman_export_tip: "Export the test collection by Postman",

View File

@ -948,11 +948,11 @@ export default {
export_tip: "导出方法", export_tip: "导出方法",
ms_tip: "支持 MeterSphere json 格式", ms_tip: "支持 MeterSphere json 格式",
ms_export_tip: "通过 MeterSphere 接口测试页面或者浏览器插件导出 json 格式文件", ms_export_tip: "通过 MeterSphere 接口测试页面或者浏览器插件导出 json 格式文件",
har_export_tip: "通过 浏览器的开发者工具 导出 Har 格式文件", har_export_tip: "通过 浏览器的开发者工具 导出 HAR 格式文件",
esb_export_tip: "暂时不支持ESB文件的导出", esb_export_tip: "暂时不支持ESB文件的导出",
postman_tip: "只支持 Postman Collection v2.1 格式的 json 文件", postman_tip: "只支持 Postman Collection v2.1 格式的 json 文件",
swagger_tip: "支持 Swagger 2.0 与 3.0 版本的 json 文件", swagger_tip: "支持 Swagger 2.0 与 3.0 版本的 json 文件",
har_tip: "只支持 Har 文件", har_tip: "只支持 HAR 文件",
esb_tip: "只支持 ESB 模版的xlsx文件", esb_tip: "只支持 ESB 模版的xlsx文件",
post_export_tip: "通过 Postman 导出测试集合", post_export_tip: "通过 Postman 导出测试集合",
swagger_export_tip: "通过 Swagger 页面导出", swagger_export_tip: "通过 Swagger 页面导出",

View File

@ -947,11 +947,11 @@ export default {
export_tip: "導出方法", export_tip: "導出方法",
ms_tip: "支持 MeterSphere json 格式", ms_tip: "支持 MeterSphere json 格式",
ms_export_tip: "通過 MeterSphere 接口測試頁面或者瀏覽器插件導出 json 格式文件", ms_export_tip: "通過 MeterSphere 接口測試頁面或者瀏覽器插件導出 json 格式文件",
har_export_tip: "通过 瀏覽器到開發者工具 导出 Har 格式文件", har_export_tip: "通过 瀏覽器到開發者工具 导出 HAR 格式文件",
esb_export_tip: "暫時不支持ESB文件的导出", esb_export_tip: "暫時不支持ESB文件的导出",
postman_tip: "只支持 Postman Collection v2.1 格式的 json 文件", postman_tip: "只支持 Postman Collection v2.1 格式的 json 文件",
swagger_tip: "支持 Swagger 2.0 與 3.0 版本的 json 文件", swagger_tip: "支持 Swagger 2.0 與 3.0 版本的 json 文件",
har_tip: "只支持 Har 文件", har_tip: "只支持 HAR 文件",
esb_tip: "只支持 ESB 模板的xlsx文件", esb_tip: "只支持 ESB 模板的xlsx文件",
post_export_tip: "通過 Postman 導出測試集合", post_export_tip: "通過 Postman 導出測試集合",
swagger_export_tip: "通過 Swagger 頁面導出", swagger_export_tip: "通過 Swagger 頁面導出",

View File

@ -0,0 +1,6 @@
const actions = {
// changeCount: ({
// commit
// }) => commit('changeCount'),
}
export default actions;

View File

@ -0,0 +1,6 @@
const getters = {
isNewVersion: state => state.versionSwitch === 'new',
isOldVersion: state => state.versionSwitch === 'old'
}
export default getters

View File

@ -0,0 +1,25 @@
import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
import actions from './actions'
import mutations from './mutations'
Vue.use(Vuex)
const state = {
projectId: "",
test: {},
versionSwitch: "new",
isReadOnly: true,
theme: undefined
}
const store = new Vuex.Store({
state,
getters,
actions,
mutations
})
export default store

View File

@ -0,0 +1,9 @@
const mutations = {
setProjectId: (state, projectId) => state.projectId = projectId,
setTest: (state, test) => state.test = test,
clearTest: state => state.test = {},
setVersionSwitch: (state, value) => state.versionSwitch = value,
setTheme: (state, value) => state.theme = value
}
export default mutations;