This commit is contained in:
chenjianxing 2021-01-11 18:14:48 +08:00
commit 5781cc7b1e
27 changed files with 1917 additions and 1498 deletions

View File

@ -24,6 +24,7 @@ public class ApiTestCaseRequest {
private List<String> moduleIds; private List<String> moduleIds;
private List<OrderRequest> orders; private List<OrderRequest> orders;
private Map<String, List<String>> filters; private Map<String, List<String>> filters;
private Map<String, Object> combine;
private boolean isSelectThisWeedData; private boolean isSelectThisWeedData;
private long createTime = 0; private long createTime = 0;
} }

View File

@ -42,11 +42,13 @@ public class Body {
return true; return true;
} else return false; } else return false;
} }
public boolean isOldKV() { public boolean isOldKV() {
if (StringUtils.equals(type, KV)) { if (StringUtils.equals(type, KV)) {
return true; return true;
} else return false; } else return false;
} }
public List<KeyValue> getBodyParams(HTTPSamplerProxy sampler, String requestId) { public List<KeyValue> getBodyParams(HTTPSamplerProxy sampler, String requestId) {
List<KeyValue> body = new ArrayList<>(); List<KeyValue> body = new ArrayList<>();
if (this.isKV() || this.isBinary()) { if (this.isKV() || this.isBinary()) {
@ -65,7 +67,7 @@ public class Body {
this.raw = JSONSchemaGenerator.getJson(com.alibaba.fastjson.JSON.toJSONString(this.getJsonSchema())); this.raw = JSONSchemaGenerator.getJson(com.alibaba.fastjson.JSON.toJSONString(this.getJsonSchema()));
} }
} }
KeyValue keyValue = new KeyValue("", this.getRaw()); KeyValue keyValue = new KeyValue("", "JSON-SCHEMA", this.getRaw(), true, true);
keyValue.setEnable(true); keyValue.setEnable(true);
keyValue.setEncode(false); keyValue.setEncode(false);
body.add(keyValue); body.add(keyValue);

View File

@ -31,6 +31,14 @@ public class KeyValue {
this(name, value, description, null); this(name, value, description, null);
} }
public KeyValue(String name, String type, String value, boolean required, boolean enable) {
this.name = name;
this.type = type;
this.value = value;
this.required = required;
this.enable = enable;
}
public KeyValue(String name, String value, String description, String contentType) { public KeyValue(String name, String value, String description, String contentType) {
this(name, value, description, contentType, true); this(name, value, description, contentType, true);
} }
@ -49,7 +57,7 @@ public class KeyValue {
} }
public boolean isValid() { public boolean isValid() {
return (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(value)) && !StringUtils.equalsIgnoreCase(type, "file"); return ((StringUtils.isNotBlank(name) && StringUtils.isNotBlank(value)) || "JSON-SCHEMA".equals(type)) && !StringUtils.equalsIgnoreCase(type, "file");
} }
public boolean isFile() { public boolean isFile() {

View File

@ -147,6 +147,25 @@
<property name="object" value="${condition}.creator"/> <property name="object" value="${condition}.creator"/>
</include> </include>
</if> </if>
<if test="${condition}.path != null">
and api_definition.path
<include refid="condition">
<property name="object" value="${condition}.path"/>
</include>
</if>
<if test="${condition}.method != null">
and api_definition.method
<include refid="condition">
<property name="object" value="${condition}.method"/>
</include>
</if>
<if test="${condition}.tags != null">
and api_definition.tags
<include refid="condition">
<property name="object" value="${condition}.tags"/>
</include>
</if>
</sql> </sql>
<sql id="condition"> <sql id="condition">

View File

@ -7,7 +7,94 @@
<result column="project_name" property="projectName"/> <result column="project_name" property="projectName"/>
<result column="user_name" property="userName"/> <result column="user_name" property="userName"/>
</resultMap> </resultMap>
<sql id="condition">
<choose>
<when test='${object}.operator == "like"'>
like CONCAT('%', #{${object}.value},'%')
</when>
<when test='${object}.operator == "not like"'>
not like CONCAT('%', #{${object}.value},'%')
</when>
<when test='${object}.operator == "in"'>
in
<foreach collection="${object}.value" item="v" separator="," open="(" close=")">
#{v}
</foreach>
</when>
<when test='${object}.operator == "not in"'>
not in
<foreach collection="${object}.value" item="v" separator="," open="(" close=")">
#{v}
</foreach>
</when>
<when test='${object}.operator == "between"'>
between #{${object}.value[0]} and #{${object}.value[1]}
</when>
<when test='${object}.operator == "gt"'>
&gt; #{${object}.value}
</when>
<when test='${object}.operator == "lt"'>
&lt; #{${object}.value}
</when>
<when test='${object}.operator == "ge"'>
&gt;= #{${object}.value}
</when>
<when test='${object}.operator == "le"'>
&lt;= #{${object}.value}
</when>
<when test='${object}.operator == "current user"'>
= '${@io.metersphere.commons.utils.SessionUtils@getUserId()}'
</when>
<otherwise>
= #{${object}.value}
</otherwise>
</choose>
</sql>
<sql id="combine">
<if test='${condition}.name != null and (${name} == null or ${name} == "")'>
and api_scenario.name
<include refid="condition">
<property name="object" value="${condition}.name"/>
</include>
</if>
<if test="${condition}.updateTime != null">
and api_scenario.update_time
<include refid="condition">
<property name="object" value="${condition}.updateTime"/>
</include>
</if>
<if test="${condition}.createTime != null">
and api_scenario.create_time
<include refid="condition">
<property name="object" value="${condition}.createTime"/>
</include>
</if>
<if test="${condition}.priority != null">
and api_scenario.level
<include refid="condition">
<property name="object" value="${condition}.priority"/>
</include>
</if>
<if test="${condition}.creator != null">
and api_scenario.user_id
<include refid="condition">
<property name="object" value="${condition}.creator"/>
</include>
</if>
<if test="${condition}.tags != null">
and api_scenario.tags
<include refid="condition">
<property name="object" value="${condition}.tags"/>
</include>
</if>
<if test="${condition}.status != null">
and api_scenario.last_result
<include refid="condition">
<property name="object" value="${condition}.status"/>
</include>
</if>
</sql>
<select id="list" resultMap="BaseResultMap"> <select id="list" resultMap="BaseResultMap">
select api_scenario.id, api_scenario.project_id, api_scenario.tags, api_scenario.user_id, api_scenario.num, select api_scenario.id, api_scenario.project_id, api_scenario.tags, api_scenario.user_id, api_scenario.num,
api_scenario.api_scenario_module_id,api_scenario.module_path, api_scenario.name, api_scenario.level, api_scenario.api_scenario_module_id,api_scenario.module_path, api_scenario.name, api_scenario.level,
@ -19,6 +106,13 @@
left join project on api_scenario.project_id = project.id left join project on api_scenario.project_id = project.id
left join user on api_scenario.user_id = user.id left join user on api_scenario.user_id = user.id
<where> <where>
<if test="request.combine != null">
<include refid="combine">
<property name="condition" value="request.combine"/>
<property name="name" value="request.name"/>
</include>
</if>
<if test="request.name != null"> <if test="request.name != null">
and api_scenario.name like CONCAT('%', #{request.name},'%') and api_scenario.name like CONCAT('%', #{request.name},'%')
</if> </if>

View File

@ -144,7 +144,51 @@
</otherwise> </otherwise>
</choose> </choose>
</sql> </sql>
<sql id="combine">
<if test='${condition}.name != null and (${name} == null or ${name} == "")'>
and atc.name
<include refid="condition">
<property name="object" value="${condition}.name"/>
</include>
</if>
<if test="${condition}.updateTime != null">
and atc.update_time
<include refid="condition">
<property name="object" value="${condition}.updateTime"/>
</include>
</if>
<if test="${condition}.createTime != null">
and atc.create_time
<include refid="condition">
<property name="object" value="${condition}.createTime"/>
</include>
</if>
<if test="${condition}.priority != null">
and atc.priority
<include refid="condition">
<property name="object" value="${condition}.priority"/>
</include>
</if>
<if test="${condition}.creator != null">
and atc.user_id
<include refid="condition">
<property name="object" value="${condition}.creator"/>
</include>
</if>
<if test="${condition}.tags != null">
and atc.tags
<include refid="condition">
<property name="object" value="${condition}.tags"/>
</include>
</if>
<if test="${condition}.status != null">
and ader.status
<include refid="condition">
<property name="object" value="${condition}.status"/>
</include>
</if>
</sql>
<select id="list" resultType="io.metersphere.api.dto.definition.ApiTestCaseResult"> <select id="list" resultType="io.metersphere.api.dto.definition.ApiTestCaseResult">
select select
atc.id, atc.id,
@ -180,6 +224,13 @@
resource_id) as ader resource_id) as ader
on atc.id = ader.resource_id on atc.id = ader.resource_id
<where> <where>
<if test="request.combine != null">
<include refid="combine">
<property name="condition" value="request.combine"/>
<property name="name" value="request.name"/>
</include>
</if>
<if test="request.name != null and request.name!=''"> <if test="request.name != null and request.name!=''">
and atc.name like CONCAT('%', #{request.name},'%') and atc.name like CONCAT('%', #{request.name},'%')
</if> </if>
@ -196,18 +247,26 @@
AND atc.api_definition_id = #{request.apiDefinitionId} AND atc.api_definition_id = #{request.apiDefinitionId}
</if> </if>
</where> </where>
<if test="request.orders != null and request.orders.size() > 0">
order by
<foreach collection="request.orders" separator="," item="order">
atc.${order.name} ${order.type}
</foreach>
</if>
</select> </select>
<select id="listSimple" resultType="io.metersphere.api.dto.definition.ApiTestCaseDTO"> <select id="listSimple" resultType="io.metersphere.api.dto.definition.ApiTestCaseDTO">
select select
c.id, c.project_id, c.name, c.api_definition_id, c.priority, c.description, c.create_user_id, c.update_user_id, c.create_time, c.update_time, c.num, atc.id, atc.project_id, atc.name, atc.api_definition_id, atc.priority, atc.description, atc.create_user_id, atc.update_user_id, atc.create_time, atc.update_time, atc.num,
a.module_id, a.path, a.protocol a.module_id, a.path, a.protocol
from from
api_test_case c api_test_case atc
inner join inner join
api_definition a api_definition a
on on
c.api_definition_id = a.id atc.api_definition_id = a.id
<if test="request.protocol != null and request.protocol!=''"> <if test="request.protocol != null and request.protocol!=''">
and a.protocol = #{request.protocol} and a.protocol = #{request.protocol}
</if> </if>
@ -219,48 +278,55 @@
and a.status != 'Trash' and a.status != 'Trash'
</otherwise> </otherwise>
</choose> </choose>
where <where>
<if test="request.projectId != null and request.projectId!=''"> <if test="request.combine != null">
c.project_id = #{request.projectId} <include refid="combine">
</if> <property name="condition" value="request.combine"/>
<if test="request.id != null and request.id!=''"> <property name="name" value="request.name"/>
and c.id = #{request.id} </include>
</if>
<if test="request.ids != null and request.ids.size() > 0">
<if test="request.projectId != null and request.projectId!=''">
and
</if> </if>
c.id in <if test="request.projectId != null and request.projectId!=''">
<foreach collection="request.ids" item="caseId" separator="," open="(" close=")"> and atc.project_id = #{request.projectId}
#{caseId} </if>
</foreach> <if test="request.id != null and request.id!=''">
</if> and atc.id = #{request.id}
<if test="request.name != null and request.name!=''"> </if>
and c.name like CONCAT('%', #{request.name},'%') <if test="request.ids != null and request.ids.size() > 0">
</if> <if test="request.projectId != null and request.projectId!=''">
<if test="request.createTime > 0"> and
and c.create_time >= #{request.createTime}
</if>
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
and a.module_id in
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
#{nodeId}
</foreach>
</if>
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
<choose>
<when test="key == 'priority'">
and c.priority in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
</choose>
</if> </if>
</foreach> atc.id in
</if> <foreach collection="request.ids" item="caseId" separator="," open="(" close=")">
#{caseId}
</foreach>
</if>
<if test="request.name != null and request.name!=''">
and atc.name like CONCAT('%', #{request.name},'%')
</if>
<if test="request.createTime > 0">
and atc.create_time >= #{request.createTime}
</if>
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
and a.module_id in
<foreach collection="request.moduleIds" item="nodeId" separator="," open="(" close=")">
#{nodeId}
</foreach>
</if>
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
<choose>
<when test="key == 'priority'">
and atc.priority in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
</choose>
</if>
</foreach>
</if>
</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
<foreach collection="request.orders" separator="," item="order"> <foreach collection="request.orders" separator="," item="order">

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?> <?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" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="io.metersphere.base.mapper.ext.ExtLoadTestMapper"> <mapper namespace="io.metersphere.base.mapper.ext.ExtLoadTestMapper">
<resultMap id="BaseResultMap" type="io.metersphere.dto.LoadTestDTO" <resultMap id="BaseResultMap" type="io.metersphere.dto.LoadTestDTO"
extends="io.metersphere.base.mapper.LoadTestMapper.BaseResultMap"> extends="io.metersphere.base.mapper.LoadTestMapper.BaseResultMap">
<result column="project_name" property="projectName"/> <result column="project_name" property="projectName"/>
@ -14,37 +13,37 @@
<sql id="combine"> <sql id="combine">
<if test='${condition}.name != null and (${name} == null or ${name} == "")'> <if test='${condition}.name != null and (${name} == null or ${name} == "")'>
and load_test.name AND load_test.name
<include refid="condition"> <include refid="condition">
<property name="object" value="${condition}.name"/> <property name="object" value="${condition}.name"/>
</include> </include>
</if> </if>
<if test="${condition}.updateTime != null"> <if test="${condition}.updateTime != null">
and load_test.update_time AND load_test.update_time
<include refid="condition"> <include refid="condition">
<property name="object" value="${condition}.updateTime"/> <property name="object" value="${condition}.updateTime"/>
</include> </include>
</if> </if>
<if test="${condition}.projectName != null"> <if test="${condition}.projectName != null">
and project.name AND project.name
<include refid="condition"> <include refid="condition">
<property name="object" value="${condition}.projectName"/> <property name="object" value="${condition}.projectName"/>
</include> </include>
</if> </if>
<if test="${condition}.createTime != null"> <if test="${condition}.createTime != null">
and load_test.create_time AND load_test.create_time
<include refid="condition"> <include refid="condition">
<property name="object" value="${condition}.createTime"/> <property name="object" value="${condition}.createTime"/>
</include> </include>
</if> </if>
<if test="${condition}.status != null"> <if test="${condition}.status != null">
and load_test.status AND load_test.status
<include refid="condition"> <include refid="condition">
<property name="object" value="${condition}.status"/> <property name="object" value="${condition}.status"/>
</include> </include>
</if> </if>
<if test="${condition}.creator != null"> <if test="${condition}.creator != null">
and load_test.user_id AND load_test.user_id
<include refid="condition"> <include refid="condition">
<property name="object" value="${condition}.creator"/> <property name="object" value="${condition}.creator"/>
</include> </include>
@ -53,10 +52,10 @@
<select id="list" resultMap="BaseResultMap" <select id="list" resultMap="BaseResultMap"
parameterType="io.metersphere.track.request.testplan.QueryTestPlanRequest"> parameterType="io.metersphere.track.request.testplan.QueryTestPlanRequest">
select load_test.*, project.name as project_name, user.name as user_name SELECT load_test.*, project.name AS project_name, user.name AS user_name
from load_test FROM load_test
left join project on load_test.project_id = project.id LEFT JOIN project ON load_test.project_id = project.id
left join user on load_test.user_id = user.id LEFT JOIN user ON load_test.user_id = user.id
<where> <where>
<if test="request.combine != null"> <if test="request.combine != null">
<include refid="combine"> <include refid="combine">
@ -65,10 +64,10 @@
</include> </include>
</if> </if>
<if test="request.name != null"> <if test="request.name != null">
and load_test.name like CONCAT('%', #{request.name},'%') and load_test.name LIKE CONCAT('%', #{request.name}, '%')
</if> </if>
<if test="request.userId != null"> <if test="request.userId != null">
and load_test.user_id= #{request.userId} AND load_test.user_id = #{request.userId}
</if> </if>
<if test="request.workspaceId != null"> <if test="request.workspaceId != null">
AND project.workspace_id = #{request.workspaceId} AND project.workspace_id = #{request.workspaceId}
@ -82,23 +81,33 @@
<if test="request.filters != null and request.filters.size() > 0"> <if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values"> <foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0"> <if test="values != null and values.size() > 0">
and load_test.status in <choose>
<foreach collection="values" item="value" separator="," open="(" close=")"> <when test="key == 'status'">
#{value} AND load_test.status IN
</foreach> <foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<when test="key == 'user_id'">
AND load_test.user_id IN
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
</choose>
</if> </if>
</foreach> </foreach>
</if> </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
<foreach collection="request.orders" separator="," item="order"> <foreach collection="request.orders" separator="," item="order">
load_test.${order.name} ${order.type} load_test.${order.name} ${order.type}
</foreach> </foreach>
</if> </if>
</select> </select>
<select id="getLoadTestByProjectId" resultType="io.metersphere.base.domain.LoadTest"> <select id="getLoadTestByProjectId" resultType="io.metersphere.base.domain.LoadTest">
SELECT id,name SELECT id, name
FROM load_test FROM load_test
WHERE project_id = #{projectId} WHERE project_id = #{projectId}
</select> </select>
@ -106,7 +115,7 @@
<select id="checkLoadTestOwner" resultType="int"> <select id="checkLoadTestOwner" resultType="int">
SELECT COUNT(1) SELECT COUNT(1)
FROM load_test FROM load_test
LEFT JOIN project ON load_test.project_id = project.id LEFT JOIN project ON load_test.project_id = project.id
<where> <where>
<if test="testId != null"> <if test="testId != null">
and load_test.id = #{testId} and load_test.id = #{testId}

View File

@ -95,6 +95,13 @@
<property name="object" value="${condition}.creator"/> <property name="object" value="${condition}.creator"/>
</include> </include>
</if> </if>
<if test="${condition}.tags != null">
and test_case.tags
<include refid="condition">
<property name="object" value="${condition}.tags"/>
</include>
</if>
</sql> </sql>
<select id="getTestCaseByNotInReview" resultType="io.metersphere.base.domain.TestCase"> <select id="getTestCaseByNotInReview" resultType="io.metersphere.base.domain.TestCase">

View File

@ -168,6 +168,9 @@ public class UserController {
@GetMapping("/info/{userId}") @GetMapping("/info/{userId}")
public UserDTO getUserInfo(@PathVariable(value = "userId") String userId) { public UserDTO getUserInfo(@PathVariable(value = "userId") String userId) {
if (!StringUtils.equals(userId, SessionUtils.getUserId())) {
MSException.throwException(Translator.get("not_authorized"));
}
return userService.getUserInfo(userId); return userService.getUserInfo(userId);
} }

@ -1 +1 @@
Subproject commit 9f4a9bbf46fc1333dbcccea21f83e27e3ec10b1f Subproject commit 068127ce59ea8b016434ed52a9de4a7a4b13bdb4

View File

@ -3,7 +3,7 @@
<el-card class="table-card" v-loading="loading"> <el-card class="table-card" v-loading="loading">
<template v-slot:header> <template v-slot:header>
<ms-table-header :condition.sync="condition" @search="selectByParam" title="" <ms-table-header :condition.sync="condition" @search="selectByParam" title=""
:show-create="false"/> :show-create="false" />
</template> </template>
<el-table ref="scenarioTable" border :data="tableData" class="adjust-table ms-select-all" @select-all="select" @select="select" <el-table ref="scenarioTable" border :data="tableData" class="adjust-table ms-select-all" @select-all="select" @select="select"
@ -12,10 +12,10 @@
<el-table-column type="selection" width="50"/> <el-table-column type="selection" width="50"/>
<ms-table-select-all v-if="!referenced" <ms-table-select-all v-if="!referenced"
:page-size="pageSize" :page-size="pageSize"
:total="total" :total="total"
@selectPageAll="isSelectDataAll(false)" @selectPageAll="isSelectDataAll(false)"
@selectAll="isSelectDataAll(true)"/> @selectAll="isSelectDataAll(true)"/>
<el-table-column v-if="!referenced" width="30" :resizable="false" align="center"> <el-table-column v-if="!referenced" width="30" :resizable="false" align="center">
<template v-slot:default="scope"> <template v-slot:default="scope">
@ -93,335 +93,338 @@
</el-drawer> </el-drawer>
</div> </div>
</el-card> </el-card>
</div> </div>
</template> </template>
<script> <script>
import MsTableHeader from "@/business/components/common/components/MsTableHeader"; import MsTableHeader from "@/business/components/common/components/MsTableHeader";
import MsTablePagination from "@/business/components/common/pagination/TablePagination"; import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import ShowMoreBtn from "@/business/components/track/case/components/ShowMoreBtn"; import ShowMoreBtn from "@/business/components/track/case/components/ShowMoreBtn";
import MsTag from "../../../common/components/MsTag"; import MsTag from "../../../common/components/MsTag";
import {getUUID, getCurrentProjectID} from "@/common/js/utils"; import {getUUID, getCurrentProjectID} from "@/common/js/utils";
import MsApiReportDetail from "../report/ApiReportDetail"; import MsApiReportDetail from "../report/ApiReportDetail";
import MsTableMoreBtn from "./TableMoreBtn"; import MsTableMoreBtn from "./TableMoreBtn";
import MsScenarioExtendButtons from "@/business/components/api/automation/scenario/ScenarioExtendBtns"; import MsScenarioExtendButtons from "@/business/components/api/automation/scenario/ScenarioExtendBtns";
import MsTestPlanList from "./testplan/TestPlanList"; import MsTestPlanList from "./testplan/TestPlanList";
import MsTableSelectAll from "../../../common/components/table/MsTableSelectAll"; import MsTableSelectAll from "../../../common/components/table/MsTableSelectAll";
import {API_CASE_CONFIGS} from "@/business/components/common/components/search/search-components";
export default { export default {
name: "MsApiScenarioList", name: "MsApiScenarioList",
components: { components: {
MsTableSelectAll, MsTableSelectAll,
MsTablePagination, MsTablePagination,
MsTableMoreBtn, MsTableMoreBtn,
ShowMoreBtn, ShowMoreBtn,
MsTableHeader, MsTableHeader,
MsTag, MsTag,
MsApiReportDetail, MsApiReportDetail,
MsScenarioExtendButtons, MsScenarioExtendButtons,
MsTestPlanList MsTestPlanList
},
props: {
referenced: {
type: Boolean,
default: false,
}, },
selectNodeIds: Array, props: {
trashEnable: { referenced: {
type: Boolean, type: Boolean,
default: false, default: false,
} },
}, selectNodeIds: Array,
data() { trashEnable: {
return { type: Boolean,
loading: false, default: false,
condition: {}, }
currentScenario: {}, },
schedule: {}, data() {
selection: [], return {
tableData: [], loading: false,
selectDataRange: 'all', condition: {
currentPage: 1, components: API_CASE_CONFIGS
pageSize: 10, },
total: 0, currentScenario: {},
reportId: "", schedule: {},
batchReportId: "", selection: [],
content: {}, tableData: [],
infoDb: false, selectDataRange: 'all',
runVisible: false, currentPage: 1,
planVisible: false, pageSize: 10,
projectId: "", total: 0,
runData: [], reportId: "",
report: {}, batchReportId: "",
selectDataSize: 0, content: {},
selectAll: false, infoDb: false,
buttons: [ runVisible: false,
{ planVisible: false,
name: this.$t('api_test.automation.batch_add_plan'), handleClick: this.handleBatchAddCase projectId: "",
}, { runData: [],
name: this.$t('api_test.automation.batch_execute'), handleClick: this.handleBatchExecute report: {},
} selectDataSize: 0,
], selectAll: false,
isSelectAllDate: false, buttons: [
unSelection: [], {
selectDataCounts: 0, name: this.$t('api_test.automation.batch_add_plan'), handleClick: this.handleBatchAddCase
} }, {
}, name: this.$t('api_test.automation.batch_execute'), handleClick: this.handleBatchExecute
created() { }
this.projectId = getCurrentProjectID(); ],
this.search(); isSelectAllDate: false,
}, unSelection: [],
watch: { selectDataCounts: 0,
selectNodeIds() { }
},
created() {
this.projectId = getCurrentProjectID();
this.search(); this.search();
}, },
trashEnable() { watch: {
if (this.trashEnable) { selectNodeIds() {
this.search(); this.search();
} },
}, trashEnable() {
batchReportId() { if (this.trashEnable) {
this.loading = true; this.search();
this.getReport(); }
} },
}, batchReportId() {
computed: {
isNotRunning() {
return "Running" !== this.report.status;
}
},
methods: {
selectByParam() {
this.changeSelectDataRangeAll();
this.search();
},
search() {
this.condition.filters = ["Prepare", "Underway", "Completed"];
this.condition.moduleIds = this.selectNodeIds;
if (this.trashEnable) {
this.condition.filters = ["Trash"];
this.condition.moduleIds = [];
}
if (this.projectId != null) {
this.condition.projectId = this.projectId;
}
//
this.condition.selectThisWeedData = false;
this.condition.executeStatus = null;
this.isSelectThissWeekData();
switch (this.selectDataRange){
case 'thisWeekCount':
this.condition.selectThisWeedData = true;
break;
case 'unExecute':
this.condition.executeStatus = 'unExecute';
break;
case 'executeFailed':
this.condition.executeStatus = 'executeFailed';
break;
case 'executePass':
this.condition.executeStatus = 'executePass';
break;
}
this.selection = [];
this.selectAll = false;
this.unSelection = [];
this.selectDataCounts = 0;
let url = "/api/automation/list/" + this.currentPage + "/" + this.pageSize;
if (this.condition.projectId) {
this.loading = true; this.loading = true;
this.$post(url, this.condition, response => { this.getReport();
let data = response.data; }
this.total = data.itemCount; },
this.tableData = data.listObject; computed: {
this.tableData.forEach(item => { isNotRunning() {
if (item.tags && item.tags.length > 0) { return "Running" !== this.report.status;
item.tags = JSON.parse(item.tags); }
},
methods: {
selectByParam() {
this.changeSelectDataRangeAll();
this.search();
},
search() {
this.condition.filters = ["Prepare", "Underway", "Completed"];
this.condition.moduleIds = this.selectNodeIds;
if (this.trashEnable) {
this.condition.filters = ["Trash"];
this.condition.moduleIds = [];
}
if (this.projectId != null) {
this.condition.projectId = this.projectId;
}
//
this.condition.selectThisWeedData = false;
this.condition.executeStatus = null;
this.isSelectThissWeekData();
switch (this.selectDataRange) {
case 'thisWeekCount':
this.condition.selectThisWeedData = true;
break;
case 'unExecute':
this.condition.executeStatus = 'unExecute';
break;
case 'executeFailed':
this.condition.executeStatus = 'executeFailed';
break;
case 'executePass':
this.condition.executeStatus = 'executePass';
break;
}
this.selection = [];
this.selectAll = false;
this.unSelection = [];
this.selectDataCounts = 0;
let url = "/api/automation/list/" + this.currentPage + "/" + this.pageSize;
if (this.condition.projectId) {
this.loading = true;
this.$post(url, this.condition, response => {
let data = response.data;
this.total = data.itemCount;
this.tableData = data.listObject;
this.tableData.forEach(item => {
if (item.tags && item.tags.length > 0) {
item.tags = JSON.parse(item.tags);
}
});
this.loading = false;
this.unSelection = data.listObject.map(s => s.id);
});
}
},
handleCommand(cmd) {
let table = this.$refs.scenarioTable;
switch (cmd) {
case "table":
this.selectAll = false;
table.toggleAllSelection();
break;
case "all":
this.selectAll = true;
break
}
},
handleBatchAddCase() {
this.planVisible = true;
},
addTestPlan(plans) {
let obj = {planIds: plans, scenarioIds: this.selection};
obj.projectId = getCurrentProjectID();
obj.selectAllDate = this.isSelectAllDate;
obj.unSelectIds = this.unSelection;
obj = Object.assign(obj, this.condition);
this.planVisible = false;
this.$post("/api/automation/scenario/plan", obj, response => {
this.$success(this.$t("commons.save_success"));
});
},
getReport() {
if (this.batchReportId) {
let url = "/api/scenario/report/get/" + this.batchReportId;
this.$get(url, response => {
this.report = response.data || {};
if (response.data) {
if (this.isNotRunning) {
try {
this.content = JSON.parse(this.report.content);
} catch (e) {
throw e;
}
this.loading = false;
this.$success("批量执行成功,请到报告页面查看详情!");
} else {
setTimeout(this.getReport, 2000)
}
} else {
this.loading = false;
this.$error(this.$t('api_report.not_exist'));
} }
}); });
this.loading = false;
this.unSelection = data.listObject.map(s => s.id);
});
}
},
handleCommand(cmd) {
let table = this.$refs.scenarioTable;
switch (cmd) {
case "table":
this.selectAll = false;
table.toggleAllSelection();
break;
case "all":
this.selectAll = true;
break
}
},
handleBatchAddCase() {
this.planVisible = true;
},
addTestPlan(plans) {
let obj = {planIds: plans, scenarioIds: this.selection};
obj.projectId = getCurrentProjectID();
obj.selectAllDate = this.isSelectAllDate;
obj.unSelectIds = this.unSelection;
obj = Object.assign(obj, this.condition);
this.planVisible = false;
this.$post("/api/automation/scenario/plan", obj, response => {
this.$success(this.$t("commons.save_success"));
});
},
getReport() {
if (this.batchReportId) {
let url = "/api/scenario/report/get/" + this.batchReportId;
this.$get(url, response => {
this.report = response.data || {};
if (response.data) {
if (this.isNotRunning) {
try {
this.content = JSON.parse(this.report.content);
} catch (e) {
throw e;
}
this.loading = false;
this.$success("批量执行成功,请到报告页面查看详情!");
} else {
setTimeout(this.getReport, 2000)
}
} else {
this.loading = false;
this.$error(this.$t('api_report.not_exist'));
}
});
}
},
handleBatchExecute() {
this.infoDb = false;
let url = "/api/automation/run/batch";
let run = {};
let scenarioIds = this.selection;
run.id = getUUID();
run.scenarioIds = scenarioIds;
run.projectId = getCurrentProjectID();
run.selectAllDate = this.isSelectAllDate;
run.unSelectIds = this.unSelection;
run = Object.assign(run, this.condition);
this.$post(url, run, response => {
let data = response.data;
this.runVisible = false;
this.batchReportId = run.id;
});
},
select(selection) {
this.selection = selection.map(s => s.id);
//
this.selectRowsCount(this.selection)
this.$emit('selection', selection);
},
isSelect(row) {
return this.selection.includes(row.id)
},
edit(row) {
this.$emit('edit', row);
},
reductionApi(row) {
row.scenarioDefinition = null;
row.tags = null;
let rows = [row];
this.$post("/api/automation/reduction", rows, response => {
this.$success(this.$t('commons.save_success'));
this.search();
})
},
execute(row) {
this.infoDb = false;
let url = "/api/automation/run";
let run = {};
let scenarioIds = [];
scenarioIds.push(row.id);
run.id = getUUID();
run.projectId = getCurrentProjectID();
run.scenarioIds = scenarioIds;
this.$post(url, run, response => {
let data = response.data;
this.runVisible = true;
this.reportId = run.id;
});
},
copy(row) {
row.copy = true;
this.$emit('edit', row);
},
showReport(row) {
this.runVisible = true;
this.infoDb = true;
this.reportId = row.reportId;
},
//
isSelectDataAll(dataType) {
this.isSelectAllDate = dataType;
this.selectRowsCount(this.selection);
//
if (this.selection.length != this.tableData.length) {
this.$refs.scenarioTable.toggleAllSelection(true);
}
},
//
selectRowsCount(selection) {
let selectedIDs = selection;
let allIDs = this.tableData.map(s => s.id);
this.unSelection = allIDs.filter(function (val) {
return selectedIDs.indexOf(val) === -1
});
if (this.isSelectAllDate) {
this.selectDataCounts = this.total - this.unSelection.length;
} else {
this.selectDataCounts = this.selection.length;
}
},
//
isSelectThissWeekData() {
let dataRange = this.$route.params.dataSelectRange;
this.selectDataRange = dataRange;
},
changeSelectDataRangeAll() {
this.$emit("changeSelectDataRangeAll");
},
remove(row) {
if (this.trashEnable) {
this.$get('/api/automation/delete/' + row.id, () => {
this.$success(this.$t('commons.delete_success'));
this.search();
});
return;
}
this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + row.name + " ", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
let ids = [row.id];
this.$post('/api/automation/removeToGc/', ids, () => {
this.$success(this.$t('commons.delete_success'));
this.search();
});
}
} }
}); },
}, handleBatchExecute() {
this.infoDb = false;
let url = "/api/automation/run/batch";
let run = {};
let scenarioIds = this.selection;
run.id = getUUID();
run.scenarioIds = scenarioIds;
run.projectId = getCurrentProjectID();
run.selectAllDate = this.isSelectAllDate;
run.unSelectIds = this.unSelection;
run = Object.assign(run, this.condition);
this.$post(url, run, response => {
let data = response.data;
this.runVisible = false;
this.batchReportId = run.id;
});
},
select(selection) {
this.selection = selection.map(s => s.id);
//
this.selectRowsCount(this.selection)
this.$emit('selection', selection);
},
isSelect(row) {
return this.selection.includes(row.id)
},
edit(row) {
this.$emit('edit', row);
},
reductionApi(row) {
row.scenarioDefinition = null;
row.tags = null;
let rows = [row];
this.$post("/api/automation/reduction", rows, response => {
this.$success(this.$t('commons.save_success'));
this.search();
})
},
execute(row) {
this.infoDb = false;
let url = "/api/automation/run";
let run = {};
let scenarioIds = [];
scenarioIds.push(row.id);
run.id = getUUID();
run.projectId = getCurrentProjectID();
run.scenarioIds = scenarioIds;
this.$post(url, run, response => {
let data = response.data;
this.runVisible = true;
this.reportId = run.id;
});
},
copy(row) {
row.copy = true;
this.$emit('edit', row);
},
showReport(row) {
this.runVisible = true;
this.infoDb = true;
this.reportId = row.reportId;
},
//
isSelectDataAll(dataType) {
this.isSelectAllDate = dataType;
this.selectRowsCount(this.selection);
//
if (this.selection.length != this.tableData.length) {
this.$refs.scenarioTable.toggleAllSelection(true);
}
},
//
selectRowsCount(selection) {
let selectedIDs = selection;
let allIDs = this.tableData.map(s => s.id);
this.unSelection = allIDs.filter(function (val) {
return selectedIDs.indexOf(val) === -1
});
if (this.isSelectAllDate) {
this.selectDataCounts = this.total - this.unSelection.length;
} else {
this.selectDataCounts = this.selection.length;
}
},
//
isSelectThissWeekData() {
let dataRange = this.$route.params.dataSelectRange;
this.selectDataRange = dataRange;
},
changeSelectDataRangeAll() {
this.$emit("changeSelectDataRangeAll");
},
remove(row) {
if (this.trashEnable) {
this.$get('/api/automation/delete/' + row.id, () => {
this.$success(this.$t('commons.delete_success'));
this.search();
});
return;
}
this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + row.name + " ", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
let ids = [row.id];
this.$post('/api/automation/removeToGc/', ids, () => {
this.$success(this.$t('commons.delete_success'));
this.search();
});
}
}
});
},
}
} }
}
</script> </script>
<style scoped> <style scoped>
/deep/ .el-drawer__header { /deep/ .el-drawer__header {
margin-bottom: 0px; margin-bottom: 0px;
} }
</style> </style>

