parent
98b0391234
commit
00c269ff8d
|
@ -94,6 +94,10 @@ public class APITestController {
|
||||||
public String runDebug(@RequestPart("request") SaveAPITestRequest request, @RequestPart(value = "file") MultipartFile file, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
|
public String runDebug(@RequestPart("request") SaveAPITestRequest request, @RequestPart(value = "file") MultipartFile file, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
|
||||||
return apiTestService.runDebug(request, file, bodyFiles);
|
return apiTestService.runDebug(request, file, bodyFiles);
|
||||||
}
|
}
|
||||||
|
@PostMapping(value = "/checkName")
|
||||||
|
public void checkName(@RequestBody SaveAPITestRequest request) {
|
||||||
|
apiTestService.checkName(request);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/import", consumes = {"multipart/form-data"})
|
@PostMapping(value = "/import", consumes = {"multipart/form-data"})
|
||||||
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
@RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR)
|
||||||
|
|
|
@ -245,6 +245,13 @@ public class APITestService {
|
||||||
MSException.throwException(Translator.get("load_test_already_exists"));
|
MSException.throwException(Translator.get("load_test_already_exists"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void checkName(SaveAPITestRequest request) {
|
||||||
|
ApiTestExample example = new ApiTestExample();
|
||||||
|
example.createCriteria().andNameEqualTo(request.getName()).andProjectIdEqualTo(request.getProjectId());
|
||||||
|
if (apiTestMapper.countByExample(example) > 0) {
|
||||||
|
MSException.throwException(Translator.get("load_test_already_exists"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private ApiTest updateTest(SaveAPITestRequest request) {
|
private ApiTest updateTest(SaveAPITestRequest request) {
|
||||||
checkNameExist(request);
|
checkNameExist(request);
|
||||||
|
|
|
@ -11,8 +11,9 @@
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<one-click-operation ref="OneClickOperation" :select-ids="selectIds" :select-names="selectNames"
|
<one-click-operation ref="OneClickOperation" :select-ids="selectIds"
|
||||||
:select-project-names="selectProjectNames" @refresh="init()"></one-click-operation>
|
:select-project-names="selectProjectNames" :select-project-id="selectProjectId"
|
||||||
|
@refresh="init()"></one-click-operation>
|
||||||
|
|
||||||
<el-table border :data="tableData" class="adjust-table table-content" @sort-change="sort"
|
<el-table border :data="tableData" class="adjust-table table-content" @sort-change="sort"
|
||||||
@row-click="handleView"
|
@row-click="handleView"
|
||||||
|
@ -59,180 +60,175 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import OneClickOperation from './OneClickOperation';
|
import OneClickOperation from './OneClickOperation';
|
||||||
import MsTablePagination from "../../common/pagination/TablePagination";
|
import MsTablePagination from "../../common/pagination/TablePagination";
|
||||||
import MsTableHeader from "../../common/components/MsTableHeader";
|
import MsTableHeader from "../../common/components/MsTableHeader";
|
||||||
import MsTableOperator from "../../common/components/MsTableOperator";
|
import MsTableOperator from "../../common/components/MsTableOperator";
|
||||||
import MsContainer from "../../common/components/MsContainer";
|
import MsContainer from "../../common/components/MsContainer";
|
||||||
import MsMainContainer from "../../common/components/MsMainContainer";
|
import MsMainContainer from "../../common/components/MsMainContainer";
|
||||||
import MsApiTestStatus from "./ApiTestStatus";
|
import MsApiTestStatus from "./ApiTestStatus";
|
||||||
import MsTableOperators from "../../common/components/MsTableOperators";
|
import MsTableOperators from "../../common/components/MsTableOperators";
|
||||||
import {_filter, _sort} from "@/common/js/utils";
|
import {_filter, _sort} from "@/common/js/utils";
|
||||||
import {TEST_CONFIGS} from "../../common/components/search/search-components";
|
import {TEST_CONFIGS} from "../../common/components/search/search-components";
|
||||||
import {ApiEvent, LIST_CHANGE} from "@/business/components/common/head/ListEvent";
|
import {ApiEvent, LIST_CHANGE} from "@/business/components/common/head/ListEvent";
|
||||||
import ApiCopyDialog from "./components/ApiCopyDialog";
|
import ApiCopyDialog from "./components/ApiCopyDialog";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
ApiCopyDialog,
|
ApiCopyDialog,
|
||||||
OneClickOperation,
|
OneClickOperation,
|
||||||
MsTableOperators,
|
MsTableOperators,
|
||||||
MsApiTestStatus, MsMainContainer, MsContainer, MsTableHeader, MsTablePagination, MsTableOperator
|
MsApiTestStatus, MsMainContainer, MsContainer, MsTableHeader, MsTablePagination, MsTableOperator
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
result: {},
|
|
||||||
condition: {
|
|
||||||
components: TEST_CONFIGS
|
|
||||||
},
|
|
||||||
projectId: null,
|
|
||||||
tableData: [],
|
|
||||||
multipleSelection: [],
|
|
||||||
currentPage: 1,
|
|
||||||
pageSize: 5,
|
|
||||||
total: 0,
|
|
||||||
loading: false,
|
|
||||||
selectIds: new Set(),
|
|
||||||
selectNames: new Set(),
|
|
||||||
selectProjectNames: new Set(),
|
|
||||||
buttons: [
|
|
||||||
{
|
|
||||||
tip: this.$t('commons.edit'), icon: "el-icon-edit",
|
|
||||||
exec: this.handleEdit
|
|
||||||
}, {
|
|
||||||
tip: this.$t('commons.copy'), icon: "el-icon-copy-document", type: "success",
|
|
||||||
exec: this.handleCopy
|
|
||||||
}, {
|
|
||||||
tip: this.$t('commons.delete'), icon: "el-icon-delete", type: "danger",
|
|
||||||
exec: this.handleDelete
|
|
||||||
}
|
|
||||||
],
|
|
||||||
statusFilters: [
|
|
||||||
{text: 'Saved', value: 'Saved'},
|
|
||||||
{text: 'Starting', value: 'Starting'},
|
|
||||||
{text: 'Running', value: 'Running'},
|
|
||||||
{text: 'Reporting', value: 'Reporting'},
|
|
||||||
{text: 'Completed', value: 'Completed'},
|
|
||||||
{text: 'Error', value: 'Error'}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
watch: {
|
|
||||||
'$route': 'init'
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
|
||||||
create() {
|
|
||||||
this.$router.push('/api/test/create');
|
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
handleSelectAll(selection) {
|
return {
|
||||||
this.selectIds.clear()
|
result: {},
|
||||||
this.selectProjectNames.clear()
|
condition: {
|
||||||
this.selectNames.clear()
|
components: TEST_CONFIGS
|
||||||
if (selection.length > 0) {
|
},
|
||||||
selection.forEach(s => {
|
projectId: null,
|
||||||
this.selectIds.add(s.id)
|
tableData: [],
|
||||||
this.selectProjectNames.add(s.projectName)
|
multipleSelection: [],
|
||||||
})
|
currentPage: 1,
|
||||||
}
|
pageSize: 5,
|
||||||
},
|
total: 0,
|
||||||
selectionChange(selection) {
|
loading: false,
|
||||||
this.selectIds.clear()
|
selectIds: new Set(),
|
||||||
this.selectProjectNames.clear()
|
selectProjectNames: new Set(),
|
||||||
this.selectNames.clear()
|
selectProjectId: new Set(),
|
||||||
if (selection.length > 0) {
|
buttons: [
|
||||||
selection.forEach(s => {
|
{
|
||||||
this.selectIds.add(s.id)
|
tip: this.$t('commons.edit'), icon: "el-icon-edit",
|
||||||
this.selectProjectNames.add(s.projectName)
|
exec: this.handleEdit
|
||||||
})
|
}, {
|
||||||
}
|
tip: this.$t('commons.copy'), icon: "el-icon-copy-document", type: "success",
|
||||||
},
|
exec: this.handleCopy
|
||||||
runTest() {
|
}, {
|
||||||
if (this.selectIds.size < 1) {
|
tip: this.$t('commons.delete'), icon: "el-icon-delete", type: "danger",
|
||||||
this.$warning(this.$t('test_track.plan_view.select_manipulate'));
|
exec: this.handleDelete
|
||||||
} else {
|
|
||||||
this.$refs.OneClickOperation.openOneClickOperation();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
search() {
|
|
||||||
if (this.projectId !== 'all') {
|
|
||||||
this.condition.projectId = this.projectId;
|
|
||||||
}
|
|
||||||
let url = "/api/list/" + this.currentPage + "/" + this.pageSize;
|
|
||||||
this.result = this.$post(url, this.condition, response => {
|
|
||||||
let data = response.data;
|
|
||||||
this.total = data.itemCount;
|
|
||||||
this.tableData = data.listObject;
|
|
||||||
this.tableData.forEach(item => {
|
|
||||||
this.selectNames.add(item.name)
|
|
||||||
})
|
|
||||||
});
|
|
||||||
},
|
|
||||||
handleSelectionChange(val) {
|
|
||||||
this.multipleSelection = val;
|
|
||||||
},
|
|
||||||
handleEdit(test) {
|
|
||||||
this.$router.push({
|
|
||||||
path: '/api/test/edit?id=' + test.id,
|
|
||||||
})
|
|
||||||
},
|
|
||||||
handleView(test) {
|
|
||||||
this.$router.push({
|
|
||||||
path: '/api/test/view?id=' + test.id,
|
|
||||||
})
|
|
||||||
},
|
|
||||||
handleDelete(test) {
|
|
||||||
this.$alert(this.$t('load_test.delete_confirm') + test.name + "?", '', {
|
|
||||||
confirmButtonText: this.$t('commons.confirm'),
|
|
||||||
callback: (action) => {
|
|
||||||
if (action === 'confirm') {
|
|
||||||
this.result = this.$post("/api/delete", {id: test.id}, () => {
|
|
||||||
this.$success(this.$t('commons.delete_success'));
|
|
||||||
this.search();
|
|
||||||
// 发送广播,刷新 head 上的最新列表
|
|
||||||
ApiEvent.$emit(LIST_CHANGE);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
],
|
||||||
});
|
statusFilters: [
|
||||||
},
|
{text: 'Saved', value: 'Saved'},
|
||||||
handleCopy(test) {
|
{text: 'Starting', value: 'Starting'},
|
||||||
this.$refs.apiCopy.open(test);
|
{text: 'Running', value: 'Running'},
|
||||||
},
|
{text: 'Reporting', value: 'Reporting'},
|
||||||
init() {
|
{text: 'Completed', value: 'Completed'},
|
||||||
this.selectIds.clear()
|
{text: 'Error', value: 'Error'}
|
||||||
this.selectProjectNames.clear()
|
]
|
||||||
this.selectNames.clear()
|
|
||||||
this.projectId = this.$route.params.projectId;
|
|
||||||
if (this.projectId && this.projectId !== "all") {
|
|
||||||
this.$store.commit('setProjectId', this.projectId);
|
|
||||||
}
|
}
|
||||||
this.search();
|
|
||||||
},
|
},
|
||||||
sort(column) {
|
|
||||||
_sort(column, this.condition);
|
|
||||||
this.init();
|
|
||||||
},
|
|
||||||
filter(filters) {
|
|
||||||
_filter(filters, this.condition);
|
|
||||||
this.init();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
watch: {
|
||||||
|
'$route': 'init'
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
create() {
|
||||||
|
this.$router.push('/api/test/create');
|
||||||
|
},
|
||||||
|
|
||||||
|
handleSelectAll(selection) {
|
||||||
|
this.selectIds.clear()
|
||||||
|
this.selectProjectNames.clear()
|
||||||
|
this.selectProjectId.clear()
|
||||||
|
selection.forEach(s => {
|
||||||
|
this.selectIds.add(s.id)
|
||||||
|
this.selectProjectNames.add(s.projectName)
|
||||||
|
this.selectProjectId.add(s.projectId)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
selectionChange(selection) {
|
||||||
|
this.selectIds.clear()
|
||||||
|
this.selectProjectNames.clear()
|
||||||
|
this.selectProjectId.clear()
|
||||||
|
selection.forEach(s => {
|
||||||
|
this.selectIds.add(s.id)
|
||||||
|
this.selectProjectNames.add(s.projectName)
|
||||||
|
this.selectProjectId.add(s.projectId)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
runTest() {
|
||||||
|
if (this.selectIds.size < 1) {
|
||||||
|
this.$warning(this.$t('test_track.plan_view.select_manipulate'));
|
||||||
|
} else {
|
||||||
|
this.$refs.OneClickOperation.openOneClickOperation();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
search() {
|
||||||
|
if (this.projectId !== 'all') {
|
||||||
|
this.condition.projectId = this.projectId;
|
||||||
|
}
|
||||||
|
let url = "/api/list/" + this.currentPage + "/" + this.pageSize;
|
||||||
|
this.result = this.$post(url, this.condition, response => {
|
||||||
|
let data = response.data;
|
||||||
|
this.total = data.itemCount;
|
||||||
|
this.tableData = data.listObject;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleSelectionChange(val) {
|
||||||
|
this.multipleSelection = val;
|
||||||
|
},
|
||||||
|
handleEdit(test) {
|
||||||
|
this.$router.push({
|
||||||
|
path: '/api/test/edit?id=' + test.id,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleView(test) {
|
||||||
|
this.$router.push({
|
||||||
|
path: '/api/test/view?id=' + test.id,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleDelete(test) {
|
||||||
|
this.$alert(this.$t('load_test.delete_confirm') + test.name + "?", '', {
|
||||||
|
confirmButtonText: this.$t('commons.confirm'),
|
||||||
|
callback: (action) => {
|
||||||
|
if (action === 'confirm') {
|
||||||
|
this.result = this.$post("/api/delete", {id: test.id}, () => {
|
||||||
|
this.$success(this.$t('commons.delete_success'));
|
||||||
|
this.search();
|
||||||
|
// 发送广播,刷新 head 上的最新列表
|
||||||
|
ApiEvent.$emit(LIST_CHANGE);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleCopy(test) {
|
||||||
|
this.$refs.apiCopy.open(test);
|
||||||
|
},
|
||||||
|
init() {
|
||||||
|
this.selectIds.clear()
|
||||||
|
this.selectProjectNames.clear()
|
||||||
|
this.selectIds.clear()
|
||||||
|
this.projectId = this.$route.params.projectId;
|
||||||
|
if (this.projectId && this.projectId !== "all") {
|
||||||
|
this.$store.commit('setProjectId', this.projectId);
|
||||||
|
}
|
||||||
|
this.search();
|
||||||
|
},
|
||||||
|
sort(column) {
|
||||||
|
_sort(column, this.condition);
|
||||||
|
this.init();
|
||||||
|
},
|
||||||
|
filter(filters) {
|
||||||
|
_filter(filters, this.condition);
|
||||||
|
this.init();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.table-content {
|
.table-content {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-table {
|
.el-table {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
tests: [],
|
tests: [],
|
||||||
ruleForm: {},
|
ruleForm: {},
|
||||||
change: false,
|
change: false,
|
||||||
|
projectId: "",
|
||||||
rule: {
|
rule: {
|
||||||
testName: [
|
testName: [
|
||||||
{required: true, message: this.$t('api_test.input_name'), trigger: 'blur'},
|
{required: true, message: this.$t('api_test.input_name'), trigger: 'blur'},
|
||||||
|
@ -61,10 +62,10 @@
|
||||||
selectIds: {
|
selectIds: {
|
||||||
type: Set
|
type: Set
|
||||||
},
|
},
|
||||||
selectNames: {
|
selectProjectNames: {
|
||||||
type: Set
|
type: Set
|
||||||
},
|
},
|
||||||
selectProjectNames: {
|
selectProjectId: {
|
||||||
type: Set
|
type: Set
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -73,23 +74,30 @@
|
||||||
this.oneClickOperationVisible = true;
|
this.oneClickOperationVisible = true;
|
||||||
},
|
},
|
||||||
checkedSaveAndRunTest() {
|
checkedSaveAndRunTest() {
|
||||||
if (this.selectNames.has(this.ruleForm.testName)) {
|
if (this.ruleForm.testName) {
|
||||||
this.$warning(this.$t('load_test.already_exists'));
|
|
||||||
this.oneClickOperationVisible = false;
|
|
||||||
this.$emit('refresh')
|
|
||||||
} else {
|
|
||||||
if (this.selectProjectNames.size > 1) {
|
if (this.selectProjectNames.size > 1) {
|
||||||
|
|
||||||
/* console.log(this.selectIds)
|
|
||||||
console.log(this.selectNames)*/
|
|
||||||
this.$warning(this.$t('load_test.same_project_test'));
|
this.$warning(this.$t('load_test.same_project_test'));
|
||||||
this.oneClickOperationVisible = false;
|
this.oneClickOperationVisible = false;
|
||||||
this.$emit('refresh')
|
this.$emit('refresh')
|
||||||
} else {
|
} else {
|
||||||
for (let x of this.selectIds) {
|
this.checkNameResult(this.ruleForm.testName)
|
||||||
this.getTest(x)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.$warning(this.$t('api_test.input_name'))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
checkNameResult() {
|
||||||
|
this.checkName(() => {
|
||||||
|
for (let x of this.selectIds) {
|
||||||
|
this.getTest(x)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
checkName(callback) {
|
||||||
|
for (let i of this.selectProjectId) {
|
||||||
|
this.result = this.$post('/api/checkName', {name: this.ruleForm.testName, projectId: i}, response => {
|
||||||
|
if (callback) callback();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_getEnvironmentAndRunTest: function (item) {
|
_getEnvironmentAndRunTest: function (item) {
|
||||||
|
@ -123,6 +131,7 @@
|
||||||
scenarioDefinition: JSON.parse(item.scenarioDefinition),
|
scenarioDefinition: JSON.parse(item.scenarioDefinition),
|
||||||
schedule: {},
|
schedule: {},
|
||||||
});
|
});
|
||||||
|
console.log(test)
|
||||||
this.test = this.test || test;
|
this.test = this.test || test;
|
||||||
if (this.tests.length > 1) {
|
if (this.tests.length > 1) {
|
||||||
this.test.scenarioDefinition = this.test.scenarioDefinition.concat(test.scenarioDefinition);
|
this.test.scenarioDefinition = this.test.scenarioDefinition.concat(test.scenarioDefinition);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
<el-dialog @close="close"
|
<el-dialog @close="close"
|
||||||
:title="operationType == 'edit' ? ( readOnly ? $t('test_track.case.view_case') : $t('test_track.case.edit_case')) : $t('test_track.case.create')"
|
: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%">
|
:visible.sync="dialogFormVisible" width="65%" :close-on-click-modal="false">
|
||||||
|
|
||||||
<el-form :model="form" :rules="rules" ref="caseFrom" v-loading="result.loading">
|
<el-form :model="form" :rules="rules" ref="caseFrom" v-loading="result.loading">
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue