This commit is contained in:
fit2-zhao 2020-12-17 16:08:50 +08:00
commit 7a43d3d5fd
30 changed files with 884 additions and 688 deletions

View File

@ -2,9 +2,8 @@ package io.metersphere.api.controller;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.api.dto.definition.ApiTestCaseRequest;
import io.metersphere.api.dto.definition.ApiTestCaseResult;
import io.metersphere.api.dto.definition.SaveApiTestCaseRequest;
import io.metersphere.api.dto.ApiCaseBatchRequest;
import io.metersphere.api.dto.definition.*;
import io.metersphere.api.service.ApiTestCaseService;
import io.metersphere.base.domain.ApiTestCase;
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
@ -35,7 +34,7 @@ public class ApiTestCaseController {
}
@PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<ApiTestCase>> listSimple(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) {
public Pager<List<ApiTestCaseDTO>> listSimple(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
return PageUtils.setPageInfo(page, apiTestCaseService.listSimple(request));
@ -56,9 +55,24 @@ public class ApiTestCaseController {
apiTestCaseService.delete(id);
}
@PostMapping("/removeToGc")
public void removeToGc(@RequestBody List<String> ids) {
apiTestCaseService.removeToGc(ids);
}
@GetMapping("/get/{id}")
public ApiTestCaseWithBLOBs get(@PathVariable String id) {
return apiTestCaseService.get(id);
}
}
@PostMapping("/batch/edit")
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
public void editApiBath(@RequestBody ApiCaseBatchRequest request) {
apiTestCaseService.editApiBath(request);
}
@PostMapping("/deleteBatch")
public void deleteBatch(@RequestBody List<String> ids) {
apiTestCaseService.deleteBatch(ids);
}
}

View File

@ -0,0 +1,16 @@
package io.metersphere.api.dto;
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
import io.metersphere.controller.request.OrderRequest;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class ApiCaseBatchRequest extends ApiTestCaseWithBLOBs {
private List<String> ids;
private List<OrderRequest> orders;
private String projectId;
}

View File

@ -0,0 +1,15 @@
package io.metersphere.api.dto.definition;
import io.metersphere.base.domain.ApiTestCase;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ApiTestCaseDTO extends ApiTestCase {
private String moduleId;
private String path;
private String protocol;
private String updateUser;
private String createUser;
}

View File