View File

@ -524,8 +524,7 @@
} }
this.sort(); this.sort();
this.reload(); this.reload();
} },
,
nodeClick(e) { nodeClick(e) {
if (e.referenced != 'REF' && e.referenced != 'Deleted') { if (e.referenced != 'REF' && e.referenced != 'Deleted') {
this.operatingElements = ELEMENTS.get(e.type); this.operatingElements = ELEMENTS.get(e.type);
@ -533,8 +532,7 @@
this.operatingElements = []; this.operatingElements = [];
} }
this.selectedTreeNode = e; this.selectedTreeNode = e;
} },
,
suggestClick(node) { suggestClick(node) {
this.response = {}; this.response = {};
if (node.parent && node.parent.data.requestResult) { if (node.parent && node.parent.data.requestResult) {
@ -544,13 +542,11 @@
showAll() { showAll() {
this.operatingElements = ELEMENTS.get("ALL"); this.operatingElements = ELEMENTS.get("ALL");
this.selectedTreeNode = undefined; this.selectedTreeNode = undefined;
this.reload(); //this.reload();
} },
,
apiListImport() { apiListImport() {
this.$refs.scenarioApiRelevance.open(); this.$refs.scenarioApiRelevance.open();
} },
,
recursiveSorting(arr) { recursiveSorting(arr) {
for (let i in arr) { for (let i in arr) {
arr[i].index = Number(i) + 1; arr[i].index = Number(i) + 1;
@ -558,8 +554,7 @@
this.recursiveSorting(arr[i].hashTree); this.recursiveSorting(arr[i].hashTree);
} }
} }
} },
,
sort() { sort() {
for (let i in this.scenarioDefinition) { for (let i in this.scenarioDefinition) {
this.scenarioDefinition[i].index = Number(i) + 1; this.scenarioDefinition[i].index = Number(i) + 1;
@ -567,8 +562,7 @@
this.recursiveSorting(this.scenarioDefinition[i].hashTree); this.recursiveSorting(this.scenarioDefinition[i].hashTree);
} }
} }
} },
,
addCustomizeApi(request) { addCustomizeApi(request) {
this.customizeVisible = false; this.customizeVisible = false;
request.enable === undefined ? request.enable = true : request.enable; request.enable === undefined ? request.enable = true : request.enable;
@ -1034,5 +1028,6 @@
.ms-opt-btn { .ms-opt-btn {
position: fixed; position: fixed;
right: 50px; right: 50px;
z-index: 1;
} }
</style> </style>

View File

@ -18,19 +18,26 @@
</el-col> </el-col>
<el-col :span="3"> <el-col :span="3">
<div> <div>
<el-select size="small" :placeholder="$t('api_test.definition.request.grade_info')" v-model="condition.priority" <el-select size="small" :placeholder="$t('api_test.definition.request.grade_order_asc')" v-model="condition.order"
:disabled="isCaseEdit" :disabled="isCaseEdit"
class="ms-api-header-select" @change="getApiTest" clearable> class="ms-api-header-select" @change="search" clearable>
<el-option v-for="grd in priorities" :key="grd.id" :label="grd.name" :value="grd.id"/> <el-option v-for="grd in priorities" :key="grd.id" :label="$t(grd.label)" :value="grd.id"/>
</el-select> </el-select>
</div> </div>
</el-col> </el-col>
<el-col :span="3"> <el-col :span="4">
<div class="ms-api-header-select" style="margin-right: 20px"> <div class="ms-api-header-select" style="margin-right: 20px">
<el-input size="small" :placeholder="$t('api_test.definition.request.select_case')" <el-row>
:disabled="isCaseEdit" <el-col :span="12">
v-model="condition.name" @blur="getApiTest" @keyup.enter.native="getApiTest" /> <el-input size="small" :placeholder="$t('api_test.definition.request.select_case')"
:disabled="isCaseEdit"
v-model="condition.name" @blur="search" @keyup.enter.native="search"/>
</el-col>
<el-col :span="12">
<el-link type="primary" style="margin-left: 5px" @click="open">{{$t('commons.adv_search.title')}}</el-link>
</el-col>
</el-row>
</div> </div>
</el-col> </el-col>
@ -43,7 +50,7 @@
</div> </div>
</el-col> </el-col>
<el-col :span="2" v-if="!(isReadOnly || isCaseEdit)"> <el-col :span="1" v-if="!(isReadOnly || isCaseEdit)">
<el-dropdown size="small" split-button type="primary" class="ms-api-header-select" @click="addCase" <el-dropdown size="small" split-button type="primary" class="ms-api-header-select" @click="addCase"
@command="handleCommand" v-tester> @command="handleCommand" v-tester>
+{{$t('api_test.definition.request.case')}} +{{$t('api_test.definition.request.case')}}
@ -54,6 +61,10 @@
</el-col> </el-col>
</el-row> </el-row>
</el-card> </el-card>
<!--高级搜索-->
<ms-table-adv-search-bar :condition.sync="condition" :showLink="false" ref="searchBar" @search="search"/>
</el-header> </el-header>
</template> </template>
@ -64,10 +75,11 @@
import MsTag from "../../../../common/components/MsTag"; import MsTag from "../../../../common/components/MsTag";
import MsEnvironmentSelect from "./MsEnvironmentSelect"; import MsEnvironmentSelect from "./MsEnvironmentSelect";
import {API_METHOD_COLOUR} from "../../model/JsonData"; import {API_METHOD_COLOUR} from "../../model/JsonData";
import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar";
export default { export default {
name: "ApiCaseHeader", name: "ApiCaseHeader",
components: {MsEnvironmentSelect, MsTag, ApiEnvironmentConfig}, components: {MsEnvironmentSelect, MsTag, ApiEnvironmentConfig, MsTableAdvSearchBar},
data() { data() {
return { return {
environments: [], environments: [],
@ -86,7 +98,7 @@
type: Object, type: Object,
default() { default() {
return {} return {}
} },
} }
}, },
created() { created() {
@ -132,9 +144,19 @@
setEnvironment(data) { setEnvironment(data) {
this.$emit('setEnvironment', data); this.$emit('setEnvironment', data);
}, },
getApiTest() { search() {
if (this.priorities && this.condition.order) {
for (let index in this.priorities) {
if (this.priorities[index].id === this.condition.order) {
this.condition.orders = [this.priorities[index]];
}
}
}
this.$emit('getApiTest'); this.$emit('getApiTest');
}, },
open() {
this.$refs.searchBar.open();
},
addCase() { addCase() {
this.$emit('addCase'); this.$emit('addCase');
}, },

View File

@ -24,7 +24,7 @@
<label class="ms-api-label" style="padding-left: 20px; padding-right: 20px;">{{ $t('commons.tag') }}</label> <label class="ms-api-label" style="padding-left: 20px; padding-right: 20px;">{{ $t('commons.tag') }}</label>
<ms-input-tag :currentScenario="apiCase" ref="tag" style="float: right;margin-right: 215px;margin-top: -3px;"/> <ms-input-tag :currentScenario="apiCase" ref="tag" style="float: right;margin-right: 215px;margin-top: -3px;" @keyup.enter.native="saveTestCase(apiCase)"/>
<div v-if="apiCase.id" style="color: #999999;font-size: 12px"> <div v-if="apiCase.id" style="color: #999999;font-size: 12px">
<span> <span>

View File

@ -43,222 +43,225 @@
</template> </template>
<script> <script>
import ApiCaseHeader from "./ApiCaseHeader"; import ApiCaseHeader from "./ApiCaseHeader";
import ApiCaseItem from "./ApiCaseItem"; import ApiCaseItem from "./ApiCaseItem";
import MsRun from "../Run"; import MsRun from "../Run";
import {getCurrentProjectID, getUUID} from "@/common/js/utils"; import {getCurrentProjectID, getUUID} from "@/common/js/utils";
import MsDrawer from "../../../../common/components/MsDrawer"; import MsDrawer from "../../../../common/components/MsDrawer";
import {PRIORITY} from "../../model/JsonData"; import {CASE_ORDER} from "../../model/JsonData";
import {API_CASE_CONFIGS} from "@/business/components/common/components/search/search-components";
export default { export default {
name: 'ApiCaseList', name: 'ApiCaseList',
components: { components: {
MsDrawer, MsDrawer,
MsRun, MsRun,
ApiCaseHeader, ApiCaseHeader,
ApiCaseItem, ApiCaseItem,
},
props: {
createCase: String,
loaded: Boolean,
refreshSign: String,
currentApi: {
type: Object
}, },
}, props: {
data() { createCase: String,
return { loaded: Boolean,
result: {}, refreshSign: String,
grades: [], currentApi: {
environment: {}, type: Object
isReadOnly: false, },
selectedEvent: Object, },
priorities: PRIORITY, data() {
apiCaseList: [], return {
batchLoading: false, result: {},
singleLoading: false, grades: [],
singleRunId: "", environment: {},
runData: [], isReadOnly: false,
reportId: "", selectedEvent: Object,
projectId: "", priorities: CASE_ORDER,
testCaseId: "", apiCaseList: [],
checkedCases: new Set(), batchLoading: false,
visible: false, singleLoading: false,
condition: {}, singleRunId: "",
api: {} runData: [],
} reportId: "",
}, projectId: "",
watch: { testCaseId: "",
refreshSign() { checkedCases: new Set(),
visible: false,
condition: {
components: API_CASE_CONFIGS
},
api: {}
}
},
watch: {
refreshSign() {
this.api = this.currentApi;
this.getApiTest();
},
createCase() {
this.api = this.currentApi;
this.sysAddition();
}
},
created() {
this.api = this.currentApi; this.api = this.currentApi;
this.getApiTest(); this.projectId = getCurrentProjectID();
if (this.createCase) {
this.sysAddition();
} else {
this.getApiTest();
}
}, },
createCase() { computed: {
this.api = this.currentApi; isCaseEdit() {
this.sysAddition(); return this.testCaseId ? true : false;
} }
},
created() {
this.api = this.currentApi;
this.projectId = getCurrentProjectID();
if (this.createCase) {
this.sysAddition();
} else {
this.getApiTest();
}
},
computed: {
isCaseEdit() {
return this.testCaseId ? true : false;
}
},
methods: {
open(api, testCaseId) {
this.api = api;
// testCaseId
this.testCaseId = testCaseId;
this.getApiTest();
this.visible = true;
}, },
setEnvironment(environment) { methods: {
this.environment = environment; open(api, testCaseId) {
}, this.api = api;
sysAddition() { // testCaseId
this.condition.projectId = this.projectId; this.testCaseId = testCaseId;
this.condition.apiDefinitionId = this.api.id; this.condition = {components: API_CASE_CONFIGS};
this.$post("/api/testcase/list", this.condition, response => { this.getApiTest();
for (let index in response.data) { this.visible = true;
let test = response.data[index]; },
test.request = JSON.parse(test.request); setEnvironment(environment) {
} this.environment = environment;
this.apiCaseList = response.data; },
this.addCase(); sysAddition() {
});
},
apiCaseClose() {
this.apiCaseList = [];
this.visible = false;
},
runRefresh(data) {
this.batchLoading = false;
this.singleLoading = false;
this.singleRunId = "";
this.$success(this.$t('schedule.event_success'));
this.getApiTest();
this.$emit('refresh');
},
refresh(data) {
this.getApiTest();
this.$emit('refresh');
},
getApiTest() {
if (this.api) {
this.condition.projectId = this.projectId; this.condition.projectId = this.projectId;
if (this.isCaseEdit) { this.condition.apiDefinitionId = this.api.id;
this.condition.id = this.testCaseId; this.$post("/api/testcase/list", this.condition, response => {
} else {
this.condition.apiDefinitionId = this.api.id;
}
this.result = this.$post("/api/testcase/list", this.condition, response => {
for (let index in response.data) { for (let index in response.data) {
let test = response.data[index]; let test = response.data[index];
test.request = JSON.parse(test.request); test.request = JSON.parse(test.request);
if (!test.request.hashTree) {
test.request.hashTree = [];
}
} }
this.apiCaseList = response.data; this.apiCaseList = response.data;
if (this.apiCaseList.length == 0 && !this.loaded) { this.addCase();
this.addCase(); });
},
apiCaseClose() {
this.apiCaseList = [];
this.visible = false;
},
runRefresh(data) {
this.batchLoading = false;
this.singleLoading = false;
this.singleRunId = "";
this.$success(this.$t('schedule.event_success'));
this.getApiTest();
this.$emit('refresh');
},
refresh(data) {
this.getApiTest();
this.$emit('refresh');
},
getApiTest() {
if (this.api) {
this.condition.projectId = this.projectId;
if (this.isCaseEdit) {
this.condition.id = this.testCaseId;
} else {
this.condition.apiDefinitionId = this.api.id;
} }
this.apiCaseList.forEach(apiCase => { this.result = this.$post("/api/testcase/list", this.condition, response => {
if (apiCase.tags && apiCase.tags.length > 0) { for (let index in response.data) {
apiCase.tags = JSON.parse(apiCase.tags); let test = response.data[index];
test.request = JSON.parse(test.request);
if (!test.request.hashTree) {
test.request.hashTree = [];
}
}
this.apiCaseList = response.data;
// if (this.apiCaseList.length == 0 && !this.loaded) {
// this.addCase();
// }
this.apiCaseList.forEach(apiCase => {
if (apiCase.tags && apiCase.tags.length > 0) {
apiCase.tags = JSON.parse(apiCase.tags);
}
})
});
}
},
addCase() {
if (this.api.request) {
//
let request = {};
if (this.api.request instanceof Object) {
request = this.api.request;
} else {
request = JSON.parse(this.api.request);
}
let obj = {apiDefinitionId: this.api.id, name: '', priority: 'P0', active: true, tags: []};
obj.request = request;
this.apiCaseList.unshift(obj);
}
},
copyCase(data) {
this.apiCaseList.unshift(data);
},
handleClose() {
this.visible = false;
},
showExecResult(row) {
this.visible = false;
this.$emit('showExecResult', row);
},
singleRun(row) {
if (!this.environment || !this.environment) {
this.$warning(this.$t('api_test.environment.select_environment'));
return;
}
this.runData = [];
this.singleLoading = true;
this.singleRunId = row.id;
row.request.name = row.id;
row.request.useEnvironment = this.environment.id;
this.runData.push(row.request);
/*触发执行操作*/
this.reportId = getUUID().substring(0, 8);
},
batchRun() {
if (!this.environment) {
this.$warning(this.$t('api_test.environment.select_environment'));
return;
}
if (this.apiCaseList.length > 0) {
this.apiCaseList.forEach(item => {
if (item.id) {
item.request.name = item.id;
item.request.useEnvironment = this.environment.id;
this.runData.push(item.request);
} }
}) })
if (this.runData.length > 0) {
}); this.batchLoading = true;
} /*触发执行操作*/
}, this.reportId = getUUID().substring(0, 8);
addCase() { } else {
if (this.api.request) { this.$warning("没有可执行的用例!");
//
let request = {};
if (this.api.request instanceof Object) {
request = this.api.request;
} else {
request = JSON.parse(this.api.request);
}
let obj = {apiDefinitionId: this.api.id, name: '', priority: 'P0', active: true, tags: []};
obj.request = request;
this.apiCaseList.unshift(obj);
}
},
copyCase(data) {
this.apiCaseList.unshift(data);
},
handleClose() {
this.visible = false;
},
showExecResult(row) {
this.visible = false;
this.$emit('showExecResult', row);
},
singleRun(row) {
if (!this.environment || !this.environment) {
this.$warning(this.$t('api_test.environment.select_environment'));
return;
}
this.runData = [];
this.singleLoading = true;
this.singleRunId = row.id;
row.request.name = row.id;
row.request.useEnvironment = this.environment.id;
this.runData.push(row.request);
/*触发执行操作*/
this.reportId = getUUID().substring(0, 8);
},
batchRun() {
if (!this.environment) {
this.$warning(this.$t('api_test.environment.select_environment'));
return;
}
if (this.apiCaseList.length > 0) {
this.apiCaseList.forEach(item => {
if (item.id) {
item.request.name = item.id;
item.request.useEnvironment = this.environment.id;
this.runData.push(item.request);
} }
})
if (this.runData.length > 0) {
this.batchLoading = true;
/*触发执行操作*/
this.reportId = getUUID().substring(0, 8);
} else { } else {
this.$warning("没有可执行的用例!"); this.$warning("没有可执行的用例!");
} }
} else { },
this.$warning("没有可执行的用例!");
}
} }
} }
}
</script> </script>
<style scoped> <style scoped>
.ms-drawer >>> .ms-drawer-body { .ms-drawer >>> .ms-drawer-body {
margin-top: 80px; margin-top: 80px;
} }
</style> </style>

View File

@ -3,6 +3,7 @@
<api-list-container <api-list-container
:is-api-list-enable="isApiListEnable" :is-api-list-enable="isApiListEnable"
@isApiListEnableChange="isApiListEnableChange"> @isApiListEnableChange="isApiListEnableChange">
<el-link type="primary" style="float:right;margin-top: 5px" @click="open">{{$t('commons.adv_search.title')}}</el-link>
<el-input placeholder="搜索" @blur="search" @keyup.enter.native="search" class="search-input" size="small" <el-input placeholder="搜索" @blur="search" @keyup.enter.native="search" class="search-input" size="small"
v-model="condition.name"/> v-model="condition.name"/>
@ -89,480 +90,484 @@
<ms-set-environment ref="setEnvironment" :testCase="clickRow" @createPerformance="createPerformance"/> <ms-set-environment ref="setEnvironment" :testCase="clickRow" @createPerformance="createPerformance"/>
<!--查看引用--> <!--查看引用-->
<ms-reference-view ref="viewRef"/> <ms-reference-view ref="viewRef"/>
<!--高级搜索-->
<ms-table-adv-search-bar :condition.sync="condition" :showLink="false" ref="searchBar" @search="initTable"/>
</div> </div>
</template> </template>
<script> <script>
import MsTableOperator from "../../../../common/components/MsTableOperator"; import MsTableOperator from "../../../../common/components/MsTableOperator";
import MsTableOperatorButton from "../../../../common/components/MsTableOperatorButton"; import MsTableOperatorButton from "../../../../common/components/MsTableOperatorButton";
import {LIST_CHANGE, TrackEvent} from "@/business/components/common/head/ListEvent"; import {LIST_CHANGE, TrackEvent} from "@/business/components/common/head/ListEvent";
import MsTablePagination from "../../../../common/pagination/TablePagination"; import MsTablePagination from "../../../../common/pagination/TablePagination";
import MsTag from "../../../../common/components/MsTag"; import MsTag from "../../../../common/components/MsTag";
import MsApiCaseList from "../case/ApiCaseList"; import MsApiCaseList from "../case/ApiCaseList";
import MsContainer from "../../../../common/components/MsContainer"; import MsContainer from "../../../../common/components/MsContainer";
import MsBottomContainer from "../BottomContainer"; import MsBottomContainer from "../BottomContainer";
import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn"; import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn";
import MsBatchEdit from "../basis/BatchEdit"; import MsBatchEdit from "../basis/BatchEdit";
import {API_METHOD_COLOUR, CASE_PRIORITY, REQ_METHOD} from "../../model/JsonData"; import {API_METHOD_COLOUR, CASE_PRIORITY, REQ_METHOD} from "../../model/JsonData";
import {getBodyUploadFiles,getCurrentProjectID} from "@/common/js/utils"; import {getBodyUploadFiles, getCurrentProjectID} from "@/common/js/utils";
import ApiListContainer from "./ApiListContainer"; import ApiListContainer from "./ApiListContainer";
import PriorityTableItem from "../../../../track/common/tableItems/planview/PriorityTableItem"; import PriorityTableItem from "../../../../track/common/tableItems/planview/PriorityTableItem";
import ApiCaseList from "../case/ApiCaseList"; import ApiCaseList from "../case/ApiCaseList";
import {_filter, _sort} from "../../../../../../common/js/utils"; import {_filter, _sort} from "../../../../../../common/js/utils";
import {_handleSelect, _handleSelectAll} from "../../../../../../common/js/tableUtils"; import {_handleSelect, _handleSelectAll} from "../../../../../../common/js/tableUtils";
import MsApiCaseTableExtendBtns from "../reference/ApiCaseTableExtendBtns"; import MsApiCaseTableExtendBtns from "../reference/ApiCaseTableExtendBtns";
import MsReferenceView from "../reference/ReferenceView"; import MsReferenceView from "../reference/ReferenceView";
import MsSetEnvironment from "@/business/components/api/definition/components/basis/SetEnvironment"; import MsSetEnvironment from "@/business/components/api/definition/components/basis/SetEnvironment";
import TestPlan from "@/business/components/api/definition/components/jmeter/components/test-plan"; import TestPlan from "@/business/components/api/definition/components/jmeter/components/test-plan";
import ThreadGroup from "@/business/components/api/definition/components/jmeter/components/thread-group"; import ThreadGroup from "@/business/components/api/definition/components/jmeter/components/thread-group";
import {parseEnvironment} from "@/business/components/api/test/model/EnvironmentModel"; import {parseEnvironment} from "@/business/components/api/test/model/EnvironmentModel";
import MsTableSelectAll from "../../../../common/components/table/MsTableSelectAll"; import MsTableSelectAll from "../../../../common/components/table/MsTableSelectAll";
import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar";
import {API_CASE_CONFIGS} from "@/business/components/common/components/search/search-components";
export default { export default {
name: "ApiCaseSimpleList", name: "ApiCaseSimpleList",
components: { components: {
MsTableSelectAll, MsTableSelectAll,
MsSetEnvironment, MsSetEnvironment,
ApiCaseList, ApiCaseList,
PriorityTableItem, PriorityTableItem,
ApiListContainer, ApiListContainer,
MsTableOperatorButton, MsTableOperatorButton,
MsTableOperator, MsTableOperator,
MsTablePagination, MsTablePagination,
MsTag, MsTag,
MsApiCaseList, MsApiCaseList,
MsContainer, MsContainer,
MsBottomContainer, MsBottomContainer,
ShowMoreBtn, ShowMoreBtn,
MsBatchEdit, MsBatchEdit,
MsApiCaseTableExtendBtns, MsApiCaseTableExtendBtns,
MsReferenceView, MsReferenceView,
}, MsTableAdvSearchBar
data() {
return {
condition: {},
selectCase: {},
result: {},
moduleId: "",
selectDataRange: "all",
deletePath: "/test/case/delete",
selectRows: new Set(),
clickRow: {},
buttons: [
{name: this.$t('api_test.definition.request.batch_delete'), handleClick: this.handleDeleteBatch},
{name: this.$t('api_test.definition.request.batch_edit'), handleClick: this.handleEditBatch}
],
typeArr: [
{id: 'priority', name: this.$t('test_track.case.priority')},
{id: 'method', name: this.$t('api_test.definition.api_type')},
{id: 'path', name: this.$t('api_test.request.path')},
],
priorityFilters: [
{text: 'P0', value: 'P0'},
{text: 'P1', value: 'P1'},
{text: 'P2', value: 'P2'},
{text: 'P3', value: 'P3'}
],
valueArr: {
priority: CASE_PRIORITY,
method: REQ_METHOD,
},
methodColorMap: new Map(API_METHOD_COLOUR),
tableData: [],
currentPage: 1,
pageSize: 10,
total: 0,
screenHeight: document.documentElement.clientHeight - 330,//
environmentId: undefined,
selectAll: false,
unSelection: [],
selectDataCounts: 0,
environments: [],
}
},
props: {
currentProtocol: String,
selectNodeIds: Array,
visible: {
type: Boolean,
default: false,
}, },
trashEnable: { data() {
type: Boolean, return {
default: false, condition: {
}, components: API_CASE_CONFIGS
isApiListEnable: { },
type: Boolean, selectCase: {},
default: false, result: {},
}, moduleId: "",
isReadOnly: { selectDataRange: "all",
type: Boolean, deletePath: "/test/case/delete",
default: false selectRows: new Set(),
}, clickRow: {},
isCaseRelevance: { buttons: [
type: Boolean, {name: this.$t('api_test.definition.request.batch_delete'), handleClick: this.handleDeleteBatch},
default: false, {name: this.$t('api_test.definition.request.batch_edit'), handleClick: this.handleEditBatch}
}, ],
relevanceProjectId: String, typeArr: [
model: { {id: 'priority', name: this.$t('test_track.case.priority')},
type: String, {id: 'method', name: this.$t('api_test.definition.api_type')},
default() { {id: 'path', name: this.$t('api_test.request.path')},
'api' ],
priorityFilters: [
{text: 'P0', value: 'P0'},
{text: 'P1', value: 'P1'},
{text: 'P2', value: 'P2'},
{text: 'P3', value: 'P3'}
],
valueArr: {
priority: CASE_PRIORITY,
method: REQ_METHOD,
},
methodColorMap: new Map(API_METHOD_COLOUR),
tableData: [],
currentPage: 1,
pageSize: 10,
total: 0,
screenHeight: document.documentElement.clientHeight - 330,//
environmentId: undefined,
selectAll: false,
unSelection: [],
selectDataCounts: 0,
environments: [],
} }
}, },
planId: String props: {
}, currentProtocol: String,
created: function () { selectNodeIds: Array,
this.initTable(); visible: {
}, type: Boolean,
watch: { default: false,
selectNodeIds() { },
trashEnable: {
type: Boolean,
default: false,
},
isApiListEnable: {
type: Boolean,
default: false,
},
isReadOnly: {
type: Boolean,
default: false
},
isCaseRelevance: {
type: Boolean,
default: false,
},
relevanceProjectId: String,
model: {
type: String,
default() {
'api'
}
},
planId: String
},
created: function () {
this.initTable(); this.initTable();
}, },
currentProtocol() { watch: {
this.initTable(); selectNodeIds() {
}, this.initTable();
trashEnable() { },
if (this.trashEnable) { currentProtocol() {
this.initTable();
},
trashEnable() {
if (this.trashEnable) {
this.initTable();
}
},
relevanceProjectId() {
this.initTable(); this.initTable();
} }
}, },
relevanceProjectId() { computed: {
this.initTable();
}
},
computed: {
// //
isApiModel() { isApiModel() {
return this.model === 'api' return this.model === 'api'
},
}, },
}, methods: {
methods: { isApiListEnableChange(data) {
isApiListEnableChange(data) { this.$emit('isApiListEnableChange', data);
this.$emit('isApiListEnableChange', data); },
}, initTable() {
initTable() { this.selectRows = new Set();
this.selectRows = new Set(); this.condition.status = "";
this.condition.status = ""; this.condition.moduleIds = this.selectNodeIds;
this.condition.moduleIds = this.selectNodeIds; if (this.trashEnable) {
if (this.trashEnable) { this.condition.status = "Trash";
this.condition.status = "Trash"; this.condition.moduleIds = [];
this.condition.moduleIds = [];
}
this.selectAll = false;
this.unSelection = [];
this.selectDataCounts = 0;
this.condition.projectId = getCurrentProjectID();
if (this.currentProtocol != null) {
this.condition.protocol = this.currentProtocol;
}
//
this.isSelectThissWeekData();
this.condition.selectThisWeedData = false;
this.condition.id = null;
if (this.selectDataRange == 'thisWeekCount') {
this.condition.selectThisWeedData = true;
} else if (this.selectDataRange != null) {
let selectParamArr = this.selectDataRange.split("single:");
if (selectParamArr.length == 2) {
this.condition.id = selectParamArr[1];
} }
} this.selectAll = false;
this.unSelection = [];
this.selectDataCounts = 0;
this.condition.projectId = getCurrentProjectID();
if (this.condition.projectId) { if (this.currentProtocol != null) {
this.result = this.$post('/api/testcase/list/' + this.currentPage + "/" + this.pageSize, this.condition, response => { this.condition.protocol = this.currentProtocol;
this.total = response.data.itemCount; }
this.tableData = response.data.listObject;
this.unSelection = response.data.listObject.map(s => s.id);
});
}
},
// getMaintainerOptions() {
// let workspaceId = localStorage.getItem(WORKSPACE_ID);
// this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
// this.valueArr.userId = response.data;
// });
// },
handleSelect(selection, row) {
_handleSelect(this, selection, row, this.selectRows);
this.selectRowsCount(this.selectRows)
},
showExecResult(row) {
this.visible = false;
this.$emit('showExecResult', row);
},
filter(filters) {
_filter(filters, this.condition);
this.initTable();
},
sort(column) {
//
if (this.condition.orders) {
this.condition.orders = [];
}
_sort(column, this.condition);
this.initTable();
},
handleSelectAll(selection) {
_handleSelectAll(this, selection, this.tableData, this.selectRows);
this.selectRowsCount(this.selectRows)
},
search() {
this.changeSelectDataRangeAll();
this.initTable();
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
handleTestCase(testCase) { //
this.$get('/api/definition/get/' + testCase.apiDefinitionId, (response) => { this.isSelectThissWeekData();
let api = response.data; this.condition.selectThisWeedData = false;
let selectApi = api; this.condition.id = null;
let request = {}; if (this.selectDataRange == 'thisWeekCount') {
if (Object.prototype.toString.call(api.request).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') { this.condition.selectThisWeedData = true;
request = api.request; } else if (this.selectDataRange != null) {
} else { let selectParamArr = this.selectDataRange.split("single:");
request = JSON.parse(api.request);
} if (selectParamArr.length == 2) {
if (!request.hashTree) { this.condition.id = selectParamArr[1];
request.hashTree = [];
}
selectApi.url = request.path;
this.$refs.caseList.open(selectApi, testCase.id);
});
},
reductionApi(row) {
let ids = [row.id];
this.$post('/api/testcase/reduction/', ids, () => {
this.$success(this.$t('commons.save_success'));
this.search();
});
},
handleDeleteBatch() {
// if (this.trashEnable) {
this.$alert(this.$t('api_test.definition.request.delete_confirm') + "", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
let obj = {};
obj.projectId = getCurrentProjectID();
obj.selectAllDate = this.isSelectAllDate;
obj.unSelectIds = this.unSelection;
obj.ids = Array.from(this.selectRows).map(row => row.id);
obj = Object.assign(obj, this.condition);
this.$post('/api/testcase/deleteBatchByParam/', obj, () => {
this.selectRows.clear();
this.initTable();
this.$success(this.$t('commons.delete_success'));
});
} }
} }
}); if (this.condition.projectId) {
// } else { this.result = this.$post('/api/testcase/list/' + this.currentPage + "/" + this.pageSize, this.condition, response => {
// this.$alert(this.$t('api_test.definition.request.delete_confirm') + "", '', { this.total = response.data.itemCount;
// confirmButtonText: this.$t('commons.confirm'), this.tableData = response.data.listObject;
// callback: (action) => { this.unSelection = response.data.listObject.map(s => s.id);
// if (action === 'confirm') {
// let ids = Array.from(this.selectRows).map(row => row.id);
// this.$post('/api/testcase/removeToGc/', ids, () => {
// this.selectRows.clear();
// this.initTable();
// this.$success(this.$t('commons.delete_success'));
// });
// }
// }
// });
// }
},
handleEditBatch() {
this.$refs.batchEdit.open();
},
batchEdit(form) {
let arr = Array.from(this.selectRows);
let ids = arr.map(row => row.id);
let param = {};
param[form.type] = form.value;
param.ids = ids;
param.projectId = getCurrentProjectID();
param.selectAllDate = this.isSelectAllDate;
param.unSelectIds = this.unSelection;
param = Object.assign(param, this.condition);
this.$post('/api/testcase/batch/editByParam', param, () => {
this.$success(this.$t('commons.save_success'));
this.initTable();
});
},
handleDelete(apiCase) {
// if (this.trashEnable) {
this.$get('/api/testcase/delete/' + apiCase.id, () => {
this.$success(this.$t('commons.delete_success'));
this.initTable();
});
return;
// }
// this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + apiCase.name + " ", '', {
// confirmButtonText: this.$t('commons.confirm'),
// callback: (action) => {
// if (action === 'confirm') {
// let ids = [apiCase.id];
// this.$post('/api/testcase/removeToGc/', ids, () => {
// this.$success(this.$t('commons.delete_success'));
// this.initTable();
// });
// }
// }
// });
},
setEnvironment(data) {
this.environmentId = data.id;
},
selectRowsCount(selection) {
let selectedIDs = this.getIds(selection);
let allIDs = this.tableData.map(s => s.id);
this.unSelection = allIDs.filter(function (val) {
return selectedIDs.indexOf(val) === -1
});
if (this.isSelectAllDate) {
this.selectDataCounts = this.total - this.unSelection.length;
} else {
this.selectDataCounts = selection.size;
}
},
isSelectDataAll(dataType) {
this.isSelectAllDate = dataType;
this.selectRowsCount(this.selectRows)
//
if (this.selectRows.size != this.tableData.length) {
this.$refs.caseTable.toggleAllSelection(true);
}
},
//
isSelectThissWeekData() {
this.selectDataRange = "all";
let routeParam = this.$route.params.dataSelectRange;
let dataType = this.$route.params.dataType;
if (dataType === 'apiTestCase') {
this.selectDataRange = routeParam;
}
},
changeSelectDataRangeAll() {
this.$emit("changeSelectDataRangeAll", "testCase");
},
getIds(rowSets) {
let rowArray = Array.from(rowSets)
let ids = rowArray.map(s => s.id);
return ids;
},
showCaseRef(row) {
this.$refs.viewRef.open(row);
},
showEnvironment(row) {
let projectID = getCurrentProjectID();
if (this.projectId) {
this.$get('/api/environment/list/' + this.projectId, response => {
this.environments = response.data;
this.environments.forEach(environment => {
parseEnvironment(environment);
}); });
}
},
open() {
this.$refs.searchBar.open();
},
handleSelect(selection, row) {
_handleSelect(this, selection, row, this.selectRows);
this.selectRowsCount(this.selectRows)
},
showExecResult(row) {
this.visible = false;
this.$emit('showExecResult', row);
},
filter(filters) {
_filter(filters, this.condition);
this.initTable();
},
sort(column) {
//
if (this.condition.orders) {
this.condition.orders = [];
}
_sort(column, this.condition);
this.initTable();
},
handleSelectAll(selection) {
_handleSelectAll(this, selection, this.tableData, this.selectRows);
this.selectRowsCount(this.selectRows)
},
search() {
this.changeSelectDataRangeAll();
this.initTable();
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
handleTestCase(testCase) {
this.$get('/api/definition/get/' + testCase.apiDefinitionId, (response) => {
let api = response.data;
let selectApi = api;
let request = {};
if (Object.prototype.toString.call(api.request).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') {
request = api.request;
} else {
request = JSON.parse(api.request);
}
if (!request.hashTree) {
request.hashTree = [];
}
selectApi.url = request.path;
this.$refs.caseList.open(selectApi, testCase.id);
}); });
} else { },
this.environment = undefined; reductionApi(row) {
} let ids = [row.id];
this.clickRow = row; this.$post('/api/testcase/reduction/', ids, () => {
this.$refs.setEnvironment.open(row); this.$success(this.$t('commons.save_success'));
}, this.search();
createPerformance(row, environment) { });
/** },
* 思路调用后台创建性能测试的方法把当前案例的hashTree在后台转化为jmx并文件创建性能测试 handleDeleteBatch() {
* 然后跳转到修改性能测试的页面 // if (this.trashEnable) {
* this.$alert(this.$t('api_test.definition.request.delete_confirm') + "", '', {
* 性能测试保存地址 performance/save confirmButtonText: this.$t('commons.confirm'),
* callback: (action) => {
*/ if (action === 'confirm') {
if (!environment) { let obj = {};
this.$warning(this.$t('api_test.environment.select_environment')); obj.projectId = getCurrentProjectID();
return; obj.selectAllDate = this.isSelectAllDate;
} obj.unSelectIds = this.unSelection;
let runData = []; obj.ids = Array.from(this.selectRows).map(row => row.id);
let singleLoading = true; obj = Object.assign(obj, this.condition);
row.request = JSON.parse(row.request); this.$post('/api/testcase/deleteBatchByParam/', obj, () => {
row.request.name = row.id; this.selectRows.clear();
row.request.useEnvironment = environment.id; this.initTable();
runData.push(row.request); this.$success(this.$t('commons.delete_success'));
/*触发执行操作*/ });
let testPlan = new TestPlan(); }
let threadGroup = new ThreadGroup(); }
threadGroup.hashTree = []; });
testPlan.hashTree = [threadGroup]; // } else {
runData.forEach(item => { // this.$alert(this.$t('api_test.definition.request.delete_confirm') + "", '', {
threadGroup.hashTree.push(item); // confirmButtonText: this.$t('commons.confirm'),
}) // callback: (action) => {
let reqObj = { // if (action === 'confirm') {
id: row.id, // let ids = Array.from(this.selectRows).map(row => row.id);
testElement: testPlan, // this.$post('/api/testcase/removeToGc/', ids, () => {
name: row.name, // this.selectRows.clear();
projectId: getCurrentProjectID(), // this.initTable();
}; // this.$success(this.$t('commons.delete_success'));
let bodyFiles = getBodyUploadFiles(reqObj, runData); // });
reqObj.reportId = "run"; // }
// }
let url = "/api/genPerformanceTestXml"; // });
this.$fileUpload(url, null, bodyFiles, reqObj, response => {
let jmxObj = {};
jmxObj.name = response.data.name;
jmxObj.xml = response.data.xml;
this.$store.commit('setTest', {
name: row.name,
jmx: jmxObj
})
this.$router.push({
path: "/performance/test/create"
})
// let performanceId = response.data;
// if(performanceId!=null){
// this.$router.push({
// path: "/performance/test/edit/"+performanceId,
// })
// } // }
}, erro => { },
this.$emit('runRefresh', {}); handleEditBatch() {
}); this.$refs.batchEdit.open();
},
batchEdit(form) {
let arr = Array.from(this.selectRows);
let ids = arr.map(row => row.id);
let param = {};
param[form.type] = form.value;
param.ids = ids;
param.projectId = getCurrentProjectID();
param.selectAllDate = this.isSelectAllDate;
param.unSelectIds = this.unSelection;
param = Object.assign(param, this.condition);
this.$post('/api/testcase/batch/editByParam', param, () => {
this.$success(this.$t('commons.save_success'));
this.initTable();
});
},
handleDelete(apiCase) {
// if (this.trashEnable) {
this.$get('/api/testcase/delete/' + apiCase.id, () => {
this.$success(this.$t('commons.delete_success'));
this.initTable();
});
return;
// }
// this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + apiCase.name + " ", '', {
// confirmButtonText: this.$t('commons.confirm'),
// callback: (action) => {
// if (action === 'confirm') {
// let ids = [apiCase.id];
// this.$post('/api/testcase/removeToGc/', ids, () => {
// this.$success(this.$t('commons.delete_success'));
// this.initTable();
// });
// }
// }
// });
},
setEnvironment(data) {
this.environmentId = data.id;
},
selectRowsCount(selection) {
let selectedIDs = this.getIds(selection);
let allIDs = this.tableData.map(s => s.id);
this.unSelection = allIDs.filter(function (val) {
return selectedIDs.indexOf(val) === -1
});
if (this.isSelectAllDate) {
this.selectDataCounts = this.total - this.unSelection.length;
} else {
this.selectDataCounts = selection.size;
}
},
isSelectDataAll(dataType) {
this.isSelectAllDate = dataType;
this.selectRowsCount(this.selectRows)
//
if (this.selectRows.size != this.tableData.length) {
this.$refs.caseTable.toggleAllSelection(true);
}
},
//
isSelectThissWeekData() {
this.selectDataRange = "all";
let routeParam = this.$route.params.dataSelectRange;
let dataType = this.$route.params.dataType;
if (dataType === 'apiTestCase') {
this.selectDataRange = routeParam;
}
},
changeSelectDataRangeAll() {
this.$emit("changeSelectDataRangeAll", "testCase");
},
getIds(rowSets) {
let rowArray = Array.from(rowSets)
let ids = rowArray.map(s => s.id);
return ids;
},
showCaseRef(row) {
this.$refs.viewRef.open(row);
},
showEnvironment(row) {
let projectID = getCurrentProjectID();
if (this.projectId) {
this.$get('/api/environment/list/' + this.projectId, response => {
this.environments = response.data;
this.environments.forEach(environment => {
parseEnvironment(environment);
});
});
} else {
this.environment = undefined;
}
this.clickRow = row;
this.$refs.setEnvironment.open(row);
},
createPerformance(row, environment) {
/**
* 思路调用后台创建性能测试的方法把当前案例的hashTree在后台转化为jmx并文件创建性能测试
* 然后跳转到修改性能测试的页面
*
* 性能测试保存地址 performance/save
*
*/
if (!environment) {
this.$warning(this.$t('api_test.environment.select_environment'));
return;
}
let runData = [];
let singleLoading = true;
row.request = JSON.parse(row.request);
row.request.name = row.id;
row.request.useEnvironment = environment.id;
runData.push(row.request);
/*触发执行操作*/
let testPlan = new TestPlan();
let threadGroup = new ThreadGroup();
threadGroup.hashTree = [];
testPlan.hashTree = [threadGroup];
runData.forEach(item => {
threadGroup.hashTree.push(item);
})
let reqObj = {
id: row.id,
testElement: testPlan,
name: row.name,
projectId: getCurrentProjectID(),
};
let bodyFiles = getBodyUploadFiles(reqObj, runData);
reqObj.reportId = "run";
let url = "/api/genPerformanceTestXml";
this.$fileUpload(url, null, bodyFiles, reqObj, response => {
let jmxObj = {};
jmxObj.name = response.data.name;
jmxObj.xml = response.data.xml;
this.$store.commit('setTest', {
name: row.name,
jmx: jmxObj
})
this.$router.push({
path: "/performance/test/create"
})
// let performanceId = response.data;
// if(performanceId!=null){
// this.$router.push({
// path: "/performance/test/edit/"+performanceId,
// })
// }
}, erro => {
this.$emit('runRefresh', {});
});
},
}, },
}, }
}
</script> </script>
<style scoped> <style scoped>
.operate-button > div { .operate-button > div {
display: inline-block; display: inline-block;
margin-left: 10px; margin-left: 10px;
} }
.request-method { .request-method {
padding: 0 5px; padding: 0 5px;
color: #1E90FF; color: #1E90FF;
} }
.api-el-tag { .api-el-tag {
color: white; color: white;
} }
.search-input { .search-input {
float: right; float: right;
width: 300px; width: 300px;
/*margin-bottom: 20px;*/ /*margin-bottom: 20px;*/
margin-right: 20px; margin-right: 10px;
} }
.ms-select-all >>> th:first-child { .ms-select-all >>> th:first-child {
margin-top: 20px; margin-top: 20px;

View File

@ -4,7 +4,8 @@
:is-api-list-enable="isApiListEnable" :is-api-list-enable="isApiListEnable"
@isApiListEnableChange="isApiListEnableChange"> @isApiListEnableChange="isApiListEnableChange">
<el-input placeholder="搜索" @blur="search" class="search-input" size="small" @keyup.enter.native="search" <el-link type="primary" @click="open" style="float: right;margin-top: 5px">{{$t('commons.adv_search.title')}}</el-link>
<el-input :placeholder="$t('api_monitor.please_search')" @blur="search" class="search-input" size="small" @keyup.enter.native="search"
v-model="condition.name"/> v-model="condition.name"/>
<el-table v-loading="result.loading" <el-table v-loading="result.loading"
@ -33,13 +34,13 @@
sortable="custom"/> sortable="custom"/>
<el-table-column prop="name" :label="$t('api_test.definition.api_name')" <el-table-column prop="name" :label="$t('api_test.definition.api_name')"
show-overflow-tooltip show-overflow-tooltip
sortable="custom"/> sortable="custom" min-width="120px"/>
<el-table-column <el-table-column
prop="status" prop="status"
column-key="status" column-key="status"
sortable="custom" sortable="custom"
:filters="statusFilters" :filters="statusFilters"
:label="$t('api_test.definition.api_status')"> :label="$t('api_test.definition.api_status')" min-width="120px">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span class="el-dropdown-link"> <span class="el-dropdown-link">
<api-status :value="scope.row.status"/> <api-status :value="scope.row.status"/>
@ -53,7 +54,7 @@
column-key="method" column-key="method"
:filters="methodFilters" :filters="methodFilters"
:label="$t('api_test.definition.api_type')" :label="$t('api_test.definition.api_type')"
show-overflow-tooltip> show-overflow-tooltip min-width="120px">
<template v-slot:default="scope" class="request-method"> <template v-slot:default="scope" class="request-method">
<el-tag size="mini" :style="{'background-color': getColor(true, scope.row.method), border: getColor(true, scope.row.method)}" <el-tag size="mini" :style="{'background-color': getColor(true, scope.row.method), border: getColor(true, scope.row.method)}"
class="api-el-tag"> class="api-el-tag">
@ -62,17 +63,17 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column
prop="path"
:label="$t('api_test.definition.api_path')"
show-overflow-tooltip/>
<el-table-column <el-table-column
prop="userName" prop="userName"
sortable="custom" sortable="custom"
:filters="userFilters" :filters="userFilters"
column-key="user_id" column-key="user_id"
:label="$t('api_test.definition.api_principal')" :label="$t('api_test.definition.api_principal')"
show-overflow-tooltip min-width="100px"/>
<el-table-column
prop="path"
:label="$t('api_test.definition.api_path')"
show-overflow-tooltip/> show-overflow-tooltip/>
<el-table-column prop="tags" :label="$t('commons.tag')"> <el-table-column prop="tags" :label="$t('commons.tag')">
@ -124,461 +125,469 @@
<ms-api-case-list @refresh="initTable" @showExecResult="showExecResult" :currentApi="selectApi" ref="caseList"/> <ms-api-case-list @refresh="initTable" @showExecResult="showExecResult" :currentApi="selectApi" ref="caseList"/>
<!--批量编辑--> <!--批量编辑-->
<ms-batch-edit ref="batchEdit" @batchEdit="batchEdit" :typeArr="typeArr" :value-arr="valueArr"/> <ms-batch-edit ref="batchEdit" @batchEdit="batchEdit" :typeArr="typeArr" :value-arr="valueArr"/>
<!--高级搜索-->
<ms-table-adv-search-bar :condition.sync="condition" :showLink="false" ref="searchBar" @search="search"/>
</div> </div>
</template> </template>
<script> <script>
import MsTableHeader from '../../../../common/components/MsTableHeader'; import MsTableHeader from '../../../../common/components/MsTableHeader';
import MsTableOperator from "../../../../common/components/MsTableOperator"; import MsTableOperator from "../../../../common/components/MsTableOperator";
import MsTableOperatorButton from "../../../../common/components/MsTableOperatorButton"; import MsTableOperatorButton from "../../../../common/components/MsTableOperatorButton";
import MsTableButton from "../../../../common/components/MsTableButton"; import MsTableButton from "../../../../common/components/MsTableButton";
import MsTablePagination from "../../../../common/pagination/TablePagination"; import MsTablePagination from "../../../../common/pagination/TablePagination";
import MsTag from "../../../../common/components/MsTag"; import MsTag from "../../../../common/components/MsTag";
import MsApiCaseList from "../case/ApiCaseList"; import MsApiCaseList from "../case/ApiCaseList";
import MsContainer from "../../../../common/components/MsContainer"; import MsContainer from "../../../../common/components/MsContainer";
import MsBottomContainer from "../BottomContainer"; import MsBottomContainer from "../BottomContainer";
import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn"; import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn";
import MsBatchEdit from "../basis/BatchEdit"; import MsBatchEdit from "../basis/BatchEdit";
import {API_METHOD_COLOUR, API_STATUS, REQ_METHOD} from "../../model/JsonData"; import {API_METHOD_COLOUR, API_STATUS, REQ_METHOD} from "../../model/JsonData";
import {_filter, _sort, getCurrentProjectID} from "@/common/js/utils"; import {_filter, _sort, getCurrentProjectID} from "@/common/js/utils";
import {WORKSPACE_ID} from '@/common/js/constants'; import {WORKSPACE_ID} from '@/common/js/constants';
import ApiListContainer from "./ApiListContainer"; import ApiListContainer from "./ApiListContainer";
import MsTableSelectAll from "../../../../common/components/table/MsTableSelectAll"; import MsTableSelectAll from "../../../../common/components/table/MsTableSelectAll";
import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus"; import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus";
import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar";
import {API_DEFINITION_CONFIGS} from "@/business/components/common/components/search/search-components";
export default { export default {
name: "ApiList", name: "ApiList",
components: { components: {
ApiStatus, ApiStatus,
MsTableSelectAll, MsTableSelectAll,
ApiListContainer, ApiListContainer,
MsTableButton, MsTableButton,
MsTableOperatorButton, MsTableOperatorButton,
MsTableOperator, MsTableOperator,
MsTableHeader, MsTableHeader,
MsTablePagination, MsTablePagination,
MsTag, MsTag,
MsApiCaseList, MsApiCaseList,
MsContainer, MsContainer,
MsBottomContainer, MsBottomContainer,
ShowMoreBtn, ShowMoreBtn,
MsBatchEdit MsBatchEdit,
}, MsTableAdvSearchBar
data() { },
return { data() {
condition: {}, return {
selectApi: {}, condition: {
result: {}, components: API_DEFINITION_CONFIGS
moduleId: "", },
selectDataRange: "all", selectApi: {},
deletePath: "/test/case/delete", result: {},
selectRows: new Set(), moduleId: "",
buttons: [ selectDataRange: "all",
{name: this.$t('api_test.definition.request.batch_delete'), handleClick: this.handleDeleteBatch}, deletePath: "/test/case/delete",
{name: this.$t('api_test.definition.request.batch_edit'), handleClick: this.handleEditBatch} selectRows: new Set(),
], buttons: [
typeArr: [ {name: this.$t('api_test.definition.request.batch_delete'), handleClick: this.handleDeleteBatch},
{id: 'status', name: this.$t('api_test.definition.api_status')}, {name: this.$t('api_test.definition.request.batch_edit'), handleClick: this.handleEditBatch}
{id: 'method', name: this.$t('api_test.definition.api_type')}, ],
{id: 'userId', name: this.$t('api_test.definition.api_principal')}, typeArr: [
], {id: 'status', name: this.$t('api_test.definition.api_status')},
statusFilters: [ {id: 'method', name: this.$t('api_test.definition.api_type')},
{text: this.$t('test_track.plan.plan_status_prepare'), value: 'Prepare'}, {id: 'userId', name: this.$t('api_test.definition.api_principal')},
{text: this.$t('test_track.plan.plan_status_running'), value: 'Underway'}, ],
{text: this.$t('test_track.plan.plan_status_completed'), value: 'Completed'}, statusFilters: [
{text: this.$t('test_track.plan.plan_status_trash'), value: 'Trash'}, {text: this.$t('test_track.plan.plan_status_prepare'), value: 'Prepare'},
], {text: this.$t('test_track.plan.plan_status_running'), value: 'Underway'},
methodFilters: [ {text: this.$t('test_track.plan.plan_status_completed'), value: 'Completed'},
{text: 'GET', value: 'GET'}, {text: this.$t('test_track.plan.plan_status_trash'), value: 'Trash'},
{text: 'POST', value: 'POST'}, ],
{text: 'PUT', value: 'PUT'}, methodFilters: [
{text: 'PATCH', value: 'PATCH'}, {text: 'GET', value: 'GET'},
{text: 'DELETE', value: 'DELETE'}, {text: 'POST', value: 'POST'},
{text: 'OPTIONS', value: 'OPTIONS'}, {text: 'PUT', value: 'PUT'},
{text: 'HEAD', value: 'HEAD'}, {text: 'PATCH', value: 'PATCH'},
{text: 'CONNECT', value: 'CONNECT'}, {text: 'DELETE', value: 'DELETE'},
{text: 'DUBBO', value: 'DUBBO'}, {text: 'OPTIONS', value: 'OPTIONS'},
{text: 'dubbo://', value: 'dubbo://'}, {text: 'HEAD', value: 'HEAD'},
{text: 'SQL', value: 'SQL'}, {text: 'CONNECT', value: 'CONNECT'},
{text: 'TCP', value: 'TCP'}, {text: 'DUBBO', value: 'DUBBO'},
], {text: 'dubbo://', value: 'dubbo://'},
userFilters: [], {text: 'SQL', value: 'SQL'},
valueArr: { {text: 'TCP', value: 'TCP'},
status: API_STATUS, ],
method: REQ_METHOD, userFilters: [],
userId: [], valueArr: {
status: API_STATUS,
method: REQ_METHOD,
userId: [],
},
methodColorMap: new Map(API_METHOD_COLOUR),
tableData: [],
currentPage: 1,
pageSize: 10,
total: 0,
screenHeight: document.documentElement.clientHeight - 330,//,
environmentId: undefined,
selectAll: false,
unSelection: [],
selectDataCounts: 0,
}
},
props: {
currentProtocol: String,
selectNodeIds: Array,
isSelectThisWeek: String,
visible: {
type: Boolean,
default: false,
},
isCaseRelevance: {
type: Boolean,
default: false,
},
trashEnable: {
type: Boolean,
default: false,
},
isApiListEnable: Boolean,
isReadOnly: {
type: Boolean,
default: false
}, },
methodColorMap: new Map(API_METHOD_COLOUR),
tableData: [],
currentPage: 1,
pageSize: 10,
total: 0,
screenHeight: document.documentElement.clientHeight - 330,//,
environmentId: undefined,
selectAll: false,
unSelection: [],
selectDataCounts: 0,
}
},
props: {
currentProtocol: String,
selectNodeIds: Array,
isSelectThisWeek: String,
visible: {
type: Boolean,
default: false,
}, },
isCaseRelevance: { created: function () {
type: Boolean, this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
default: false,
},
trashEnable: {
type: Boolean,
default: false,
},
isApiListEnable: Boolean,
isReadOnly: {
type: Boolean,
default: false
},
},
created: function () {
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
this.initTable();
this.getMaintainerOptions();
},
watch: {
selectNodeIds() {
this.initTable(); this.initTable();
this.getMaintainerOptions();
}, },
currentProtocol() { watch: {
this.initTable(); selectNodeIds() {
}, this.initTable();
trashEnable() { },
if (this.trashEnable) { currentProtocol() {
this.condition.filters = {status: ["Trash"]}; this.initTable();
this.condition.moduleIds = []; },
} else { trashEnable() {
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]}; if (this.trashEnable) {
} this.condition.filters = {status: ["Trash"]};
this.initTable(); this.condition.moduleIds = [];
}
},
methods: {
isApiListEnableChange(data) {
this.$emit('isApiListEnableChange', data);
},
initTable() {
this.selectRows = new Set();
this.selectAll = false;
this.unSelection = [];
this.selectDataCounts = 0;
this.condition.moduleIds = this.selectNodeIds;
this.condition.projectId = getCurrentProjectID();
if (this.currentProtocol != null) {
this.condition.protocol = this.currentProtocol;
}
//
this.getSelectDataRange();
this.condition.selectThisWeedData = false;
this.condition.apiCaseCoverage = null;
switch (this.selectDataRange) {
case 'thisWeekCount':
this.condition.selectThisWeedData = true;
break;
case 'uncoverage':
this.condition.apiCaseCoverage = 'uncoverage';
break;
case 'coverage':
this.condition.apiCaseCoverage = 'coverage';
break;
}
if (this.condition.projectId) {
this.result = this.$post("/api/definition/list/" + this.currentPage + "/" + this.pageSize, this.condition, response => {
this.total = response.data.itemCount;
this.tableData = response.data.listObject;
this.unSelection = response.data.listObject.map(s => s.id);
this.tableData.forEach(item => {
if (item.tags && item.tags.length > 0) {
item.tags = JSON.parse(item.tags);
}
})
});
}
},
getMaintainerOptions() {
let workspaceId = localStorage.getItem(WORKSPACE_ID);
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
this.valueArr.userId = response.data;
this.userFilters = response.data.map(u => {
return {text: u.name, value: u.id}
});
});
},
handleSelect(selection, row) {
row.hashTree = [];
if (this.selectRows.has(row)) {
this.$set(row, "showMore", false);
this.selectRows.delete(row);
} else {
this.$set(row, "showMore", true);
this.selectRows.add(row);
}
let arr = Array.from(this.selectRows);
// 1
if (this.selectRows.size === 1) {
this.$set(arr[0], "showMore", true);
} else if (this.selectRows.size === 2) {
arr.forEach(row => {
this.$set(row, "showMore", true);
})
}
this.selectRowsCount(this.selectRows)
},
handleSelectAll(selection) {
if (selection.length > 0) {
if (selection.length === 1) {
selection.hashTree = [];
this.selectRows.add(selection[0]);
} else { } else {
this.tableData.forEach(item => { this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
item.hashTree = []; }
this.$set(item, "showMore", true); this.initTable();
this.selectRows.add(item); }
},
methods: {
isApiListEnableChange(data) {
this.$emit('isApiListEnableChange', data);
},
initTable() {
this.selectRows = new Set();
this.selectAll = false;
this.unSelection = [];
this.selectDataCounts = 0;
this.condition.moduleIds = this.selectNodeIds;
this.condition.projectId = getCurrentProjectID();
if (this.currentProtocol != null) {
this.condition.protocol = this.currentProtocol;
}
//
this.getSelectDataRange();
this.condition.selectThisWeedData = false;
this.condition.apiCaseCoverage = null;
switch (this.selectDataRange) {
case 'thisWeekCount':
this.condition.selectThisWeedData = true;
break;
case 'uncoverage':
this.condition.apiCaseCoverage = 'uncoverage';
break;
case 'coverage':
this.condition.apiCaseCoverage = 'coverage';
break;
}
if (this.condition.projectId) {
this.result = this.$post("/api/definition/list/" + this.currentPage + "/" + this.pageSize, this.condition, response => {
this.total = response.data.itemCount;
this.tableData = response.data.listObject;
this.unSelection = response.data.listObject.map(s => s.id);
this.tableData.forEach(item => {
if (item.tags && item.tags.length > 0) {
item.tags = JSON.parse(item.tags);
}
})
}); });
} }
} else { },
this.selectRows.clear(); getMaintainerOptions() {
this.tableData.forEach(row => { let workspaceId = localStorage.getItem(WORKSPACE_ID);
this.$set(row, "showMore", false); this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
}) this.valueArr.userId = response.data;
} this.userFilters = response.data.map(u => {
this.selectRowsCount(this.selectRows) return {text: u.name, value: u.id}
}, });
search() {
this.changeSelectDataRangeAll();
this.initTable();
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
editApi(row) {
this.$emit('editApi', row);
},
reductionApi(row) {
let tmp = JSON.parse(JSON.stringify(row));
tmp.request = null;
tmp.response = null;
if (tmp.tags instanceof Array) {
tmp.tags = JSON.stringify(tmp.tags);
}
let rows = [tmp];
this.$post('/api/definition/reduction/', rows, () => {
this.$success(this.$t('commons.save_success'));
this.search();
});
},
handleDeleteBatch() {
if (this.trashEnable) {
this.$alert(this.$t('api_test.definition.request.delete_confirm') + "", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
let deleteParam = {};
let ids = Array.from(this.selectRows).map(row => row.id);
deleteParam.dataIds = ids;
deleteParam.projectId = getCurrentProjectID();
deleteParam.selectAllDate = this.isSelectAllDate;
deleteParam.unSelectIds = this.unSelection;
deleteParam = Object.assign(deleteParam, this.condition);
this.$post('/api/definition/deleteBatchByParams/', deleteParam, () => {
this.selectRows.clear();
this.initTable();
this.$success(this.$t('commons.delete_success'));
});
}
}
}); });
} else { },
this.$alert(this.$t('api_test.definition.request.delete_confirm') + "", '', { handleSelect(selection, row) {
row.hashTree = [];
if (this.selectRows.has(row)) {
this.$set(row, "showMore", false);
this.selectRows.delete(row);
} else {
this.$set(row, "showMore", true);
this.selectRows.add(row);
}
let arr = Array.from(this.selectRows);
// 1
if (this.selectRows.size === 1) {
this.$set(arr[0], "showMore", true);
} else if (this.selectRows.size === 2) {
arr.forEach(row => {
this.$set(row, "showMore", true);
})
}
this.selectRowsCount(this.selectRows)
},
handleSelectAll(selection) {
if (selection.length > 0) {
if (selection.length === 1) {
selection.hashTree = [];
this.selectRows.add(selection[0]);
} else {
this.tableData.forEach(item => {
item.hashTree = [];
this.$set(item, "showMore", true);
this.selectRows.add(item);
});
}
} else {
this.selectRows.clear();
this.tableData.forEach(row => {
this.$set(row, "showMore", false);
})
}
this.selectRowsCount(this.selectRows)
},
search() {
this.changeSelectDataRangeAll();
this.initTable();
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
editApi(row) {
this.$emit('editApi', row);
},
reductionApi(row) {
let tmp = JSON.parse(JSON.stringify(row));
tmp.request = null;
tmp.response = null;
if (tmp.tags instanceof Array) {
tmp.tags = JSON.stringify(tmp.tags);
}
let rows = [tmp];
this.$post('/api/definition/reduction/', rows, () => {
this.$success(this.$t('commons.save_success'));
this.search();
});
},
handleDeleteBatch() {
if (this.trashEnable) {
this.$alert(this.$t('api_test.definition.request.delete_confirm') + "", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
let deleteParam = {};
let ids = Array.from(this.selectRows).map(row => row.id);
deleteParam.dataIds = ids;
deleteParam.projectId = getCurrentProjectID();
deleteParam.selectAllDate = this.isSelectAllDate;
deleteParam.unSelectIds = this.unSelection;
deleteParam = Object.assign(deleteParam, this.condition);
this.$post('/api/definition/deleteBatchByParams/', deleteParam, () => {
this.selectRows.clear();
this.initTable();
this.$success(this.$t('commons.delete_success'));
});
}
}
});
} else {
this.$alert(this.$t('api_test.definition.request.delete_confirm') + "", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
let ids = Array.from(this.selectRows).map(row => row.id);
let deleteParam = {};
deleteParam.dataIds = ids;
deleteParam.projectId = getCurrentProjectID();
deleteParam.selectAllDate = this.isSelectAllDate;
deleteParam.unSelectIds = this.unSelection;
deleteParam = Object.assign(deleteParam, this.condition);
this.$post('/api/definition/removeToGcByParams/', deleteParam, () => {
this.selectRows.clear();
this.initTable();
this.$success(this.$t('commons.delete_success'));
this.$refs.caseList.apiCaseClose();
});
}
}
});
}
},
handleEditBatch() {
this.$refs.batchEdit.open();
},
batchEdit(form) {
let arr = Array.from(this.selectRows);
let ids = arr.map(row => row.id);
let param = {};
param[form.type] = form.value;
param.ids = ids;
param.projectId = getCurrentProjectID();
param.selectAllDate = this.isSelectAllDate;
param.unSelectIds = this.unSelection;
param = Object.assign(param, this.condition);
this.$post('/api/definition/batch/editByParams', param, () => {
this.$success(this.$t('commons.save_success'));
this.initTable();
});
},
handleTestCase(api) {
this.selectApi = api;
let request = {};
if (Object.prototype.toString.call(api.request).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') {
request = api.request;
} else {
request = JSON.parse(api.request);
}
if (!request.hashTree) {
request.hashTree = [];
}
this.selectApi.url = request.path;
this.$refs.caseList.open(this.selectApi);
},
handleDelete(api) {
if (this.trashEnable) {
this.$get('/api/definition/delete/' + api.id, () => {
this.$success(this.$t('commons.delete_success'));
this.initTable();
});
return;
}
this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + api.name + " ", '', {
confirmButtonText: this.$t('commons.confirm'), confirmButtonText: this.$t('commons.confirm'),
callback: (action) => { callback: (action) => {
if (action === 'confirm') { if (action === 'confirm') {
let ids = Array.from(this.selectRows).map(row => row.id); let ids = [api.id];
let deleteParam = {}; this.$post('/api/definition/removeToGc/', ids, () => {
deleteParam.dataIds = ids;
deleteParam.projectId = getCurrentProjectID();
deleteParam.selectAllDate = this.isSelectAllDate;
deleteParam.unSelectIds = this.unSelection;
deleteParam = Object.assign(deleteParam, this.condition);
this.$post('/api/definition/removeToGcByParams/', deleteParam, () => {
this.selectRows.clear();
this.initTable();
this.$success(this.$t('commons.delete_success')); this.$success(this.$t('commons.delete_success'));
this.initTable();
this.$refs.caseList.apiCaseClose(); this.$refs.caseList.apiCaseClose();
}); });
} }
} }
}); });
} },
}, getColor(enable, method) {
handleEditBatch() { if (enable) {
this.$refs.batchEdit.open(); return this.methodColorMap.get(method);
},
batchEdit(form) {
let arr = Array.from(this.selectRows);
let ids = arr.map(row => row.id);
let param = {};
param[form.type] = form.value;
param.ids = ids;
param.projectId = getCurrentProjectID();
param.selectAllDate = this.isSelectAllDate;
param.unSelectIds = this.unSelection;
param = Object.assign(param, this.condition);
this.$post('/api/definition/batch/editByParams', param, () => {
this.$success(this.$t('commons.save_success'));
this.initTable();
});
},
handleTestCase(api) {
this.selectApi = api;
let request = {};
if (Object.prototype.toString.call(api.request).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') {
request = api.request;
} else {
request = JSON.parse(api.request);
}
if (!request.hashTree) {
request.hashTree = [];
}
this.selectApi.url = request.path;
this.$refs.caseList.open(this.selectApi);
},
handleDelete(api) {
if (this.trashEnable) {
this.$get('/api/definition/delete/' + api.id, () => {
this.$success(this.$t('commons.delete_success'));
this.initTable();
});
return;
}
this.$alert(this.$t('api_test.definition.request.delete_confirm') + ' ' + api.name + " ", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
let ids = [api.id];
this.$post('/api/definition/removeToGc/', ids, () => {
this.$success(this.$t('commons.delete_success'));
this.initTable();
this.$refs.caseList.apiCaseClose();
});
}
} }
}); },
}, showExecResult(row) {
getColor(enable, method) { this.$emit('showExecResult', row);
if (enable) { },
return this.methodColorMap.get(method); selectRowsCount(selection) {
let selectedIDs = this.getIds(selection);
let allIDs = this.tableData.map(s => s.id);
this.unSelection = allIDs.filter(function (val) {
return selectedIDs.indexOf(val) === -1
});
if (this.isSelectAllDate) {
this.selectDataCounts = this.total - this.unSelection.length;
} else {
this.selectDataCounts = selection.size;
}
},
isSelectDataAll(dataType) {
this.isSelectAllDate = dataType;
this.selectRowsCount(this.selectRows)
//
if (this.selectRows.size != this.tableData.length) {
this.$refs.apiDefinitionTable.toggleAllSelection(true);
}
},
//
getSelectDataRange() {
let dataRange = this.$route.params.dataSelectRange;
let dataType = this.$route.params.dataType;
if (dataType === 'api') {
this.selectDataRange = dataRange;
} else {
this.selectDataRange = 'all';
}
},
changeSelectDataRangeAll() {
this.$emit("changeSelectDataRangeAll", "api");
},
getIds(rowSets) {
let rowArray = Array.from(rowSets)
let ids = rowArray.map(s => s.id);
return ids;
},
sort(column) {
//
if (this.condition.orders) {
this.condition.orders = [];
}
_sort(column, this.condition);
this.initTable();
},
filter(filters) {
_filter(filters, this.condition);
this.initTable();
},
open() {
this.$refs.searchBar.open();
} }
}, },
showExecResult(row) { }
this.$emit('showExecResult', row);
},
selectRowsCount(selection) {
let selectedIDs = this.getIds(selection);
let allIDs = this.tableData.map(s => s.id);
this.unSelection = allIDs.filter(function (val) {
return selectedIDs.indexOf(val) === -1
});
if (this.isSelectAllDate) {
this.selectDataCounts = this.total - this.unSelection.length;
} else {
this.selectDataCounts = selection.size;
}
},
isSelectDataAll(dataType) {
this.isSelectAllDate = dataType;
this.selectRowsCount(this.selectRows)
//
if (this.selectRows.size != this.tableData.length) {
this.$refs.apiDefinitionTable.toggleAllSelection(true);
}
},
//
getSelectDataRange() {
let dataRange = this.$route.params.dataSelectRange;
let dataType = this.$route.params.dataType;
if (dataType === 'api') {
this.selectDataRange = dataRange;
} else {
this.selectDataRange = 'all';
}
},
changeSelectDataRangeAll() {
this.$emit("changeSelectDataRangeAll", "api");
},
getIds(rowSets) {
let rowArray = Array.from(rowSets)
let ids = rowArray.map(s => s.id);
return ids;
},
sort(column) {
//
if (this.condition.orders) {
this.condition.orders = [];
}
_sort(column, this.condition);
this.initTable();
},
filter(filters) {
_filter(filters, this.condition);
this.initTable();
},
},
}
</script> </script>
<style scoped> <style scoped>
.operate-button > div { .operate-button > div {
display: inline-block; display: inline-block;
margin-left: 10px; margin-left: 10px;
} }
.request-method { .request-method {
padding: 0 5px; padding: 0 5px;
color: #1E90FF; color: #1E90FF;
} }
.api-el-tag { .api-el-tag {
color: white; color: white;
} }
.search-input { .search-input {
float: right; float: right;
width: 300px; width: 300px;
margin-right: 20px; margin-right: 10px;
} }
.el-tag { .el-tag {
margin-left: 10px; margin-left: 10px;
} }
.ms-select-all >>> th:first-child { .ms-select-all >>> th:first-child {
margin-top: 20px; margin-top: 20px;
} }
.ms-select-all >>> th:nth-child(2) .el-icon-arrow-down { .ms-select-all >>> th:nth-child(2) .el-icon-arrow-down {
top: -2px; top: -2px;
} }
</style> </style>

