diff --git a/backend/src/main/java/io/metersphere/api/controller/APITestController.java b/backend/src/main/java/io/metersphere/api/controller/APITestController.java index 883f90772c..ce4a70f857 100644 --- a/backend/src/main/java/io/metersphere/api/controller/APITestController.java +++ b/backend/src/main/java/io/metersphere/api/controller/APITestController.java @@ -378,11 +378,8 @@ public class APITestController { String testName = runRequest.getName(); //将jmx处理封装为通用方法 - jmxString = apiTestService.updateJmxString(jmxString,testName,false); - - JmxInfoDTO dto = new JmxInfoDTO(); + JmxInfoDTO dto = apiTestService.updateJmxString(jmxString,testName,false); dto.setName(runRequest.getName() + ".jmx"); - dto.setXml(jmxString); return dto; } diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiDocumentController.java b/backend/src/main/java/io/metersphere/api/controller/ApiDocumentController.java index bb7800157a..8e84fe72b9 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiDocumentController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiDocumentController.java @@ -1,32 +1,18 @@ package io.metersphere.api.controller; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import io.metersphere.api.dto.document.ApiDocumentInfoDTO; import io.metersphere.api.dto.document.ApiDocumentRequest; -import io.metersphere.api.dto.document.ApiDocumentShareRequest; -import io.metersphere.api.dto.document.ApiDocumentSimpleInfoDTO; import io.metersphere.api.dto.document.ApiDocumentShareDTO; +import io.metersphere.api.dto.document.ApiDocumentShareRequest; import io.metersphere.api.service.APITestService; import io.metersphere.api.service.ApiDefinitionService; import io.metersphere.api.service.ApiDocumentService; -import io.metersphere.base.domain.ApiDefinition; import io.metersphere.base.domain.ApiDefinitionWithBLOBs; import io.metersphere.base.domain.ApiDocumentShare; -import io.metersphere.base.domain.ApiDocumentShareExample; -import lombok.Getter; -import org.apache.commons.lang3.StringUtils; -import org.python.antlr.ast.Str; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * @author song.tianyang @@ -68,28 +54,4 @@ public class ApiDocumentController { ApiDocumentShareDTO returnDTO = apiDocumentService.conversionApiDocumentShareToDTO(apiShare); return returnDTO; } - - @GetMapping("/updateJmxByFile") - public String updateJmxByFile(){ - StringBuilder jmxBuilder = new StringBuilder(); - try { - String filePath = "/Users/admin/Downloads/成功吧 (20).jmx"; - File file = new File(filePath); - BufferedReader bufferedReader = new BufferedReader(new FileReader(file)); - - String strLine = null; - while(null != (strLine = bufferedReader.readLine())){ - if(StringUtils.isNotEmpty(strLine)){ - jmxBuilder.append(strLine); - } - - } - }catch(Exception e){ - e.printStackTrace(); - } - - - String jmx = apiTestService.updateJmxString(jmxBuilder.toString(),null,false); - return jmx; - } } diff --git a/backend/src/main/java/io/metersphere/api/dto/JmxInfoDTO.java b/backend/src/main/java/io/metersphere/api/dto/JmxInfoDTO.java index 3de0a1d6e2..1bd70f634f 100644 --- a/backend/src/main/java/io/metersphere/api/dto/JmxInfoDTO.java +++ b/backend/src/main/java/io/metersphere/api/dto/JmxInfoDTO.java @@ -1,8 +1,11 @@ package io.metersphere.api.dto; +import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; +import java.util.Map; + /** * @author song.tianyang * @Date 2021/1/5 5:48 下午 @@ -10,7 +13,9 @@ import lombok.Setter; */ @Getter @Setter +@AllArgsConstructor public class JmxInfoDTO { private String name; private String xml; + private Map attachFiles; } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java index 6303166c99..642b71b976 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java @@ -85,6 +85,7 @@ public class MsScenario extends MsTestElement { JSONObject element = JSON.parseObject(scenario.getScenarioDefinition()); hashTree = mapper.readValue(element.getString("hashTree"), new TypeReference>() { }); + OldVersionUtil.transferHashTree(hashTree); // 场景变量 if (StringUtils.isNotEmpty(element.getString("variables"))) { LinkedList variables = mapper.readValue(element.getString("variables"), diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java index 182dbf5512..8238f27752 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java @@ -161,6 +161,7 @@ public abstract class MsTestElement { element = mapper.readValue(apiDefinition.getRequest(), new TypeReference() { }); hashTree.add(element); + OldVersionUtil.transferHashTree(hashTree); } } catch (Exception ex) { ex.printStackTrace(); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/OldVersionUtil.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/OldVersionUtil.java new file mode 100644 index 0000000000..943f5502a8 --- /dev/null +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/OldVersionUtil.java @@ -0,0 +1,23 @@ +package io.metersphere.api.dto.definition.request; + + +import io.metersphere.commons.utils.SessionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.List; + +public class OldVersionUtil { + + public static void transferHashTree(List hashTree) { + for (int i = 0; i < hashTree.size(); i++) { + MsTestElement element = hashTree.get(i); + if (StringUtils.isBlank(element.getProjectId())) { + element.setProjectId(SessionUtils.getCurrentProjectId()); + } + if (element.getHashTree() != null && element.getHashTree().size() > 0) { + transferHashTree(element.getHashTree()); + } + } + } + +} diff --git a/backend/src/main/java/io/metersphere/api/service/APITestService.java b/backend/src/main/java/io/metersphere/api/service/APITestService.java index 44504fbe8a..102c3a2a80 100644 --- a/backend/src/main/java/io/metersphere/api/service/APITestService.java +++ b/backend/src/main/java/io/metersphere/api/service/APITestService.java @@ -472,11 +472,13 @@ public class APITestService { * @return * @author song tianyang */ - public String updateJmxString(String jmxString, String testNameParam, boolean isFromScenario) { + public JmxInfoDTO updateJmxString(String jmxString, String testNameParam, boolean isFromScenario) { //注: 与1.7分支合并时,如果该方法产生冲突,请以master为准 String attribute_testName = "testname"; String[] requestElementNameArr = new String[]{"HTTPSamplerProxy", "TCPSampler", "JDBCSampler", "DubboSample"}; + List attachmentFilePathList = new ArrayList<>(); + try { //将ThreadGroup的testname改为接口名称 Document doc = DocumentHelper.parseText(jmxString);// 获取可续保保单列表报文模板 @@ -511,6 +513,9 @@ public class APITestService { for (Element configTestElement : hashTreeConfigTestElementList) { this.updateDubboDefaultConfigGuiElement(configTestElement); } + + //HTTPSamplerProxy, 进行附件转化: 1.elementProp里去掉路径; 2。elementProp->filePath获取路径并读出来 + attachmentFilePathList.addAll(this.parseAttachmentFileInfo(element)); } } jmxString = root.asXML(); @@ -521,7 +526,60 @@ public class APITestService { if (!jmxString.startsWith("")) { jmxString = "" + jmxString; } - return jmxString; + + //处理附件 + Map attachmentFiles = new HashMap<>(); + int fileIndex = 0; + for (String filePath: attachmentFilePathList) { + File file = new File(filePath); + if(file.exists() && file.isFile()){ + try{ + FileMetadata fileMetadata = fileService.saveFile(file,FileUtil.readAsByteArray(file),fileIndex++); + attachmentFiles.put(fileMetadata.getId(),fileMetadata.getName()); + }catch (Exception e){ + e.printStackTrace(); + } + } + } + + JmxInfoDTO returnDTO = new JmxInfoDTO("Demo.jmx",jmxString,attachmentFiles); + + return returnDTO; + } + + private List parseAttachmentFileInfo(Element parentHashTreeElement) { + List attachmentFilePathList = new ArrayList<>(); + List parentElementList = parentHashTreeElement.elements(); + for (Element parentElement: parentElementList) { + String qname = parentElement.getQName().getName(); + if (StringUtils.equals(qname,"HTTPSamplerProxy")){ + List elementPropElementList = parentElement.elements("elementProp"); + for (Element element : elementPropElementList) { + if(StringUtils.equals(element.attributeValue("name"),"HTTPsampler.Files")){ + String name = element.getName(); + List collectionPropList = element.elements("collectionProp"); + for (Element prop: collectionPropList) { + List elementProps = prop.elements(); + for (Element elementProp: elementProps) { + if(StringUtils.equals(elementProp.attributeValue("elementType"),"HTTPFileArg")){ + try{ + String filePath = elementProp.attributeValue("name"); + File file = new File(filePath); + if(file.exists() && file.isFile()){ + attachmentFilePathList.add(filePath); + String fileName = file.getName(); + elementProp.attribute("name").setText(fileName); + } + }catch (Exception e){ + } + } + } + } + } + } + } + } + return attachmentFilePathList; } private void updateDubboDefaultConfigGuiElement(Element configTestElement) { diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 2084a7eb85..d6a92e7d44 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -376,6 +376,7 @@ public class ApiAutomationService { return report; } + private void parse(String scenarioDefinition, MsScenario scenario) { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); @@ -743,12 +744,10 @@ public class ApiAutomationService { } MsTestPlan testPlan = new MsTestPlan(); testPlan.setHashTree(new LinkedList<>()); - String jmx = apiTestService.updateJmxString(generateJmx(apiScenarios.get(0)), testName, true); + JmxInfoDTO dto = apiTestService.updateJmxString(generateJmx(apiScenarios.get(0)), testName, true); String name = request.getName() + ".jmx"; - JmxInfoDTO dto = new JmxInfoDTO(); dto.setName(name); - dto.setXml(jmx); return dto; } @@ -897,7 +896,7 @@ public class ApiAutomationService { if (StringUtils.isNotEmpty(item.getScenarioDefinition())) { String jmx = generateJmx(item); if (StringUtils.isNotEmpty(jmx)) { - ApiScenrioExportJmx scenrioExportJmx = new ApiScenrioExportJmx(item.getName(), apiTestService.updateJmxString(jmx, null, true)); + ApiScenrioExportJmx scenrioExportJmx = new ApiScenrioExportJmx(item.getName(), apiTestService.updateJmxString(jmx, null, true).getXml()); resList.add(scenrioExportJmx); } } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestReviewCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestReviewCaseMapper.xml index e0988937dc..00f773ad2b 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestReviewCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestReviewCaseMapper.xml @@ -100,7 +100,7 @@ select test_case_review_test_case.id as id, test_case.id as caseId, test_case.name, test_case.priority, test_case.type, test_case.node_path, test_case.method, test_case.num, test_case_review_test_case.reviewer, test_case.review_status, test_case_review_test_case.update_time, test_case_node.name as model, - project.name as projectName, test_case_review_test_case.review_id as reviewId + project.name as projectName, test_case_review_test_case.review_id as reviewId,test_case.test_id as testId from test_case_review_test_case inner join test_case on test_case_review_test_case.case_id = test_case.id left join test_case_node on test_case_node.id=test_case.node_id diff --git a/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java b/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java index dce702e35b..e9f370bfb2 100644 --- a/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java +++ b/backend/src/main/java/io/metersphere/performance/controller/PerformanceTestController.java @@ -150,6 +150,11 @@ public class PerformanceTestController { return fileService.getFileMetadataByTestId(testId); } + @GetMapping("/file/getMetadataById/{metadataId}") + public FileMetadata getMetadataById(@PathVariable String metadataId) { + return fileService.getFileMetadataById(metadataId); + } + @PostMapping("/file/download") public ResponseEntity downloadJmx(@RequestBody FileOperationRequest fileOperationRequest) { byte[] bytes = fileService.loadFileAsBytes(fileOperationRequest.getId()); diff --git a/backend/src/main/java/io/metersphere/performance/request/SaveTestPlanRequest.java b/backend/src/main/java/io/metersphere/performance/request/SaveTestPlanRequest.java index 05c63cd9b1..e781ac5cfc 100644 --- a/backend/src/main/java/io/metersphere/performance/request/SaveTestPlanRequest.java +++ b/backend/src/main/java/io/metersphere/performance/request/SaveTestPlanRequest.java @@ -12,4 +12,5 @@ import java.util.Map; public class SaveTestPlanRequest extends TestPlanRequest { private List updatedFileList; private Map fileSorts; + private List conversionFileIdList; } diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index c5cb712610..2422f4afef 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -138,10 +138,35 @@ public class PerformanceTestService { this.importFiles(importFileIds, loadTest.getId(), request.getFileSorts()); // 保存上传的文件 this.saveUploadFiles(files, loadTest.getId(), request.getFileSorts()); - + //关联转化的文件 + this.conversionFiles(loadTest.getId(),request.getConversionFileIdList()); return loadTest.getId(); } + private void conversionFiles(String id, List conversionFileIdList) { + for (String metaFileId : conversionFileIdList) { + if(!this.loadTestFileExsits(id,metaFileId)){ + LoadTestFile loadTestFile = new LoadTestFile(); + loadTestFile.setTestId(id); + loadTestFile.setFileId(metaFileId); + loadTestFileMapper.insert(loadTestFile); + } + } + } + + private boolean loadTestFileExsits(String testId, String metaFileId) { + boolean fileExsits = fileService.isFileExsits(metaFileId); + LoadTestFileExample example = new LoadTestFileExample(); + example.createCriteria().andTestIdEqualTo(testId).andFileIdEqualTo(metaFileId); + long loadTestFiles = loadTestFileMapper.countByExample(example); + + if(!fileExsits && loadTestFiles>0){ + return false; + }else { + return true; + } + } + private void saveUploadFiles(List files, String testId, Map fileSorts) { if (files != null) { for (int i = 0; i < files.size(); i++) { diff --git a/backend/src/main/java/io/metersphere/service/FileService.java b/backend/src/main/java/io/metersphere/service/FileService.java index a5c2695f37..328b427ee5 100644 --- a/backend/src/main/java/io/metersphere/service/FileService.java +++ b/backend/src/main/java/io/metersphere/service/FileService.java @@ -12,6 +12,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; +import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -113,6 +114,26 @@ public class FileService { return fileMetadata; } + public FileMetadata saveFile(File file, byte[] fileByte, Integer sort) { + final FileMetadata fileMetadata = new FileMetadata(); + fileMetadata.setId(UUID.randomUUID().toString()); + fileMetadata.setName(file.getName()); + fileMetadata.setSize(file.length()); + fileMetadata.setCreateTime(System.currentTimeMillis()); + fileMetadata.setUpdateTime(System.currentTimeMillis()); + FileType fileType = getFileType(fileMetadata.getName()); + fileMetadata.setType(fileType.name()); + fileMetadata.setSort(sort); + fileMetadataMapper.insert(fileMetadata); + + FileContent fileContent = new FileContent(); + fileContent.setFileId(fileMetadata.getId()); + fileContent.setFile(fileByte); + fileContentMapper.insert(fileContent); + + return fileMetadata; + } + public FileMetadata saveFile(byte[] fileByte, String fileName, Long fileSize) { final FileMetadata fileMetadata = new FileMetadata(); fileMetadata.setId(UUID.randomUUID().toString()); @@ -185,4 +206,15 @@ public class FileService { public void updateFileMetadata(FileMetadata fileMetadata) { fileMetadataMapper.updateByPrimaryKeySelective(fileMetadata); } + + public boolean isFileExsits(String fileId) { + FileMetadataExample example = new FileMetadataExample(); + example.createCriteria().andIdEqualTo(fileId); + long fileCount = fileMetadataMapper.countByExample(example); + if(fileCount>0){ + return true; + }else { + return false; + } + } } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseReviewController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseReviewController.java index 6ea0f97fb8..a2e3b0daea 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseReviewController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseReviewController.java @@ -68,8 +68,8 @@ public class TestCaseReviewController { @PostMapping("/edit") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) - public void editCaseReview(@RequestBody SaveTestCaseReviewRequest testCaseReview) { - testCaseReviewService.editCaseReview(testCaseReview); + public String editCaseReview(@RequestBody SaveTestCaseReviewRequest testCaseReview) { + return testCaseReviewService.editCaseReview(testCaseReview); } @GetMapping("/delete/{reviewId}") diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java index 2857fecd68..948ae0af0f 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java @@ -203,7 +203,7 @@ public class TestCaseReviewService { return extTestCaseReviewMapper.listByWorkspaceId(currentWorkspaceId, SessionUtils.getUserId(), SessionUtils.getCurrentProjectId()); } - public void editCaseReview(SaveTestCaseReviewRequest testCaseReview) { + public String editCaseReview(SaveTestCaseReviewRequest testCaseReview) { editCaseReviewer(testCaseReview); testCaseReview.setUpdateTime(System.currentTimeMillis()); checkCaseReviewExist(testCaseReview); @@ -221,6 +221,7 @@ public class TestCaseReviewService { .event(NoticeConstants.Event.UPDATE) .build(); noticeSendService.send(NoticeConstants.TaskType.REVIEW_TASK, noticeModel); + return testCaseReview.getId(); } private void editCaseReviewer(SaveTestCaseReviewRequest testCaseReview) { diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index b0b2fbfd21..af479b9619 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -1,15 +1,18 @@ @@ -222,6 +230,7 @@ props: { moduleOptions: Array, currentScenario: {}, + type: String }, components: { MsVariableList, @@ -532,6 +541,9 @@ if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].hashTree && arr[i].hashTree.length > 1) { arr[i].countController.proceed = true; } + if (!arr[i].projectId) { + arr[i].projectId = getCurrentProjectID(); + } if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) { this.recursiveSorting(arr[i].hashTree); } @@ -544,6 +556,9 @@ && this.scenarioDefinition[i].hashTree.length > 1) { this.scenarioDefinition[i].countController.proceed = true; } + if (!this.scenarioDefinition[i].projectId) { + this.scenarioDefinition.projectId = getCurrentProjectID(); + } if (this.scenarioDefinition[i].hashTree != undefined && this.scenarioDefinition[i].hashTree.length > 0) { this.recursiveSorting(this.scenarioDefinition[i].hashTree); } @@ -919,14 +934,15 @@ } this.enableCookieShare = obj.enableCookieShare; this.scenarioDefinition = obj.hashTree; - this.initProjectIds(); } } if (this.currentScenario.copy) { this.path = "/api/automation/create"; } } - this.getEnvironments(); + this.sort(); + this.initProjectIds(); + // this.getEnvironments(); }) } }, diff --git a/frontend/src/business/components/api/automation/scenario/ScenarioExtendBtns.vue b/frontend/src/business/components/api/automation/scenario/ScenarioExtendBtns.vue index b80d9f861d..029fb385c8 100644 --- a/frontend/src/business/components/api/automation/scenario/ScenarioExtendBtns.vue +++ b/frontend/src/business/components/api/automation/scenario/ScenarioExtendBtns.vue @@ -55,6 +55,8 @@ let jmxObj = {}; jmxObj.name = response.data.name; jmxObj.xml = response.data.xml; + jmxObj.attachFiles = response.data.attachFiles; + jmxObj.attachByteFiles = response.data.attachByteFiles; this.$store.commit('setTest', { name: row.name, jmx: jmxObj diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue index a0b2873f78..932ad0f4f8 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue @@ -108,6 +108,9 @@ recursive(arr) { for (let i in arr) { arr[i].disabled = true; + if (!arr[i].projectId) { + arr[i].projectId = getCurrentProjectID(); + } if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) { this.recursive(arr[i].hashTree); } @@ -116,6 +119,9 @@ setDisabled(scenarioDefinition) { for (let i in scenarioDefinition) { scenarioDefinition[i].disabled = true; + if (!scenarioDefinition[i].projectId) { + scenarioDefinition[i].projectId = getCurrentProjectID(); + } if (scenarioDefinition[i].hashTree != undefined && scenarioDefinition[i].hashTree.length > 0) { this.recursive(scenarioDefinition[i].hashTree); } 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 bd54431588..76c6bb56f7 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue @@ -1,6 +1,6 @@ diff --git a/frontend/src/business/components/track/review/view/components/TestReviewTestCaseEdit.vue b/frontend/src/business/components/track/review/view/components/TestReviewTestCaseEdit.vue index 2760c085f3..55604d3485 100644 --- a/frontend/src/business/components/track/review/view/components/TestReviewTestCaseEdit.vue +++ b/frontend/src/business/components/track/review/view/components/TestReviewTestCaseEdit.vue @@ -39,11 +39,14 @@ + :disabled="isReadOnly" :icon="testCase.reviewStatus === 'Pass' ? 'el-icon-check' : ''" + @click="saveCase('Pass')"> {{ $t('test_track.review.pass') }} + :disabled="isReadOnly" + :icon="testCase.reviewStatus === 'UnPass' ? 'el-icon-check' : ''" + @click="saveCase('UnPass')"> {{ $t('test_track.review.un_pass') }} @@ -66,29 +69,22 @@ {{ $t('test_track.case.case_type') }}: - {{ - $t('commons.functional') - }} + + 场景用例 + {{ $t('commons.performance') }} {{ $t('commons.api') }} + 接口用例 + - - {{ $t('test_track.case.method') }}: - {{ $t('test_track.case.manual') }} - {{ $t('test_track.case.auto') }} - - + {{ $t('test_track.case.module') }}: {{ testCase.nodePath }} - - {{ $t('test_track.plan.plan_project') }}: - {{ testCase.projectName }} - @@ -98,7 +94,7 @@ - + @@ -108,12 +104,17 @@ :is-read-only="true" :id="testCase.testId" ref="performanceTestDetail"/> + + + - +
{{ $t('test_track.case.steps') }}: @@ -229,7 +230,8 @@ - +
@@ -248,9 +250,11 @@ import PerformanceTestDetail from "../../../plan/view/comonents/test/Performance import ApiTestResult from "../../../plan/view/comonents/test/ApiTestResult"; import ApiTestDetail from "../../../plan/view/comonents/test/ApiTestDetail"; import TestPlanTestCaseStatusButton from "../../../plan/common/TestPlanTestCaseStatusButton"; -import {listenGoBack, removeGoBackListener} from "@/common/js/utils"; +import {getCurrentProjectID, listenGoBack, removeGoBackListener} from "@/common/js/utils"; import ReviewComment from "../../commom/ReviewComment"; import TestCaseAttachment from "@/business/components/track/case/components/TestCaseAttachment"; +import ApiCaseItem from "@/business/components/api/definition/components/case/ApiCaseItem"; +import MsEditApiScenario from "@/business/components/api/automation/scenario/EditApiScenario" export default { name: "TestReviewTestCaseEdit", @@ -261,7 +265,10 @@ export default { ApiTestDetail, TestPlanTestCaseStatusButton, ReviewComment, - TestCaseAttachment + TestCaseAttachment, + ApiCaseItem, + MsEditApiScenario + }, data() { return { @@ -277,7 +284,11 @@ export default { users: [], activeName: 'comment', comments: [], - tableData: [] + tableData: [], + currentScenario: {}, + mark: 'detail', + api: {}, + apiCase: {}, }; }, props: { @@ -378,16 +389,55 @@ export default { listenGoBack(this.handleClose); this.initData(testCase); this.getComments(testCase); + this.getApiTestCase(testCase); + this.getCurrentScenario(testCase) + }, + getApiTestCase(testCase) { + let param = {} + param.projectId = getCurrentProjectID(); + param.id = testCase.testId; + this.result = this.$post("/api/testcase/list", param, response => { + let apiCaseList = [] + this.apiCaseList = response.data; + this.apiCaseList.forEach(apiCase => { + if (apiCase.tags && apiCase.tags.length > 0) { + apiCase.tags = JSON.parse(apiCase.tags); + this.$set(apiCase, 'selected', false); + } + if (Object.prototype.toString.call(apiCase.request).match(/\[object (\w+)\]/)[1].toLowerCase() != 'object') { + apiCase.request = JSON.parse(apiCase.request); + } + if (!apiCase.request.hashTree) { + apiCase.request.hashTree = []; + } + this.apiCase = apiCase + this.handleTestCase(apiCase) + }) + + }); + }, + getCurrentScenario(testCase) { + this.result = this.$get("/api/automation/getApiScenario/" + testCase.testId, response => { + this.currentScenario=response.data + }); + }, + + handleTestCase(testCase) { + this.$get('/api/definition/get/' + testCase.apiDefinitionId, (response) => { + this.api = response.data; + }); }, initTest() { this.$nextTick(() => { if (this.testCase.testId && this.testCase.testId !== 'other') { - if (this.testCase.method === 'auto') { - if (this.$refs.apiTestDetail && this.testCase.type === 'api') { - this.$refs.apiTestDetail.init(); - } else if (this.testCase.type === 'performance') { - this.$refs.performanceTestDetail.init(); - } + if (this.$refs.apiTestDetail && this.testCase.type === 'api') { + this.$refs.apiTestDetail.init(); + } else if (this.testCase.type === 'performance') { + this.$refs.performanceTestDetail.init(); + } else if (this.testCase.type === 'testcase') { + this.$refs.apiCaseConfig.active(this.api); + } else if (this.testCase.type === 'automation') { + this.$refs.autoScenarioConfig.showAll(); } } }); diff --git a/frontend/src/business/components/track/review/view/components/TestReviewTestCaseList.vue b/frontend/src/business/components/track/review/view/components/TestReviewTestCaseList.vue index a3c5e0e88b..213b447120 100644 --- a/frontend/src/business/components/track/review/view/components/TestReviewTestCaseList.vue +++ b/frontend/src/business/components/track/review/view/components/TestReviewTestCaseList.vue @@ -84,7 +84,7 @@ - - + -->