fix: 用例评审测试计划版本选择框

This commit is contained in:
zhangdahai112 2022-01-19 22:22:05 +08:00 committed by zhangdahai112
parent 49a4d67ce9
commit 823f04c8f4
6 changed files with 320 additions and 281 deletions

View File

@ -31,26 +31,6 @@
<if test="request.refId != null"> <if test="request.refId != null">
and load_test.ref_id = #{request.refId} and load_test.ref_id = #{request.refId}
</if> </if>
<if test="request.versionId == null and request.refId == null and request.id == null">
AND (
load_test.version_id = (SELECT project_version.id
FROM load_test tmp
JOIN project_version
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
WHERE ref_id = load_test.ref_id
LIMIT 1)
OR
load_test.version_id = (SELECT project_version.id
FROM load_test tmp
JOIN project_version ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id
WHERE ref_id = load_test.ref_id
GROUP BY ref_id
HAVING MAX(latest) = 0
ORDER BY MAX(project_version.create_time) DESC
LIMIT 1)
)
</if>
<if test="request.filters != null and request.filters.size() > 0"> <if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values"> <foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0"> <if test="values != null and values.size() > 0">

View File

@ -9,6 +9,7 @@ import io.metersphere.base.mapper.LoadTestMapper;
import io.metersphere.base.mapper.LoadTestReportMapper; import io.metersphere.base.mapper.LoadTestReportMapper;
import io.metersphere.base.mapper.TestPlanLoadCaseMapper; import io.metersphere.base.mapper.TestPlanLoadCaseMapper;
import io.metersphere.base.mapper.TestPlanMapper; import io.metersphere.base.mapper.TestPlanMapper;
import io.metersphere.base.mapper.ext.ExtLoadTestMapper;
import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper; import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanLoadCaseMapper; import io.metersphere.base.mapper.ext.ExtTestPlanLoadCaseMapper;
import io.metersphere.commons.constants.PerformanceTestStatus; import io.metersphere.commons.constants.PerformanceTestStatus;
@ -21,6 +22,7 @@ import io.metersphere.controller.request.OrderRequest;
import io.metersphere.controller.request.ResetOrderRequest; import io.metersphere.controller.request.ResetOrderRequest;
import io.metersphere.dto.LoadTestDTO; import io.metersphere.dto.LoadTestDTO;
import io.metersphere.log.vo.OperatingLogDetails; import io.metersphere.log.vo.OperatingLogDetails;
import io.metersphere.performance.request.QueryTestPlanRequest;
import io.metersphere.performance.request.RunTestPlanRequest; import io.metersphere.performance.request.RunTestPlanRequest;
import io.metersphere.performance.service.PerformanceTestService; import io.metersphere.performance.service.PerformanceTestService;
import io.metersphere.track.dto.*; import io.metersphere.track.dto.*;
@ -69,6 +71,8 @@ public class TestPlanLoadCaseService {
@Resource @Resource
@Lazy @Lazy
private TestPlanService testPlanService; private TestPlanService testPlanService;
@Resource
private ExtLoadTestMapper extLoadTestMapper;
public Pager<List<LoadTestDTO>> relevanceList(LoadCaseRequest request, int goPage, int pageSize) { public Pager<List<LoadTestDTO>> relevanceList(LoadCaseRequest request, int goPage, int pageSize) {
List<OrderRequest> orders = ServiceUtils.getDefaultSortOrder(request.getOrders()); List<OrderRequest> orders = ServiceUtils.getDefaultSortOrder(request.getOrders());
@ -82,7 +86,12 @@ public class TestPlanLoadCaseService {
return PageUtils.setPageInfo(PageHelper.startPage(goPage, pageSize, true), new ArrayList <>()); return PageUtils.setPageInfo(PageHelper.startPage(goPage, pageSize, true), new ArrayList <>());
} }
Page<Object> page = PageHelper.startPage(goPage, pageSize, true); Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, performanceTestService.getLoadTestListByIds(ids)); QueryTestPlanRequest newRequest = new QueryTestPlanRequest();
Map filters = new HashMap();
filters.put("id", ids);
newRequest.setFilters(filters);
List<LoadTestDTO> loadTestDTOS = extLoadTestMapper.list(newRequest);
return PageUtils.setPageInfo(page, loadTestDTOS);
} }
public List<TestPlanLoadCaseDTO> list(LoadCaseRequest request) { public List<TestPlanLoadCaseDTO> list(LoadCaseRequest request) {

View File

@ -27,7 +27,11 @@
:plan-id="planId" :plan-id="planId"
:versionFilters="versionFilters" :versionFilters="versionFilters"
@isApiListEnableChange="isApiListEnableChange" @isApiListEnableChange="isApiListEnableChange"
ref="apiList"/> ref="apiList">
<template v-slot:version>
<version-select v-xpack :project-id="projectId" @changeVersion="changeVersion($event,'api')" margin-left="10"/>
</template>
</relevance-api-list>
<relevance-case-list <relevance-case-list
v-if="!isApiListEnable" v-if="!isApiListEnable"
@ -36,9 +40,15 @@
:is-api-list-enable="isApiListEnable" :is-api-list-enable="isApiListEnable"
:project-id="projectId" :project-id="projectId"
:is-test-plan="true" :is-test-plan="true"
:versionFilters="versionFilters"
:plan-id="planId" :plan-id="planId"
@isApiListEnableChange="isApiListEnableChange" @isApiListEnableChange="isApiListEnableChange"
ref="apiCaseList"/> ref="apiCaseList">
<template v-slot:version>
<version-select v-xpack :project-id="projectId" @changeVersion="changeVersion($event, 'case')"
margin-left="10"/>
</template>
</relevance-case-list>
</test-case-relevance-base> </test-case-relevance-base>
@ -51,6 +61,8 @@
import RelevanceApiList from "../../../../../api/automation/scenario/api/RelevanceApiList"; import RelevanceApiList from "../../../../../api/automation/scenario/api/RelevanceApiList";
import RelevanceCaseList from "../../../../../api/automation/scenario/api/RelevanceCaseList"; import RelevanceCaseList from "../../../../../api/automation/scenario/api/RelevanceCaseList";
import {getCurrentProjectID, hasLicense} from "@/common/js/utils"; import {getCurrentProjectID, hasLicense} from "@/common/js/utils";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {};
export default { export default {
name: "TestCaseApiRelevance", name: "TestCaseApiRelevance",
@ -59,6 +71,7 @@
RelevanceApiList, RelevanceApiList,
MsApiModule, MsApiModule,
TestCaseRelevanceBase, TestCaseRelevanceBase,
'VersionSelect': VersionSelect.default,
}, },
data() { data() {
return { return {
@ -198,6 +211,15 @@
}); });
} }
}, },
changeVersion(currentVersion, type) {
if (type == 'api') {
this.$refs.apiList.condition.versionId = currentVersion || null;
this.$refs.apiList.initTable();
} else {
this.$refs.apiCaseList.condition.versionId = currentVersion || null;
this.$refs.apiCaseList.initTable();
}
}
} }
} }
</script> </script>