View File

@ -6,6 +6,15 @@ export const PRIORITY = [
{name: 'P3', id: 'P3'} {name: 'P3', id: 'P3'}
] ]
export const CASE_ORDER = [
{label: 'api_test.definition.request.grade_order_asc', name: 'priority', type: 'desc', id: 'grade_order_asc'},
{label: 'api_test.definition.request.grade_order_desc', name: 'priority', type: 'asc', id: 'grade_order_desc'},
{label: 'api_test.definition.request.create_time_order_asc', name: 'create_time', type: 'asc', id: 'create_time_order_asc'},
{label: 'api_test.definition.request.create_time_order_desc', name: 'create_time', type: 'desc', id: 'create_time_order_desc'},
{label: 'api_test.definition.request.update_time_order_asc', name: 'update_time', type: 'asc', id: 'update_time_order_asc'},
{label: 'api_test.definition.request.update_time_order_desc', name: 'update_time', type: 'desc', id: 'update_time_order_desc'}
]
export const OPTIONS = [ export const OPTIONS = [
{value: 'HTTP', name: 'HTTP'}, {value: 'HTTP', name: 'HTTP'},
{value: 'TCP', name: 'TCP'}, {value: 'TCP', name: 'TCP'},

View File

@ -1,6 +1,6 @@
<template> <template>
<span class="adv-search-bar"> <span class="adv-search-bar">
<el-link type="primary" @click="open">{{$t('commons.adv_search.title')}}</el-link> <el-link type="primary" @click="open" v-if="showLink">{{$t('commons.adv_search.title')}}</el-link>
<el-dialog :title="$t('commons.adv_search.combine')" :visible.sync="visible" custom-class="adv-dialog" <el-dialog :title="$t('commons.adv_search.combine')" :visible.sync="visible" custom-class="adv-dialog"
:append-to-body="true"> :append-to-body="true">
<div> <div>
@ -28,6 +28,10 @@
name: "MsTableAdvSearchBar", name: "MsTableAdvSearchBar",
props: { props: {
condition: Object, condition: Object,
showLink: {
type: Boolean,
default: true,
}
}, },
data() { data() {
return { return {

View File

@ -115,6 +115,101 @@ export const STATUS = {
} }
} }
export const API_STATUS = {
key: "status",
name: 'MsTableSearchSelect',
label: 'commons.status',
operator: {
options: [OPERATORS.IN, OPERATORS.NOT_IN]
},
options: [
{value: 'Prepare', label: '未开始'},
{value: 'Underway', label: '进行中'},
{value: 'Completed', label: '已完成'}
],
props: { // 尾部控件的props一般为element ui控件的props
multiple: true
}
}
export const API_CASE_PRIORITY = {
key: "priority",
name: 'MsTableSearchSelect',
label: 'test_track.case.priority',
operator: {
options: [OPERATORS.IN, OPERATORS.NOT_IN]
},
options: [
{value: 'P0', label: 'P0'},
{value: 'P1', label: 'P1'},
{value: 'P2', label: 'P2'},
{value: 'P3', label: 'P3'}
],
props: { // 尾部控件的props一般为element ui控件的props
multiple: true
}
}
export const API_CASE_RESULT = {
key: "status",
name: 'MsTableSearchSelect',
label: 'test_track.plan_view.execute_result',
operator: {
options: [OPERATORS.IN, OPERATORS.NOT_IN]
},
options: [
{value: 'success', label: 'api_test.automation.success'},
{value: 'error', label: 'api_test.automation.fail'}
],
props: { // 尾部控件的props一般为element ui控件的props
multiple: true
}
}
export const API_METHOD = {
key: "method",
name: 'MsTableSearchSelect',
label: 'api_test.definition.api_type',
operator: {
options: [OPERATORS.IN, OPERATORS.NOT_IN]
},
options: [
{value: 'GET', label: 'GET'},
{value: 'POST', label: 'POST'},
{value: 'PUT', label: 'PUT'},
{value: 'PATCH', label: 'PATCH'},
{value: 'DELETE', label: 'DELETE'},
{value: 'OPTIONS', label: 'OPTIONS'},
{value: 'HEAD', label: 'HEAD'},
{value: 'CONNECT', label: 'CONNECT'},
{value: 'DUBBO', label: 'DUBBO'},
{value: 'dubbo://', label: 'dubbo://'},
{value: 'SQL', label: 'SQL'},
{value: 'TCP', label: 'TCP'}
],
props: { // 尾部控件的props一般为element ui控件的props
multiple: true
}
}
export const API_PATH = {
key: "path", // 返回结果Map的key
name: 'MsTableSearchInput', // Vue控件名称
label: 'api_test.definition.api_path', // 显示名称
operator: { // 运算符设置
value: OPERATORS.LIKE.value, // 如果未设置value初始值则value初始值为options[0]
options: [OPERATORS.LIKE, OPERATORS.NOT_LIKE] // 运算符候选项
},
}
export const API_TAGS = {
key: "tags", // 返回结果Map的key
name: 'MsTableSearchInput', // Vue控件名称
label: 'commons.tag', // 显示名称
operator: { // 运算符设置
value: OPERATORS.LIKE.value, // 如果未设置value初始值则value初始值为options[0]
options: [OPERATORS.LIKE, OPERATORS.NOT_LIKE] // 运算符候选项
},
}
export const CREATOR = { export const CREATOR = {
key: "creator", key: "creator",
name: 'MsTableSearchSelect', name: 'MsTableSearchSelect',
@ -311,10 +406,14 @@ export const TEST_PLAN_STATUS = {
} }
}; };
export const TEST_CONFIGS = [NAME, UPDATE_TIME, PROJECT_NAME, CREATE_TIME, STATUS, CREATOR]; export const TEST_CONFIGS = [NAME, UPDATE_TIME, CREATE_TIME, STATUS, CREATOR];
export const REPORT_CONFIGS = [NAME, TEST_NAME, PROJECT_NAME, CREATE_TIME, STATUS, CREATOR, TRIGGER_MODE]; export const REPORT_CONFIGS = [NAME, TEST_NAME, CREATE_TIME, STATUS, CREATOR, TRIGGER_MODE];
export const TEST_CASE_CONFIGS = [NAME, MODULE, PRIORITY, CREATE_TIME, TYPE, UPDATE_TIME, METHOD, CREATOR, EXECUTOR]; export const TEST_CASE_CONFIGS = [NAME, API_TAGS, MODULE, PRIORITY, CREATE_TIME, TYPE, UPDATE_TIME, METHOD, CREATOR, EXECUTOR];
export const TEST_PLAN_CONFIGS = [NAME, UPDATE_TIME, PROJECT_NAME, CREATE_TIME, PRINCIPAL, TEST_PLAN_STATUS, STAGE]; export const TEST_PLAN_CONFIGS = [NAME, UPDATE_TIME, CREATE_TIME, PRINCIPAL, TEST_PLAN_STATUS, STAGE];
export const API_DEFINITION_CONFIGS = [NAME, API_METHOD, API_PATH, API_STATUS, API_TAGS, UPDATE_TIME, CREATE_TIME, CREATOR];
export const API_CASE_CONFIGS = [NAME, API_CASE_PRIORITY, API_TAGS, API_CASE_RESULT, UPDATE_TIME, CREATE_TIME, CREATOR];

View File

@ -499,6 +499,7 @@ export default {
} else { } else {
this.maxUsers = '0'; this.maxUsers = '0';
this.avgThroughput = '0'; this.avgThroughput = '0';
this.avgTransactions = '0';
this.errors = '0'; this.errors = '0';
this.avgResponseTime = '0'; this.avgResponseTime = '0';
this.responseTime90 = '0'; this.responseTime90 = '0';

View File

@ -27,6 +27,9 @@
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="userName" prop="userName"
sortable="custom"
:filters="userFilters"
column-key="user_id"
:label="$t('load_test.user_name')" :label="$t('load_test.user_name')"
width="150" width="150"
show-overflow-tooltip> show-overflow-tooltip>
@ -80,11 +83,11 @@ import MsContainer from "../../common/components/MsContainer";
import MsMainContainer from "../../common/components/MsMainContainer"; import MsMainContainer from "../../common/components/MsMainContainer";
import MsPerformanceTestStatus from "./PerformanceTestStatus"; import MsPerformanceTestStatus from "./PerformanceTestStatus";
import MsTableOperators from "../../common/components/MsTableOperators"; import MsTableOperators from "../../common/components/MsTableOperators";
import {_filter, _sort} from "@/common/js/utils"; import {_filter, _sort, getCurrentProjectID} from "@/common/js/utils";
import MsTableHeader from "../../common/components/MsTableHeader"; import MsTableHeader from "../../common/components/MsTableHeader";
import {TEST_CONFIGS} from "../../common/components/search/search-components"; import {TEST_CONFIGS} from "../../common/components/search/search-components";
import {LIST_CHANGE, PerformanceEvent} from "@/business/components/common/head/ListEvent"; import {LIST_CHANGE, PerformanceEvent} from "@/business/components/common/head/ListEvent";
import {getCurrentProjectID} from "../../../../common/js/utils"; import {WORKSPACE_ID} from "@/common/js/constants";
export default { export default {
components: { components: {
@ -131,7 +134,8 @@ export default {
{text: 'Reporting', value: 'Reporting'}, {text: 'Reporting', value: 'Reporting'},
{text: 'Completed', value: 'Completed'}, {text: 'Completed', value: 'Completed'},
{text: 'Error', value: 'Error'} {text: 'Error', value: 'Error'}
] ],
userFilters: [],
} }
}, },
watch: { watch: {
@ -143,8 +147,17 @@ export default {
created: function () { created: function () {
this.projectId = this.$route.params.projectId; this.projectId = this.$route.params.projectId;
this.initTableData(); this.initTableData();
this.getMaintainerOptions();
}, },
methods: { methods: {
getMaintainerOptions() {
let workspaceId = localStorage.getItem(WORKSPACE_ID);
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
this.userFilters = response.data.map(u => {
return {text: u.name, value: u.id}
});
});
},
initTableData() { initTableData() {
if (this.projectId !== 'all') { if (this.projectId !== 'all') {
this.condition.projectId = this.projectId; this.condition.projectId = this.projectId;

View File

@ -48,14 +48,14 @@
<span>{{ scope.row.createTime | timestampFormatDate }}</span> <span>{{ scope.row.createTime | timestampFormatDate }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <!-- <el-table-column-->
sortable <!-- sortable-->
prop="updateTime" <!-- prop="updateTime"-->
:label="$t('commons.update_time')"> <!-- :label="$t('commons.update_time')">-->
<template v-slot:default="scope"> <!-- <template v-slot:default="scope">-->
<span>{{ scope.row.updateTime | timestampFormatDate }}</span> <!-- <span>{{ scope.row.updateTime | timestampFormatDate }}</span>-->
</template> <!-- </template>-->
</el-table-column> <!-- </el-table-column>-->
<el-table-column <el-table-column
prop="status" prop="status"
column-key="status" column-key="status"
@ -67,7 +67,7 @@
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="caseStatus" prop="caseStatus"
label="执行状态"> :label="$t('test_track.plan.load_case.execution_status')">
<template v-slot:default="{row}"> <template v-slot:default="{row}">
<el-tag size="mini" type="danger" v-if="row.caseStatus === 'error'"> <el-tag size="mini" type="danger" v-if="row.caseStatus === 'error'">
{{ row.caseStatus }} {{ row.caseStatus }}
@ -79,11 +79,11 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
label="报告" :label="$t('test_track.plan.load_case.report')"
show-overflow-tooltip> show-overflow-tooltip>
<template v-slot:default="scope"> <template v-slot:default="scope">
<div v-loading="loading === scope.row.id"> <div v-loading="loading === scope.row.id">
<el-link type="info" @click="getReport(scope.row)" v-if="scope.row.loadReportId">查看报告</el-link> <el-link type="info" @click="getReport(scope.row)" v-if="scope.row.loadReportId">{{ $t('test_track.plan.load_case.view_report') }}</el-link>
<span v-else> - </span> <span v-else> - </span>
</div> </div>
</template> </template>
@ -141,10 +141,10 @@ export default {
// name: "", handleClick: this.handleBatchEdit // name: "", handleClick: this.handleBatchEdit
// }, // },
{ {
name: "批量取消关联", handleClick: this.handleDeleteBatch name: this.$t('test_track.plan.load_case.unlink_in_bulk'), handleClick: this.handleDeleteBatch
}, },
{ {
name: "批量执行用例", handleClick: this.handleRunBatch name: this.$t('test_track.plan.load_case.batch_exec_cases'), handleClick: this.handleRunBatch
} }
], ],
statusFilters: [ statusFilters: [
@ -200,7 +200,6 @@ export default {
if (arr.length > 0) { if (arr.length > 0) {
this.initTable(); this.initTable();
} else { } else {
setTimeout(this.initTable, 3000);
clearInterval(this.refreshScheduler); clearInterval(this.refreshScheduler);
} }
}, 4000); }, 4000);
@ -263,7 +262,7 @@ export default {
}).then(() => { }).then(() => {
this.$notify({ this.$notify({
title: loadCase.caseName, title: loadCase.caseName,
message: '正在执行....', message: this.$t('test_track.plan.load_case.exec'),
type: 'success' type: 'success'
}); });
this.initTable(); this.initTable();
@ -274,7 +273,7 @@ export default {
}); });
this.$notify.error({ this.$notify.error({
title: loadCase.caseName, title: loadCase.caseName,
message: '用例执行错误,请单独调试该用例!' message: this.$t('test_track.plan.load_case.error')
}); });
}) })
}, },
@ -310,7 +309,7 @@ export default {
if (exist) { if (exist) {
this.$refs.loadCaseReport.drawer = true; this.$refs.loadCaseReport.drawer = true;
} else { } else {
this.$warning("报告不存在"); this.$warning(this.$t('test_track.plan.load_case.report_not_found'));
// this.initTable(); // this.initTable();
} }
}) })

