# Conflicts:
#	frontend/src/business/components/api/automation/scenario/EditApiScenario.vue
This commit is contained in:
fit2-zhao 2021-01-08 17:53:45 +08:00
commit fe74a26fd2
19 changed files with 425 additions and 289 deletions

View File

@ -116,4 +116,8 @@ public class ApiTestCaseController {
public String jenkinsRun(@RequestBody RunCaseRequest request) { public String jenkinsRun(@RequestBody RunCaseRequest request) {
return apiTestCaseService.run(request); return apiTestCaseService.run(request);
} }
@GetMapping(value = "/jenkins/exec/result/{id}")
public String getExecResult(@PathVariable String id) {
return apiTestCaseService.getExecResult(id);
}
} }

View File

@ -0,0 +1,5 @@
package io.metersphere.api.dto.definition.request.variable;
public enum ScenarioVariableType {
CONSTANT, LIST, CSV, COUNTER, RANDOM,
}

View File

@ -220,16 +220,20 @@ public class Swagger2Parser extends SwaggerAbstractParser {
//模型数组 //模型数组
ArrayModel arrayModel = (ArrayModel) schema; ArrayModel arrayModel = (ArrayModel) schema;
Property items = arrayModel.getItems(); Property items = arrayModel.getItems();
JSONArray propertyList = new JSONArray();
if (items instanceof RefProperty) { if (items instanceof RefProperty) {
RefProperty refProperty = (RefProperty) items; RefProperty refProperty = (RefProperty) items;
String simpleRef = refProperty.getSimpleRef(); String simpleRef = refProperty.getSimpleRef();
HashSet<String> refSet = new HashSet<>(); HashSet<String> refSet = new HashSet<>();
refSet.add(simpleRef); refSet.add(simpleRef);
Model model = definitions.get(simpleRef); Model model = definitions.get(simpleRef);
JSONArray propertyList = new JSONArray(); if (model != null) {
propertyList.add(getBodyParameters(model.getProperties(), refSet)); propertyList.add(getBodyParameters(model.getProperties(), refSet));
return propertyList.toString(); } else {
propertyList.add(new JSONObject());
}
} }
return propertyList.toString();
} }
return ""; return "";
} }

View File

@ -16,6 +16,7 @@ import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
import io.metersphere.api.dto.scenario.request.RequestType; import io.metersphere.api.dto.scenario.request.RequestType;
import io.metersphere.api.jmeter.JMeterService; import io.metersphere.api.jmeter.JMeterService;
import io.metersphere.base.domain.*; import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
import io.metersphere.base.mapper.ApiDefinitionMapper; import io.metersphere.base.mapper.ApiDefinitionMapper;
import io.metersphere.base.mapper.ApiTestCaseMapper; import io.metersphere.base.mapper.ApiTestCaseMapper;
import io.metersphere.base.mapper.ApiTestFileMapper; import io.metersphere.base.mapper.ApiTestFileMapper;
@ -71,6 +72,8 @@ public class ApiTestCaseService {
private ApiDefinitionMapper apiDefinitionMapper; private ApiDefinitionMapper apiDefinitionMapper;
@Resource @Resource
private JMeterService jMeterService; private JMeterService jMeterService;
@Resource
private ApiDefinitionExecResultMapper apiDefinitionExecResultMapper;
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body"; private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
@ -438,6 +441,7 @@ public class ApiTestCaseService {
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
MsTestElement element = mapper.readValue(testCaseWithBLOBs.getRequest(), new TypeReference<MsTestElement>() { MsTestElement element = mapper.readValue(testCaseWithBLOBs.getRequest(), new TypeReference<MsTestElement>() {
}); });
element.setName(request.getCaseId());
// 测试计划 // 测试计划
MsTestPlan testPlan = new MsTestPlan(); MsTestPlan testPlan = new MsTestPlan();
testPlan.setHashTree(new LinkedList<>()); testPlan.setHashTree(new LinkedList<>());
@ -466,4 +470,11 @@ public class ApiTestCaseService {
return request.getReportId(); return request.getReportId();
} }
public String getExecResult(String id){
ApiDefinitionExecResultExample apidefinitionexecresultexample = new ApiDefinitionExecResultExample();
ApiDefinitionExecResultExample.Criteria criteria = apidefinitionexecresultexample.createCriteria();
criteria.andResourceIdEqualTo(id);
String status=apiDefinitionExecResultMapper.selectByExample(apidefinitionexecresultexample).get(0).getStatus();
return status;
}
} }

View File