View File

@ -17,8 +17,11 @@
ref="nodeTree"/> ref="nodeTree"/>
</template> </template>
<ms-table-header :condition.sync="page.condition" @search="getTestCases" title="" :show-create="false"/> <ms-table-header :condition.sync="page.condition" @search="getTestCases" title="" :show-create="false">
<template v-slot:searchBarBefore>
<version-select v-xpack :project-id="projectId" @changeVersion="changeVersion" margin-right="20"/>
</template>
</ms-table-header>
<ms-table <ms-table
v-loading="page.result.loading" v-loading="page.result.loading"
:data="page.data" :data="page.data"
@ -112,6 +115,8 @@ import MsTable from "@/business/components/common/components/table/MsTable";
import MsTablePagination from "@/business/components/common/pagination/TablePagination"; import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import MsTag from "@/business/components/common/components/MsTag"; import MsTag from "@/business/components/common/components/MsTag";
import {hasLicense, getCurrentProjectID} from "@/common/js/utils"; import {hasLicense, getCurrentProjectID} from "@/common/js/utils";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {};
export default { export default {
name: "FunctionalRelevance", name: "FunctionalRelevance",
@ -127,6 +132,7 @@ export default {
MsTableSearchBar, MsTableSearchBar,
MsTableAdvSearchBar, MsTableAdvSearchBar,
MsTableHeader, MsTableHeader,
'VersionSelect': VersionSelect.default,
}, },
mounted(){ mounted(){
this.getVersionOptions(); this.getVersionOptions();
@ -255,6 +261,10 @@ export default {
}); });
} }
}, },
changeVersion(currentVersion) {
this.page.condition.versionId = currentVersion || null;
this.getTestCases();
}
} }
} }
</script> </script>