@ -1 +1 @@
Subproject commit 010ad7a5f072a5e9d368c756a2473bbd20781433 Subproject commit 7d43154a7c19732407a8e9ace8a7d1ea13c91f36

View File

@ -517,6 +517,12 @@ export default {
}, },
request: { request: {
grade_info: "Filter by rank", grade_info: "Filter by rank",
grade_order_asc: "from high to low by use case level",
grade_order_desc: "from high to low by use case level,",
create_time_order_asc: "by creation time from front to back",
create_time_order_desc: "from back to front by creation time,",
update_time_order_asc: "by update time from front to back",
update_time_order_desc: "from back to front by update time,",
run_env: "Operating environment", run_env: "Operating environment",
select_case: "Search use cases", select_case: "Search use cases",
case: "Case", case: "Case",
@ -1100,6 +1106,16 @@ export default {
plan_delete_confirm: "All use cases under this plan will be deleted,confirm delete test plan: ", plan_delete_confirm: "All use cases under this plan will be deleted,confirm delete test plan: ",
plan_delete_tip: "The test plan is under way, please confirm and delete it!", plan_delete_tip: "The test plan is under way, please confirm and delete it!",
plan_delete: "Delete test plan", plan_delete: "Delete test plan",
load_case: {
execution_status: "Execution status",
report: "report",
view_report: "View report",
unlink_in_bulk: "Unlink in bulk",
batch_exec_cases: "Batch execution use cases",
exec: "Executing....",
error: "Use case execution error, please debug this use case separately!",
report_not_found: "Report does not exist",
}
}, },
review: { review: {
test_review: "Test Review", test_review: "Test Review",

View File

@ -515,6 +515,12 @@ export default {
}, },
request: { request: {
grade_info: "按等级筛选", grade_info: "按等级筛选",
grade_order_asc: "按用例等级从高到低",
grade_order_desc: "按用例等级从高到低",
create_time_order_asc: "按创建时间从前到后",
create_time_order_desc: "按创建时间从后到前",
update_time_order_asc: "按更新时间从前到后",
update_time_order_desc: "按更新时间从后到前",
run_env: "运行环境", run_env: "运行环境",
select_case: "搜索用例", select_case: "搜索用例",
case: "用例", case: "用例",
@ -1101,6 +1107,16 @@ export default {
plan_delete_confirm: "将删除该测试计划下所有用例,确认删除测试计划: ", plan_delete_confirm: "将删除该测试计划下所有用例,确认删除测试计划: ",
plan_delete_tip: "该测试计划正在进行中,请确认再删除!", plan_delete_tip: "该测试计划正在进行中,请确认再删除!",
plan_delete: "删除计划", plan_delete: "删除计划",
load_case: {
execution_status: "执行状态",
report: "报告",
view_report: "查看报告",
unlink_in_bulk: "批量取消关联",
batch_exec_cases: "批量执行用例",
exec: "正在执行....",
error: "用例执行错误,请单独调试该用例!",
report_not_found: "报告不存在",
}
}, },
review: { review: {
test_review: "用例评审", test_review: "用例评审",

View File

@ -515,6 +515,12 @@ export default {
}, },
request: { request: {
grade_info: "按等級篩選", grade_info: "按等級篩選",
grade_order_asc: "按用例等級從高到低",
grade_order_desc: "按用例等級從高到低",
create_time_order_asc: "按創建時間從前到後",
create_time_order_desc: "按創建時間從後到前",
update_time_order_asc: "按更新時間從前到後",
update_time_order_desc: "按更新時間從後到前",
run_env: "運行環境", run_env: "運行環境",
select_case: "搜索用例", select_case: "搜索用例",
case: "用例", case: "用例",
@ -1101,6 +1107,16 @@ export default {
plan_delete_confirm: "將刪除該測試計劃下所有用例,確認刪除測試計劃: ", plan_delete_confirm: "將刪除該測試計劃下所有用例,確認刪除測試計劃: ",
plan_delete_tip: "該測試計劃正在進行中,請確認再刪除!", plan_delete_tip: "該測試計劃正在進行中,請確認再刪除!",
plan_delete: "刪除計劃", plan_delete: "刪除計劃",
load_case: {
execution_status: "執行狀態",
report: "報告",
view_report: "查看報告",
unlink_in_bulk: "批量取消關聯",
batch_exec_cases: "批量執行用例",
exec: "正在執行....",
error: "用例執行錯誤,請單獨調試該用例!",
report_not_found: "報告不存在",
}
}, },
review: { review: {
test_review: "用例評審", test_review: "用例評審",