@ -5,11 +5,11 @@ import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.Map;
@Getter
@Setter
public class ApiTestCaseRequest {
private String id;
private String projectId;
private String priority;
@ -17,6 +17,8 @@ public class ApiTestCaseRequest {
private String environmentId;
private String workspaceId;
private String apiDefinitionId;
private String status;
private List<String> moduleIds;
private List<OrderRequest> orders;
private Map<String, List<String>> filters;
}

View File

@ -1,23 +1,20 @@
package io.metersphere.api.service;
import com.alibaba.fastjson.JSONObject;
import io.metersphere.api.dto.definition.ApiDefinitionRequest;
import io.metersphere.api.dto.definition.ApiTestCaseRequest;
import io.metersphere.api.dto.definition.ApiTestCaseResult;
import io.metersphere.api.dto.definition.SaveApiTestCaseRequest;
import io.metersphere.api.dto.ApiCaseBatchRequest;
import io.metersphere.api.dto.definition.*;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.ApiTestCaseMapper;
import io.metersphere.base.mapper.ApiTestFileMapper;
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.ServiceUtils;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.commons.utils.*;
import io.metersphere.i18n.Translator;
import io.metersphere.notice.domain.UserDetail;
import io.metersphere.service.FileService;
import io.metersphere.service.QuotaService;
import io.metersphere.service.UserService;
import org.aspectj.util.FileUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -26,10 +23,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;
@Service
@ -38,6 +32,8 @@ public class ApiTestCaseService {
@Resource
private ApiTestCaseMapper apiTestCaseMapper;
@Resource
private UserService userService;
@Resource
private ExtApiTestCaseMapper extApiTestCaseMapper;
@Resource
private ApiTestFileMapper apiTestFileMapper;
@ -53,9 +49,22 @@ public class ApiTestCaseService {
return extApiTestCaseMapper.list(request);
}
public List<ApiTestCase> listSimple(ApiTestCaseRequest request) {
public List<ApiTestCaseDTO> listSimple(ApiTestCaseRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
List<ApiTestCase> apiTestCases = extApiTestCaseMapper.listSimple(request);
List<ApiTestCaseDTO> apiTestCases = extApiTestCaseMapper.listSimple(request);
if (CollectionUtils.isEmpty(apiTestCases)) {
return apiTestCases;
}
List<String> userIds = new ArrayList();
userIds.addAll(apiTestCases.stream().map(ApiTestCaseDTO::getCreateUserId).collect(Collectors.toList()));
userIds.addAll(apiTestCases.stream().map(ApiTestCaseDTO::getUpdateUserId).collect(Collectors.toList()));
if (!CollectionUtils.isEmpty(userIds)) {
Map<String, User> userMap = userService.queryNameByIds(userIds);
apiTestCases.forEach(caseResult -> {
caseResult.setCreateUser(userMap.get(caseResult.getCreateUserId()).getName());
caseResult.setUpdateUser(userMap.get(caseResult.getUpdateUserId()).getName());
});
}
return apiTestCases;
}
@ -215,4 +224,23 @@ public class ApiTestCaseService {
fileService.deleteFileByIds(fileIds);
}
}
public void removeToGc(List<String> ids) {
// todo
}
public void editApiBath(ApiCaseBatchRequest request) {
ApiTestCaseExample apiDefinitionExample = new ApiTestCaseExample();
apiDefinitionExample.createCriteria().andIdIn(request.getIds());
ApiTestCaseWithBLOBs apiDefinitionWithBLOBs = new ApiTestCaseWithBLOBs();
BeanUtils.copyBean(apiDefinitionWithBLOBs, request);
apiDefinitionWithBLOBs.setUpdateTime(System.currentTimeMillis());
apiTestCaseMapper.updateByExampleSelective(apiDefinitionWithBLOBs, apiDefinitionExample);
}
public void deleteBatch(List<String> ids) {
ApiTestCaseExample example = new ApiTestCaseExample();
example.createCriteria().andIdIn(ids);
apiTestCaseMapper.deleteByExample(example);
}
}

View File

@ -1,5 +1,6 @@
package io.metersphere.base.mapper.ext;
import io.metersphere.api.dto.definition.ApiTestCaseDTO;
import io.metersphere.api.dto.definition.ApiTestCaseRequest;
import io.metersphere.api.dto.definition.ApiTestCaseResult;
import io.metersphere.base.domain.ApiTestCase;
@ -10,5 +11,5 @@ import java.util.List;
public interface ExtApiTestCaseMapper {
List<ApiTestCaseResult> list(@Param("request") ApiTestCaseRequest request);
List<ApiTestCase> listSimple(@Param("request") ApiTestCaseRequest request);
List<ApiTestCaseDTO> listSimple(@Param("request") ApiTestCaseRequest request);
}

View File

@ -208,19 +208,54 @@
</if>
</select>
<select id="listSimple" resultType="io.metersphere.base.domain.ApiTestCase">
<select id="listSimple" resultType="io.metersphere.api.dto.definition.ApiTestCaseDTO">
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,
a.moudule_id as moudule_id,
from api_test_case c
left join api_definition a
on c.api_definition_id = a.id
where c.project_id = #{request.projectId}
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,
a.module_id, a.path, a.protocol
from
api_test_case c
inner join
api_definition a
on
c.api_definition_id = a.id
<choose>
<when test="request.status == 'Trash'">
and a.status = 'Trash'
</when>
<otherwise>
and a.status != 'Trash'
</otherwise>
</choose>
where
c.project_id = #{request.projectId}
<if test="request.name != null and request.name!=''">
and c.name like CONCAT('%', #{request.name},'%')
</if>
<if test="request.moduleIds != null and request.moduleIds.size() > 0">
AND a.module_id in
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>
</foreach>
</if>
<if test="request.orders != null and request.orders.size() > 0">
order by
<foreach collection="request.orders" separator="," item="order">
${order.name} ${order.type}
</foreach>
</if>
</select>
</mapper>

View File

@ -3,9 +3,11 @@ package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.User;
import io.metersphere.controller.request.UserRequest;
import io.metersphere.notice.domain.UserDetail;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface ExtUserMapper {
@ -19,4 +21,6 @@ public interface ExtUserMapper {
List<UserDetail> queryTypeByIds(List<String> userIds);
@MapKey("id")
Map<String, User> queryNameByIds(List<String> userIds);
}

View File

@ -62,4 +62,14 @@
select id, name, email, last_organization_id, last_workspace_id from `user` where id like CONCAT('%', #{condition},'%') or email like CONCAT('%', #{condition},'%') limit 100;
</select>
<select id="queryNameByIds" resultType="io.metersphere.base.domain.User">
select id, name
from `user`
WHERE id IN
<foreach collection="list" item="id" index="index"
open="(" close=")" separator=",">
#{id}
</foreach>
</select>
</mapper>

View File

@ -53,6 +53,7 @@ public class PerformanceTestController {
public Pager<List<LoadTestDTO>> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
request.setProjectId(SessionUtils.getCurrentProjectId());
return PageUtils.setPageInfo(page, performanceTestService.list(request));
}

View File

@ -79,7 +79,6 @@ public class PerformanceTestService {
public List<LoadTestDTO> list(QueryTestPlanRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
request.setProjectId(SessionUtils.getCurrentProjectId());
return extLoadTestMapper.list(request);
}

View File

@ -66,6 +66,10 @@ public class UserService {
return extUserMapper.queryTypeByIds(userIds);
}
public Map<String, User> queryNameByIds(List<String> userIds) {
return extUserMapper.queryNameByIds(userIds);
}
/* public List<String> queryEmailByIds(List<String> userIds) {
return extUserMapper.queryTypeByIds(userIds);
}*/

@ -1 +1 @@
Subproject commit 61397c16728a63493507679f7e0940d9099f337f
Subproject commit bb494fc68a2367359c9048fa7250c7618de4afb6

View File

@ -35,26 +35,31 @@
:name="item.name">
<!-- 列表集合 -->
<ms-api-list
v-if="item.type === 'list'"
v-if="item.type === 'list' && isApiListEnable"
:current-protocol="currentProtocol"
:visible="visible"
:currentRow="currentRow"
:select-node-ids="selectNodeIds"
:trash-enable="trashEnable"
:is-api-list-enable="isApiListEnable"
@editApi="editApi"
@handleCase="handleCase"
@showExecResult="showExecResult"
@isApiListEnableChange="isApiListEnableChange"
ref="apiList"/>
<!--测试用例列表-->
<api-case-simple-list
v-if="item.type === 'list' && !isApiListEnable"
:current-protocol="currentProtocol"
:visible="visible"
:currentRow="currentRow"
:select-node-ids="selectNodeIds"
:trash-enable="trashEnable"
:is-api-list-enable="isApiListEnable"
@isApiListEnableChange="isApiListEnableChange"
@handleCase="handleCase"
@showExecResult="showExecResult"
ref="apiList"/>
<!--<api-case-simple-list-->
<!--v-if="item.type === 'list'"-->
<!--:current-protocol="currentProtocol"-->
<!--:visible="visible"-->
<!--:currentRow="currentRow"-->
<!--:select-node-ids="selectNodeIds"-->
<!--:trash-enable="trashEnable"-->
<!--@handleCase="handleCase"-->
<!--@showExecResult="showExecResult"-->
<!--ref="apiList"/>-->
<!-- 添加/编辑测试窗口-->
<div v-else-if="item.type=== 'ADD'" class="ms-api-div">
@ -147,6 +152,7 @@
type: "list",
closable: false
}],
isApiListEnable: true
}
},
watch: {
@ -155,6 +161,9 @@
}
},
methods: {
isApiListEnableChange(data) {
this.isApiListEnable = data;
},
handleCommand(e) {
switch (e) {
case "ADD":
@ -241,7 +250,7 @@
downloadFile("导出API.json", JSON.stringify(obj));
},
refresh(data) {
this.$refs.apiList[0].initApiTable(data);
this.$refs.apiList[0].initTable(data);
},
setTabTitle(data) {
for (let index in this.apiTabs) {

View File

@ -13,12 +13,13 @@
<el-col :span="api.protocol==='HTTP'? 4:0">
<div class="variable-combine" style="margin-left: 10px">{{api.path ===null ? " " : api.path}}</div>
</el-col>
<el-col :span="2">
<el-col :span="2" v-if="!isCaseEdit">
<div>{{$t('test_track.plan_view.case_count')}}{{apiCaseList.length}}</div>
</el-col>
<el-col :span="3">
<div>
<el-select size="small" :placeholder="$t('api_test.definition.request.grade_info')" v-model="condition.priority"
:disabled="isCaseEdit"
class="ms-api-header-select" @change="getApiTest">
<el-option v-for="grd in priorities" :key="grd.id" :label="grd.name" :value="grd.id"/>
</el-select>
@ -48,25 +49,19 @@
<el-col :span="3">
<div class="ms-api-header-select">
<el-input size="small" :placeholder="$t('api_test.definition.request.select_case')"
:disabled="isCaseEdit"
v-model="condition.name" @blur="getApiTest" @keyup.enter.native="getApiTest"/>
</div>
</el-col>
<el-col :span="2">
<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" :disabled="isReadOnly || isCaseEdit"
@command="handleCommand">
+{{$t('api_test.definition.request.case')}}
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="run">{{$t('commons.test')}}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-col>
<el-col :span="2">
<button type="button" aria-label="Close" class="el-card-btn" @click="close()"><i
class="el-dialog__close el-icon el-icon-close"></i></button>
</el-col>
</el-row>
</el-card>
@ -95,6 +90,7 @@
priorities: Array,
apiCaseList: Array,
isReadOnly: Boolean,
isCaseEdit: Boolean,
condition: {
type: Object,
default() {
@ -145,9 +141,6 @@
getApiTest() {
this.$emit('getApiTest');
},
close() {
this.$emit('close');
},
addCase() {
this.$emit('addCase');
},

View File

@ -37,10 +37,10 @@
<ms-tip-button @click="singleRun(apiCase)" :tip="$t('api_test.run')" icon="el-icon-video-play"
style="background-color: #409EFF;color: white" size="mini" :disabled="!apiCase.id" circle/>
<ms-tip-button @click="copyCase(apiCase)" :tip="$t('commons.copy')" icon="el-icon-document-copy"
size="mini" :disabled="!apiCase.id" circle/>
size="mini" :disabled="!apiCase.id || isCaseEdit" circle/>
<ms-tip-button @click="deleteCase(index,apiCase)" :tip="$t('commons.delete')" icon="el-icon-delete"
size="mini" :disabled="!apiCase.id" circle/>
<ms-api-extend-btns :row="apiCase"/>
size="mini" :disabled="!apiCase.id || isCaseEdit" circle/>
<ms-api-extend-btns :is-case-edit="isCaseEdit" :row="apiCase"/>
</el-col>
<el-col :span="3">
@ -85,7 +85,6 @@
import MsDubboBasisParameters from "../request/dubbo/BasisParameters";
import MsApiExtendBtns from "../reference/ApiExtendBtns";
export default {
name: "ApiCaseItem",
components: {
@ -132,7 +131,8 @@
default() {
return {}
}
}
},
isCaseEdit: Boolean,
},
watch: {
},
@ -149,7 +149,7 @@
},
copyCase(data) {
let obj = {name: "copy_" + data.name, priority: data.priority, active: false, request: data.request};
this.apiCaseList.unshift(obj);
this.$emit('copyCase', obj);
},
selectTestCase(item, $event) {
@ -211,6 +211,9 @@
return true;
}
},
showExecResult(data) {
this.$emit('showExecResult', data);
},
getBodyUploadFiles(row) {
let bodyUploadFiles = [];
row.bodyUploadIds = [];

View File

@ -1,12 +1,11 @@
<template>
<div v-if="visible">
<ms-drawer :size="40" direction="bottom">
<ms-drawer :size="40" @close="apiCaseClose" direction="bottom">
<template v-slot:header>
<api-case-header
:api="api"
@getApiTest="getApiTest"
@setEnvironment="setEnvironment"
@close="apiCaseClose"
@addCase="addCase"
@batchRun="batchRun"
:condition="condition"
@ -14,6 +13,7 @@
:apiCaseList="apiCaseList"
:is-read-only="isReadOnly"
:project-id="projectId"
:is-case-edit="isCaseEdit"
/>
</template>
@ -21,10 +21,13 @@
<el-main v-loading="batchLoading" style="overflow: auto">
<div v-for="(item,index) in apiCaseList" :key="index">
<api-case-item v-loading="singleLoading && singleRunId === item.id"
@refresh="getApiTest"
@singleRun="singleRun"
:api="api"
:api-case="item" :index="index"/>
@refresh="getApiTest"
@singleRun="singleRun"
@copyCase="copyCase"
@showExecResult="showExecResult"
:is-case-edit="isCaseEdit"
:api="api"
:api-case="item" :index="index"/>
</div>
</el-main>
</el-container>
@ -78,6 +81,7 @@
runData: [],
reportId: "",
projectId: "",
testCaseId: "",
checkedCases: new Set(),
visible: false,
condition: {},
@ -103,9 +107,16 @@
this.getApiTest();
}
},
computed: {
isCaseEdit() {
return this.testCaseId ? true : false;
}
},
methods: {
open(api) {
open(api, testCaseId) {
this.api = api;
// testCaseId
this.testCaseId = testCaseId;
this.getApiTest();
this.visible = true;
},
@ -142,7 +153,11 @@
getApiTest() {
if (this.api) {
this.condition.projectId = this.projectId;
this.condition.apiDefinitionId = this.api.id;
if (this.isCaseEdit) {
this.condition.id = this.testCaseId;
} else {
this.condition.apiDefinitionId = this.api.id;
}
this.result = this.$post("/api/testcase/list", this.condition, response => {
for (let index in response.data) {
let test = response.data[index];
@ -152,9 +167,9 @@
}
}
this.apiCaseList = response.data;
if (this.apiCaseList.length == 0) {
this.addCase();
}
// if (this.apiCaseList.length == 0) {
// this.addCase();
// }
});
}
},
@ -173,6 +188,10 @@
}
},
copyCase(data) {
this.apiCaseList.unshift(data);
},
handleClose() {
this.visible = false;
},

View File

@ -1,13 +1,16 @@
<template>
<div>
<api-list-container>
<api-list-container
:is-api-list-enable="isApiListEnable"
@isApiListEnableChange="isApiListEnableChange">
<el-input placeholder="搜索" @blur="search" class="search-input" size="small" v-model="condition.name"/>
<el-table v-loading="result.loading"
border
:data="tableData" row-key="id" class="test-content adjust-table"
@select-all="handleSelectAll"
@select="handleSelect" :height="screenHeight">
border
:data="tableData" row-key="id" class="test-content adjust-table"
@select-all="handleSelectAll"
@filter-change="filter"
@sort-change="sort"
@select="handleSelect" :height="screenHeight">
<el-table-column type="selection"/>
<el-table-column width="40" :resizable="false" align="center">
<template v-slot:default="scope">
@ -34,11 +37,15 @@
show-overflow-tooltip/>
<el-table-column
prop="createUserId"
prop="createUser"
:label="'创建人'"
show-overflow-tooltip/>
<el-table-column width="160" :label="$t('api_test.definition.api_last_time')" prop="updateTime">
<el-table-column
sortable="custom"
width="160"
:label="$t('api_test.definition.api_last_time')"
prop="updateTime">
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template>
@ -47,18 +54,18 @@
<el-table-column :label="$t('commons.operating')" min-width="130" align="center">
<template v-slot:default="scope">
<el-button type="text" @click="reductionApi(scope.row)" v-if="trashEnable">恢复</el-button>
<el-button type="text" @click="editCase(scope.row)" v-else>{{$t('commons.edit')}}</el-button>
<!--<el-button type="text" @click="reductionApi(scope.row)" v-if="trashEnable">恢复</el-button>-->
<el-button type="text" @click="handleTestCase(scope.row)" v-if="!trashEnable">{{$t('commons.edit')}}</el-button>
<el-button type="text" @click="handleDelete(scope.row)" style="color: #F56C6C">{{$t('commons.delete')}}</el-button>
</template>
</el-table-column>
</el-table>
<ms-table-pagination :change="initApiTable" :current-page.sync="currentPage" :page-size.sync="pageSize"
<ms-table-pagination :change="initTable" :current-page.sync="currentPage" :page-size.sync="pageSize"
:total="total"/>
</api-list-container>
<api-case-list @refresh="initApiTable" @showExecResult="showExecResult" :currentApi="selectApi" ref="caseList"/>
<api-case-list @showExecResult="showExecResult" @refresh="initTable" :currentApi="selectCase" ref="caseList"/>
<!--批量编辑-->
<ms-batch-edit ref="batchEdit" @batchEdit="batchEdit" :typeArr="typeArr" :value-arr="valueArr"/>
</div>
@ -79,11 +86,12 @@
import MsBottomContainer from "../BottomContainer";
import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn";
import MsBatchEdit from "../basis/BatchEdit";
import {API_METHOD_COLOUR, REQ_METHOD, API_STATUS} from "../../model/JsonData";
import {API_METHOD_COLOUR, CASE_PRIORITY} from "../../model/JsonData";
import {getCurrentProjectID} from "@/common/js/utils";
import ApiListContainer from "./ApiListContainer";
import PriorityTableItem from "../../../../track/common/tableItems/planview/PriorityTableItem";
import ApiCaseList from "../case/ApiCaseList";
import {_filter, _sort} from "../../../../../../common/js/utils";
export default {
name: "ApiCaseSimpleList",
@ -106,7 +114,7 @@
data() {
return {
condition: {},
selectApi: {},
selectCase: {},
result: {},
moduleId: "",
deletePath: "/test/case/delete",
@ -116,14 +124,16 @@
{name: this.$t('api_test.definition.request.batch_edit'), handleClick: this.handleEditBatch}
],
typeArr: [
{id: 'status', name: this.$t('api_test.definition.api_case_status')},
{id: 'method', name: this.$t('api_test.definition.api_type')},
{id: 'userId', name: this.$t('api_test.definition.api_principal')},
{id: 'priority', name: this.$t('test_track.case.priority')},
],
priorityFilters: [
{text: 'P0', value: 'P0'},
{text: 'P1', value: 'P1'},
{text: 'P2', value: 'P2'},
{text: 'P3', value: 'P3'}
],
valueArr: {
status: API_STATUS,
method: REQ_METHOD,
userId: [],
priority: CASE_PRIORITY,
},
methodColorMap: new Map(API_METHOD_COLOUR),
tableData: [],
@ -144,34 +154,37 @@
trashEnable: {
type: Boolean,
default: false,
}
},
isApiListEnable: Boolean
},
created: function () {
this.projectId = getCurrentProjectID();
this.initApiTable();
this.getMaintainerOptions();
this.initTable();
},
watch: {
selectNodeIds() {
this.initApiTable();
this.initTable();
},
currentProtocol() {
this.initApiTable();
this.initTable();
},
trashEnable() {
if (this.trashEnable) {
this.initApiTable();
this.initTable();
}
},
},
methods: {
initApiTable() {
isApiListEnableChange(data) {
this.$emit('isApiListEnableChange', data);
},
initTable() {
this.selectRows = new Set();
this.condition.filters = ["Prepare", "Underway", "Completed"];
// this.condition.filters = ["Prepare", "Underway", "Completed"];
this.condition.status = "";
this.condition.moduleIds = this.selectNodeIds;
if (this.trashEnable) {
this.condition.filters = ["Trash"];
this.condition.status = "Trash";
this.condition.moduleIds = [];
}
if (this.projectId != null) {
@ -210,6 +223,22 @@
})
}
},
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) {
if (selection.length > 0) {
if (selection.length === 1) {
@ -230,81 +259,66 @@
}
},
search() {
this.initApiTable();
this.initTable();
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
// 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);
// },
editCase(row) {
// this.$emit('editCase', row);
this.$get('/api/definition/' + row.api_definition_id, (response) => {
})
// 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);
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);
});
},
reductionApi(row) {
let ids = [row.id];
this.$post('/api/definition/reduction/', ids, () => {
this.$post('/api/testcase/reduction/', ids, () => {
this.$success(this.$t('commons.save_success'));
this.search();
});
},
handleDeleteBatch() {
if (this.trashEnable) {
// if (this.trashEnable) {
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);
this.$post('/api/definition/deleteBatch/', ids, () => {
this.$post('/api/testcase/deleteBatch/', ids, () => {
this.selectRows.clear();
this.initApiTable();
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);
this.$post('/api/definition/removeToGc/', ids, () => {
this.selectRows.clear();
this.initApiTable();
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);
// this.$post('/api/testcase/removeToGc/', ids, () => {
// this.selectRows.clear();
// this.initTable();
// this.$success(this.$t('commons.delete_success'));
// });
// }
// }
// });
// }
},
handleEditBatch() {
this.$refs.batchEdit.open();
@ -315,39 +329,31 @@
let param = {};
param[form.type] = form.value;
param.ids = ids;
this.$post('/api/definition/batch/edit', param, () => {
this.$post('/api/testcase/batch/edit', param, () => {
this.$success(this.$t('commons.save_success'));
this.initApiTable();
this.initTable();
});
},
handleDelete(api) {
if (this.trashEnable) {
this.$get('/api/definition/delete/' + api.id, () => {
handleDelete(apiCase) {
// if (this.trashEnable) {
this.$get('/api/testcase/delete/' + apiCase.id, () => {
this.$success(this.$t('commons.delete_success'));
this.initApiTable();
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.initApiTable();
});
}
}
});
},
getColor(enable, method) {
if (enable) {
return this.methodColorMap.get(method);
}
},
showExecResult(row) {
this.$emit('showExecResult', row);
// }
// 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();
// });
// }
// }
// });
}
},
}

View File

@ -1,6 +1,8 @@
<template>
<div>
<api-list-container>
<api-list-container
:is-api-list-enable="isApiListEnable"
@isApiListEnableChange="isApiListEnableChange">
<el-input placeholder="搜索" @blur="search" class="search-input" size="small" v-model="condition.name"/>
<el-table v-loading="result.loading"
@ -80,10 +82,10 @@
</template>
</el-table-column>
</el-table>
<ms-table-pagination :change="initApiTable" :current-page.sync="currentPage" :page-size.sync="pageSize"
<ms-table-pagination :change="initTable" :current-page.sync="currentPage" :page-size.sync="pageSize"
:total="total"/>
</api-list-container>
<ms-api-case-list @refresh="initApiTable" @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"/>
</div>
@ -166,28 +168,32 @@
trashEnable: {
type: Boolean,
default: false,
}
},
isApiListEnable: Boolean
},
created: function () {
this.projectId = getCurrentProjectID();
this.initApiTable();
this.initTable();
this.getMaintainerOptions();
},
watch: {
selectNodeIds() {
this.initApiTable();
this.initTable();
},
currentProtocol() {
this.initApiTable();
this.initTable();
},
trashEnable() {
if (this.trashEnable) {
this.initApiTable();
this.initTable();
}
},
},
methods: {
initApiTable() {
isApiListEnableChange(data) {
this.$emit('isApiListEnableChange', data);
},
initTable() {
this.selectRows = new Set();
this.condition.filters = ["Prepare", "Underway", "Completed"];
@ -252,7 +258,7 @@
}
},
search() {
this.initApiTable();
this.initTable();
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
@ -277,7 +283,7 @@
let ids = Array.from(this.selectRows).map(row => row.id);
this.$post('/api/definition/deleteBatch/', ids, () => {
this.selectRows.clear();
this.initApiTable();
this.initTable();
this.$success(this.$t('commons.delete_success'));
});
}
@ -291,7 +297,7 @@
let ids = Array.from(this.selectRows).map(row => row.id);
this.$post('/api/definition/removeToGc/', ids, () => {
this.selectRows.clear();
this.initApiTable();
this.initTable();
this.$success(this.$t('commons.delete_success'));
});
}
@ -310,7 +316,7 @@
param.ids = ids;
this.$post('/api/definition/batch/edit', param, () => {
this.$success(this.$t('commons.save_success'));
this.initApiTable();
this.initTable();
});
},
handleTestCase(api) {
@ -331,7 +337,7 @@
if (this.trashEnable) {
this.$get('/api/definition/delete/' + api.id, () => {
this.$success(this.$t('commons.delete_success'));
this.initApiTable();
this.initTable();
});
return;
}
@ -342,7 +348,7 @@
let ids = [api.id];
this.$post('/api/definition/removeToGc/', ids, () => {
this.$success(this.$t('commons.delete_success'));
this.initApiTable();
this.initTable();
});
}
}

View File

@ -1,8 +1,8 @@
<template>
<el-card class="card-content" v-if="isShow">
<el-button-group>
<el-button plain size="small" icon="el-icon-tickets" :class="{active: activeButton == 'api'}" @click="click('api')"></el-button>
<el-button plain size="small" icon="el-icon-paperclip" :class="{active: activeButton == 'case'}" @click="click('case')"></el-button>
<el-button plain size="small" icon="el-icon-tickets" :class="{active: isApiListEnable}" @click="apiChange('api')"></el-button>
<el-button plain class="case-button" size="small" icon="el-icon-paperclip" :class="{active: !isApiListEnable}" @click="caseChange('case')"></el-button>
</el-button-group>
<slot></slot>
</el-card>
@ -13,29 +13,32 @@
name: "ApiListContainer",
data() {
return {
activeButton: 'api',
isShow: true
}
},
props: {
isApiListEnable: Boolean
},
methods: {
click(type) {
this.activeButton = type;
// this.reload();
apiChange() {
this.$emit('isApiListEnableChange', true);
},
// reload() {
// this.isShow = false;
// this.$nextTick(() => {
// this.isShow = true;
// })
// }
caseChange() {
this.$emit('isApiListEnableChange', false);
}
}
}
</script>
<style scoped>
/*.active {*/
/*background-color: #409EFF;*/
/*}*/
.active {
border: solid 1px #6d317c;
}
.case-button {
border-left: solid 1px #6d317c;
}
</style>

View File

@ -4,7 +4,7 @@
<ms-node-tree
v-loading="result.loading"
:tree-nodes="data"
:type="'edit'"
:type="isReadOnly ? 'view' : 'edit'"
@add="add"
@edit="edit"
@drag="drag"
@ -16,6 +16,7 @@
<api-module-header
:condition="condition"
:current-module="currentModule"
:is-read-only="isReadOnly"
@exportAPI="exportAPI"
@saveAsEdit="saveAsEdit"
@refresh="refresh"
@ -60,6 +61,14 @@
currentModule: {},
}
},
props: {
isReadOnly: {
type: Boolean,
default() {
return false
}
}
},
mounted() {
this.projectId = getCurrentProjectID();
this.$emit('protocolChange', this.condition.protocol);

View File

@ -9,9 +9,9 @@
:disabled="item.disabled">
</el-option>
</el-select>
<el-input class="filter-input" :placeholder="$t('test_track.module.search')" v-model="condition.filterText" size="small">
<el-input class="filter-input" :class="{'read-only': isReadOnly}" :placeholder="$t('test_track.module.search')" v-model="condition.filterText" size="small">
<template v-slot:append>
<el-dropdown size="small" split-button type="primary" class="ms-api-button" @click="handleCommand('add-api')"
<el-dropdown v-if="!isReadOnly" size="small" split-button type="primary" class="ms-api-button" @click="handleCommand('add-api')"
@command="handleCommand">
<el-button icon="el-icon-folder-add" @click="addApi"></el-button>
<el-dropdown-menu slot="dropdown">
@ -61,6 +61,12 @@
default() {
return {}
}
},
isReadOnly: {
type: Boolean,
default() {
return false
}
}
},
methods: {
@ -105,8 +111,13 @@
height: 30px;
}
.read-only {
width: 150px !important;
}
.filter-input {
width: 175px;
padding-left: 3px;
}
</style>

