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) {
|
||||
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"})
|
||||
@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"));
|
||||
}
|
||||
}
|
||||
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) {
|
||||
checkNameExist(request);
|
||||
|
|
|
@ -11,8 +11,9 @@
|
|||
|
||||
</template>
|
||||
|
||||
<one-click-operation ref="OneClickOperation" :select-ids="selectIds" :select-names="selectNames"
|
||||
:select-project-names="selectProjectNames" @refresh="init()"></one-click-operation>
|
||||
<one-click-operation ref="OneClickOperation" :select-ids="selectIds"
|
||||
: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"
|
||||
@row-click="handleView"
|
||||
|
@ -93,8 +94,8 @@ export default {
|
|||
total: 0,
|
||||
loading: false,
|
||||
selectIds: new Set(),
|
||||
selectNames: new Set(),
|
||||
selectProjectNames: new Set(),
|
||||
selectProjectId: new Set(),
|
||||
buttons: [
|
||||
{
|
||||
tip: this.$t('commons.edit'), icon: "el-icon-edit",
|
||||
|
@ -130,24 +131,22 @@ export default {
|
|||
handleSelectAll(selection) {
|
||||
this.selectIds.clear()
|
||||
this.selectProjectNames.clear()
|
||||
this.selectNames.clear()
|
||||
if (selection.length > 0) {
|
||||
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.selectNames.clear()
|
||||
if (selection.length > 0) {
|
||||
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) {
|
||||
|
@ -165,9 +164,6 @@ export default {
|
|||
let data = response.data;
|
||||
this.total = data.itemCount;
|
||||
this.tableData = data.listObject;
|
||||
this.tableData.forEach(item => {
|
||||
this.selectNames.add(item.name)
|
||||
})
|
||||
});
|
||||
},
|
||||
handleSelectionChange(val) {
|
||||
|
@ -204,7 +200,7 @@ export default {
|
|||
init() {
|
||||
this.selectIds.clear()
|
||||
this.selectProjectNames.clear()
|
||||
this.selectNames.clear()
|
||||
this.selectIds.clear()
|
||||
this.projectId = this.$route.params.projectId;
|
||||
if (this.projectId && this.projectId !== "all") {
|
||||
this.$store.commit('setProjectId', this.projectId);
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
tests: [],
|
||||
ruleForm: {},
|
||||
change: false,
|
||||
projectId: "",
|
||||
rule: {
|
||||
testName: [
|
||||
{required: true, message: this.$t('api_test.input_name'), trigger: 'blur'},
|
||||
|
@ -61,10 +62,10 @@
|
|||
selectIds: {
|
||||
type: Set
|
||||
},
|
||||
selectNames: {
|
||||
selectProjectNames: {
|
||||
type: Set
|
||||
},
|
||||
selectProjectNames: {
|
||||
selectProjectId: {
|
||||
type: Set
|
||||
}
|
||||
},
|
||||
|
@ -73,23 +74,30 @@
|
|||
this.oneClickOperationVisible = true;
|
||||
},
|
||||
checkedSaveAndRunTest() {
|
||||
if (this.selectNames.has(this.ruleForm.testName)) {
|
||||
this.$warning(this.$t('load_test.already_exists'));
|
||||
this.oneClickOperationVisible = false;
|
||||
this.$emit('refresh')
|
||||
} else {
|
||||
if (this.ruleForm.testName) {
|
||||
if (this.selectProjectNames.size > 1) {
|
||||
|
||||
/* console.log(this.selectIds)
|
||||
console.log(this.selectNames)*/
|
||||
this.$warning(this.$t('load_test.same_project_test'));
|
||||
this.oneClickOperationVisible = false;
|
||||
this.$emit('refresh')
|
||||
} else {
|
||||
this.checkNameResult(this.ruleForm.testName)
|
||||
}
|
||||
} 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) {
|
||||
|
@ -123,6 +131,7 @@
|
|||
scenarioDefinition: JSON.parse(item.scenarioDefinition),
|
||||
schedule: {},
|
||||
});
|
||||
console.log(test)
|
||||
this.test = this.test || test;
|
||||
if (this.tests.length > 1) {
|
||||
this.test.scenarioDefinition = this.test.scenarioDefinition.concat(test.scenarioDefinition);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<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')"
|
||||
: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">
|
||||
|
||||
|
|
Loading…
Reference in New Issue