@ -252,6 +252,18 @@
#{value} #{value}
</foreach> </foreach>
</when> </when>
<when test="key=='method'">
and api_definition.method in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<when test="key=='user_id'">
and api_definition.user_id in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
</choose> </choose>
</if> </if>
</foreach> </foreach>
@ -270,7 +282,12 @@
<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">
<if test="order.name == 'user_name'">
user_name ${order.type}
</if>
<if test="order.name != 'user_name'">
api_definition.${order.name} ${order.type} api_definition.${order.name} ${order.type}
</if>
</foreach> </foreach>
</if> </if>
</select> </select>
@ -351,9 +368,29 @@
</foreach> </foreach>
</if> </if>
<if test="request.filters != null and request.filters.size() > 0"> <if test="request.filters != null and request.filters.size() > 0">
and api_definition.status in <foreach collection="request.filters.entrySet()" index="key" item="values">
<foreach collection="request.filters" item="value" separator="," open="(" close=")"> <if test="values != null and values.size() > 0">
#{value} <choose>
<when test="key=='status'">
and api_definition.status in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<when test="key=='method'">
and api_definition.method in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<when test="key=='user_id'">
and api_definition.user_id in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
</choose>
</if>
</foreach> </foreach>
</if> </if>
and exists ( and exists (

View File

@ -196,12 +196,6 @@
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">

View File

@ -320,21 +320,28 @@
</if> </if>
</select> </select>
<select id="listByMethod" resultType="io.metersphere.track.dto.TestCaseDTO"> <select id="listByMethod" resultType="io.metersphere.track.dto.TestCaseDTO">
SELECT id,name,status,project_id,"api" as type from api_test SELECT id,name,project_id,"api" as type from api_test
<where> <where>
<if test="request.projectId!=null"> <if test="request.projectId!=null">
and project_id=#{request.projectId} and project_id=#{request.projectId}
</if> </if>
</where> </where>
UNION ALL UNION ALL
select id,name,status,project_id,"perform" as type from load_test select id,name,project_id,"perform" as type from load_test
<where> <where>
<if test="request.projectId!=null"> <if test="request.projectId!=null">
and project_id= #{request.projectId} and project_id= #{request.projectId}
</if> </if>
</where> </where>
UNION ALL UNION ALL
select id,name,status,project_id,"scenario" as type from api_scenario select id,name,project_id,"scenario" as type from api_scenario
<where>
<if test="request.projectId!=null">
and project_id= #{request.projectId}
</if>
</where>
UNION ALL
select id,name,project_id,"definition" as type from api_test_case
<where> <where>
<if test="request.projectId!=null"> <if test="request.projectId!=null">
and project_id= #{request.projectId} and project_id= #{request.projectId}

View File

@ -23,7 +23,7 @@
from from
test_plan_api_case t test_plan_api_case t
inner join inner join
api_test_case c api_test_case c
on t.api_case_id = c.id on t.api_case_id = c.id
<if test="request.planId != null and request.planId!=''"> <if test="request.planId != null and request.planId!=''">
and t.test_plan_id = #{request.planId} and t.test_plan_id = #{request.planId}
@ -72,6 +72,12 @@
#{value} #{value}
</foreach> </foreach>
</when> </when>
<when test="key == 'user_id'">
and c.create_user_id in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
</choose> </choose>
</if> </if>
</foreach> </foreach>
@ -83,6 +89,9 @@
<when test="order.name == 'update_time'"> <when test="order.name == 'update_time'">
t.${order.name} ${order.type} t.${order.name} ${order.type}
</when> </when>
<when test="order.name == 'create_user'">
create_user_id ${order.type}
</when>
<otherwise> <otherwise>
${order.name} ${order.type} ${order.name} ${order.type}
</otherwise> </otherwise>

View File

@ -106,18 +106,18 @@
resultType="io.metersphere.track.dto.TestCaseReportStatusResultDTO"> resultType="io.metersphere.track.dto.TestCaseReportStatusResultDTO">
select count(t1.id) as `count`, t1.status select count(t1.id) as `count`, t1.status
from test_plan_test_case t1 from test_plan_test_case t1
inner join test_case t2 inner join test_case t2
where t1.case_id = t2.id where t1.case_id = t2.id
and plan_id = #{planId} and plan_id = #{planId}
group by t1.status; group by t1.status;
</select> </select>
<select id="getExecutors" resultType="java.lang.String" parameterType="java.lang.String"> <select id="getExecutors" resultType="java.lang.String" parameterType="java.lang.String">
select distinct t1.executor select distinct t1.executor
from test_plan_test_case t1 from test_plan_test_case t1
inner join test_case t2 inner join test_case t2
where t1.case_id = t2.id where t1.case_id = t2.id
and plan_id = #{planId}; and plan_id = #{planId};
</select> </select>
<select id="list" resultType="io.metersphere.track.dto.TestPlanCaseDTO"> <select id="list" resultType="io.metersphere.track.dto.TestPlanCaseDTO">
@ -320,31 +320,46 @@
</select> </select>
<select id="get" resultType="io.metersphere.track.dto.TestPlanCaseDTO"> <select id="get" resultType="io.metersphere.track.dto.TestPlanCaseDTO">
select test_case.remark, test_plan_test_case.id as id, test_plan_test_case.*,test_case.*,test_case_node.name as model, project.name as projectName select test_case.remark,
test_plan_test_case.id as id,
test_plan_test_case.*,
test_case.*,
test_case_node.name as model,
project.name as projectName
from test_plan_test_case from test_plan_test_case
inner join test_case on test_plan_test_case.case_id = test_case.id inner join test_case on test_plan_test_case.case_id = test_case.id
left join test_case_node on test_case_node.id=test_case.node_id left join test_case_node on test_case_node.id = test_case.node_id
inner join project on project.id = test_case.project_id inner join project on project.id = test_case.project_id
where test_plan_test_case.id = #{testPlanTestCaseId} where test_plan_test_case.id = #{testPlanTestCaseId}
</select> </select>
<select id="getExecResultByPlanId" resultType="java.lang.String"> <select id="getExecResultByPlanId" resultType="java.lang.String">
select status select status
from from test_plan_test_case
test_plan_test_case where plan_id = #{planId}
where plan_id = #{planId}
</select> </select>
<select id="listByPlanId" resultType="io.metersphere.track.dto.TestPlanCaseDTO"> <select id="listByPlanId" resultType="io.metersphere.track.dto.TestPlanCaseDTO">
SELECT test_plan_api_case.api_case_id as id,"definition" as type,api_test_case.name,test_plan_api_case.status SELECT test_plan_api_case.api_case_id as id,"definition" as type,api_test_case.name,test_plan_api_case.status
from test_plan_api_case left join api_test_case on test_plan_api_case.api_case_id=api_test_case.id from test_plan_api_case left join api_test_case on test_plan_api_case.api_case_id=api_test_case.id
inner join
api_definition a
on
api_test_case.api_definition_id = a.id
and a.status != 'Trash'
<where> <where>
<if test="request.planId != null"> <if test="request.planId != null">
and test_plan_api_case.test_plan_id = #{request.planId} and test_plan_api_case.test_plan_id = #{request.planId}
</if> </if>
</where> </where>
UNION ALL UNION ALL
SELECT test_plan_api_scenario.api_scenario_id as id,"scenario" as type,api_scenario.name,test_plan_api_scenario.status SELECT test_plan_api_scenario.api_scenario_id as id,"scenario" as
from test_plan_api_scenario left join api_scenario on test_plan_api_scenario.api_scenario_id=api_scenario.id type,api_scenario.name,test_plan_api_scenario.status
from test_plan_api_scenario
left join
api_scenario
on
test_plan_api_scenario.api_scenario_id=api_scenario.id
and api_scenario.status != 'Trash'
<where> <where>
<if test="request.planId != null"> <if test="request.planId != null">
and test_plan_api_scenario.test_plan_id = #{request.planId} and test_plan_api_scenario.test_plan_id = #{request.planId}
@ -352,7 +367,7 @@
</where> </where>
UNION ALL UNION ALL
SELECT test_case.test_id as id,test_case.type as type,test_case.name,test_plan_test_case.status SELECT test_case.test_id as id,test_case.type as type,test_case.name,test_plan_test_case.status
from test_plan_test_case left join test_case on test_plan_test_case.case_id =test_case.id from test_plan_test_case left join test_case on test_plan_test_case.case_id =test_case.id
<where> <where>
<if test="request.planId != null"> <if test="request.planId != null">
and test_plan_test_case.plan_id = #{request.planId} and test_plan_test_case.plan_id = #{request.planId}
@ -377,6 +392,8 @@
</update> </update>
<delete id="deleteByTestCaseID" parameterType="java.lang.String"> <delete id="deleteByTestCaseID" parameterType="java.lang.String">
delete from test_plan_api_case where api_case_id = #{id,jdbcType=VARCHAR} delete
from test_plan_api_case
where api_case_id = #{id,jdbcType=VARCHAR}
</delete> </delete>
</mapper> </mapper>

View File

@ -52,4 +52,9 @@ public class TestPlanLoadCaseController {
public Boolean isExistReport(@RequestBody LoadCaseReportRequest request) { public Boolean isExistReport(@RequestBody LoadCaseReportRequest request) {
return testPlanLoadCaseService.isExistReport(request); return testPlanLoadCaseService.isExistReport(request);
} }
@PostMapping("/batch/delete")
public void batchDelete(@RequestBody List<String> ids) {
testPlanLoadCaseService.batchDelete(ids);
}
} }

View File

@ -113,4 +113,13 @@ public class TestPlanLoadCaseService {
} }
testPlanLoadCaseMapper.deleteByExample(testPlanLoadCaseExample); testPlanLoadCaseMapper.deleteByExample(testPlanLoadCaseExample);
} }
public void batchDelete(List<String> ids) {
if (CollectionUtils.isEmpty(ids)) {
return;
}
TestPlanLoadCaseExample example = new TestPlanLoadCaseExample();
example.createCriteria().andIdIn(ids);
testPlanLoadCaseMapper.deleteByExample(example);
}
} }

