diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java b/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java index e74246f3f8..26d20b7aae 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiTestCaseController.java @@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper; 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; import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.utils.PageUtils; @@ -61,13 +62,13 @@ public class ApiTestCaseController { } @PostMapping(value = "/create", consumes = {"multipart/form-data"}) - public void create(@RequestPart("request") SaveApiTestCaseRequest request, @RequestPart(value = "files") List bodyFiles) { - apiTestCaseService.create(request, bodyFiles); + public ApiTestCase create(@RequestPart("request") SaveApiTestCaseRequest request, @RequestPart(value = "files") List bodyFiles) { + return apiTestCaseService.create(request, bodyFiles); } @PostMapping(value = "/update", consumes = {"multipart/form-data"}) - public void update(@RequestPart("request") SaveApiTestCaseRequest request, @RequestPart(value = "files") List bodyFiles) { - apiTestCaseService.update(request, bodyFiles); + public ApiTestCase update(@RequestPart("request") SaveApiTestCaseRequest request, @RequestPart(value = "files") List bodyFiles) { + return apiTestCaseService.update(request, bodyFiles); } @GetMapping("/delete/{id}") diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java index f6de4b0a81..78875cf026 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -116,10 +116,11 @@ public class ApiTestCaseService { return apiTestCaseMapper.selectByPrimaryKey(id); } - public void create(SaveApiTestCaseRequest request, List bodyFiles) { + public ApiTestCase create(SaveApiTestCaseRequest request, List bodyFiles) { List bodyUploadIds = new ArrayList<>(request.getBodyUploadIds()); ApiTestCase test = createTest(request); createBodyFiles(test, bodyUploadIds, bodyFiles); + return test; } private void checkQuota() { @@ -129,13 +130,13 @@ public class ApiTestCaseService { } } - public void update(SaveApiTestCaseRequest request, List bodyFiles) { - + public ApiTestCase update(SaveApiTestCaseRequest request, List bodyFiles) { deleteFileByTestId(request.getId()); List bodyUploadIds = new ArrayList<>(request.getBodyUploadIds()); request.setBodyUploadIds(null); ApiTestCase test = updateTest(request); createBodyFiles(test, bodyUploadIds, bodyFiles); + return test; } private void createBodyFiles(ApiTestCase test, List bodyUploadIds, List bodyFiles) { diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 9d360afdf3..8ab3c34732 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -665,7 +665,7 @@ let obj = JSON.parse(JSON.stringify(row)); obj.resourceId = getUUID(); if (obj.name) { - obj.name = obj.name + '_copy'; + obj.name = obj.name + '_copy'; } hashTree.push(obj); this.sort(); @@ -817,21 +817,23 @@ } }) // 场景变量csv 文件 - this.currentScenario.variables.forEach(param => { - if (param.type === 'CSV' && param.files) { - param.files.forEach(item => { - if (item.file) { - if (!item.id) { - let fileId = getUUID().substring(0, 12); - item.name = item.file.name; - item.id = fileId; + if (this.currentScenario.variables) { + this.currentScenario.variables.forEach(param => { + if (param.type === 'CSV' && param.files) { + param.files.forEach(item => { + if (item.file) { + if (!item.id) { + let fileId = getUUID().substring(0, 12); + item.name = item.file.name; + item.id = fileId; + } + obj.bodyUploadIds.push(item.id); + bodyUploadFiles.push(item.file); } - obj.bodyUploadIds.push(item.id); - bodyUploadFiles.push(item.file); - } - }) - } - }) + }) + } + }) + } return bodyUploadFiles; }, editScenario(showMessage) { diff --git a/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue b/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue index e2d383b5bb..1c026f4873 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue @@ -16,7 +16,7 @@ @click="active(apiCase)"/> + @blur="saveTestCase(apiCase)" :placeholder="$t('commons.input_name')"/> {{ apiCase.id ? apiCase.name : '' }} @@ -211,9 +211,12 @@ export default { if (tmp.tags instanceof Array) { tmp.tags = JSON.stringify(tmp.tags); } - this.$fileUpload(url, null, bodyFiles, tmp, () => { + this.$fileUpload(url, null, bodyFiles, tmp, (response) => { + let data = response.data; + row.id = data.id; + row.createTime = data.createTime; + row.updateTime = data.updateTime; this.$success(this.$t('commons.save_success')); - this.$emit('refresh'); }); }, showInput(row) { diff --git a/frontend/src/business/components/api/definition/components/reference/ReferenceView.vue b/frontend/src/business/components/api/definition/components/reference/ReferenceView.vue index c3c14f7860..30602db2b0 100644 --- a/frontend/src/business/components/api/definition/components/reference/ReferenceView.vue +++ b/frontend/src/business/components/api/definition/components/reference/ReferenceView.vue @@ -3,12 +3,20 @@ :modal="false" width="45%" :destroy-on-close="true"> {{ $t('api_test.automation.scenario_ref') }}:
-
{{ item.name }}
+
+ + {{ item.name }} + +
{{ $t('api_test.automation.plan_ref') }}:
-
{{ item.name }}
+
+ + {{ item.name }} + +
+ prop="caseStatus" + :label="$t('test_track.plan.load_case.execution_status')"> - - - - - - - - - - - - -