View File

@ -5,7 +5,7 @@
</el-link>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="ref">{{ $t('api_test.automation.view_ref') }}</el-dropdown-item>
<el-dropdown-item command="add_plan">{{ $t('api_test.automation.batch_add_plan') }}</el-dropdown-item>
<el-dropdown-item :disabled="isCaseEdit" command="add_plan">{{ $t('api_test.automation.batch_add_plan') }}</el-dropdown-item>
</el-dropdown-menu>
<ms-reference-view ref="viewRef"/>
<!--测试计划-->
@ -23,7 +23,8 @@
name: "MsApiExtendBtns",
components: {MsReferenceView, MsTestPlanList},
props: {
row: Object
row: Object,
isCaseEdit: Boolean,
},
data() {
return {

View File

@ -36,6 +36,13 @@ export const REQ_METHOD = [
{id: 'CONNECT', label: 'CONNECT'}
]
export const CASE_PRIORITY = [
{id: 'P0', label: 'P0'},
{id: 'P1', label: 'P1'},
{id: 'P2', label: 'P2'},
{id: 'P3', label: 'P3'}
]
export const API_STATUS = [
{id: 'Prepare', label: '未开始'},
{id: 'Underway', label: '进行中'},

View File

@ -3,6 +3,7 @@
<ms-drag-move-bar :direction="dragBarDirection" @widthChange="widthChange" @heightChange="heightChange"/>
<div class="ms-drawer-header" >
<slot name="header"></slot>
<i class="el-icon-close" @click="close"/>
</div>
<div class="ms-drawer-body">
<slot></slot>
@ -131,6 +132,9 @@
if (this.w > document.body.clientWidth) {
this.w = document.body.clientWidth;
}
},
close() {
this.$emit('close')
}
}
}
@ -177,4 +181,16 @@
position: relative;
}
.el-icon-close {
position: absolute;
right: 10px;
top: 13px;
color: gray;
font-size: 20px;
}
.el-icon-close:hover {
color: red;
}
</style>

