feat: 测试用例关联多个测试

This commit is contained in:
wenyann 2021-03-21 19:43:15 +08:00
parent b0a1fbe6dd
commit c96928384e
12 changed files with 1033 additions and 223 deletions

View File

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

View File

@ -0,0 +1,480 @@
package io.metersphere.base.domain;
import java.util.ArrayList;
import java.util.List;
public class TestCaseTestExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public TestCaseTestExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(String value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(String value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(String value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(String value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(String value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(String value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdLike(String value) {
addCriterion("id like", value, "id");
return (Criteria) this;
}
public Criteria andIdNotLike(String value) {
addCriterion("id not like", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<String> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<String> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(String value1, String value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(String value1, String value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andTestCaseIdIsNull() {
addCriterion("test_case_id is null");
return (Criteria) this;
}
public Criteria andTestCaseIdIsNotNull() {
addCriterion("test_case_id is not null");
return (Criteria) this;
}
public Criteria andTestCaseIdEqualTo(String value) {
addCriterion("test_case_id =", value, "testCaseId");
return (Criteria) this;
}
public Criteria andTestCaseIdNotEqualTo(String value) {
addCriterion("test_case_id <>", value, "testCaseId");
return (Criteria) this;
}
public Criteria andTestCaseIdGreaterThan(String value) {
addCriterion("test_case_id >", value, "testCaseId");
return (Criteria) this;
}
public Criteria andTestCaseIdGreaterThanOrEqualTo(String value) {
addCriterion("test_case_id >=", value, "testCaseId");
return (Criteria) this;
}
public Criteria andTestCaseIdLessThan(String value) {
addCriterion("test_case_id <", value, "testCaseId");
return (Criteria) this;
}
public Criteria andTestCaseIdLessThanOrEqualTo(String value) {
addCriterion("test_case_id <=", value, "testCaseId");
return (Criteria) this;
}
public Criteria andTestCaseIdLike(String value) {
addCriterion("test_case_id like", value, "testCaseId");
return (Criteria) this;
}
public Criteria andTestCaseIdNotLike(String value) {
addCriterion("test_case_id not like", value, "testCaseId");
return (Criteria) this;
}
public Criteria andTestCaseIdIn(List<String> values) {
addCriterion("test_case_id in", values, "testCaseId");
return (Criteria) this;
}
public Criteria andTestCaseIdNotIn(List<String> values) {
addCriterion("test_case_id not in", values, "testCaseId");
return (Criteria) this;
}
public Criteria andTestCaseIdBetween(String value1, String value2) {
addCriterion("test_case_id between", value1, value2, "testCaseId");
return (Criteria) this;
}
public Criteria andTestCaseIdNotBetween(String value1, String value2) {
addCriterion("test_case_id not between", value1, value2, "testCaseId");
return (Criteria) this;
}
public Criteria andTestIdIsNull() {
addCriterion("test_id is null");
return (Criteria) this;
}
public Criteria andTestIdIsNotNull() {
addCriterion("test_id is not null");
return (Criteria) this;
}
public Criteria andTestIdEqualTo(String value) {
addCriterion("test_id =", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdNotEqualTo(String value) {
addCriterion("test_id <>", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdGreaterThan(String value) {
addCriterion("test_id >", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdGreaterThanOrEqualTo(String value) {
addCriterion("test_id >=", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdLessThan(String value) {
addCriterion("test_id <", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdLessThanOrEqualTo(String value) {
addCriterion("test_id <=", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdLike(String value) {
addCriterion("test_id like", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdNotLike(String value) {
addCriterion("test_id not like", value, "testId");
return (Criteria) this;
}
public Criteria andTestIdIn(List<String> values) {
addCriterion("test_id in", values, "testId");
return (Criteria) this;
}
public Criteria andTestIdNotIn(List<String> values) {
addCriterion("test_id not in", values, "testId");
return (Criteria) this;
}
public Criteria andTestIdBetween(String value1, String value2) {
addCriterion("test_id between", value1, value2, "testId");
return (Criteria) this;
}
public Criteria andTestIdNotBetween(String value1, String value2) {
addCriterion("test_id not between", value1, value2, "testId");
return (Criteria) this;
}
public Criteria andTestTypeIsNull() {
addCriterion("test_type is null");
return (Criteria) this;
}
public Criteria andTestTypeIsNotNull() {
addCriterion("test_type is not null");
return (Criteria) this;
}
public Criteria andTestTypeEqualTo(String value) {
addCriterion("test_type =", value, "testType");
return (Criteria) this;
}
public Criteria andTestTypeNotEqualTo(String value) {
addCriterion("test_type <>", value, "testType");
return (Criteria) this;
}
public Criteria andTestTypeGreaterThan(String value) {
addCriterion("test_type >", value, "testType");
return (Criteria) this;
}
public Criteria andTestTypeGreaterThanOrEqualTo(String value) {
addCriterion("test_type >=", value, "testType");
return (Criteria) this;
}
public Criteria andTestTypeLessThan(String value) {
addCriterion("test_type <", value, "testType");
return (Criteria) this;
}
public Criteria andTestTypeLessThanOrEqualTo(String value) {
addCriterion("test_type <=", value, "testType");
return (Criteria) this;
}
public Criteria andTestTypeLike(String value) {
addCriterion("test_type like", value, "testType");
return (Criteria) this;
}
public Criteria andTestTypeNotLike(String value) {
addCriterion("test_type not like", value, "testType");
return (Criteria) this;
}
public Criteria andTestTypeIn(List<String> values) {
addCriterion("test_type in", values, "testType");
return (Criteria) this;
}
public Criteria andTestTypeNotIn(List<String> values) {
addCriterion("test_type not in", values, "testType");
return (Criteria) this;
}
public Criteria andTestTypeBetween(String value1, String value2) {
addCriterion("test_type between", value1, value2, "testType");
return (Criteria) this;
}
public Criteria andTestTypeNotBetween(String value1, String value2) {
addCriterion("test_type not between", value1, value2, "testType");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

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

View File

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

View File

@ -30,6 +30,7 @@ import io.metersphere.track.request.testcase.QueryTestCaseRequest;
import io.metersphere.track.request.testcase.TestCaseBatchRequest;
import io.metersphere.track.request.testcase.TestCaseMinderEditRequest;
import io.metersphere.xmind.XmindCaseParser;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.ExecutorType;
@ -37,7 +38,6 @@ import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
@ -88,6 +88,8 @@ public class TestCaseService {
FileService fileService;
@Resource
TestCaseFileMapper testCaseFileMapper;
@Resource
TestCaseTestMapper testCaseTestMapper;
public TestCaseWithBLOBs addTestCase(TestCaseWithBLOBs testCase) {
testCase.setName(testCase.getName());
@ -181,6 +183,9 @@ public class TestCaseService {
testPlanTestCaseMapper.deleteByExample(example);
testCaseIssueService.delTestCaseIssues(testCaseId);
testCaseCommentService.deleteCaseComment(testCaseId);
TestCaseTestExample examples = new TestCaseTestExample();
examples.createCriteria().andTestCaseIdEqualTo(testCaseId);
testCaseTestMapper.deleteByExample(examples);
return testCaseMapper.deleteByPrimaryKey(testCaseId);
}
@ -652,7 +657,18 @@ public class TestCaseService {
}
final TestCaseWithBLOBs testCaseWithBLOBs = addTestCase(request);
//插入测试与用例关系表
if (!CollectionUtils.isEmpty(request.getSelected())) {
List<List<String>> selecteds = request.getSelected();
TestCaseTest test = new TestCaseTest();
selecteds.forEach(id -> {
test.setTestType(id.get(0));
test.setTestId(id.get(1));
test.setId(UUID.randomUUID().toString());
test.setTestCaseId(request.getId());
testCaseTestMapper.insert(test);
});
}
// 复制用例时传入文件ID进行复制
if (!CollectionUtils.isEmpty(request.getFileIds())) {
List<String> fileIds = request.getFileIds();
@ -665,6 +681,7 @@ public class TestCaseService {
});
}
files.forEach(file -> {
final FileMetadata fileMetadata = fileService.saveFile(file, testCaseWithBLOBs.getProjectId());
TestCaseFile testCaseFile = new TestCaseFile();
@ -680,7 +697,21 @@ public class TestCaseService {
if (testCaseWithBLOBs == null) {
MSException.throwException(Translator.get("edit_load_test_not_found") + request.getId());
}
//插入测试与用例关系表
if (!CollectionUtils.isEmpty(request.getSelected())) {
TestCaseTestExample example = new TestCaseTestExample();
example.createCriteria().andTestCaseIdEqualTo(request.getId());
testCaseTestMapper.deleteByExample(example);
List<List<String>> selecteds = request.getSelected();
TestCaseTest test = new TestCaseTest();
selecteds.forEach(id -> {
test.setTestType(id.get(0));
test.setTestId(id.get(1));
test.setId(UUID.randomUUID().toString());
test.setTestCaseId(request.getId());
testCaseTestMapper.insert(test);
});
}
// 新选择了一个文件删除原来的文件
List<FileMetadata> updatedFiles = request.getUpdatedFileList();
List<FileMetadata> originFiles = fileService.getFileMetadataByCaseId(request.getId());

View File

@ -169,11 +169,25 @@ CREATE TABLE IF NOT EXISTS `esb_api_params`
response_data_struct LONGTEXT null,
backed_script LONGTEXT null,
primary key (id),
UNIQUE KEY `resource_id` ( `resource_id` )
UNIQUE KEY `resource_id` (`resource_id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
-- add execution_times testPlan
alter table test_plan
add execution_times int null;
alter table test_case modify method varchar(15) null comment 'Test case method type';
alter table test_case
modify method varchar(15) null comment 'Test case method type';
-- add test_case_test
create table test_case_test
(
id varchar(70) null,
test_case_id varchar(70) null,
test_id varchar(70) null,
test_type varchar(70) null,
constraint test_case_test_pk
primary key (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
alter table test_case
modify test_id varchar(2000) null;

View File

@ -76,6 +76,7 @@
<table tableName="test_case_review_load"/>
<table tableName="test_case_review_scenario"/>
<table tableName="test_plan"/>
<table tableName="test_case_test"/>
</context>
</generatorConfiguration>

View File

@ -71,6 +71,12 @@ export const API_STATUS = [
{id: 'Underway', label: '进行中'},
{id: 'Completed', label: '已完成'}
]
export const TEST = [
{id: 'performance', name: '性能测试'},
{id: 'api', name: '接口测试'},
{id: 'testcase', name: '测试用例'},
{id: 'automation', name: '场景测试'}
]
export const API_METHOD_COLOUR = [
['GET', "#61AFFE"], ['POST', '#49CC90'], ['PUT', '#fca130'],

View File

@ -197,6 +197,7 @@ export default {
}
},
addTab(tab) {
this.projectId=getCurrentProjectID();
if (!this.projectId) {
this.$warning(this.$t('commons.check_project_tip'));
return;
@ -257,6 +258,7 @@ export default {
this.testCaseReadOnly = true;
}
let caseId = this.$route.params.caseId;
this.projectId=getCurrentProjectID();
if (!this.projectId) {
this.$warning(this.$t('commons.check_project_tip'));
return;

View File

@ -98,38 +98,16 @@
</el-select>
</el-form-item>
</el-col>
<el-col :span="7">
<el-form-item :label="$t('test_track.case.type')" :label-width="formLabelWidth" prop="type">
<el-select @change="typeChange" :disabled="readOnly" v-model="form.type"
:placeholder="$t('test_track.case.input_type')" class="ms-case-input">
<el-option :label="$t('commons.performance')" value="performance"></el-option>
<el-option :label="$t('commons.api')" value="api"></el-option>
<el-option :label="$t('api_test.home_page.failed_case_list.table_value.case_type.api')"
value="testcase"></el-option>
<el-option :label="$t('api_test.home_page.failed_case_list.table_value.case_type.scene')"
value="automation"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="7">
<el-form-item :label="$t('test_track.case.relate_test')" :label-width="formLabelWidth" prop="testId">
<el-select filterable :disabled="readOnly" v-model="form.testId"
:placeholder="$t('test_track.case.input_type')" class="ms-case-input">
<el-option
v-for="item in testOptions"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
<el-cascader show-all-levels v-model="form.selected" :props="props" ></el-cascader>
</el-form-item>
</el-col>
<el-col :span="7" v-if="form.testId=='other'">
<!-- <el-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-col>-->
</el-row>
@ -146,6 +124,7 @@
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="10">
<el-form-item label="需求名称" :label-width="formLabelWidth" prop="demandName" v-if="form.demandId=='other'">
@ -310,7 +289,6 @@
</template>
<script>
import {TokenKey, WORKSPACE_ID} from '@/common/js/constants';
import MsDialogFooter from '../../../common/components/MsDialogFooter'
import {getCurrentUser, listenGoBack, removeGoBackListener} from "@/common/js/utils";
@ -325,16 +303,59 @@ import MsPreviousNextButton from "../../../common/components/MsPreviousNextButto
import {ELEMENTS} from "@/business/components/api/automation/scenario/Setting";
import TestCaseComment from "@/business/components/track/case/components/TestCaseComment";
import ReviewCommentItem from "@/business/components/track/review/commom/ReviewCommentItem";
import {API_STATUS, REVIEW_STATUS} from "@/business/components/api/definition/model/JsonData";
import {API_STATUS, REVIEW_STATUS, TEST} from "@/business/components/api/definition/model/JsonData";
export default {
name: "TestCaseEdit",
components: {
ReviewCommentItem,
TestCaseComment, MsPreviousNextButton, MsInputTag, CaseComment, MsDialogFooter, TestCaseAttachment
},
data() {
return {
props: {
multiple: true,
lazy: true,
lazyLoad: ((node, resolve) => {
const { level } = node;
if(node.level==0){
const nodes = TEST
.map(item => ({
value: item.id,
label: item.name,
leaf: level >= 1
}));
resolve(nodes)
}
if(node.level==1){
this.projectId = getCurrentProjectID()
this.testOptions = [];
let url = '';
this.form.type=node.data.value
console.log(this.form.type)
if (this.form.type === 'testcase' || this.form.type === 'automation') {
url = '/api/' + this.form.type + '/list/' + this.projectId
} else if (this.form.type === 'performance' || this.form.type === 'api') {
url = '/' + this.form.type + '/list/' + this.projectId
}
if (this.projectId && this.form.type != '' && this.form.type != 'undefined') {
this.$get(url, response => {
response.data.unshift({id: 'other', name: this.$t('test_track.case.other')})
const nodes = response.data
.map(item => ({
value: item.id,
label: item.name,
leaf: level >= 1
}));
resolve(nodes)
});
}
}
}),
},
options: REVIEW_STATUS,
statuOptions:API_STATUS,
comments: [],
@ -356,6 +377,7 @@ export default {
desc: '',
result: ''
}],
selected:[],
remark: '',
tags: [],
demandId: '',
@ -433,6 +455,7 @@ export default {
}
},
methods: {
handleCommand(e) {
if (e === "ADD_AND_CREATE") {
this.$refs['caseFrom'].validate((valid) => {
@ -548,6 +571,7 @@ export default {
},
setFormData(testCase) {
testCase.tags = JSON.parse(testCase.tags);
testCase.selected = JSON.parse(testCase.testId);
let tmp = {};
Object.assign(tmp, testCase);
tmp.steps = JSON.parse(testCase.steps);
@ -555,8 +579,8 @@ export default {
tmp.steps = []
}
Object.assign(this.form, tmp);
this.form.module = testCase.nodeId;
this.form.testId=testCase.testId
this.getFileMetaData(testCase);
},
setTestCaseExtInfo(testCase) {
@ -662,8 +686,8 @@ export default {
},
buildParam() {
let param = {};
Object.assign(param, this.form);
console.log(this.form)
param.steps = JSON.stringify(this.form.steps);
param.nodeId = this.form.module;
this.moduleOptions.forEach(item => {
@ -679,6 +703,7 @@ export default {
if (this.form.tags instanceof Array) {
this.form.tags = JSON.stringify(this.form.tags);
}
param.testId=JSON.stringify(this.form.selected)
param.tags = this.form.tags;
return param;
},
@ -749,7 +774,8 @@ export default {
this.maintainerOptions = response.data;
});
},
getTestOptions() {
getTestOptions(val) {
console.log(val)
this.projectId = getCurrentProjectID()
this.testOptions = [];
let url = '';