This commit is contained in:
wenyann 2020-12-10 17:33:30 +08:00
commit cfa0489e59
33 changed files with 580 additions and 384 deletions

View File

@ -12,6 +12,7 @@ import io.metersphere.api.dto.definition.request.auth.MsAuthManager;
import io.metersphere.api.dto.definition.request.configurations.MsHeaderManager; import io.metersphere.api.dto.definition.request.configurations.MsHeaderManager;
import io.metersphere.api.dto.definition.request.controller.MsIfController; import io.metersphere.api.dto.definition.request.controller.MsIfController;
import io.metersphere.api.dto.definition.request.extract.MsExtract; import io.metersphere.api.dto.definition.request.extract.MsExtract;
import io.metersphere.api.dto.definition.request.processors.MsJSR223Processor;
import io.metersphere.api.dto.definition.request.processors.post.MsJSR223PostProcessor; import io.metersphere.api.dto.definition.request.processors.post.MsJSR223PostProcessor;
import io.metersphere.api.dto.definition.request.processors.pre.MsJSR223PreProcessor; import io.metersphere.api.dto.definition.request.processors.pre.MsJSR223PreProcessor;
import io.metersphere.api.dto.definition.request.sampler.MsDubboSampler; import io.metersphere.api.dto.definition.request.sampler.MsDubboSampler;
@ -37,6 +38,7 @@ import java.util.List;
@JsonSubTypes({ @JsonSubTypes({
@JsonSubTypes.Type(value = MsHTTPSamplerProxy.class, name = "HTTPSamplerProxy"), @JsonSubTypes.Type(value = MsHTTPSamplerProxy.class, name = "HTTPSamplerProxy"),
@JsonSubTypes.Type(value = MsHeaderManager.class, name = "HeaderManager"), @JsonSubTypes.Type(value = MsHeaderManager.class, name = "HeaderManager"),
@JsonSubTypes.Type(value = MsJSR223Processor.class, name = "JSR223Processor"),
@JsonSubTypes.Type(value = MsJSR223PostProcessor.class, name = "JSR223PostProcessor"), @JsonSubTypes.Type(value = MsJSR223PostProcessor.class, name = "JSR223PostProcessor"),
@JsonSubTypes.Type(value = MsJSR223PreProcessor.class, name = "JSR223PreProcessor"), @JsonSubTypes.Type(value = MsJSR223PreProcessor.class, name = "JSR223PreProcessor"),
@JsonSubTypes.Type(value = MsTestPlan.class, name = "TestPlan"), @JsonSubTypes.Type(value = MsTestPlan.class, name = "TestPlan"),
@ -52,7 +54,7 @@ import java.util.List;
@JsonSubTypes.Type(value = MsScenario.class, name = "scenario"), @JsonSubTypes.Type(value = MsScenario.class, name = "scenario"),
}) })
@JSONType(seeAlso = {MsHTTPSamplerProxy.class, MsHeaderManager.class, MsJSR223PostProcessor.class, @JSONType(seeAlso = {MsHTTPSamplerProxy.class, MsHeaderManager.class, MsJSR223Processor.class, MsJSR223PostProcessor.class,
MsJSR223PreProcessor.class, MsTestPlan.class, MsThreadGroup.class, AuthManager.class, MsAssertions.class, MsJSR223PreProcessor.class, MsTestPlan.class, MsThreadGroup.class, AuthManager.class, MsAssertions.class,
MsExtract.class, MsTCPSampler.class, MsDubboSampler.class, MsJDBCSampler.class, MsConstantTimer.class, MsIfController.class, MsScenario.class}, typeKey = "type") MsExtract.class, MsTCPSampler.class, MsDubboSampler.class, MsJDBCSampler.class, MsConstantTimer.class, MsIfController.class, MsScenario.class}, typeKey = "type")
@Data @Data
@ -118,7 +120,8 @@ public abstract class MsTestElement {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
ApiDefinitionWithBLOBs apiDefinition = apiDefinitionService.getBLOBs(this.getId()); ApiDefinitionWithBLOBs apiDefinition = apiDefinitionService.getBLOBs(this.getId());
element = mapper.readValue(apiDefinition.getRequest(), new TypeReference<MsTestElement>() {}); element = mapper.readValue(apiDefinition.getRequest(), new TypeReference<MsTestElement>() {
});
hashTree.add(element); hashTree.add(element);
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();

View File

@ -12,7 +12,7 @@ public interface ExtTestCaseReviewMapper {
List<TestCaseReviewDTO> list(@Param("request") QueryCaseReviewRequest params); List<TestCaseReviewDTO> list(@Param("request") QueryCaseReviewRequest params);
List<TestCaseReviewDTO> listByWorkspaceId(@Param("workspaceId") String workspaceId, @Param("userId") String userId); List<TestCaseReviewDTO> listByWorkspaceId(@Param("workspaceId") String workspaceId, @Param("userId") String userId, @Param("projectId") String projectId);
List<TestReviewDTOWithMetric> listRelate(@Param("request") QueryTestReviewRequest request); List<TestReviewDTOWithMetric> listRelate(@Param("request") QueryTestReviewRequest request);

View File

@ -15,6 +15,9 @@
and test_case_review.name like CONCAT('%', #{request.name},'%') and test_case_review.name like CONCAT('%', #{request.name},'%')
</if> </if>
and project.workspace_id = #{request.workspaceId} and project.workspace_id = #{request.workspaceId}
<if test="request.projectId != null">
and test_case_review_project.project_id = #{request.projectId}
</if>
</where> </where>
<if test="request.orders != null and request.orders.size() > 0"> <if test="request.orders != null and request.orders.size() > 0">
order by order by
@ -32,6 +35,9 @@
test_case_review.id = test_case_review_project.review_id test_case_review.id = test_case_review_project.review_id
and test_case_review_project.project_id = project.id and test_case_review_project.project_id = project.id
and project.workspace_id = #{workspaceId} and project.workspace_id = #{workspaceId}
<if test="projectId != null">
and test_case_review_project.project_id = #{projectId}
</if>
and ( and (
(test_case_review_users.review_id = test_case_review.id (test_case_review_users.review_id = test_case_review.id
and test_case_review_users.user_id = #{userId} ) and test_case_review_users.user_id = #{userId} )
@ -51,6 +57,9 @@
<if test="request.reviewerId != null"> <if test="request.reviewerId != null">
and test_case_review_users.user_id = #{request.reviewerId} and test_case_review_users.user_id = #{request.reviewerId}
</if> </if>
<if test="request.projectId != null">
and test_case_review_project.project_id = #{request.projectId}
</if>
<if test="request.creator != null"> <if test="request.creator != null">
and (test_case_review.creator = #{request.creator} and (test_case_review.creator = #{request.creator}
<if test="request.reviewIds != null and request.reviewIds.size() > 0"> <if test="request.reviewIds != null and request.reviewIds.size() > 0">

View File

@ -114,6 +114,9 @@
<if test="request.workspaceId != null"> <if test="request.workspaceId != null">
AND test_plan.workspace_id = #{request.workspaceId} AND test_plan.workspace_id = #{request.workspaceId}
</if> </if>
<if test="request.projectId != null">
AND test_plan_project.project_id = #{request.projectId}
</if>
<if test="request.id != null"> <if test="request.id != null">
AND test_plan.id = #{request.id} AND test_plan.id = #{request.id}
</if> </if>
@ -160,8 +163,13 @@
</select> </select>
<select id="listRelate" resultType="io.metersphere.track.dto.TestPlanDTOWithMetric"> <select id="listRelate" resultType="io.metersphere.track.dto.TestPlanDTOWithMetric">
select test_plan.* from test_plan select distinct test_plan.* from test_plan
where test_plan.workspace_id = #{request.workspaceId} inner join test_plan_project on test_plan.id = test_plan_project.test_plan_id
<where>
test_plan.workspace_id = #{request.workspaceId}
<if test="request.projectId != null">
and test_plan_project.project_id = #{request.projectId}
</if>
and (test_plan.principal = #{request.principal} and (test_plan.principal = #{request.principal}
<if test="request.planIds != null and request.planIds.size() > 0"> <if test="request.planIds != null and request.planIds.size() > 0">
or test_plan.id in or test_plan.id in
@ -170,6 +178,7 @@
</foreach> </foreach>
</if> </if>
) )
</where>
order by test_plan.update_time desc order by test_plan.update_time desc
</select> </select>

View File

@ -19,7 +19,7 @@ public interface ExtTestPlanTestCaseMapper {
List<TestPlanCaseDTO> listByNodes(@Param("request") QueryTestPlanCaseRequest request); List<TestPlanCaseDTO> listByNodes(@Param("request") QueryTestPlanCaseRequest request);
List<String> findRelateTestPlanId(@Param("userId") String userId, @Param("workspaceId") String workspaceId); List<String> findRelateTestPlanId(@Param("userId") String userId, @Param("workspaceId") String workspaceId, @Param("projectId") String projectId);
List<TestPlanCaseDTO> getRecentTestedTestCase(@Param("request") QueryTestPlanCaseRequest request); List<TestPlanCaseDTO> getRecentTestedTestCase(@Param("request") QueryTestPlanCaseRequest request);

View File

@ -270,8 +270,15 @@
select distinct plan_id from test_plan_test_case select distinct plan_id from test_plan_test_case
inner join test_plan inner join test_plan
on test_plan_test_case.plan_id = test_plan.id on test_plan_test_case.plan_id = test_plan.id
where test_plan_test_case.executor = #{userId} inner join test_plan_project
on test_plan.id = test_plan_project.test_plan_id
<where>
test_plan_test_case.executor = #{userId}
and test_plan.workspace_id = #{workspaceId} and test_plan.workspace_id = #{workspaceId}
<if test="projectId != null">
and test_plan_project.project_id = #{projectId}
</if>
</where>
</select> </select>
<select id="getRecentTestedTestCase" resultType="io.metersphere.track.dto.TestPlanCaseDTO"> <select id="getRecentTestedTestCase" resultType="io.metersphere.track.dto.TestPlanCaseDTO">
select test_plan_test_case.*, test_case.* select test_plan_test_case.*, test_case.*

View File

@ -11,7 +11,7 @@ public interface ExtTestReviewCaseMapper {
List<TestReviewCaseDTO> list(@Param("request") QueryCaseReviewRequest request); List<TestReviewCaseDTO> list(@Param("request") QueryCaseReviewRequest request);
List<String> getStatusByReviewId(String reviewId); List<String> getStatusByReviewId(String reviewId);
List<String> findRelateTestReviewId(@Param("userId") String userId, @Param("workspaceId") String workspaceId); List<String> findRelateTestReviewId(@Param("userId") String userId, @Param("workspaceId") String workspaceId, @Param("projectId") String projectId);
/** /**
* 根据项目 ids 查询 TestReviewCaseDTO 列表 * 根据项目 ids 查询 TestReviewCaseDTO 列表

View File

@ -206,6 +206,7 @@
inner join project on project.id = test_case_review_project.project_id inner join project on project.id = test_case_review_project.project_id
where test_case_review_test_case.review_id = #{userId} where test_case_review_test_case.review_id = #{userId}
and project.workspace_id = #{workspaceId} and project.workspace_id = #{workspaceId}
and test_case_review_project.project_id = #{projectId}
</select> </select>
<select id="listTestCaseByProjectIds" resultType="io.metersphere.track.dto.TestReviewCaseDTO"> <select id="listTestCaseByProjectIds" resultType="io.metersphere.track.dto.TestReviewCaseDTO">
select distinct * from test_case_review_test_case, test_case select distinct * from test_case_review_test_case, test_case

View File

@ -68,4 +68,8 @@ public class SessionUtils {
public static String getCurrentOrganizationId() { public static String getCurrentOrganizationId() {
return Optional.ofNullable(getUser()).orElse(new SessionUser()).getLastOrganizationId(); return Optional.ofNullable(getUser()).orElse(new SessionUser()).getLastOrganizationId();
} }
public static String getCurrentProjectId() {
return Optional.ofNullable(getUser()).orElse(new SessionUser()).getLastProjectId();
}
} }

View File

@ -81,8 +81,7 @@ public class TestCaseReviewController {
@PostMapping("/list/all") @PostMapping("/list/all")
public List<TestCaseReview> listAll() { public List<TestCaseReview> listAll() {
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId(); return testCaseReviewService.listCaseReviewAll();
return testCaseReviewService.listCaseReviewAll(currentWorkspaceId);
} }
@PostMapping("/relevance") @PostMapping("/relevance")

View File

@ -35,4 +35,6 @@ public class QueryCaseReviewRequest extends TestCaseReviewTestCase {
private String method; private String method;
private Map<String, Object> combine; private Map<String, Object> combine;
private String projectId;
} }

View File

@ -156,6 +156,7 @@ public class TestCaseReviewService {
public List<TestCaseReviewDTO> listCaseReview(QueryCaseReviewRequest request) { public List<TestCaseReviewDTO> listCaseReview(QueryCaseReviewRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
request.setProjectId(SessionUtils.getCurrentProjectId());
return extTestCaseReviewMapper.list(request); return extTestCaseReviewMapper.list(request);
} }
@ -198,7 +199,7 @@ public class TestCaseReviewService {
} }
public List<TestCaseReviewDTO> recent(String currentWorkspaceId) { public List<TestCaseReviewDTO> recent(String currentWorkspaceId) {
return extTestCaseReviewMapper.listByWorkspaceId(currentWorkspaceId, SessionUtils.getUserId()); return extTestCaseReviewMapper.listByWorkspaceId(currentWorkspaceId, SessionUtils.getUserId(), SessionUtils.getCurrentProjectId());
} }
public void editCaseReview(SaveTestCaseReviewRequest testCaseReview) { public void editCaseReview(SaveTestCaseReviewRequest testCaseReview) {
@ -346,21 +347,16 @@ public class TestCaseReviewService {
testCaseReviewTestCaseMapper.deleteByExample(testCaseReviewTestCaseExample); testCaseReviewTestCaseMapper.deleteByExample(testCaseReviewTestCaseExample);
} }
public List<TestCaseReview> listCaseReviewAll(String currentWorkspaceId) { public List<TestCaseReview> listCaseReviewAll() {
ProjectExample projectExample = new ProjectExample(); TestCaseReviewProjectExample reviewProjectExample = new TestCaseReviewProjectExample();
projectExample.createCriteria().andWorkspaceIdEqualTo(currentWorkspaceId); TestCaseReviewProjectExample.Criteria criteria = reviewProjectExample.createCriteria();
List<Project> projects = projectMapper.selectByExample(projectExample); if (StringUtils.isNotBlank(SessionUtils.getCurrentProjectId())) {
List<String> projectIds = projects.stream().map(Project::getId).collect(Collectors.toList()); criteria.andProjectIdEqualTo(SessionUtils.getCurrentProjectId());
List<TestCaseReviewProject> testCaseReviewProjects = testCaseReviewProjectMapper.selectByExample(reviewProjectExample);
if (!CollectionUtils.isEmpty(projectIds)) { if (!CollectionUtils.isEmpty(testCaseReviewProjects)) {
TestCaseReviewProjectExample testCaseReviewProjectExample = new TestCaseReviewProjectExample(); List<String> caseReviewIds = testCaseReviewProjects.stream().map(TestCaseReviewProject::getReviewId).collect(Collectors.toList());
testCaseReviewProjectExample.createCriteria().andProjectIdIn(projectIds);
List<TestCaseReviewProject> testCaseReviewProjects = testCaseReviewProjectMapper.selectByExample(testCaseReviewProjectExample);
List<String> reviewIds = testCaseReviewProjects.stream().map(TestCaseReviewProject::getReviewId).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(reviewIds)) {
TestCaseReviewExample testCaseReviewExample = new TestCaseReviewExample(); TestCaseReviewExample testCaseReviewExample = new TestCaseReviewExample();
testCaseReviewExample.createCriteria().andIdIn(reviewIds); testCaseReviewExample.createCriteria().andIdIn(caseReviewIds);
return testCaseReviewMapper.selectByExample(testCaseReviewExample); return testCaseReviewMapper.selectByExample(testCaseReviewExample);
} }
} }
@ -481,7 +477,8 @@ public class TestCaseReviewService {
request.setReviewerId(user.getId()); request.setReviewerId(user.getId());
} }
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
request.setReviewIds(extTestReviewCaseMapper.findRelateTestReviewId(user.getId(), SessionUtils.getCurrentWorkspaceId())); request.setProjectId(SessionUtils.getCurrentProjectId());
request.setReviewIds(extTestReviewCaseMapper.findRelateTestReviewId(user.getId(), SessionUtils.getCurrentWorkspaceId(), user.getLastProjectId()));
List<String> projectIds = extProjectMapper.getProjectIdByWorkspaceId(SessionUtils.getCurrentWorkspaceId()); List<String> projectIds = extProjectMapper.getProjectIdByWorkspaceId(SessionUtils.getCurrentWorkspaceId());
@ -545,9 +542,11 @@ public class TestCaseReviewService {
if (userIds.size() > 0) { if (userIds.size() > 0) {
for (String id : userIds) { for (String id : userIds) {
if (StringUtils.isNotBlank(userMap.get(id))) {
stringBuilder.append(userMap.get(id)).append(""); stringBuilder.append(userMap.get(id)).append("");
} }
name = stringBuilder.toString().substring(0, stringBuilder.length() - 1); }
name = stringBuilder.substring(0, stringBuilder.length() - 1);
} }
return name; return name;
} }

View File

@ -220,28 +220,18 @@ public class TestCaseService {
public List<TestCase> recentTestPlans(QueryTestCaseRequest request, int count) { public List<TestCase> recentTestPlans(QueryTestCaseRequest request, int count) {
if (StringUtils.isBlank(request.getWorkspaceId())) {
return null;
}
ProjectExample projectExample = new ProjectExample();
projectExample.createCriteria().andWorkspaceIdEqualTo(request.getWorkspaceId());
List<String> projectIds = projectMapper.selectByExample(projectExample).stream()
.map(Project::getId).collect(Collectors.toList());
if (projectIds.isEmpty()) {
return null;
}
PageHelper.startPage(1, count, true); PageHelper.startPage(1, count, true);
TestCaseExample testCaseExample = new TestCaseExample(); TestCaseExample testCaseExample = new TestCaseExample();
testCaseExample.createCriteria().andProjectIdIn(projectIds).andMaintainerEqualTo(request.getUserId()); TestCaseExample.Criteria criteria = testCaseExample.createCriteria();
criteria.andMaintainerEqualTo(request.getUserId());
String projectId = SessionUtils.getCurrentProjectId();
if (StringUtils.isNotBlank(projectId)) {
criteria.andProjectIdEqualTo(projectId);
testCaseExample.setOrderByClause("update_time desc, sort desc"); testCaseExample.setOrderByClause("update_time desc, sort desc");
return testCaseMapper.selectByExample(testCaseExample); return testCaseMapper.selectByExample(testCaseExample);
} }
return new ArrayList<>();
}
public Project getProjectByTestCaseId(String testCaseId) { public Project getProjectByTestCaseId(String testCaseId) {
TestCaseWithBLOBs testCaseWithBLOBs = testCaseMapper.selectByPrimaryKey(testCaseId); TestCaseWithBLOBs testCaseWithBLOBs = testCaseMapper.selectByPrimaryKey(testCaseId);

View File

@ -327,6 +327,10 @@ public class TestPlanService {
public List<TestPlanDTOWithMetric> listTestPlan(QueryTestPlanRequest request) { public List<TestPlanDTOWithMetric> listTestPlan(QueryTestPlanRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
String projectId = SessionUtils.getCurrentProjectId();
if (StringUtils.isNotBlank(projectId)) {
request.setProjectId(projectId);
}
List<TestPlanDTOWithMetric> testPlans = extTestPlanMapper.list(request); List<TestPlanDTOWithMetric> testPlans = extTestPlanMapper.list(request);
calcTestPlanRate(testPlans); calcTestPlanRate(testPlans);
return testPlans; return testPlans;
@ -392,25 +396,50 @@ public class TestPlanService {
if (StringUtils.isBlank(currentWorkspaceId)) { if (StringUtils.isBlank(currentWorkspaceId)) {
return null; return null;
} }
TestPlanProjectExample testPlanProjectExample = new TestPlanProjectExample();
TestPlanProjectExample.Criteria criteria = testPlanProjectExample.createCriteria();
if (StringUtils.isNotBlank(SessionUtils.getCurrentProjectId())) {
criteria.andProjectIdEqualTo(SessionUtils.getCurrentProjectId());
List<TestPlanProject> testPlanProjects = testPlanProjectMapper.selectByExample(testPlanProjectExample);
if (!CollectionUtils.isEmpty(testPlanProjects)) {
List<String> testPlanIds = testPlanProjects.stream().map(TestPlanProject::getTestPlanId).collect(Collectors.toList());
TestPlanExample testPlanTestCaseExample = new TestPlanExample(); TestPlanExample testPlanTestCaseExample = new TestPlanExample();
testPlanTestCaseExample.createCriteria().andWorkspaceIdEqualTo(currentWorkspaceId) testPlanTestCaseExample.createCriteria().andWorkspaceIdEqualTo(currentWorkspaceId)
.andIdIn(testPlanIds)
.andPrincipalEqualTo(SessionUtils.getUserId()); .andPrincipalEqualTo(SessionUtils.getUserId());
testPlanTestCaseExample.setOrderByClause("update_time desc"); testPlanTestCaseExample.setOrderByClause("update_time desc");
return testPlanMapper.selectByExample(testPlanTestCaseExample); return testPlanMapper.selectByExample(testPlanTestCaseExample);
} }
}
return new ArrayList<>();
}
public List<TestPlan> listTestAllPlan(String currentWorkspaceId) { public List<TestPlan> listTestAllPlan(String currentWorkspaceId) {
TestPlanProjectExample testPlanProjectExample = new TestPlanProjectExample();
TestPlanProjectExample.Criteria criteria = testPlanProjectExample.createCriteria();
if (StringUtils.isNotBlank(SessionUtils.getCurrentProjectId())) {
criteria.andProjectIdEqualTo(SessionUtils.getCurrentProjectId());
List<TestPlanProject> testPlanProjects = testPlanProjectMapper.selectByExample(testPlanProjectExample);
if (!CollectionUtils.isEmpty(testPlanProjects)) {
List<String> testPlanIds = testPlanProjects.stream().map(TestPlanProject::getTestPlanId).collect(Collectors.toList());
TestPlanExample testPlanExample = new TestPlanExample(); TestPlanExample testPlanExample = new TestPlanExample();
testPlanExample.createCriteria().andWorkspaceIdEqualTo(currentWorkspaceId); TestPlanExample.Criteria testPlanCriteria = testPlanExample.createCriteria();
testPlanCriteria.andWorkspaceIdEqualTo(currentWorkspaceId);
testPlanCriteria.andIdIn(testPlanIds);
return testPlanMapper.selectByExample(testPlanExample); return testPlanMapper.selectByExample(testPlanExample);
} }
}
return new ArrayList<>();
}
public List<TestPlanDTOWithMetric> listRelateAllPlan() { public List<TestPlanDTOWithMetric> listRelateAllPlan() {
SessionUser user = SessionUtils.getUser(); SessionUser user = SessionUtils.getUser();
QueryTestPlanRequest request = new QueryTestPlanRequest(); QueryTestPlanRequest request = new QueryTestPlanRequest();
request.setPrincipal(user.getId()); request.setPrincipal(user.getId());
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
request.setPlanIds(extTestPlanTestCaseMapper.findRelateTestPlanId(user.getId(), SessionUtils.getCurrentWorkspaceId())); request.setProjectId(SessionUtils.getCurrentProjectId());
request.setPlanIds(extTestPlanTestCaseMapper.findRelateTestPlanId(user.getId(), SessionUtils.getCurrentWorkspaceId(), SessionUtils.getCurrentProjectId()));
List<TestPlanDTOWithMetric> testPlans = extTestPlanMapper.listRelate(request); List<TestPlanDTOWithMetric> testPlans = extTestPlanMapper.listRelate(request);
calcTestPlanRate(testPlans); calcTestPlanRate(testPlans);
return testPlans; return testPlans;

View File

@ -123,7 +123,7 @@ public class TestPlanTestCaseService {
public void buildQueryRequest(QueryTestPlanCaseRequest request, int count) { public void buildQueryRequest(QueryTestPlanCaseRequest request, int count) {
SessionUser user = SessionUtils.getUser(); SessionUser user = SessionUtils.getUser();
List<String> relateTestPlanIds = extTestPlanTestCaseMapper.findRelateTestPlanId(user.getId(), SessionUtils.getCurrentWorkspaceId()); List<String> relateTestPlanIds = extTestPlanTestCaseMapper.findRelateTestPlanId(user.getId(), SessionUtils.getCurrentWorkspaceId(), SessionUtils.getCurrentProjectId());
PageHelper.startPage(1, count, true); PageHelper.startPage(1, count, true);
request.setPlanIds(relateTestPlanIds); request.setPlanIds(relateTestPlanIds);
request.setExecutor(user.getId()); request.setExecutor(user.getId());

View File

@ -14,6 +14,7 @@ import io.metersphere.xmind.parser.XmindParser;
import io.metersphere.xmind.parser.pojo.Attached; import io.metersphere.xmind.parser.pojo.Attached;
import io.metersphere.xmind.parser.pojo.JsonRootBean; import io.metersphere.xmind.parser.pojo.JsonRootBean;
import io.metersphere.xmind.utils.DetailUtil; import io.metersphere.xmind.utils.DetailUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -185,7 +186,7 @@ public class XmindCaseParser {
String nodePath = parent.getPath() + "/" + item.getTitle(); String nodePath = parent.getPath() + "/" + item.getTitle();
item.setPath(nodePath); item.setPath(nodePath);
item.setParent(parent); item.setParent(parent);
if (item.getChildren() != null && !item.getChildren().getAttached().isEmpty()) { if (item.getChildren() != null && CollectionUtils.isNotEmpty(item.getChildren().getAttached())) {
recursion(item, level + 1, item.getChildren().getAttached()); recursion(item, level + 1, item.getChildren().getAttached());
} else { } else {
if (!nodePath.startsWith("/")) { if (!nodePath.startsWith("/")) {

View File

@ -2,21 +2,32 @@
<div v-loading="loading"> <div v-loading="loading">
<el-card> <el-card>
<el-row> <el-row>
<div class="el-step__icon is-text ms-api-col" v-if="request.referenced"> <div class="el-step__icon is-text ms-api-col" v-if="request.referenced!=undefined && request.referenced==='Deleted' || request.referenced=='REF'">
<div class="el-step__icon-inner">{{request.index}}</div> <div class="el-step__icon-inner">{{request.index}}</div>
</div> </div>
<div class="el-step__icon is-text ms-api-col-create" v-else> <div class="el-step__icon is-text ms-api-col-create" v-else>
<div class="el-step__icon-inner">{{request.index}}</div> <div class="el-step__icon-inner">{{request.index}}</div>
</div> </div>
<i class="icon el-icon-arrow-right" :class="{'is-active': request.active}" <el-button v-if="request.referenced!=undefined && request.referenced==='Deleted' || request.referenced=='REF'" class="ms-left-buttion" size="small">
@click="active(request)" v-if="request.referenced!=undefined && request.referenced!='Deleted' && request.referenced!='REF'"/> {{$t('api_test.automation.api_list_import')}}
<span>{{request.type!= 'create' ? request.name:''}} </span> </el-button>
<el-button v-if="request.referenced==undefined || request.referenced==='Created' || request.referenced==='Copy'" class="ms-create-buttion" size="small">
{{$t('api_test.automation.customize_req')}}
</el-button>
<span v-if="request.referenced!=undefined && request.referenced==='Deleted' || request.referenced=='REF'">{{request.name}} </span>
<el-input size="small" v-model="request.name" style="width: 40%;" :placeholder="$t('commons.input_name')" v-else/>
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag> <el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag>
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced ==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag> <el-tag size="mini" style="margin-left: 20px" v-if="request.referenced ==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
<div style="margin-right: 20px; float: right">
<el-button size="mini" type="danger" icon="el-icon-delete" circle @click="remove" style="margin-right: 20px; float: right"/> <i class="icon el-icon-arrow-right" :class="{'is-active': request.active}"
@click="active(request)" v-if="request.referenced!=undefined && request.referenced!='Deleted' && request.referenced!='REF'"/>
<el-switch v-model="request.enable" style="margin-left: 10px"/>
<el-button size="mini" icon="el-icon-delete" circle @click="remove" style="margin-left: 10px"/>
</div>
</el-row> </el-row>
<!-- 请求参数--> <!-- 请求参数-->
<el-collapse-transition> <el-collapse-transition>
@ -112,6 +123,12 @@
color: #F56C6C; color: #F56C6C;
} }
.ms-left-buttion {
color: #F56C6C;
background-color: #FCF1F1;
margin-right: 20px;
}
.ms-api-col-create { .ms-api-col-create {
background-color: #EBF2F2; background-color: #EBF2F2;
border-color: #008080; border-color: #008080;
@ -127,6 +144,12 @@
transform: rotate(90deg); transform: rotate(90deg);
} }
.ms-create-buttion {
color: #008080;
background-color: #EBF2F2;
margin-right: 20px;
}
.tip { .tip {
padding: 3px 5px; padding: 3px 5px;
font-size: 16px; font-size: 16px;

View File

@ -61,7 +61,9 @@
this.request.method = row.method; this.request.method = row.method;
} }
this.request.resourceId = getUUID(); this.request.resourceId = getUUID();
this.$emit('addCustomizeApi', this.request); let obj = {};
Object.assign(obj, this.request);
this.$emit('addCustomizeApi', obj);
}, },
reload() { reload() {
this.loading = true this.loading = true

View File

@ -2,13 +2,17 @@
<div v-loading="loading"> <div v-loading="loading">
<el-card> <el-card>
<el-row> <el-row>
<div class="el-step__icon is-text ms-api-col" style="float: left"> <div class="el-step__icon is-text ms-api-col">
<div class="el-step__icon-inner">{{scenario.index}}</div> <div class="el-step__icon-inner">{{scenario.index}}</div>
</div> </div>
<div style="margin-left: 20px;float: left"> {{scenario.name}}</div> <el-button class="ms-title-buttion" size="small">{{$t('api_test.automation.scenario_import')}}</el-button>
{{scenario.name}}
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag> <el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag>
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag> <el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
<el-button size="mini" type="danger" icon="el-icon-delete" circle @click="remove" style="margin-right: 20px; float: right"/> <div style="margin-right: 20px; float: right">
<el-switch v-model="scenario.enable" style="margin-left: 10px"/>
<el-button size="mini" icon="el-icon-delete" circle @click="remove" style="margin-left: 10px"/>
</div>
</el-row> </el-row>
</el-card> </el-card>
</div> </div>
@ -73,6 +77,12 @@
padding: 15px; padding: 15px;
} }
.ms-title-buttion {
background-color: #F4F4F5;
margin-right: 20px;
color: #606266;
}
.icon.is-active { .icon.is-active {
transform: rotate(90deg); transform: rotate(90deg);
} }

View File

@ -2,23 +2,15 @@
<div> <div>
<el-card> <el-card>
<el-row> <el-row>
<div class="el-step__icon is-text ms-api-col" style="float: left"> <div class="el-step__icon is-text ms-api-col">
<div class="el-step__icon-inner">{{timer.index}}</div> <div class="el-step__icon-inner">{{timer.index}}</div>
</div> </div>
<div> <el-button class="ms-title-buttion" size="small">{{$t('api_test.automation.wait_controller')}}</el-button>
<el-row :gutter="10" type="flex" align="middle">
<el-col :span="2">{{ $t('api_test.request.wait') }}</el-col>
<el-col :span="10">
<el-input-number class="width-100" size="small" v-model="timer.delay" :min="0" :step="1000"/> <el-input-number class="width-100" size="small" v-model="timer.delay" :min="0" :step="1000"/>
</el-col> ms
<el-col :span="2">ms</el-col> <div style="margin-right: 20px; float: right">
<el-col :span="8"> <el-switch v-model="timer.enable" style="margin-left: 10px"/>
<el-switch v-model="timer.enable" :inactive-text="$t('api_test.scenario.enable_disable')"/> <el-button size="mini" icon="el-icon-delete" circle @click="remove" style="margin-left: 10px;"/>
</el-col>
<el-col :span="2">
<el-button size="mini" type="danger" icon="el-icon-delete" circle @click="remove"/>
</el-col>
</el-row>
</div> </div>
</el-row> </el-row>
</el-card> </el-card>
@ -45,7 +37,7 @@
<style scoped> <style scoped>
.width-100 { .width-100 {
width: 100% width: 40%
} }
.ms-api-col { .ms-api-col {
@ -55,6 +47,12 @@
color: #67C23A; color: #67C23A;
} }
.ms-title-buttion {
background-color: #F2F9EE;
color: #67C23A;
margin-right: 20px;
}
/deep/ .el-card__body { /deep/ .el-card__body {
padding: 15px; padding: 15px;
} }

View File

@ -1,10 +1,10 @@
<template> <template>
<el-card class="card-content"> <el-card class="card-content">
<div style="background-color: white;"> <div class="ms-main-div">
<el-row> <el-row>
<el-col> <el-col>
<!--操作按钮--> <!--操作按钮-->
<div style="float: right;margin-right: 20px"> <div class="ms-opt-btn">
<el-button type="primary" size="small" @click="editScenario">{{$t('commons.save')}}</el-button> <el-button type="primary" size="small" @click="editScenario">{{$t('commons.save')}}</el-button>
</div> </div>
</el-col> </el-col>
@ -119,7 +119,7 @@
<el-row> <el-row>
<el-col :span="21"> <el-col :span="21">
<!-- 调试部分 --> <!-- 调试部分 -->
<div style="margin-left: 20px;border:1px #DCDFE6 solid;border-radius: 4px;margin-right: 10px"> <div class="ms-debug-div">
<el-row style="margin: 5px"> <el-row style="margin: 5px">
<el-col :span="6" class="ms-col-one"> <el-col :span="6" class="ms-col-one">
{{currentScenario.name ===undefined || ''? $t('api_test.scenario.name') : currentScenario.name}} {{currentScenario.name ===undefined || ''? $t('api_test.scenario.name') : currentScenario.name}}
@ -199,37 +199,37 @@
<el-button type="primary" icon="el-icon-refresh" size="small" @click="showAll">{{$t('commons.show_all')}}</el-button> <el-button type="primary" icon="el-icon-refresh" size="small" @click="showAll">{{$t('commons.show_all')}}</el-button>
<br/> <br/>
<div v-if="operatingElements.indexOf('HTTPSamplerProxy')>0 || operatingElements.indexOf('DubboSampler')>0 || operatingElements.indexOf('JDBCSampler')>0 || operatingElements.indexOf('TCPSampler')>0 "> <div v-if="operatingElements.indexOf('HTTPSamplerProxy')>0 || operatingElements.indexOf('DubboSampler')>0 || operatingElements.indexOf('JDBCSampler')>0 || operatingElements.indexOf('TCPSampler')>0 ">
<el-button class="ms-right-buttion" size="small" style="color: #F56C6C;background-color: #FCF1F1" @click="apiListImport">+{{$t('api_test.automation.api_list_import')}}</el-button> <el-button class="ms-right-buttion ms-btn-1" size="small" @click="apiListImport">+{{$t('api_test.automation.api_list_import')}}</el-button>
</div> </div>
<!--<div v-if="operatingElements.indexOf('OT_IMPORT')>0"> <!--<div v-if="operatingElements.indexOf('OT_IMPORT')>0">
<el-button class="ms-right-buttion" size="small" style="color: #409EFF;background-color: #EEF5FE" @click="addComponent('OT_IMPORT')">+{{$t('api_test.automation.external_import')}}</el-button> <el-button class="ms-right-buttion" size="small" style="color: #409EFF;background-color: #EEF5FE" @click="addComponent('OT_IMPORT')">+{{$t('api_test.automation.external_import')}}</el-button>
</div>--> </div>-->
<div v-if="operatingElements.indexOf('ConstantTimer')>0"> <div v-if="operatingElements.indexOf('ConstantTimer')>0">
<el-button class="ms-right-buttion" size="small" style="color: #67C23A;background-color: #F2F9EE" @click="addComponent('ConstantTimer')">+{{$t('api_test.automation.wait_controller')}}</el-button> <el-button class="ms-right-buttion ms-btn-3" size="small" @click="addComponent('ConstantTimer')">+{{$t('api_test.automation.wait_controller')}}</el-button>
</div> </div>
<div v-if="operatingElements.indexOf('IfController')>0"> <div v-if="operatingElements.indexOf('IfController')>0">
<el-button class="ms-right-buttion" size="small" style="color: #E6A23C;background-color: #FCF6EE" @click="addComponent('IfController')">+{{$t('api_test.automation.if_controller')}}</el-button> <el-button class="ms-right-buttion ms-btn-4" size="small" @click="addComponent('IfController')">+{{$t('api_test.automation.if_controller')}}</el-button>
</div> </div>
<div v-if="operatingElements.indexOf('scenario')===0"> <div v-if="operatingElements.indexOf('scenario')===0">
<el-button class="ms-right-buttion" size="small" style="color: #606266;background-color: #F4F4F5" @click="addComponent('scenario')">+{{$t('api_test.automation.scenario_import')}}</el-button> <el-button class="ms-right-buttion ms-btn-5" size="small" @click="addComponent('scenario')">+{{$t('api_test.automation.scenario_import')}}</el-button>
</div> </div>
<div v-if="operatingElements.indexOf('JSR223Processor')>0"> <div v-if="operatingElements.indexOf('JSR223Processor')>0">
<el-button class="ms-right-buttion" size="small" style="color: #7B4D12;background-color: #F1EEE9" @click="addComponent('JSR223Processor')">+{{$t('api_test.automation.customize_script')}}</el-button> <el-button class="ms-right-buttion ms-btn-6" size="small" @click="addComponent('JSR223Processor')">+{{$t('api_test.automation.customize_script')}}</el-button>
</div> </div>
<div v-if="operatingElements.indexOf('CustomizeReq')>0"> <div v-if="operatingElements.indexOf('CustomizeReq')>0">
<el-button class="ms-right-buttion" size="small" style="color: #008080;background-color: #EBF2F2" @click="addComponent('CustomizeReq')">+{{$t('api_test.automation.customize_req')}}</el-button> <el-button class="ms-right-buttion ms-btn-7" size="small" @click="addComponent('CustomizeReq')">+{{$t('api_test.automation.customize_req')}}</el-button>
</div> </div>
<div v-if="operatingElements.indexOf('JSR223PreProcessor')>0"> <div v-if="operatingElements.indexOf('JSR223PreProcessor')>0">
<el-button class="ms-right-buttion" size="small" style="color: #B8741A;background-color: #F9F1EA" @click="addComponent('JSR223PreProcessor')">+{{$t('api_test.definition.request.pre_script')}}</el-button> <el-button class="ms-right-buttion ms-btn-8" size="small" @click="addComponent('JSR223PreProcessor')">+{{$t('api_test.definition.request.pre_script')}}</el-button>
</div> </div>
<div v-if="operatingElements.indexOf('JSR223PostProcessor')>0"> <div v-if="operatingElements.indexOf('JSR223PostProcessor')>0">
<el-button class="ms-right-buttion" size="small" style="color: #783887;background-color: #F2ECF3" @click="addComponent('JSR223PostProcessor')">+{{$t('api_test.definition.request.post_script')}}</el-button> <el-button class="ms-right-buttion ms-btn-9" size="small" @click="addComponent('JSR223PostProcessor')">+{{$t('api_test.definition.request.post_script')}}</el-button>
</div> </div>
<div v-if="operatingElements.indexOf('Assertions')>0"> <div v-if="operatingElements.indexOf('Assertions')>0">
<el-button class="ms-right-buttion" size="small" style="color: #A30014;background-color: #F7E6E9" @click="addComponent('Assertions')">+{{$t('api_test.definition.request.assertions_rule')}}</el-button> <el-button class="ms-right-buttion ms-btn-10" size="small" @click="addComponent('Assertions')">+{{$t('api_test.definition.request.assertions_rule')}}</el-button>
</div> </div>
<div v-if="operatingElements.indexOf('Extract')>0"> <div v-if="operatingElements.indexOf('Extract')>0">
<el-button class="ms-right-buttion" size="small" style="color: #015478;background-color: #E6EEF2" @click="addComponent('Extract')">+{{$t('api_test.definition.request.extract_param')}}</el-button> <el-button class="ms-right-buttion ms-btn-11" size="small" @click="addComponent('Extract')">+{{$t('api_test.definition.request.extract_param')}}</el-button>
</div> </div>
</el-col> </el-col>
</div> </div>
@ -361,38 +361,6 @@
}, },
watch: {}, watch: {},
methods: { methods: {
nodeClick(e) {
if (e.referenced != 'REF' && e.referenced != 'Deleted') {
this.operatingElements = ELEMENTS.get(e.type);
} else {
this.operatingElements = [];
}
this.selectedTreeNode = e;
},
showAll() {
this.operatingElements = ELEMENTS.get("ALL");
this.selectedTreeNode = undefined;
this.reload();
},
apiListImport() {
this.apiListVisible = true;
},
recursiveSorting(arr) {
for (let i in arr) {
arr[i].index = Number(i) + 1;
if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) {
this.recursiveSorting(arr[i].hashTree);
}
}
},
sort() {
for (let i in this.scenarioDefinition) {
this.scenarioDefinition[i].index = Number(i) + 1;
if (this.scenarioDefinition[i].hashTree != undefined && this.scenarioDefinition[i].hashTree.length > 0) {
this.recursiveSorting(this.scenarioDefinition[i].hashTree);
}
}
},
addComponent(type) { addComponent(type) {
switch (type) { switch (type) {
case ELEMENT_TYPE.IfController: case ELEMENT_TYPE.IfController:
@ -436,8 +404,41 @@
this.sort(); this.sort();
this.reload(); this.reload();
}, },
nodeClick(e) {
if (e.referenced != 'REF' && e.referenced != 'Deleted') {
this.operatingElements = ELEMENTS.get(e.type);
} else {
this.operatingElements = [];
}
this.selectedTreeNode = e;
},
showAll() {
this.operatingElements = ELEMENTS.get("ALL");
this.selectedTreeNode = undefined;
this.reload();
},
apiListImport() {
this.apiListVisible = true;
},
recursiveSorting(arr) {
for (let i in arr) {
arr[i].index = Number(i) + 1;
if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) {
this.recursiveSorting(arr[i].hashTree);
}
}
},
sort() {
for (let i in this.scenarioDefinition) {
this.scenarioDefinition[i].index = Number(i) + 1;
if (this.scenarioDefinition[i].hashTree != undefined && this.scenarioDefinition[i].hashTree.length > 0) {
this.recursiveSorting(this.scenarioDefinition[i].hashTree);
}
}
},
addCustomizeApi(request) { addCustomizeApi(request) {
this.customizeVisible = false; this.customizeVisible = false;
request.enable === undefined ? request.enable = true : request.enable;
if (this.selectedTreeNode != undefined) { if (this.selectedTreeNode != undefined) {
this.selectedTreeNode.hashTree.push(request); this.selectedTreeNode.hashTree.push(request);
} else { } else {
@ -450,6 +451,7 @@
addScenario(arr) { addScenario(arr) {
if (arr.length > 0) { if (arr.length > 0) {
arr.forEach(item => { arr.forEach(item => {
item.enable === undefined ? item.enable = true : item.enable;
this.scenarioDefinition.push(item); this.scenarioDefinition.push(item);
}) })
} }
@ -470,6 +472,7 @@
request = item.request; request = item.request;
} }
request.referenced = referenced; request.referenced = referenced;
request.enable === undefined ? request.enable = true : request.enable;
request.active = false; request.active = false;
request.resourceId = getUUID(); request.resourceId = getUUID();
if (referenced === 'REF') { if (referenced === 'REF') {
@ -489,6 +492,7 @@
request = item.request; request = item.request;
} }
request.referenced = referenced; request.referenced = referenced;
request.enable === undefined ? request.enable = true : request.enable;
request.active = false; request.active = false;
request.resourceId = getUUID(); request.resourceId = getUUID();
if (referenced === 'REF') { if (referenced === 'REF') {
@ -734,6 +738,22 @@
width: 100%; width: 100%;
} }
.ms-main-div {
background-color: white;
}
.ms-opt-btn {
float: right;
margin-right: 20px;
}
.ms-debug-div {
margin-left: 20px;
border: 1px #DCDFE6 solid;
border-radius: 4px;
margin-right: 10px;
}
.ms-scenario-button { .ms-scenario-button {
margin-left: 30%; margin-left: 30%;
padding: 7px; padding: 7px;
@ -761,6 +781,61 @@
margin-top: 10px; margin-top: 10px;
} }
.ms-btn-1 {
color: #F56C6C;
background-color: #FCF1F1
}
.ms-btn-2 {
color: #F56C6C;
background-color: #FCF1F1
}
.ms-btn-3 {
color: #67C23A;
background-color: #F2F9EE
}
.ms-btn-4 {
color: #E6A23C;
background-color: #FCF6EE
}
.ms-btn-5 {
color: #606266;
background-color: #F4F4F5
}
.ms-btn-6 {
color: #7B4D12;
background-color: #F1EEE9
}
.ms-btn-7 {
color: #008080;
background-color: #EBF2F2
}
.ms-btn-8 {
color: #B8741A;
background-color: #F9F1EA
}
.ms-btn-9 {
color: #783887;
background-color: #F2ECF3
}
.ms-btn-10 {
color: #A30014;
background-color: #F7E6E9
}
.ms-btn-11 {
color: #015478;
background-color: #E6EEF2
}
/deep/ .el-tree-node__content { /deep/ .el-tree-node__content {
height: 100%; height: 100%;
margin-top: 8px; margin-top: 8px;
@ -775,4 +850,7 @@
overflow: auto; overflow: auto;
} }
/deep/ .el-step__icon.is-text {
border: 1px solid;
}
</style> </style>

View File

@ -1,31 +1,22 @@
<template> <template>
<el-card> <el-card>
<el-row> <el-row>
<div class="el-step__icon is-text ms-api-col" style="float: left"> <div class="el-step__icon is-text ms-api-col">
<div class="el-step__icon-inner">{{controller.index}}</div> <div class="el-step__icon-inner">{{controller.index}}</div>
</div> </div>
<div> <el-button class="ms-title-buttion" size="small">{{$t('api_test.automation.if_controller')}}</el-button>
<el-row :gutter="10" type="flex" align="middle">
<el-col :span="1">If</el-col> <el-input size="small" v-model="controller.variable" style="width: 20%" :placeholder="$t('api_test.request.condition_variable')"/>
<el-col :span="6">
<el-input size="small" v-model="controller.variable" :placeholder="$t('api_test.request.condition_variable')"/>
</el-col>
<el-col :span="5">
<el-select v-model="controller.operator" :placeholder="$t('commons.please_select')" size="small" <el-select v-model="controller.operator" :placeholder="$t('commons.please_select')" size="small"
@change="change"> @change="change" style="width: 10%;margin-left: 10px">
<el-option v-for="o in operators" :key="o.value" :label="$t(o.label)" :value="o.value"/> <el-option v-for="o in operators" :key="o.value" :label="$t(o.label)" :value="o.value"/>
</el-select> </el-select>
</el-col>
<el-col :span="6"> <el-input size="small" v-model="controller.value" :placeholder="$t('api_test.value')" v-if="!hasEmptyOperator" style="width: 20%;margin-left: 20px"/>
<el-input size="small" v-model="controller.value" :placeholder="$t('api_test.value')" v-if="!hasEmptyOperator"/> <div style="margin-right: 20px; float: right">
</el-col> <el-switch v-model="controller.enable" style="margin-left: 10px"/>
<el-col :span="4"> <el-button size="mini" icon="el-icon-delete" circle @click="remove" style="margin-left: 10px;"/>
<el-switch v-model="controller.enable" :inactive-text="$t('api_test.scenario.enable_disable')"/>
</el-col>
<el-col :span="2">
<el-button size="mini" type="danger" icon="el-icon-delete" circle @click="remove"/>
</el-col>
</el-row>
</div> </div>
</el-row> </el-row>
</el-card> </el-card>
@ -102,4 +93,10 @@
margin-right: 10px; margin-right: 10px;
color: #E6A23C; color: #E6A23C;
} }
.ms-title-buttion {
background-color: #FCF6EE;
margin-right: 20px;
color: #E6A23C;
}
</style> </style>

View File

@ -6,9 +6,12 @@
<div class="el-step__icon-inner">{{jsr223ProcessorData.index}}</div> <div class="el-step__icon-inner">{{jsr223ProcessorData.index}}</div>
</div> </div>
<el-button class="ms-left-buttion" size="small" :style="styleType" style="color: #B8741A;background-color: #F9F1EA">{{title}}</el-button> <el-button class="ms-left-buttion" size="small" :style="styleType" style="color: #B8741A;background-color: #F9F1EA">{{title}}</el-button>
<el-input size="small" v-model="jsr223ProcessorData.name" :placeholder="$t('commons.input_name')" class="ms-api-header-select" style="width: 40%"/>
<div style="margin-right: 20px; float: right">
<i class="icon el-icon-arrow-right" :class="{'is-active': this.jsr223ProcessorData.active}" @click="changeActive" style="margin-left: 20px"/> <i class="icon el-icon-arrow-right" :class="{'is-active': this.jsr223ProcessorData.active}" @click="changeActive" style="margin-left: 20px"/>
<el-input size="small" v-model="jsr223ProcessorData.name" class="ms-api-header-select" style="width: 380px"/> <el-switch v-model="jsr223ProcessorData.enable" style="margin-left: 10px"/>
<el-button size="small" style="float: right" @click="remove">{{$t('commons.remove')}}</el-button> <el-button size="mini" icon="el-icon-delete" circle @click="remove" style="margin-left: 10px;"/>
</div>
</div> </div>
</el-row> </el-row>
<el-collapse-transition> <el-collapse-transition>

View File

@ -6,8 +6,17 @@
<div class="el-step__icon-inner">{{assertions.index}}</div> <div class="el-step__icon-inner">{{assertions.index}}</div>
</div> </div>
<el-button class="ms-left-buttion" size="small" style="color: #A30014;background-color: #F7E6E9">{{$t('api_test.definition.request.assertions_rule')}}</el-button> <el-button class="ms-left-buttion" size="small" style="color: #A30014;background-color: #F7E6E9">{{$t('api_test.definition.request.assertions_rule')}}</el-button>
<el-button size="small" style="float: right;margin-top: 0px" @click="remove">{{$t('commons.remove')}}</el-button>
<el-input size="small" v-model="assertions.name" style="width: 40%;margin-left: 20px" :placeholder="$t('commons.input_name')"/>
<div style="margin-right: 20px; float: right">
<i class="icon el-icon-arrow-right" :class="{'is-active': assertions.active}" @click="active(assertions)" style="margin-left: 20px"/>
<el-switch v-model="assertions.enable" style="margin-left: 10px"/>
<el-button size="mini" icon="el-icon-delete" circle @click="remove" style="margin-left: 10px;"/>
</div> </div>
</div>
<!-- 请求参数-->
<el-collapse-transition>
<div v-if="assertions.active">
<div class="assertion-add"> <div class="assertion-add">
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="4"> <el-col :span="4">
@ -38,8 +47,10 @@
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
<ms-api-assertions-edit :is-read-only="isReadOnly" :assertions="assertions" :reloadData="reloadData" style="margin-bottom: 20px"/> <ms-api-assertions-edit :is-read-only="isReadOnly" :assertions="assertions" :reloadData="reloadData" style="margin-bottom: 20px"/>
</div>
</el-collapse-transition>
</el-card> </el-card>
</div> </div>
</template> </template>
@ -111,6 +122,10 @@
this.loading = false this.loading = false
}) })
}, },
active(item) {
item.active = !item.active;
this.reload();
},
remove() { remove() {
this.$emit('remove', this.assertions, this.node); this.$emit('remove', this.assertions, this.node);
}, },
@ -142,31 +157,11 @@
border-radius: 5px; border-radius: 5px;
} }
.bg-purple-dark { .icon.is-active {
background: #99a9bf; transform: rotate(90deg);
} }
.bg-purple { /deep/ .el-card__body {
background: #d3dce6; padding: 15px;
} }
.bg-purple-light {
background: #e5e9f2;
}
.grid-content {
border-radius: 4px;
min-height: 36px;
}
.row-bg {
padding: 10px 0;
background-color: #f9fafc;
}
.json-path-suggest-button {
margin-top: 20px;
margin-left: 20px;
}
</style> </style>

View File

@ -1,12 +1,19 @@
<template> <template>
<div :style="customizeStyle"> <div :style="customizeStyle" v-loading="loading">
<el-card> <el-card>
<div class="el-step__icon is-text" style="color: #015478;background-color: #E6EEF2;margin-right: 10px" v-if="extract.index"> <div class="el-step__icon is-text" style="color: #015478;background-color: #E6EEF2;margin-right: 10px" v-if="extract.index">
<div class="el-step__icon-inner">{{extract.index}}</div> <div class="el-step__icon-inner">{{extract.index}}</div>
</div> </div>
<el-button class="ms-left-buttion" size="small" style="color: #015478;background-color: #E6EEF2">{{$t('api_test.definition.request.extract_param')}}</el-button> <el-button class="ms-left-buttion" size="small" style="color: #015478;background-color: #E6EEF2">{{$t('api_test.definition.request.extract_param')}}</el-button>
<el-button size="small" style="float: right;margin-top: 0px" @click="remove">移除</el-button> <el-input size="small" v-model="extract.name" style="width: 40%;margin-left: 20px" :placeholder="$t('commons.input_name')"/>
<div style="margin-right: 20px; float: right">
<i class="icon el-icon-arrow-right" :class="{'is-active': extract.active}" @click="active(extract)" style="margin-left: 20px"/>
<el-switch v-model="extract.enable" style="margin-left: 10px"/>
<el-button size="mini" icon="el-icon-delete" circle @click="remove" style="margin-left: 10px;"/>
</div>
<!-- 请求参数-->
<el-collapse-transition>
<div v-if="extract.active">
<div style="margin: 20px"> <div style="margin: 20px">
<div class="extract-description"> <div class="extract-description">
{{$t('api_test.request.extract.description')}} {{$t('api_test.request.extract.description')}}
@ -30,6 +37,8 @@
</div> </div>
<ms-api-extract-edit :is-read-only="isReadOnly" :reloadData="reloadData" :extract="extract"/> <ms-api-extract-edit :is-read-only="isReadOnly" :reloadData="reloadData" :extract="extract"/>
</div> </div>
</div>
</el-collapse-transition>
</el-card> </el-card>
</div> </div>
</template> </template>
@ -66,6 +75,7 @@
options: EXTRACT_TYPE, options: EXTRACT_TYPE,
type: "", type: "",
reloadData: "", reloadData: "",
loading: false,
} }
}, },
@ -77,9 +87,17 @@
remove() { remove() {
this.$emit('remove', this.extract, this.node); this.$emit('remove', this.extract, this.node);
}, },
reload() {
this.loading = true
this.$nextTick(() => {
this.loading = false
})
},
active(item) {
item.active = !item.active;
this.reload();
},
}, },
computed: { computed: {
list() { list() {
switch (this.type) { switch (this.type) {
@ -113,4 +131,12 @@
margin: 5px 0; margin: 5px 0;
border-radius: 5px; border-radius: 5px;
} }
.icon.is-active {
transform: rotate(90deg);
}
/deep/ .el-card__body {
padding: 15px;
}
</style> </style>

View File

@ -1,11 +1,12 @@
<template> <template>
<div style="border:1px #DCDFE6 solid; height: 100%;border-radius: 4px ;width: 100% ;margin-top: 20px"> <div style="margin-top: 10px">
<el-card>
<el-row> <el-row>
<div> <div>
<el-button class="ms-left-buttion" size="small" :style="styleType" style="color: #B8741A;background-color: #F9F1EA">{{title}}</el-button> <el-button class="ms-left-buttion" size="small" :style="styleType" style="color: #B8741A;background-color: #F9F1EA">{{title}}</el-button>
<i class="icon el-icon-arrow-right" :class="{'is-active': active}" @click="changeActive" style="margin-left: 20px"/> <i class="icon el-icon-arrow-right" :class="{'is-active': active}" @click="changeActive" style="margin-left: 20px"/>
<el-input size="small" v-model="jsr223ProcessorData.name" class="ms-api-header-select" style="width: 380px"/> <el-input size="small" v-model="jsr223ProcessorData.name" class="ms-api-header-select" style="width: 380px"/>
<el-button size="small" style="float: right" @click="remove">移除</el-button> <el-button size="mini" icon="el-icon-delete" circle @click="remove" style="margin-right: 20px; float: right"/>
</div> </div>
</el-row> </el-row>
<el-collapse-transition> <el-collapse-transition>
@ -37,6 +38,7 @@
</el-row> </el-row>
</div> </div>
</el-collapse-transition> </el-collapse-transition>
</el-card>
</div> </div>
</template> </template>
@ -195,4 +197,7 @@
.icon.is-active { .icon.is-active {
transform: rotate(90deg); transform: rotate(90deg);
} }
/deep/ .el-card__body {
padding: 15px;
}
</style> </style>

View File

@ -776,7 +776,7 @@ export class Assertions extends BaseConfig {
this.jsr223 = []; this.jsr223 = [];
this.xpath2 = []; this.xpath2 = [];
this.duration = undefined; this.duration = undefined;
this.enable = true;
this.set(options); this.set(options);
this.sets({text: Text, regex: Regex, jsonPath: JSONPath, jsr223: AssertionJSR223, xpath2: XPath2}, options); this.sets({text: Text, regex: Regex, jsonPath: JSONPath, jsr223: AssertionJSR223, xpath2: XPath2}, options);
} }
@ -843,6 +843,7 @@ export class JSR223Processor extends BaseConfig {
this.type = "JSR223Processor"; this.type = "JSR223Processor";
this.script = undefined; this.script = undefined;
this.language = "beanshell"; this.language = "beanshell";
this.enable = true;
this.set(options); this.set(options);
} }
} }
@ -917,7 +918,7 @@ export class Extract extends BaseConfig {
this.regex = []; this.regex = [];
this.json = []; this.json = [];
this.xpath = []; this.xpath = [];
this.enable = true;
this.set(options); this.set(options);
let types = { let types = {
json: ExtractJSONPath, json: ExtractJSONPath,

View File

@ -2,11 +2,6 @@
<ms-container> <ms-container>
<ms-aside-container> <ms-aside-container>
<select-menu
:data="projects"
:current-data="currentProject"
:title="$t('test_track.project')"
@dataChange="changeProject"/>
<node-tree <node-tree
class="node-tree" class="node-tree"
v-loading="result.loading" v-loading="result.loading"
@ -17,13 +12,13 @@
:draggable="nodeTreeDraggable" :draggable="nodeTreeDraggable"
:select-node.sync="selectNode" :select-node.sync="selectNode"
@refreshTable="refreshTable" @refreshTable="refreshTable"
:current-project="currentProject" :current-project="{id:currentProject}"
ref="nodeTree"/> ref="nodeTree"/>
</ms-aside-container> </ms-aside-container>
<ms-main-container> <ms-main-container>
<test-case-list <test-case-list
:current-project="currentProject" :current-project="{id:currentProject}"
:select-node-ids="selectNodeIds" :select-node-ids="selectNodeIds"
:select-parent-nodes="selectParentNodes" :select-parent-nodes="selectParentNodes"
@testCaseEdit="editTestCase" @testCaseEdit="editTestCase"
@ -41,7 +36,7 @@
:read-only="testCaseReadOnly" :read-only="testCaseReadOnly"
:tree-nodes="treeNodes" :tree-nodes="treeNodes"
:select-node="selectNode" :select-node="selectNode"
:current-project="currentProject" :current-project="{id:currentProject}"
ref="testCaseEditDialog"> ref="testCaseEditDialog">
</test-case-edit> </test-case-edit>
@ -57,7 +52,7 @@
import NodeTree from '../common/NodeTree'; import NodeTree from '../common/NodeTree';
import TestCaseEdit from './components/TestCaseEdit'; import TestCaseEdit from './components/TestCaseEdit';
import {CURRENT_PROJECT, ROLE_TEST_MANAGER, ROLE_TEST_USER} from '../../../../common/js/constants'; import {PROJECT_ID, ROLE_TEST_MANAGER, ROLE_TEST_USER} from '../../../../common/js/constants';
import TestCaseList from "./components/TestCaseList"; import TestCaseList from "./components/TestCaseList";
import SelectMenu from "../common/SelectMenu"; import SelectMenu from "../common/SelectMenu";
import TestCaseMove from "./components/TestCaseMove"; import TestCaseMove from "./components/TestCaseMove";
@ -90,11 +85,15 @@ export default {
nodeTreeDraggable: true, nodeTreeDraggable: true,
} }
}, },
activated() {
this.currentProject = localStorage.getItem(PROJECT_ID);
},
mounted() { mounted() {
this.init(this.$route); this.init(this.$route);
}, },
watch: { watch: {
'$route'(to, from) { '$route'(to, from) {
// console.log(this.$route.params.projectId)
this.init(to); this.init(to);
}, },
currentProject() { currentProject() {
@ -105,7 +104,7 @@ export default {
init(route) { init(route) {
let path = route.path; let path = route.path;
if (path.indexOf("/track/case/edit") >= 0 || path.indexOf("/track/case/create") >= 0) { if (path.indexOf("/track/case/edit") >= 0 || path.indexOf("/track/case/create") >= 0) {
this.getProjects(); // this.getProjects();
this.testCaseReadOnly = false; this.testCaseReadOnly = false;
if (!checkoutTestManagerOrTestUser()) { if (!checkoutTestManagerOrTestUser()) {
this.testCaseReadOnly = true; this.testCaseReadOnly = true;
@ -113,48 +112,49 @@ export default {
let caseId = this.$route.params.caseId; let caseId = this.$route.params.caseId;
this.openRecentTestCaseEditDialog(caseId); this.openRecentTestCaseEditDialog(caseId);
this.$router.push('/track/case/all'); this.$router.push('/track/case/all');
} else if (route.params.projectId) {
this.getProjects();
this.getProjectById(route.params.projectId);
} }
// else if (route.params.projectId) {
// this.getProjects();
// this.getProjectById(route.params.projectId);
// }
}, },
getProjects() { // getProjects() {
this.$get("/project/listAll", (response) => { // this.$get("/project/listAll", (response) => {
this.projects = response.data; // this.projects = response.data;
let lastProject = JSON.parse(localStorage.getItem(CURRENT_PROJECT)); // let lastProject = JSON.parse(localStorage.getItem(CURRENT_PROJECT));
if (lastProject) { // if (lastProject) {
let hasCurrentProject = false; // let hasCurrentProject = false;
for (let i = 0; i < this.projects.length; i++) { // for (let i = 0; i < this.projects.length; i++) {
if (this.projects[i].id == lastProject.id) { // if (this.projects[i].id == lastProject.id) {
this.currentProject = lastProject; // this.currentProject = lastProject;
hasCurrentProject = true; // hasCurrentProject = true;
break; // break;
} // }
} // }
if (!hasCurrentProject) { // if (!hasCurrentProject) {
this.setCurrentProject(this.projects[0]); // this.setCurrentProject(this.projects[0]);
} // }
} else { // } else {
if (this.projects.length > 0) { // if (this.projects.length > 0) {
this.setCurrentProject(this.projects[0]); // this.setCurrentProject(this.projects[0]);
} // }
} // }
// this.checkProject(); // // this.checkProject();
}); // });
}, // },
checkProject() { // checkProject() {
if (this.currentProject === null) { // if (this.currentProject === null) {
this.$alert(this.$t('test_track.case.no_project'), { // this.$alert(this.$t('test_track.case.no_project'), {
confirmButtonText: this.$t('project.create'), // confirmButtonText: this.$t('project.create'),
callback: action => { // callback: action => {
this.$router.push("/track/project/create"); // this.$router.push("/track/project/create");
} // }
}); // });
} // }
}, // },
changeProject(project) { // changeProject(project) {
this.setCurrentProject(project); // this.setCurrentProject(project);
}, // },
nodeChange(nodeIds, pNodes) { nodeChange(nodeIds, pNodes) {
this.selectNodeIds = nodeIds; this.selectNodeIds = nodeIds;
this.selectParentNodes = pNodes; this.selectParentNodes = pNodes;
@ -182,21 +182,21 @@ export default {
this.testCaseReadOnly = true; this.testCaseReadOnly = true;
this.$refs.testCaseEditDialog.open(testCase); this.$refs.testCaseEditDialog.open(testCase);
}, },
getProjectByCaseId(caseId) { // getProjectByCaseId(caseId) {
return this.$get('/test/case/project/' + caseId, async response => { // return this.$get('/test/case/project/' + caseId, async response => {
this.setCurrentProject(response.data); // this.setCurrentProject(response.data);
}); // });
}, // },
refresh() { refresh() {
this.selectNodeIds = []; this.selectNodeIds = [];
this.selectParentNodes = []; this.selectParentNodes = [];
this.selectNode = {}; this.selectNode = {};
this.$refs.testCaseList.initTableData(); this.refreshTable();
this.getNodeTree(); this.getNodeTree();
}, },
openRecentTestCaseEditDialog(caseId) { openRecentTestCaseEditDialog(caseId) {
if (caseId) { if (caseId) {
this.getProjectByCaseId(caseId); // this.getProjectByCaseId(caseId);
this.$get('/test/case/get/' + caseId, response => { this.$get('/test/case/get/' + caseId, response => {
if (response.data) { if (response.data) {
this.$refs.testCaseEditDialog.open(response.data); this.$refs.testCaseEditDialog.open(response.data);
@ -206,31 +206,31 @@ export default {
this.$refs.testCaseEditDialog.open(); this.$refs.testCaseEditDialog.open();
} }
}, },
getProjectById(id) { // getProjectById(id) {
if (id && id != 'all') { // if (id && id != 'all') {
this.$get('/project/get/' + id, response => { // this.$get('/project/get/' + id, response => {
let project = response.data; // let project = response.data;
this.setCurrentProject(project); // this.setCurrentProject(project);
// this.$router.push('/track/case/all'); // // this.$router.push('/track/case/all');
}); // });
} // }
if (id === 'all') { // if (id === 'all') {
this.refresh(); // this.refresh();
} // }
}, // },
setCurrentProject(project) { // setCurrentProject(project) {
if (project) { // if (project) {
this.currentProject = project; // this.currentProject = project;
localStorage.setItem(CURRENT_PROJECT, JSON.stringify(project)); // localStorage.setItem(CURRENT_PROJECT, JSON.stringify(project));
} // }
this.refresh(); // this.refresh();
}, // },
getNodeTree() { getNodeTree() {
if (!hasRoles(ROLE_TEST_USER, ROLE_TEST_MANAGER)) { if (!hasRoles(ROLE_TEST_USER, ROLE_TEST_MANAGER)) {
this.nodeTreeDraggable = false; this.nodeTreeDraggable = false;
} }
if (this.currentProject) { if (this.currentProject) {
this.result = this.$get("/case/node/list/" + this.currentProject.id, response => { this.result = this.$get("/case/node/list/" + this.currentProject, response => {
this.treeNodes = response.data; this.treeNodes = response.data;
}); });
} }

View File

@ -489,7 +489,7 @@ export default {
param.nodePath = item.path; param.nodePath = item.path;
} }
}); });
if (this.currentProject) { if (this.currentProject.id) {
param.projectId = this.currentProject.id; param.projectId = this.currentProject.id;
} }
param.name = param.name.trim(); param.name = param.name.trim();
@ -563,7 +563,7 @@ export default {
}, },
getTestOptions() { getTestOptions() {
this.testOptions = []; this.testOptions = [];
if (this.currentProject && this.form.type != '' && this.form.type != 'functional') { if (this.currentProject.id && this.form.type != '' && this.form.type != 'functional') {
this.result = this.$get('/' + this.form.type + '/list/' + this.currentProject.id, response => { this.result = this.$get('/' + this.form.type + '/list/' + this.currentProject.id, response => {
this.testOptions = response.data; this.testOptions = response.data;
this.testOptions.unshift({id: 'other', name: this.$t('test_track.case.other')}) this.testOptions.unshift({id: 'other', name: this.$t('test_track.case.other')})

View File

@ -302,7 +302,9 @@ export default {
// param.nodeIds = this.selectNodeIds; // param.nodeIds = this.selectNodeIds;
this.condition.nodeIds = this.selectNodeIds; this.condition.nodeIds = this.selectNodeIds;
} }
if (this.currentProject.id) {
this.getData(); this.getData();
}
}, },
getData() { getData() {
if (this.currentProject) { if (this.currentProject) {

View File

@ -135,14 +135,14 @@ export default {
}, },
init() { init() {
let path = this.$route.path; let path = this.$route.path;
if (path.indexOf("/track/case") >= 0 && !!this.$route.params.projectId) { // if (path.indexOf("/track/case") >= 0 && !!this.$route.params.projectId) {
this.testCaseProjectPath = path; // this.testCaseProjectPath = path;
// // //
this.isProjectActivation = false; // this.isProjectActivation = false;
this.reload(); // this.reload();
} else { // } else {
this.isProjectActivation = true; // this.isProjectActivation = true;
} // }
if (path.indexOf("/track/plan/view") >= 0) { if (path.indexOf("/track/plan/view") >= 0) {
this.testPlanViewPath = path; this.testPlanViewPath = path;
this.reload(); this.reload();
@ -151,6 +151,10 @@ export default {
this.testCaseEditPath = path; this.testCaseEditPath = path;
this.reload(); this.reload();
} }
if (path.indexOf("/track/review/view") >= 0) {
this.testCaseReviewEditPath = path;
this.reload();
}
}, },
registerEvents() { registerEvents() {
TrackEvent.$on(LIST_CHANGE, () => { TrackEvent.$on(LIST_CHANGE, () => {

View File

@ -1,4 +1,3 @@
import MsProject from "@/business/components/settings/project/MsProject";
const TestTrack = () => import('@/business/components/track/TestTrack') const TestTrack = () => import('@/business/components/track/TestTrack')
const TrackHome = () => import('@/business/components/track/home/TrackHome') const TrackHome = () => import('@/business/components/track/home/TrackHome')

@ -1 +1 @@
Subproject commit 8a972a198775b3783ed6e4cef27197e53d1ebdc8 Subproject commit a22a3005d9bd254793fcf634d72539cbdf31be3a