View File

@ -0,0 +1,66 @@
<template>
<el-card v-loading="result.loading">
<template slot="header">
<span style="font-size: 15px; color: #1E90FF">{{ $t('test_track.review.comment') }}</span>
<i class="el-icon-refresh" @click="getComments()"
style="margin-left:10px;font-size: 14px; cursor: pointer"/>
</template>
<div class="comment-list" style="height: 500px; overflow: auto;">
<review-comment-item v-for="(comment,index) in comments"
:key="index"
:comment="comment"
@refresh="getComments()"/>
<div v-if="comments.length === 0" style="text-align: center">
<i class="el-icon-chat-line-square" style="font-size: 15px;color: #8a8b8d;">
<span style="font-size: 15px; color: #8a8b8d;">
{{ $t('test_track.comment.no_comment') }}
</span>
</i>
</div>
</div>
</el-card>
</template>
<script>
import ReviewCommentItem from "@/business/components/track/review/commom/ReviewCommentItem";
export default {
name: "CaseComment",
components: {ReviewCommentItem},
props: {
caseId: {
type: String,
default: ''
}
},
watch: {
caseId() {
this.comments = [];
this.getComments();
}
},
created() {
this.comments = [];
this.getComments();
},
data() {
return {
comments: [],
result: {}
}
},
methods: {
getComments() {
if (this.caseId) {
this.result = this.$get('/test/case/comment/list/' + this.caseId, res => {
this.comments = res.data;
})
}
}
}
}
</script>
<style scoped>
</style>