View File

@ -19,6 +19,7 @@
<ms-table-adv-search-bar :condition.sync="condition" class="adv-search-bar" <ms-table-adv-search-bar :condition.sync="condition" class="adv-search-bar"
v-if="condition.components !== undefined && condition.components.length > 0" v-if="condition.components !== undefined && condition.components.length > 0"
@search="getTestCases"/> @search="getTestCases"/>
<version-select v-xpack :project-id="projectId" @changeVersion="changeVersion" margin-right="20" class="search-input"/>
<el-table <el-table
v-loading="result.loading" v-loading="result.loading"
@ -101,6 +102,8 @@ import MsTablePagination from "@/business/components/common/pagination/TablePagi
import {_filter} from "@/common/js/tableUtils"; import {_filter} from "@/common/js/tableUtils";
import {TEST_PLAN_RELEVANCE_LOAD_CASE} from "@/business/components/common/components/search/search-components"; import {TEST_PLAN_RELEVANCE_LOAD_CASE} from "@/business/components/common/components/search/search-components";
import {hasLicense, getCurrentProjectID} from "@/common/js/utils"; import {hasLicense, getCurrentProjectID} from "@/common/js/utils";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {};
export default { export default {
name: "TestCaseLoadRelevance", name: "TestCaseLoadRelevance",
@ -113,7 +116,8 @@ export default {
MsTableAdvSearchBar, MsTableAdvSearchBar,
MsTableHeader, MsTableHeader,
MsPerformanceTestStatus, MsPerformanceTestStatus,
MsTablePagination MsTablePagination,
'VersionSelect': VersionSelect.default,
}, },
data() { data() {
return { return {
@ -140,7 +144,7 @@ export default {
{text: 'Completed', value: 'Completed'}, {text: 'Completed', value: 'Completed'},
{text: 'Error', value: 'Error'} {text: 'Error', value: 'Error'}
], ],
versionFilters: [] versionFilters: [],
}; };
}, },
props: { props: {
@ -303,6 +307,10 @@ export default {
}); });
} }
}, },
changeVersion(currentVersion){
this.condition.versionId = currentVersion || null;
this.search();
}
} }
} }
</script> </script>

View File

@ -24,7 +24,11 @@
<el-container> <el-container>
<el-main class="case-content"> <el-main class="case-content">
<ms-table-header :condition.sync="condition" @search="search" title="" :show-create="false"/> <ms-table-header :condition.sync="condition" @search="search" title="" :show-create="false">
<template v-slot:searchBarBefore>
<version-select v-xpack :project-id="projectId" @changeVersion="changeVersion" margin-right="20"/>
</template>
</ms-table-header>
<el-table :data="testReviews" @mouseleave.passive="leave" v-el-table-infinite-scroll="scrollLoading" <el-table :data="testReviews" @mouseleave.passive="leave" v-el-table-infinite-scroll="scrollLoading"
@filter-change="filter" row-key="id" @filter-change="filter" row-key="id"
@select-all="handleSelectAll" @select-all="handleSelectAll"
@ -122,6 +126,8 @@ import elTableInfiniteScroll from 'el-table-infinite-scroll';
import SelectMenu from "../../../common/SelectMenu"; import SelectMenu from "../../../common/SelectMenu";
import {_filter} from "@/common/js/tableUtils"; import {_filter} from "@/common/js/tableUtils";
import {getCurrentProjectID, getCurrentUserId, getCurrentWorkspaceId, hasLicense} from "@/common/js/utils"; import {getCurrentProjectID, getCurrentUserId, getCurrentWorkspaceId, hasLicense} from "@/common/js/utils";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {};
export default { export default {
@ -136,8 +142,8 @@ export default {
MsTableAdvSearchBar, MsTableAdvSearchBar,
MsTableHeader, MsTableHeader,
SwitchProject, SwitchProject,
ReviewStatus ReviewStatus,
'VersionSelect': VersionSelect.default,
}, },
directives: { directives: {
'el-table-infinite-scroll': elTableInfiniteScroll 'el-table-infinite-scroll': elTableInfiniteScroll
@ -396,6 +402,10 @@ export default {
}); });
} }
}, },
changeVersion(version) {
this.condition.versionId = version || null;
this.search();
}
} }
} }
</script> </script>