View File

@ -383,8 +383,9 @@ public class TestPlanService {
return testPlans; return testPlans;
} }
public List<TestPlanDTO> listTestPlanByProject(QueryTestPlanRequest request) { public List<TestPlanDTOWithMetric> listTestPlanByProject(QueryTestPlanRequest request) {
return extTestPlanMapper.planList(request); List<TestPlanDTOWithMetric> testPlans=extTestPlanMapper.list(request);
return testPlans;
} }
public void testPlanRelevance(PlanCaseRelevanceRequest request) { public void testPlanRelevance(PlanCaseRelevanceRequest request) {

View File

@ -6,28 +6,23 @@
:show-create="false"/> :show-create="false"/>
</template> </template>
<el-table ref="scenarioTable" border :data="tableData" class="adjust-table" @select-all="select" @select="select" <el-table ref="scenarioTable" border :data="tableData" class="adjust-table ms-select-all" @select-all="select" @select="select"
v-loading="loading"> v-loading="loading">
<el-table-column type="selection" width="38"/>
<el-table-column v-if="!referenced" width="40" :resizable="false" align="center">
<el-dropdown slot="header" style="width: 14px">
<span class="el-dropdown-link" style="width: 14px">
<i class="el-icon-arrow-down el-icon--right" style="margin-left: 0px"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item @click.native.stop="isSelectDataAll(true)">
{{ $t('api_test.batch_menus.select_all_data', [total]) }}
</el-dropdown-item>
<el-dropdown-item @click.native.stop="isSelectDataAll(false)">
{{ $t('api_test.batch_menus.select_show_data', [tableData.length]) }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<template v-slot:default="{row}"> <el-table-column type="selection" width="50"/>
<show-more-btn :is-show="isSelect(row)" :buttons="buttons" :size="selectDataCounts"/>
<ms-table-select-all v-if="!referenced"
:page-size="pageSize"
:total="total"
@selectPageAll="isSelectDataAll(false)"
@selectAll="isSelectDataAll(true)"/>
<el-table-column v-if="!referenced" width="30" :resizable="false" align="center">
<template v-slot:default="scope">
<show-more-btn :is-show="isSelect(scope.row)" :buttons="buttons" :size="selectDataCounts"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="num" label="ID" <el-table-column prop="num" label="ID"
show-overflow-tooltip/> show-overflow-tooltip/>
<el-table-column prop="name" :label="$t('api_test.automation.scenario_name')" <el-table-column prop="name" :label="$t('api_test.automation.scenario_name')"
@ -111,10 +106,12 @@ 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";
export default { export default {
name: "MsApiScenarioList", name: "MsApiScenarioList",
components: { components: {
MsTableSelectAll,
MsTablePagination, MsTablePagination,
MsTableMoreBtn, MsTableMoreBtn,
ShowMoreBtn, ShowMoreBtn,

View File

@ -2,14 +2,12 @@
<el-card> <el-card>
<div class="card-content"> <div class="card-content">
<div class="ms-main-div" @click="showAll"> <div class="ms-main-div" @click="showAll">
<el-row>
<el-col> <!--操作按钮-->
<!--操作按钮--> <div class="ms-opt-btn">
<div class="ms-opt-btn"> <el-button type="primary" size="small" @click="editScenario">{{$t('commons.save')}}</el-button>
<el-button type="primary" size="small" @click="editScenario(true)">{{$t('commons.save')}}</el-button> </div>
</div>
</el-col>
</el-row>
<div class="tip">{{$t('test_track.plan_view.base_info')}}</div> <div class="tip">{{$t('test_track.plan_view.base_info')}}</div>
<el-form :model="currentScenario" label-position="right" label-width="80px" size="small" :rules="rules" ref="currentScenario" style="margin-right: 20px"> <el-form :model="currentScenario" label-position="right" label-width="80px" size="small" :rules="rules" ref="currentScenario" style="margin-right: 20px">
<!-- 基础信息 --> <!-- 基础信息 -->
@ -109,7 +107,7 @@
</el-col> </el-col>
<el-col :span="3" class="ms-col-one ms-font"> <el-col :span="3" class="ms-col-one ms-font">
<el-link class="head" @click="showScenarioParameters">{{$t('api_test.automation.scenario_total')}}</el-link> <el-link class="head" @click="showScenarioParameters">{{$t('api_test.automation.scenario_total')}}</el-link>
{{this.currentScenario.variables!=undefined?this.currentScenario.variables.length: 0}} {{this.currentScenario.variables!=undefined?this.currentScenario.variables.length-1: 0}}
</el-col> </el-col>
<el-col :span="3" class="ms-col-one ms-font"> <el-col :span="3" class="ms-col-one ms-font">
<el-checkbox v-model="enableCookieShare">共享cookie</el-checkbox> <el-checkbox v-model="enableCookieShare">共享cookie</el-checkbox>

View File

@ -3,9 +3,9 @@
:is-api-list-enable="isApiListEnable" :is-api-list-enable="isApiListEnable"
@isApiListEnableChange="isApiListEnableChange"> @isApiListEnableChange="isApiListEnableChange">
<ms-environment-select :project-id="projectId" v-if="isTestPlan" :is-read-only="isReadOnly" @setEnvironment="setEnvironment"/> <ms-environment-select :project-id="projectId" v-if="isTestPlan" :is-read-only="isReadOnly" @setEnvironment="setEnvironment"/>
<el-input placeholder="搜索" @blur="initTable" class="search-input" size="small" @keyup.enter.native="initTable" v-model="condition.name"/> <el-input placeholder="搜索" @blur="initTable" class="search-input" size="small" @keyup.enter.native="initTable" v-model="condition.name"/>
<el-table v-loading="result.loading" <el-table v-loading="result.loading"
@ -36,7 +36,7 @@
show-overflow-tooltip> show-overflow-tooltip>
<template v-slot:default="scope" class="request-method"> <template v-slot:default="scope" class="request-method">
<el-tag size="mini" :style="{'background-color': getColor(scope.row.method), border: getColor(true, scope.row.method)}" class="api-el-tag"> <el-tag size="mini" :style="{'background-color': getColor(scope.row.method), border: getColor(true, scope.row.method)}" class="api-el-tag">
{{ scope.row.method}} {{ scope.row.method }}
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
@ -74,189 +74,188 @@
<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 MsTablePagination from "../../../../common/pagination/TablePagination";
import MsTablePagination from "../../../../common/pagination/TablePagination"; import MsTag from "../../../../common/components/MsTag";
import MsTag from "../../../../common/components/MsTag"; import MsBottomContainer from "../../../definition/components/BottomContainer";
import MsBottomContainer from "../../../definition/components/BottomContainer"; import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn";
import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn"; import MsBatchEdit from "../../../definition/components/basis/BatchEdit";
import MsBatchEdit from "../../../definition/components/basis/BatchEdit"; import {API_METHOD_COLOUR, CASE_PRIORITY} from "../../../definition/model/JsonData";
import {API_METHOD_COLOUR, CASE_PRIORITY} from "../../../definition/model/JsonData"; import {getCurrentProjectID} from "@/common/js/utils";
import {getCurrentProjectID} from "@/common/js/utils"; import ApiListContainer from "../../../definition/components/list/ApiListContainer";
import ApiListContainer from "../../../definition/components/list/ApiListContainer"; import PriorityTableItem from "../../../../track/common/tableItems/planview/PriorityTableItem";
import PriorityTableItem from "../../../../track/common/tableItems/planview/PriorityTableItem"; 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 MsEnvironmentSelect from "../../../definition/components/case/MsEnvironmentSelect";
import MsEnvironmentSelect from "../../../definition/components/case/MsEnvironmentSelect";
export default { export default {
name: "RelevanceApiList", name: "RelevanceApiList",
components: { components: {
MsEnvironmentSelect, MsEnvironmentSelect,
PriorityTableItem, PriorityTableItem,
ApiListContainer, ApiListContainer,
MsTableOperatorButton, MsTableOperatorButton,
MsTableOperator, MsTableOperator,
MsTablePagination, MsTablePagination,
MsTag, MsTag,
MsBottomContainer, MsBottomContainer,
ShowMoreBtn, ShowMoreBtn,
MsBatchEdit MsBatchEdit
},
data() {
return {
condition: {},
selectCase: {},
result: {},
moduleId: "",
deletePath: "/test/case/delete",
selectRows: new Set(),
typeArr: [
{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: {
priority: CASE_PRIORITY,
},
methodColorMap: new Map(API_METHOD_COLOUR),
tableData: [],
currentPage: 1,
pageSize: 10,
total: 0,
environmentId: ""
}
},
props: {
currentProtocol: String,
selectNodeIds: Array,
visible: {
type: Boolean,
default: false,
}, },
data() { isApiListEnable: {
return { type: Boolean,
condition: {}, default: false,
selectCase: {},
result: {},
moduleId: "",
deletePath: "/test/case/delete",
selectRows: new Set(),
typeArr: [
{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: {
priority: CASE_PRIORITY,
},
methodColorMap: new Map(API_METHOD_COLOUR),
tableData: [],
currentPage: 1,
pageSize: 10,
total: 0,
environmentId: ""
}
}, },
props: { isReadOnly: {
currentProtocol: String, type: Boolean,
selectNodeIds: Array, default: false
visible: {
type: Boolean,
default: false,
},
isApiListEnable: {
type: Boolean,
default: false,
},
isReadOnly: {
type: Boolean,
default: false
},
isCaseRelevance: {
type: Boolean,
default: false,
},
projectId: String,
planId: String,
isTestPlan: Boolean
}, },
created: function () { isCaseRelevance: {
type: Boolean,
default: false,
},
projectId: String,
planId: String,
isTestPlan: Boolean
},
created: function () {
this.initTable();
},
watch: {
selectNodeIds() {
this.initTable(); this.initTable();
}, },
watch: { currentProtocol() {
selectNodeIds() { this.initTable();
this.initTable();
},
currentProtocol() {
this.initTable();
},
projectId() {
this.initTable();
}
}, },
computed: {}, projectId() {
methods: { this.initTable();
isApiListEnableChange(data) { }
this.$emit('isApiListEnableChange', data); },
}, computed: {},
initTable() { methods: {
this.selectRows = new Set(); isApiListEnableChange(data) {
this.condition.filters = ["Prepare", "Underway", "Completed"]; this.$emit('isApiListEnableChange', data);
this.condition.moduleIds = this.selectNodeIds;
if (this.trashEnable) {
this.condition.filters = ["Trash"];
this.condition.moduleIds = [];
}
if (this.projectId != null) {
this.condition.projectId = this.projectId;
} else {
this.condition.projectId = getCurrentProjectID();
}
if (this.currentProtocol != null) {
this.condition.protocol = this.currentProtocol;
}
let url = '/api/definition/list/';
if (this.isTestPlan) {
url = '/api/definition/list/relevance/';
this.condition.planId = this.planId;
}
this.result = this.$post(url + this.currentPage + "/" + this.pageSize, this.condition, response => {
this.total = response.data.itemCount;
this.tableData = response.data.listObject;
});
},
handleSelect(selection, row) {
_handleSelect(this, selection, row, 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);
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
getColor(method) {
return this.methodColorMap.get(method);
},
setEnvironment(data) {
this.environmentId = data.id;
}
}, },
} initTable() {
this.selectRows = new Set();
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
this.condition.moduleIds = this.selectNodeIds;
if (this.trashEnable) {
this.condition.filters = {status: ["Trash"]};
this.condition.moduleIds = [];
}
if (this.projectId != null) {
this.condition.projectId = this.projectId;
} else {
this.condition.projectId = getCurrentProjectID();
}
if (this.currentProtocol != null) {
this.condition.protocol = this.currentProtocol;
}
let url = '/api/definition/list/';
if (this.isTestPlan) {
url = '/api/definition/list/relevance/';
this.condition.planId = this.planId;
}
this.result = this.$post(url + this.currentPage + "/" + this.pageSize, this.condition, response => {
this.total = response.data.itemCount;
this.tableData = response.data.listObject;
});
},
handleSelect(selection, row) {
_handleSelect(this, selection, row, 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);
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
getColor(method) {
return this.methodColorMap.get(method);
},
setEnvironment(data) {
this.environmentId = data.id;
}
},
}
</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: 30%; width: 30%;
margin-bottom: 20px; margin-bottom: 20px;
margin-right: 20px; margin-right: 20px;
} }
</style> </style>

View File

@ -10,28 +10,23 @@
<el-table v-loading="result.loading" <el-table v-loading="result.loading"
ref="caseTable" ref="caseTable"
border border
:data="tableData" row-key="id" class="test-content adjust-table" :data="tableData" row-key="id" class="test-content adjust-table ms-select-all"
@select-all="handleSelectAll" @select-all="handleSelectAll"
@filter-change="filter" @filter-change="filter"
@sort-change="sort" @sort-change="sort"
@select="handleSelect" :height="screenHeight"> @select="handleSelect" :height="screenHeight">
<el-table-column type="selection"/>
<el-table-column width="40" :resizable="false" align="center"> <el-table-column type="selection" width="50"/>
<el-dropdown slot="header" style="width: 14px">
<span class="el-dropdown-link" style="width: 14px"> <ms-table-select-all
<i class="el-icon-arrow-down el-icon--right" style="margin-left: 0px"></i> :page-size="pageSize"
</span> :total="total"
<el-dropdown-menu slot="dropdown"> @selectPageAll="isSelectDataAll(false)"
<el-dropdown-item @click.native.stop="isSelectDataAll(true)"> @selectAll="isSelectDataAll(true)"/>
{{ $t('api_test.batch_menus.select_all_data', [total]) }}
</el-dropdown-item> <el-table-column width="30" :resizable="false" align="center">
<el-dropdown-item @click.native.stop="isSelectDataAll(false)">
{{ $t('api_test.batch_menus.select_show_data', [tableData.length]) }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<template v-slot:default="scope"> <template v-slot:default="scope">
<show-more-btn :is-show="scope.row.showMore && !isReadOnly" :buttons="buttons" :size="selectDataCounts"/> <show-more-btn :is-show="scope.row.showMore" :buttons="buttons" :size="selectDataCounts"/>
</template> </template>
</el-table-column> </el-table-column>
@ -117,8 +112,6 @@ 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 TestPlanCaseListHeader from "../../../../track/plan/view/comonents/api/TestPlanCaseListHeader";
import MsEnvironmentSelect from "../case/MsEnvironmentSelect";
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";
@ -126,10 +119,12 @@ import MsSetEnvironment from "@/business/components/api/definition/components/ba
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";
export default { export default {
name: "ApiCaseSimpleList", name: "ApiCaseSimpleList",
components: { components: {
MsTableSelectAll,
MsSetEnvironment, MsSetEnvironment,
ApiCaseList, ApiCaseList,
PriorityTableItem, PriorityTableItem,
@ -569,4 +564,12 @@ export default {
margin-right: 20px; margin-right: 20px;
} }
.ms-select-all >>> th:first-child {
margin-top: 20px;
}
.ms-select-all >>> th:nth-child(2) .el-icon-arrow-down {
top: -2px;
}
</style> </style>

View File

@ -49,6 +49,9 @@
<el-table-column <el-table-column
prop="method" prop="method"
sortable="custom"
column-key="method"
:filters="methodFilters"
:label="$t('api_test.definition.api_type')" :label="$t('api_test.definition.api_type')"
show-overflow-tooltip> show-overflow-tooltip>
<template v-slot:default="scope" class="request-method"> <template v-slot:default="scope" class="request-method">
@ -66,6 +69,9 @@
<el-table-column <el-table-column
prop="userName" prop="userName"
sortable="custom"
:filters="userFilters"
column-key="user_id"
:label="$t('api_test.definition.api_principal')" :label="$t('api_test.definition.api_principal')"
show-overflow-tooltip/> show-overflow-tooltip/>
@ -77,7 +83,11 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="160" :label="$t('api_test.definition.api_last_time')" prop="updateTime"> <el-table-column
width="160"
:label="$t('api_test.definition.api_last_time')"
sortable="custom"
prop="updateTime">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span> <span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template> </template>
@ -180,6 +190,21 @@ export default {
{text: this.$t('test_track.plan.plan_status_completed'), value: 'Completed'}, {text: this.$t('test_track.plan.plan_status_completed'), value: 'Completed'},
{text: this.$t('test_track.plan.plan_status_trash'), value: 'Trash'}, {text: this.$t('test_track.plan.plan_status_trash'), value: 'Trash'},
], ],
methodFilters: [
{text: 'GET', value: 'GET'},
{text: 'POST', value: 'POST'},
{text: 'PUT', value: 'PUT'},
{text: 'PATCH', value: 'PATCH'},
{text: 'DELETE', value: 'DELETE'},
{text: 'OPTIONS', value: 'OPTIONS'},
{text: 'HEAD', value: 'HEAD'},
{text: 'CONNECT', value: 'CONNECT'},
{text: 'DUBBO', value: 'DUBBO'},
{text: 'dubbo://', value: 'dubbo://'},
{text: 'SQL', value: 'SQL'},
{text: 'TCP', value: 'TCP'},
],
userFilters: [],
valueArr: { valueArr: {
status: API_STATUS, status: API_STATUS,
method: REQ_METHOD, method: REQ_METHOD,
@ -292,6 +317,9 @@ export default {
let workspaceId = localStorage.getItem(WORKSPACE_ID); let workspaceId = localStorage.getItem(WORKSPACE_ID);
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => { this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
this.valueArr.userId = response.data; this.valueArr.userId = response.data;
this.userFilters = response.data.map(u => {
return {text: u.name, value: u.id}
});
}); });
}, },
handleSelect(selection, row) { handleSelect(selection, row) {
@ -541,37 +569,16 @@ export default {
margin-right: 20px; margin-right: 20px;
} }
.api-list >>> th:first-child {
/*border: 1px solid #DCDFE6;*/
/*border-right: 0px;*/
/*border-top-left-radius:5px;*/
/*border-bottom-left-radius:5px;*/
/*width: 20px;*/
}
.api-list >>> th:nth-child(2) {
/*border: 1px solid #DCDFE6;*/
/*border-left: 0px;*/
/*border-top-right-radius:5px;*/
/*border-bottom-right-radius:5px;*/
}
.api-list >>> th:first-child > .cell {
padding: 5px;
width: 30px;
}
.api-list >>> th:nth-child(2) > .cell {
/*background-color: black;*/
}
.api-list >>> .el-dropdown {
float: left;
}
.el-tag { .el-tag {
margin-left: 10px; margin-left: 10px;
} }
.ms-select-all >>> th:first-child {
margin-top: 20px;
}
.ms-select-all >>> th:nth-child(2) .el-icon-arrow-down {
top: -2px;
}
</style> </style>

View File

@ -26,12 +26,13 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="num" label="ID" show-overflow-tooltip/> <el-table-column prop="num" sortable="custom" label="ID" show-overflow-tooltip/>
<el-table-column prop="name" :label="$t('api_test.definition.api_name')" show-overflow-tooltip/> <el-table-column prop="name" sortable="custom" :label="$t('api_test.definition.api_name')" show-overflow-tooltip/>
<el-table-column <el-table-column
prop="priority" prop="priority"
:filters="priorityFilters" :filters="priorityFilters"
sortable="custom"
column-key="priority" column-key="priority"
:label="$t('test_track.case.priority')" :label="$t('test_track.case.priority')"
show-overflow-tooltip> show-overflow-tooltip>
@ -47,6 +48,9 @@
<el-table-column <el-table-column
prop="createUser" prop="createUser"
column-key="user_id"
sortable="custom"
:filters="userFilters"
:label="'创建人'" :label="'创建人'"
show-overflow-tooltip/> show-overflow-tooltip/>
@ -134,6 +138,7 @@ import MsRun from "../../../../../api/definition/components/Run";
import TestPlanApiCaseResult from "./TestPlanApiCaseResult"; import TestPlanApiCaseResult from "./TestPlanApiCaseResult";
import TestPlan from "../../../../../api/definition/components/jmeter/components/test-plan"; import TestPlan from "../../../../../api/definition/components/jmeter/components/test-plan";
import ThreadGroup from "../../../../../api/definition/components/jmeter/components/thread-group"; import ThreadGroup from "../../../../../api/definition/components/jmeter/components/thread-group";
import {WORKSPACE_ID} from "@/common/js/constants";
export default { export default {
name: "TestPlanApiCaseList", name: "TestPlanApiCaseList",
@ -177,6 +182,7 @@ export default {
], ],
valueArr: { valueArr: {
priority: CASE_PRIORITY, priority: CASE_PRIORITY,
userId: [],
}, },
methodColorMap: new Map(API_METHOD_COLOUR), methodColorMap: new Map(API_METHOD_COLOUR),
tableData: [], tableData: [],
@ -189,7 +195,8 @@ export default {
runData: [], runData: [],
reportId: "", reportId: "",
response: {}, response: {},
rowLoading: "" rowLoading: "",
userFilters: []
} }
}, },
props: { props: {
@ -220,6 +227,7 @@ export default {
planId: String planId: String
}, },
created: function () { created: function () {
this.getMaintainerOptions();
this.initTable(); this.initTable();
}, },
watch: { watch: {
@ -248,6 +256,15 @@ export default {
}, },
}, },
methods: { methods: {
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}
});
});
},
isApiListEnableChange(data) { isApiListEnableChange(data) {
this.$emit('isApiListEnableChange', data); this.$emit('isApiListEnableChange', data);
}, },

View File

@ -205,7 +205,19 @@ export default {
// //
// }, // },
handleDeleteBatch() { handleDeleteBatch() {
this.$alert(this.$t('test_track.plan_view.confirm_cancel_relevance') + "", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
let ids = Array.from(this.selectRows).map(row => row.id);
this.result = this.$post('/test/plan/load/case/batch/delete', ids, () => {
this.selectRows.clear();
this.initTable();
this.$success(this.$t('test_track.cancel_relevance_success'));
});
}
}
})
}, },
handleRunBatch() { handleRunBatch() {
@ -221,7 +233,7 @@ export default {
}) })
}, },
handleDelete(loadCase) { handleDelete(loadCase) {
this.$get('/test/plan/load/case/delete/' + loadCase.id, () => { this.result = this.$get('/test/plan/load/case/delete/' + loadCase.id, () => {
this.$success(this.$t('test_track.cancel_relevance_success')); this.$success(this.$t('test_track.cancel_relevance_success'));
this.$emit('refresh'); this.$emit('refresh');
this.initTable(); this.initTable();