View File

@ -1,255 +1,263 @@
<template>
<div>
<el-dialog :close-on-click-modal="false" class="case-dialog"
@close="close"
:title="operationType == 'edit' ? ( readOnly ? $t('test_track.case.view_case') : $t('test_track.case.edit_case')) : $t('test_track.case.create')"
:visible.sync="dialogFormVisible" width="88%">
<el-dialog :close-on-click-modal="false"
@close="close"
:title="operationType == 'edit' ? ( readOnly ? $t('test_track.case.view_case') : $t('test_track.case.edit_case')) : $t('test_track.case.create')"
:visible.sync="dialogFormVisible" width="65%">
<el-row :gutter="10">
<div>
<el-col :span="17">
<el-card>
<el-form :model="form" :rules="rules" ref="caseFrom" v-loading="result.loading">
<el-form :model="form" :rules="rules" ref="caseFrom" v-loading="result.loading">
<el-row>
<el-col :span="8" :offset="1">
<el-form-item
:placeholder="$t('test_track.case.input_name')"
:label="$t('test_track.case.name')"
:label-width="formLabelWidth"
prop="name">
<el-input class="case-name" :disabled="readOnly" v-model="form.name"></el-input>
</el-form-item>
</el-col>
<el-row>
<el-col :span="8" :offset="1">
<el-form-item
:placeholder="$t('test_track.case.input_name')"
:label="$t('test_track.case.name')"
:label-width="formLabelWidth"
prop="name">
<el-input class="case-name" :disabled="readOnly" v-model="form.name"></el-input>
</el-form-item>
</el-col>
<el-col :span="11" :offset="2">
<el-form-item :label="$t('test_track.case.module')" :label-width="formLabelWidth" prop="module">
<el-select
v-model="form.module"
:disabled="readOnly"
:placeholder="$t('test_track.case.input_module')"
filterable>
<el-option
v-for="item in moduleOptions"
:key="item.id"
:label="item.path"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-col :span="11" :offset="2">
<el-form-item :label="$t('test_track.case.module')" :label-width="formLabelWidth" prop="module">
<el-select
v-model="form.module"
:disabled="readOnly"
:placeholder="$t('test_track.case.input_module')"
filterable>
<el-option
v-for="item in moduleOptions"
:key="item.id"
:label="item.path"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="10" :offset="1">
<el-form-item :label="$t('test_track.case.maintainer')" :label-width="formLabelWidth" prop="maintainer">
<el-select :disabled="readOnly" v-model="form.maintainer"
:placeholder="$t('test_track.case.input_maintainer')" filterable>
<el-option
v-for="item in maintainerOptions"
:key="item.id"
:label="item.id + ' (' + item.name + ')'"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :label="$t('test_track.case.priority')" :label-width="formLabelWidth" prop="priority">
<el-select :disabled="readOnly" v-model="form.priority" clearable
:placeholder="$t('test_track.case.input_priority')">
<el-option label="P0" value="P0"></el-option>
<el-option label="P1" value="P1"></el-option>
<el-option label="P2" value="P2"></el-option>
<el-option label="P3" value="P3"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="10" :offset="1">
<el-form-item :label="$t('test_track.case.maintainer')" :label-width="formLabelWidth" prop="maintainer">
<el-select :disabled="readOnly" v-model="form.maintainer"
:placeholder="$t('test_track.case.input_maintainer')" filterable>
<el-option
v-for="item in maintainerOptions"
:key="item.id"
:label="item.id + ' (' + item.name + ')'"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :label="$t('test_track.case.priority')" :label-width="formLabelWidth" prop="priority">
<el-select :disabled="readOnly" v-model="form.priority" clearable
:placeholder="$t('test_track.case.input_priority')">
<el-option label="P0" value="P0"></el-option>
<el-option label="P1" value="P1"></el-option>
<el-option label="P2" value="P2"></el-option>
<el-option label="P3" value="P3"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="10" :offset="1">
<el-form-item :label="$t('test_track.case.type')" :label-width="formLabelWidth" prop="type">
<el-select @change="typeChange" :disabled="readOnly" v-model="form.type"
:placeholder="$t('test_track.case.input_type')">
<el-option :label="$t('commons.functional')" value="functional"></el-option>
<el-option :label="$t('commons.performance')" value="performance"></el-option>
<el-option :label="$t('commons.api')" value="api"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :label="$t('test_track.case.method')" :label-width="formLabelWidth" prop="method">
<el-select :disabled="readOnly" v-model="form.method" :placeholder="$t('test_track.case.input_method')">
<el-option
v-for="item in methodOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="10" :offset="1">
<el-form-item :label="$t('test_track.case.type')" :label-width="formLabelWidth" prop="type">
<el-select @change="typeChange" :disabled="readOnly" v-model="form.type"
:placeholder="$t('test_track.case.input_type')">
<el-option :label="$t('commons.functional')" value="functional"></el-option>
<el-option :label="$t('commons.performance')" value="performance"></el-option>
<el-option :label="$t('commons.api')" value="api"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :label="$t('test_track.case.method')" :label-width="formLabelWidth" prop="method">
<el-select :disabled="readOnly" v-model="form.method" :placeholder="$t('test_track.case.input_method')">
<el-option
v-for="item in methodOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row v-if="form.method && form.method == 'auto'">
<el-col :span="9" :offset="1">
<el-form-item :label="$t('test_track.case.relate_test')" :label-width="formLabelWidth" prop="testId">
<el-select filterable :disabled="readOnly" v-model="form.testId"
:placeholder="$t('test_track.case.input_type')">
<el-option
v-for="item in testOptions"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="9" :offset="1" v-if="form.testId=='other'">
<el-form-item :label="$t('test_track.case.test_name')" :label-width="formLabelWidth" prop="testId">
<el-input v-model="form.otherTestName" :placeholder="$t('test_track.case.input_test_case')"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row style="margin-top: 15px;">
<el-col :offset="2">{{ $t('test_track.case.prerequisite') }}:</el-col>
</el-row>
<el-row type="flex" justify="center" style="margin-top: 10px;">
<el-col :span="20">
<el-form-item prop="prerequisite">
<el-input :disabled="readOnly" v-model="form.prerequisite"
type="textarea"
:autosize="{ minRows: 2, maxRows: 4}"
:rows="2"
:placeholder="$t('test_track.case.input_prerequisite')"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row v-if="form.method && form.method == 'auto'">
<el-col :span="9" :offset="1">
<el-form-item :label="$t('test_track.case.relate_test')" :label-width="formLabelWidth" prop="testId">
<el-select filterable :disabled="readOnly" v-model="form.testId"
:placeholder="$t('test_track.case.input_type')">
<el-option
v-for="item in testOptions"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="9" :offset="1" v-if="form.testId=='other'">
<el-form-item :label="$t('test_track.case.test_name')" :label-width="formLabelWidth" prop="testId">
<el-input v-model="form.otherTestName" :placeholder="$t('test_track.case.input_test_case')"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row style="margin-top: 15px;">
<el-col :offset="2">{{ $t('test_track.case.prerequisite') }}:</el-col>
</el-row>
<el-row type="flex" justify="center" style="margin-top: 10px;">
<el-col :span="20">
<el-form-item prop="prerequisite">
<el-input :disabled="readOnly" v-model="form.prerequisite"
type="textarea"
:autosize="{ minRows: 2, maxRows: 4}"
:rows="2"
:placeholder="$t('test_track.case.input_prerequisite')"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row v-if="form.method && form.method != 'auto'" style="margin-bottom: 10px">
<el-col :offset="2">{{ $t('test_track.case.steps') }}:</el-col>
</el-row>
<el-row v-if="form.method && form.method != 'auto'" style="margin-bottom: 10px">
<el-col :offset="2">{{ $t('test_track.case.steps') }}:</el-col>
</el-row>
<el-row v-if="form.method && form.method != 'auto'" type="flex" justify="center">
<el-col :span="20">
<el-table
v-if="isStepTableAlive"
:data="form.steps"
class="tb-edit"
border
size="mini"
:default-sort="{prop: 'num', order: 'ascending'}"
highlight-current-row>
<el-table-column :label="$t('test_track.case.number')" prop="num" min-width="10%"></el-table-column>
<el-table-column :label="$t('test_track.case.step_desc')" prop="desc" min-width="35%">
<template v-slot:default="scope">
<el-input
class="table-edit-input"
<el-row v-if="form.method && form.method != 'auto'" type="flex" justify="center">
<el-col :span="20">
<el-table
v-if="isStepTableAlive"
:data="form.steps"
class="tb-edit"
border
size="mini"
:disabled="readOnly"
type="textarea"
:autosize="{ minRows: 1, maxRows: 6}"
:rows="2"
v-model="scope.row.desc"
:placeholder="$t('commons.input_content')"
clearable/>
</template>
</el-table-column>
<el-table-column :label="$t('test_track.case.expected_results')" prop="result" min-width="35%">
<template v-slot:default="scope">
<el-input
class="table-edit-input"
size="mini"
:disabled="readOnly"
type="textarea"
:autosize="{ minRows: 1, maxRows: 6}"
:rows="2"
v-model="scope.row.result"
:placeholder="$t('commons.input_content')"
clearable/>
</template>
</el-table-column>
<el-table-column :label="$t('commons.input_content')" min-width="20%">
<template v-slot:default="scope">
<el-button
type="primary"
:disabled="readOnly"
icon="el-icon-plus"
circle size="mini"
@click="handleAddStep(scope.$index, scope.row)"></el-button>
<el-button
icon="el-icon-document-copy"
type="success"
:disabled="readOnly"
circle size="mini"
@click="handleCopyStep(scope.$index, scope.row)"></el-button>
<el-button
type="danger"
icon="el-icon-delete"
circle size="mini"
@click="handleDeleteStep(scope.$index, scope.row)"
:disabled="readOnly || (scope.$index == 0 && form.steps.length <= 1)"></el-button>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
:default-sort="{prop: 'num', order: 'ascending'}"
highlight-current-row>
<el-table-column :label="$t('test_track.case.number')" prop="num" min-width="10%"></el-table-column>
<el-table-column :label="$t('test_track.case.step_desc')" prop="desc" min-width="35%">
<template v-slot:default="scope">
<el-input
class="table-edit-input"
size="mini"
:disabled="readOnly"
type="textarea"
:autosize="{ minRows: 1, maxRows: 6}"
:rows="2"
v-model="scope.row.desc"
:placeholder="$t('commons.input_content')"
clearable/>
</template>
</el-table-column>
<el-table-column :label="$t('test_track.case.expected_results')" prop="result" min-width="35%">
<template v-slot:default="scope">
<el-input
class="table-edit-input"
size="mini"
:disabled="readOnly"
type="textarea"
:autosize="{ minRows: 1, maxRows: 6}"
:rows="2"
v-model="scope.row.result"
:placeholder="$t('commons.input_content')"
clearable/>
</template>
</el-table-column>
<el-table-column :label="$t('commons.input_content')" min-width="20%">
<template v-slot:default="scope">
<el-button
type="primary"
:disabled="readOnly"
icon="el-icon-plus"
circle size="mini"
@click="handleAddStep(scope.$index, scope.row)"></el-button>
<el-button
icon="el-icon-document-copy"
type="success"
:disabled="readOnly"
circle size="mini"
@click="handleCopyStep(scope.$index, scope.row)"></el-button>
<el-button
type="danger"
icon="el-icon-delete"
circle size="mini"
@click="handleDeleteStep(scope.$index, scope.row)"
:disabled="readOnly || (scope.$index == 0 && form.steps.length <= 1)"></el-button>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<el-row style="margin-top: 15px;margin-bottom: 10px">
<el-col :offset="2">{{ $t('commons.remark') }}:</el-col>
</el-row>
<el-row type="flex" justify="center">
<el-col :span="20">
<el-form-item prop="remark">
<el-input v-model="form.remark"
:autosize="{ minRows: 2, maxRows: 4}"
type="textarea"
:disabled="readOnly"
:rows="2"
:placeholder="$t('commons.input_content')"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row style="margin-top: 15px;margin-bottom: 10px">
<el-col :offset="2">{{ $t('commons.remark') }}:</el-col>
</el-row>
<el-row type="flex" justify="center">
<el-col :span="20">
<el-form-item prop="remark">
<el-input v-model="form.remark"
:autosize="{ minRows: 2, maxRows: 4}"
type="textarea"
:disabled="readOnly"
:rows="2"
:placeholder="$t('commons.input_content')"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row style="margin-top: 15px;margin-bottom: 10px">
<el-col :offset="2" :span="20">{{ $t('test_track.case.attachment') }}:
<el-upload
accept=".jpg,.jpeg,.png,.xlsx,.doc,.pdf,.docx"
action=""
:show-file-list="false"
:before-upload="beforeUpload"
:http-request="handleUpload"
:on-exceed="handleExceed"
multiple
:limit="8"
:file-list="fileList">
<el-button icon="el-icon-plus" size="mini"></el-button>
<span slot="tip" class="el-upload__tip"> {{ $t('test_track.case.upload_tip') }} </span>
</el-upload>
</el-col>
<el-col :offset="2" :span="20">
<test-case-attachment :table-data="tableData"
:read-only="readOnly"
:is-delete="true"
@handleDelete="handleDelete"
/>
</el-col>
</el-row>
<el-row style="margin-top: 15px;margin-bottom: 10px">
<el-col :offset="2" :span="20">{{ $t('test_track.case.attachment') }}:
<el-upload
accept=".jpg,.jpeg,.png,.xlsx,.doc,.pdf,.docx"
action=""
:show-file-list="false"
:before-upload="beforeUpload"
:http-request="handleUpload"
:on-exceed="handleExceed"
multiple
:limit="8"
:file-list="fileList">
<el-button icon="el-icon-plus" size="mini"></el-button>
<span slot="tip" class="el-upload__tip"> {{ $t('test_track.case.upload_tip') }} </span>
</el-upload>
</el-col>
<el-col :offset="2" :span="20">
<test-case-attachment :table-data="tableData"
:read-only="readOnly"
:is-delete="true"
@handleDelete="handleDelete"
/>
</el-col>
</el-row>
</el-form>
<el-row style="float: right; margin-bottom: 10px;">
<el-switch v-if="operationType == 'add'"
v-model="isCreateContinue"
:active-text="$t('test_track.case.save_create_continue')">
</el-switch>
<ms-dialog-footer v-if="!readOnly"
@cancel="dialogFormVisible = false"
@confirm="saveCase"/>
</el-row>
<template v-slot:footer>
<el-switch v-if="operationType == 'add'"
v-model="isCreateContinue"
:active-text="$t('test_track.case.save_create_continue')">
</el-switch>
<ms-dialog-footer v-if="!readOnly"
@cancel="dialogFormVisible = false"
@confirm="saveCase"/>
</template>
</el-form>
</el-dialog>
</el-card>
</el-col>
<el-col :span="7">
<case-comment :case-id="testCase ? testCase.id : ''"/>
</el-col>
</div>
</el-row>
</div>
</el-dialog>
</template>
@ -264,10 +272,11 @@ import {Message} from "element-ui";
import TestCaseAttachment from "@/business/components/track/case/components/TestCaseAttachment";
import {getCurrentProjectID} from "../../../../../common/js/utils";
import {buildNodePath} from "../../../api/definition/model/NodeTree";
import CaseComment from "@/business/components/track/case/components/CaseComment";
export default {
name: "TestCaseEdit",
components: {MsDialogFooter, TestCaseAttachment},
components: {CaseComment, MsDialogFooter, TestCaseAttachment},
data() {
return {
result: {},
@ -318,7 +327,8 @@ export default {
methodOptions: [
{value: 'auto', label: this.$t('test_track.case.auto')},
{value: 'manual', label: this.$t('test_track.case.manual')}
]
],
testCase: {}
};
},
props: {
@ -347,6 +357,11 @@ export default {
this.$nextTick(() => (this.isStepTableAlive = true));
},
open(testCase) {
this.testCase = {};
if (testCase) {
//
this.testCase = testCase.isCopy ? {} : testCase;
}
this.resetForm();
this.projectId = getCurrentProjectID();
if (window.history && window.history.pushState) {
@ -697,4 +712,8 @@ export default {
width: 194px;
}
.case-dialog >>> .el-dialog__body {
padding: 0 20px 10px 20px;
}
</style>

View File

@ -7,62 +7,40 @@
ref="baseRelevance">
<template v-slot:aside>
<node-tree class="node-tree"
@nodeSelectEvent="nodeChange"
@refresh="refresh"
:tree-nodes="treeNodes"
ref="nodeTree"/>
<!--<node-tree class="node-tree"-->
<!--@nodeSelectEvent="nodeChange"-->
<!--@refresh="refresh"-->
<!--:tree-nodes="treeNodes"-->
<!--ref="nodeTree"/>-->
<ms-api-module
@nodeSelectEvent="nodeChange"
@protocolChange="handleProtocolChange"
@refreshTable="refresh"
@exportAPI="exportAPI"
@debug="debug"
@saveAsEdit="editApi"
@setModuleOptions="setModuleOptions"
@enableTrash="enableTrash"
:is-read-only="true"
:type="'edit'"
ref="nodeTree"/>
</template>
<ms-table-header :condition.sync="condition" @search="search" title="" :show-create="false"/>
<el-table
v-loading="result.loading"
:data="testCases"
@filter-change="filter"
row-key="id"
@mouseleave.passive="leave"
v-el-table-infinite-scroll="scrollLoading"
@select-all="handleSelectAll"
@select="handleSelectionChange"
height="50vh"
ref="table">
<api-list
v-if="isApiListEnable"
:current-protocol="currentProtocol"
:currentRow="currentRow"
:select-node-ids="selectNodeIds"
:trash-enable="trashEnable"
:is-api-list-enable="isApiListEnable"
@editApi="editApi"
@handleCase="handleCase"
@showExecResult="showExecResult"
@isApiListEnableChange="isApiListEnableChange"
ref="apiList"/>
<el-table-column
type="selection"></el-table-column>
<el-table-column
prop="name"
:label="$t('test_track.case.name')"
style="width: 100%">
<template v-slot:default="scope">
{{scope.row.name}}
</template>
</el-table-column>
<el-table-column
prop="priority"
:filters="priorityFilters"
column-key="priority"
:label="$t('test_track.case.priority')"
show-overflow-tooltip>
<template v-slot:default="scope">
<priority-table-item :value="scope.row.priority"/>
</template>
</el-table-column>
<el-table-column
prop="type"
:filters="typeFilters"
column-key="type"
:label="$t('test_track.case.type')"
show-overflow-tooltip>
<template v-slot:default="scope">
<type-table-item :value="scope.row.type"/>
</template>
</el-table-column>
</el-table>
<div v-if="!lineStatus" style="text-align: center">{{$t('test_track.review_view.last_page')}}</div>
<div style="text-align: center"> {{total}} </div>
</test-case-relevance-base>
@ -76,14 +54,17 @@
import MsTableSearchBar from "../../../../../common/components/MsTableSearchBar";
import MsTableAdvSearchBar from "../../../../../common/components/search/MsTableAdvSearchBar";
import MsTableHeader from "../../../../../common/components/MsTableHeader";
import {TEST_CASE_CONFIGS} from "../../../../../common/components/search/search-components";
import elTableInfiniteScroll from 'el-table-infinite-scroll';
import TestCaseRelevanceBase from "../base/TestCaseRelevanceBase";
import {_filter} from "../../../../../../../common/js/utils";
import ApiList from "../../../../../api/automation/scenario/api/ApiList";
import MsApiModule from "../../../../../api/definition/components/module/ApiModule";
import {getCurrentProjectID} from "../../../../../../../common/js/utils";
export default {
name: "TestCaseApiRelevance",
components: {
MsApiModule,
ApiList,
TestCaseRelevanceBase,
NodeTree,
PriorityTableItem,
@ -97,34 +78,17 @@
},
data() {
return {
result: {},
isCheckAll: false,
testCases: [],
selectIds: new Set(),
treeNodes: [],
showCasePage: true,
apiDefaultTab: 'default',
currentProtocol: null,
currentModule: null,
selectNodeIds: [],
selectNodeNames: [],
projectId: '',
projectName: '',
projects: [],
pageSize: 50,
currentPage: 1,
total: 0,
lineStatus: true,
condition: {
components: TEST_CASE_CONFIGS
},
priorityFilters: [
{text: 'P0', value: 'P0'},
{text: 'P1', value: 'P1'},
{text: 'P2', value: 'P2'},
{text: 'P3', value: 'P3'}
],
typeFilters: [
{text: this.$t('commons.functional'), value: 'functional'},
{text: this.$t('commons.performance'), value: 'performance'},
{text: this.$t('commons.api'), value: 'api'}
]
currentApi: {},
moduleOptions: {},
trashEnable: false,
isApiListEnable: true,
condition: {},
currentRow: {}
};
},
props: {
@ -134,15 +98,12 @@
},
watch: {
planId() {
this.condition.planId = this.planId;
},
selectNodeIds() {
this.search();
// this.condition.planId = this.planId;
},
projectId() {
this.condition.projectId = this.projectId;
this.getProjectNode();
this.search();
// this.getProjectNode();
// this.search();
}
},
updated() {
@ -153,11 +114,96 @@
open() {
this.$refs.baseRelevance.open();
},
search() {
},
setProject(projectId) {
this.projectId = projectId;
},
isApiListEnableChange(data) {
this.isApiListEnable = data;
},
handleCommand(e) {
switch (e) {
case "ADD":
this.handleTabAdd(e);
break;
case "TEST":
this.handleTabsEdit(this.$t("commons.api"), e);
break;
case "CLOSE_ALL":
this.handleTabClose();
break;
default:
this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug");
break;
}
},
debug(id) {
this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug", id);
},
editApi(row) {
let name = this.$t('api_test.definition.request.edit_api');
if (row.name) {
name = this.$t('api_test.definition.request.edit_api') + "-" + row.name;
}
// this.handleTabsEdit(name, "ADD", row);
},
handleCase(api) {
this.currentApi = api;
this.showCasePage = false;
},
apiCaseClose() {
this.showCasePage = true;
},
exportAPI() {
if (!this.$refs.apiList[0].tableData) {
return;
}
let obj = {projectName: getCurrentProjectID(), protocol: this.currentProtocol, data: this.$refs.apiList[0].tableData}
// downloadFile("API.json", JSON.stringify(obj));
},
refresh(data) {
this.$refs.apiList[0].initTable(data);
},
setTabTitle(data) {
for (let index in this.apiTabs) {
let tab = this.apiTabs[index];
if (tab.name === this.apiDefaultTab) {
tab.title = this.$t('api_test.definition.request.edit_api') + "-" + data.name;
break;
}
}
this.runTestData = data;
},
runTest(data) {
this.setTabTitle(data);
this.handleCommand("TEST");
},
saveApi(data) {
this.setTabTitle(data);
this.$refs.apiList[0].initApiTable(data);
},
showExecResult(row){
this.debug(row);
},
nodeChange(node, nodeIds, pNodes) {
this.selectNodeIds = nodeIds;
},
handleProtocolChange(protocol) {
this.currentProtocol = protocol;
},
setModuleOptions(data) {
this.moduleOptions = data;
},
enableTrash(data) {
this.trashEnable = data;
},
saveCaseRelevance() {
let param = {};
param.planId = this.planId;
@ -176,148 +222,6 @@
this.$emit('refresh');
});
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
search() {
this.currentPage = 1;
this.testCases = [];
this.getTestCases(true);
},
getTestCases(flag) {
if (this.planId) {
this.condition.planId = this.planId;
}
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
this.condition.nodeIds = this.selectNodeIds;
} else {
this.condition.nodeIds = [];
}
if (this.projectId) {
this.condition.projectId = this.projectId;
// this.result = this.$post(this.buildPagePath('/test/case/name'), this.condition, response => {
// let data = response.data;
// this.total = data.itemCount;
// let tableData = data.listObject;
// tableData.forEach(item => {
// item.checked = false;
// });
// flag ? this.testCases = tableData : this.testCases = this.testCases.concat(tableData);
// //
// let hash = {}
// this.testCases = this.testCases.reduce((item, next) => {
// if (!hash[next.id]) {
// hash[next.id] = true
// item.push(next)
// }
// return item
// }, [])
//
// this.lineStatus = tableData.length === 50 && this.testCases.length < this.total;
// });
this.result = this.$post('/api/definition/list/1/10', this.condition, response => {
let data = response.data;
this.total = data.itemCount;
let tableData = data.listObject;
tableData.forEach(item => {
item.checked = false;
});
flag ? this.testCases = tableData : this.testCases = this.testCases.concat(tableData);
//
let hash = {}
this.testCases = this.testCases.reduce((item, next) => {
if (!hash[next.id]) {
hash[next.id] = true
item.push(next)
}
return item
}, [])
this.lineStatus = tableData.length === 50 && this.testCases.length < this.total;
});
}
},
handleSelectAll(selection) {
if (selection.length > 0) {
this.testCases.forEach(item => {
this.selectIds.add(item.id);
});
} else {
this.testCases.forEach(item => {
if (this.selectIds.has(item.id)) {
this.selectIds.delete(item.id);
}
});
}
},
handleSelectionChange(selection, row) {
if (this.selectIds.has(row.id)) {
this.selectIds.delete(row.id);
} else {
this.selectIds.add(row.id);
}
},
nodeChange(nodeIds, nodeNames) {
this.selectNodeIds = nodeIds;
this.selectNodeNames = nodeNames;
},
refresh() {
this.close();
},
scrollLoading() {
if (this.lineStatus) {
this.currentPage += 1;
this.getTestCases();
}
},
getAllNodeTreeByPlanId() {
if (this.planId) {
let param = {
testPlanId: this.planId,
projectId: this.projectId
};
this.result = this.$get('/api/module/list/' + this.project + '/HTTP', response => {
this.treeNodes = response.data;
});
}
},
close() {
this.lineStatus = false;
this.selectIds.clear();
this.selectNodeIds = [];
this.selectNodeNames = [];
},
filter(filters) {
_filter(filters, this.condition);
this.search();
},
toggleSelection(rows) {
rows.forEach(row => {
this.selectIds.forEach(id => {
if (row.id === id) {
// true
this.$refs.table.toggleRowSelection(row, true)
}
})
})
},
getProjectNode(projectId) {
const index = this.projects.findIndex(project => project.id === projectId);
if (index !== -1) {
this.projectName = this.projects[index].name;
}
if (projectId) {
this.projectId = projectId;
}
this.$refs.nodeTree.result = this.$get('/api/module/list/' + this.projectId + '/HTTP', response => {
this.treeNodes = response.data;
});
// this.$refs.nodeTree.result = this.$post('/api/module/list/' + this.project + '/HTTP',
// {testPlanId: this.planId, projectId: this.projectId}, response => {
// this.treeNodes = response.data;
// });
this.selectNodeIds = [];
}
}
}
</script>

View File

@ -11,9 +11,9 @@
<el-aside class="tree-aside" width="250px">
<select-menu
:data="projects"
width="185px"
width="160px"
:current-data="currentProject"
:title="$t('test_track.plan_view.plan')"
:title="$t('test_track.switch_project')"
@dataChange="changeProject"/>
<slot name="aside"></slot>
</el-aside>
@ -79,11 +79,6 @@
this.$emit('save');
},
refresh() {
// this.close();
},
close() {
this.dialogVisible = false;
},

@ -1 +1 @@
Subproject commit d39dafaf84b9c7a56cb51f2caf67dd7dfde5938c
Subproject commit a22a3005d9bd254793fcf634d72539cbdf31be3a