fix: 解决冲突
This commit is contained in:
commit
b7e12652dd
|
@ -49,6 +49,9 @@ public class MsScenario extends MsTestElement {
|
|||
@JSONField(ordinal = 24)
|
||||
private boolean enableCookieShare;
|
||||
|
||||
@JSONField(ordinal = 26)
|
||||
private List<KeyValue> headers;
|
||||
|
||||
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||
|
||||
@Override
|
||||
|
@ -87,7 +90,7 @@ public class MsScenario extends MsTestElement {
|
|||
}
|
||||
// 场景变量和环境变量
|
||||
tree.add(arguments(config));
|
||||
//this.addCsvDataSet(tree, variables);
|
||||
this.addCsvDataSet(tree, variables);
|
||||
this.addCounter(tree, variables);
|
||||
this.addRandom(tree, variables);
|
||||
if (CollectionUtils.isNotEmpty(hashTree)) {
|
||||
|
@ -131,6 +134,12 @@ public class MsScenario extends MsTestElement {
|
|||
arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=")
|
||||
);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(this.headers)) {
|
||||
this.headers.stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
|
||||
arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=")
|
||||
);
|
||||
}
|
||||
|
||||
return arguments;
|
||||
}
|
||||
|
||||
|
|
|
@ -79,13 +79,13 @@ public class MsIfController extends MsTestElement {
|
|||
}
|
||||
|
||||
if (StringUtils.equals(operator, "is empty")) {
|
||||
variable = "!empty(" + variable + ")";
|
||||
variable = variable + "==" + "\"\\" + this.variable + "\"" + "|| empty(" + variable + ")";
|
||||
operator = "";
|
||||
value = "";
|
||||
}
|
||||
|
||||
if (StringUtils.equals(operator, "is not empty")) {
|
||||
variable = "empty(" + variable + ")";
|
||||
variable = variable + "!=" + "\"\\" + this.variable + "\"" + "&& !empty(" + variable + ")";
|
||||
operator = "";
|
||||
value = "";
|
||||
}
|
||||
|
|
|
@ -123,13 +123,13 @@ public class MsLoopController extends MsTestElement {
|
|||
}
|
||||
|
||||
if (StringUtils.equals(operator, "is empty")) {
|
||||
variable = "!empty(" + variable + ")";
|
||||
variable = variable + "==" + "\"\\" + this.whileController.getVariable() + "\"" + "|| empty(" + variable + ")";
|
||||
operator = "";
|
||||
value = "";
|
||||
}
|
||||
|
||||
if (StringUtils.equals(operator, "is not empty")) {
|
||||
variable = "empty(" + variable + ")";
|
||||
variable = variable + "!=" + "\"\\" + this.whileController.getVariable() + "\"" + "&& !empty(" + variable + ")";
|
||||
operator = "";
|
||||
value = "";
|
||||
}
|
||||
|
|
|
@ -62,8 +62,6 @@ public class ApiAutomationService {
|
|||
@Resource
|
||||
private ApiScenarioMapper apiScenarioMapper;
|
||||
@Resource
|
||||
private ApiDefinitionService apiDefinitionService;
|
||||
@Resource
|
||||
private ExtApiScenarioMapper extApiScenarioMapper;
|
||||
@Resource
|
||||
private TestPlanApiScenarioMapper testPlanApiScenarioMapper;
|
||||
|
@ -103,13 +101,13 @@ public class ApiAutomationService {
|
|||
if (setDefultOrders) {
|
||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||
}
|
||||
if(StringUtils.isNotEmpty(request.getExecuteStatus())){
|
||||
Map<String,List<String>> statusFilter = new HashMap<>();
|
||||
if (StringUtils.isNotEmpty(request.getExecuteStatus())) {
|
||||
Map<String, List<String>> statusFilter = new HashMap<>();
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("Prepare");
|
||||
list.add("Underway");
|
||||
list.add("Completed");
|
||||
statusFilter.put("status",list);
|
||||
statusFilter.put("status", list);
|
||||
request.setFilters(statusFilter);
|
||||
}
|
||||
if (checkThisWeekData) {
|
||||
|
@ -174,7 +172,7 @@ public class ApiAutomationService {
|
|||
apiScenarioMapper.insert(scenario);
|
||||
|
||||
List<String> bodyUploadIds = request.getBodyUploadIds();
|
||||
apiDefinitionService.createBodyFiles(bodyUploadIds, bodyFiles);
|
||||
FileUtils.createBodyFiles(bodyUploadIds, bodyFiles);
|
||||
return scenario;
|
||||
}
|
||||
|
||||
|
@ -190,7 +188,7 @@ public class ApiAutomationService {
|
|||
public void update(SaveApiScenarioRequest request, List<MultipartFile> bodyFiles) {
|
||||
checkNameExist(request);
|
||||
List<String> bodyUploadIds = request.getBodyUploadIds();
|
||||
apiDefinitionService.createBodyFiles(bodyUploadIds, bodyFiles);
|
||||
FileUtils.createBodyFiles(bodyUploadIds, bodyFiles);
|
||||
|
||||
final ApiScenarioWithBLOBs scenario = new ApiScenarioWithBLOBs();
|
||||
scenario.setId(request.getId());
|
||||
|
@ -480,8 +478,8 @@ public class ApiAutomationService {
|
|||
public void checkScenarioIsRunnng(List<String> ids) {
|
||||
List<ApiScenarioReport> lastReportStatusByIds = apiReportService.selectLastReportByIds(ids);
|
||||
for (ApiScenarioReport report : lastReportStatusByIds) {
|
||||
if(StringUtils.equals(report.getStatus(),APITestStatus.Running.name())){
|
||||
MSException.throwException(report.getName()+" Is Running!");
|
||||
if (StringUtils.equals(report.getStatus(), APITestStatus.Running.name())) {
|
||||
MSException.throwException(report.getName() + " Is Running!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -518,7 +516,7 @@ public class ApiAutomationService {
|
|||
*/
|
||||
public String debugRun(RunDefinitionRequest request, List<MultipartFile> bodyFiles) {
|
||||
List<String> bodyUploadIds = new ArrayList<>(request.getBodyUploadIds());
|
||||
apiDefinitionService.createBodyFiles(bodyUploadIds, bodyFiles);
|
||||
FileUtils.createBodyFiles(bodyUploadIds, bodyFiles);
|
||||
EnvironmentConfig envConfig = null;
|
||||
if (request.getEnvironmentId() != null) {
|
||||
ApiTestEnvironmentWithBLOBs environment = environmentService.get(request.getEnvironmentId());
|
||||
|
|
|
@ -44,7 +44,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
import sun.security.util.Cache;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -131,7 +131,7 @@ public class ApiDefinitionService {
|
|||
public void create(SaveApiDefinitionRequest request, List<MultipartFile> bodyFiles) {
|
||||
List<String> bodyUploadIds = new ArrayList<>(request.getBodyUploadIds());
|
||||
createTest(request);
|
||||
createBodyFiles(bodyUploadIds, bodyFiles);
|
||||
FileUtils.createBodyFiles(bodyUploadIds, bodyFiles);
|
||||
}
|
||||
|
||||
public void update(SaveApiDefinitionRequest request, List<MultipartFile> bodyFiles) {
|
||||
|
@ -141,27 +141,7 @@ public class ApiDefinitionService {
|
|||
List<String> bodyUploadIds = request.getBodyUploadIds();
|
||||
request.setBodyUploadIds(null);
|
||||
updateTest(request);
|
||||
createBodyFiles(bodyUploadIds, bodyFiles);
|
||||
}
|
||||
|
||||
public void createBodyFiles(List<String> bodyUploadIds, List<MultipartFile> bodyFiles) {
|
||||
if (CollectionUtils.isNotEmpty(bodyUploadIds) && CollectionUtils.isNotEmpty(bodyFiles)) {
|
||||
File testDir = new File(BODY_FILE_DIR);
|
||||
if (!testDir.exists()) {
|
||||
testDir.mkdirs();
|
||||
}
|
||||
for (int i = 0; i < bodyUploadIds.size(); i++) {
|
||||
MultipartFile item = bodyFiles.get(i);
|
||||
File file = new File(BODY_FILE_DIR + "/" + bodyUploadIds.get(i) + "_" + item.getOriginalFilename());
|
||||
try (InputStream in = item.getInputStream(); OutputStream out = new FileOutputStream(file)) {
|
||||
file.createNewFile();
|
||||
FileUtil.copyStream(in, out);
|
||||
} catch (IOException e) {
|
||||
LogUtil.error(e);
|
||||
MSException.throwException(Translator.get("upload_fail"));
|
||||
}
|
||||
}
|
||||
}
|
||||
FileUtils.createBodyFiles(bodyUploadIds, bodyFiles);
|
||||
}
|
||||
|
||||
public void delete(String apiId) {
|
||||
|
@ -356,10 +336,10 @@ public class ApiDefinitionService {
|
|||
return request;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入是插件或者postman时创建用例
|
||||
* postman考虑是否有前置脚本
|
||||
*/
|
||||
/**
|
||||
* 导入是插件或者postman时创建用例
|
||||
* postman考虑是否有前置脚本
|
||||
*/
|
||||
private void importApiCase(ApiDefinitionWithBLOBs apiDefinition, ApiTestCaseMapper apiTestCaseMapper,
|
||||
ApiTestImportRequest apiTestImportRequest, Boolean isInsert) {
|
||||
try {
|
||||
|
@ -404,7 +384,7 @@ public class ApiDefinitionService {
|
|||
*/
|
||||
public String run(RunDefinitionRequest request, List<MultipartFile> bodyFiles) {
|
||||
List<String> bodyUploadIds = new ArrayList<>(request.getBodyUploadIds());
|
||||
createBodyFiles(bodyUploadIds, bodyFiles);
|
||||
FileUtils.createBodyFiles(bodyUploadIds, bodyFiles);
|
||||
|
||||
HashTree hashTree = request.getTestElement().generateHashTree();
|
||||
String runMode = ApiRunMode.DEFINITION.name();
|
||||
|
@ -541,7 +521,7 @@ public class ApiDefinitionService {
|
|||
public void editApiByParam(ApiBatchRequest request) {
|
||||
List<String> ids = request.getIds();
|
||||
if (request.isSelectAllDate()) {
|
||||
ids = this.getAllApiIdsByFontedSelect(request.getFilters(), request.getName(), request.getModuleIds(), request.getProjectId(), request.getUnSelectIds(),request.getProtocol());
|
||||
ids = this.getAllApiIdsByFontedSelect(request.getFilters(), request.getName(), request.getModuleIds(), request.getProjectId(), request.getUnSelectIds(), request.getProtocol());
|
||||
}
|
||||
//name在这里只是查询参数
|
||||
request.setName(null);
|
||||
|
@ -605,14 +585,14 @@ public class ApiDefinitionService {
|
|||
public void deleteByParams(ApiDefinitionBatchProcessingRequest request) {
|
||||
List<String> apiIds = request.getDataIds();
|
||||
if (request.isSelectAllDate()) {
|
||||
apiIds = this.getAllApiIdsByFontedSelect(request.getFilters(), request.getName(), request.getModuleIds(), request.getProjectId(), request.getUnSelectIds(),request.getProtocol());
|
||||
apiIds = this.getAllApiIdsByFontedSelect(request.getFilters(), request.getName(), request.getModuleIds(), request.getProjectId(), request.getUnSelectIds(), request.getProtocol());
|
||||
}
|
||||
ApiDefinitionExample example = new ApiDefinitionExample();
|
||||
example.createCriteria().andIdIn(apiIds);
|
||||
apiDefinitionMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
private List<String> getAllApiIdsByFontedSelect(Map<String, List<String>> filters, String name, List<String> moduleIds, String projectId, List<String> unSelectIds,String protocol) {
|
||||
private List<String> getAllApiIdsByFontedSelect(Map<String, List<String>> filters, String name, List<String> moduleIds, String projectId, List<String> unSelectIds, String protocol) {
|
||||
ApiDefinitionRequest request = new ApiDefinitionRequest();
|
||||
request.setFilters(filters);
|
||||
request.setName(name);
|
||||
|
@ -632,7 +612,7 @@ public class ApiDefinitionService {
|
|||
public void removeToGcByParams(ApiDefinitionBatchProcessingRequest request) {
|
||||
List<String> apiIds = request.getDataIds();
|
||||
if (request.isSelectAllDate()) {
|
||||
apiIds = this.getAllApiIdsByFontedSelect(request.getFilters(), request.getName(), request.getModuleIds(), request.getProjectId(), request.getUnSelectIds(),request.getProtocol());
|
||||
apiIds = this.getAllApiIdsByFontedSelect(request.getFilters(), request.getName(), request.getModuleIds(), request.getProjectId(), request.getUnSelectIds(), request.getProtocol());
|
||||
}
|
||||
extApiDefinitionMapper.removeToGc(apiIds);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import io.metersphere.service.FileService;
|
|||
import io.metersphere.service.QuotaService;
|
||||
import io.metersphere.service.UserService;
|
||||
import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
|
@ -38,11 +39,10 @@ import org.apache.jorphan.collections.ListedHashTree;
|
|||
import org.aspectj.util.FileUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class ApiTestCaseService {
|
|||
@Resource
|
||||
private ApiDefinitionExecResultMapper apiDefinitionExecResultMapper;
|
||||
@Resource
|
||||
TestPlanApiCaseMapper testPlanApiCaseMapper;
|
||||
private TestPlanApiCaseMapper testPlanApiCaseMapper;
|
||||
|
||||
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||
|
||||
|
@ -136,7 +136,7 @@ public class ApiTestCaseService {
|
|||
public ApiTestCase create(SaveApiTestCaseRequest request, List<MultipartFile> bodyFiles) {
|
||||
List<String> bodyUploadIds = new ArrayList<>(request.getBodyUploadIds());
|
||||
ApiTestCase test = createTest(request);
|
||||
createBodyFiles(test, bodyUploadIds, bodyFiles);
|
||||
FileUtils.createBodyFiles(bodyUploadIds, bodyFiles);
|
||||
return test;
|
||||
}
|
||||
|
||||
|
@ -152,31 +152,10 @@ public class ApiTestCaseService {
|
|||
List<String> bodyUploadIds = new ArrayList<>(request.getBodyUploadIds());
|
||||
request.setBodyUploadIds(null);
|
||||
ApiTestCase test = updateTest(request);
|
||||
createBodyFiles(test, bodyUploadIds, bodyFiles);
|
||||
FileUtils.createBodyFiles(bodyUploadIds, bodyFiles);
|
||||
return test;
|
||||
}
|
||||
|
||||
private void createBodyFiles(ApiTestCase test, List<String> bodyUploadIds, List<MultipartFile> bodyFiles) {
|
||||
if (bodyUploadIds.size() > 0) {
|
||||
String dir = BODY_FILE_DIR + "/" + test.getId();
|
||||
File testDir = new File(dir);
|
||||
if (!testDir.exists()) {
|
||||
testDir.mkdirs();
|
||||
}
|
||||
for (int i = 0; i < bodyUploadIds.size(); i++) {
|
||||
MultipartFile item = bodyFiles.get(i);
|
||||
File file = new File(testDir + "/" + bodyUploadIds.get(i) + "_" + item.getOriginalFilename());
|
||||
try (InputStream in = item.getInputStream(); OutputStream out = new FileOutputStream(file)) {
|
||||
file.createNewFile();
|
||||
FileUtil.copyStream(in, out);
|
||||
} catch (IOException e) {
|
||||
LogUtil.error(e);
|
||||
MSException.throwException(Translator.get("upload_fail"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(String testId) {
|
||||
extTestPlanTestCaseMapper.deleteByTestCaseID(testId);
|
||||
deleteFileByTestId(testId);
|
||||
|
@ -279,19 +258,14 @@ public class ApiTestCaseService {
|
|||
}
|
||||
}
|
||||
|
||||
private void saveFile(String testId, MultipartFile file) {
|
||||
final FileMetadata fileMetadata = fileService.saveFile(file);
|
||||
ApiTestFile apiTestFile = new ApiTestFile();
|
||||
apiTestFile.setTestId(testId);
|
||||
apiTestFile.setFileId(fileMetadata.getId());
|
||||
apiTestFileMapper.insert(apiTestFile);
|
||||
}
|
||||
|
||||
private void deleteFileByTestId(String testId) {
|
||||
ApiTestFileExample ApiTestFileExample = new ApiTestFileExample();
|
||||
ApiTestFileExample.createCriteria().andTestIdEqualTo(testId);
|
||||
final List<ApiTestFile> ApiTestFiles = apiTestFileMapper.selectByExample(ApiTestFileExample);
|
||||
apiTestFileMapper.deleteByExample(ApiTestFileExample);
|
||||
if (CollectionUtils.isNotEmpty(ApiTestFiles)) {
|
||||
apiTestFileMapper.deleteByExample(ApiTestFileExample);
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(ApiTestFiles)) {
|
||||
final List<String> fileIds = ApiTestFiles.stream().map(ApiTestFile::getFileId).collect(Collectors.toList());
|
||||
|
|
|
@ -7,6 +7,7 @@ import io.metersphere.api.dto.SaveHistoricalDataUpgrade;
|
|||
import io.metersphere.api.dto.automation.ScenarioStatus;
|
||||
import io.metersphere.api.dto.definition.request.MsScenario;
|
||||
import io.metersphere.api.dto.definition.request.MsTestElement;
|
||||
import io.metersphere.api.dto.definition.request.assertions.MsAssertionDuration;
|
||||
import io.metersphere.api.dto.definition.request.assertions.MsAssertions;
|
||||
import io.metersphere.api.dto.definition.request.controller.MsIfController;
|
||||
import io.metersphere.api.dto.definition.request.extract.MsExtract;
|
||||
|
@ -84,6 +85,7 @@ public class HistoricalDataUpgradeService {
|
|||
scenario.setReferenced("Upgrade");
|
||||
scenario.setId(oldScenario.getId());
|
||||
scenario.setResourceId(UUID.randomUUID().toString());
|
||||
scenario.setHeaders(oldScenario.getHeaders());
|
||||
LinkedList<MsTestElement> testElements = new LinkedList<>();
|
||||
int index = 1;
|
||||
for (Request request : oldScenario.getRequests()) {
|
||||
|
@ -202,6 +204,23 @@ public class HistoricalDataUpgradeService {
|
|||
if (StringUtils.isEmpty(msAssertions.getName())) {
|
||||
msAssertions.setName("Assertions");
|
||||
}
|
||||
// 给初始值
|
||||
if (msAssertions.getDuration() == null) {
|
||||
msAssertions.setDuration(new MsAssertionDuration());
|
||||
}
|
||||
if (CollectionUtils.isEmpty(msAssertions.getJsr223())) {
|
||||
msAssertions.setJsr223(new LinkedList<>());
|
||||
}
|
||||
if (CollectionUtils.isEmpty(msAssertions.getXpath2())) {
|
||||
msAssertions.setXpath2(new LinkedList<>());
|
||||
}
|
||||
if (CollectionUtils.isEmpty(msAssertions.getJsonPath())) {
|
||||
msAssertions.setJsonPath(new LinkedList<>());
|
||||
}
|
||||
if (CollectionUtils.isEmpty(msAssertions.getRegex())) {
|
||||
msAssertions.setRegex(new LinkedList<>());
|
||||
}
|
||||
|
||||
msAssertions.setType("Assertions");
|
||||
msAssertions.setIndex(index + "");
|
||||
msAssertions.setResourceId(UUID.randomUUID().toString());
|
||||
|
@ -216,6 +235,16 @@ public class HistoricalDataUpgradeService {
|
|||
if (StringUtils.isEmpty(extract.getName())) {
|
||||
extract.setName("Extract");
|
||||
}
|
||||
// 默认给初始值
|
||||
if (CollectionUtils.isEmpty(extract.getJson())) {
|
||||
extract.setJson(new LinkedList<>());
|
||||
}
|
||||
if (CollectionUtils.isEmpty(extract.getXpath())) {
|
||||
extract.setXpath(new LinkedList<>());
|
||||
}
|
||||
if (CollectionUtils.isEmpty(extract.getRegex())) {
|
||||
extract.setRegex(new LinkedList<>());
|
||||
}
|
||||
extract.setType("Extract");
|
||||
extract.setIndex(index + "");
|
||||
extract.setHashTree(new LinkedList<>());
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package io.metersphere.commons.utils;
|
||||
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.aspectj.util.FileUtil;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
|
||||
public class FileUtils {
|
||||
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||
|
||||
public static void createBodyFiles(List<String> bodyUploadIds, List<MultipartFile> bodyFiles) {
|
||||
if (CollectionUtils.isNotEmpty(bodyUploadIds) && CollectionUtils.isNotEmpty(bodyFiles)) {
|
||||
File testDir = new File(BODY_FILE_DIR);
|
||||
if (!testDir.exists()) {
|
||||
testDir.mkdirs();
|
||||
}
|
||||
for (int i = 0; i < bodyUploadIds.size(); i++) {
|
||||
MultipartFile item = bodyFiles.get(i);
|
||||
File file = new File(BODY_FILE_DIR + "/" + bodyUploadIds.get(i) + "_" + item.getOriginalFilename());
|
||||
try (InputStream in = item.getInputStream(); OutputStream out = new FileOutputStream(file)) {
|
||||
file.createNewFile();
|
||||
FileUtil.copyStream(in, out);
|
||||
} catch (IOException e) {
|
||||
LogUtil.error(e);
|
||||
MSException.throwException(Translator.get("upload_fail"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.sql.SQLException;
|
||||
|
||||
|
||||
@RestControllerAdvice
|
||||
|
@ -30,6 +31,12 @@ public class RestControllerExceptionHandler {
|
|||
}
|
||||
|
||||
|
||||
@ExceptionHandler(SQLException.class)
|
||||
public ResultHolder sqlExceptionHandler(HttpServletRequest request, HttpServletResponse response, MSException e) {
|
||||
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
|
||||
return ResultHolder.error("SQL error happened, please check logs.");
|
||||
}
|
||||
|
||||
@ExceptionHandler(MSException.class)
|
||||
public ResultHolder msExceptionHandler(HttpServletRequest request, HttpServletResponse response, MSException e) {
|
||||
response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
|
||||
|
|
|
@ -180,14 +180,16 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
|
|||
List<String> projectIds = testPlanProjectService.getProjectIdsByPlanId(planId);
|
||||
projectIds.forEach(id -> {
|
||||
Project project = projectMapper.selectByPrimaryKey(id);
|
||||
String name = project.getName();
|
||||
List<TestCaseNodeDTO> nodeList = getNodeDTO(id, planId);
|
||||
TestCaseNodeDTO testCaseNodeDTO = new TestCaseNodeDTO();
|
||||
testCaseNodeDTO.setId(project.getId());
|
||||
testCaseNodeDTO.setName(name);
|
||||
testCaseNodeDTO.setLabel(name);
|
||||
testCaseNodeDTO.setChildren(nodeList);
|
||||
list.add(testCaseNodeDTO);
|
||||
if (project != null) {
|
||||
String name = project.getName();
|
||||
List<TestCaseNodeDTO> nodeList = getNodeDTO(id, planId);
|
||||
TestCaseNodeDTO testCaseNodeDTO = new TestCaseNodeDTO();
|
||||
testCaseNodeDTO.setId(project.getId());
|
||||
testCaseNodeDTO.setName(name);
|
||||
testCaseNodeDTO.setLabel(name);
|
||||
testCaseNodeDTO.setChildren(nodeList);
|
||||
list.add(testCaseNodeDTO);
|
||||
}
|
||||
});
|
||||
|
||||
return list;
|
||||
|
|
|
@ -62,15 +62,16 @@ public class TestPlanProjectService {
|
|||
}
|
||||
|
||||
public List<String> getPlanIdByProjectId(String projectId) {
|
||||
TestPlanProjectExample testPlanProjectExample = new TestPlanProjectExample();
|
||||
testPlanProjectExample.createCriteria().andProjectIdEqualTo(projectId);
|
||||
List<TestPlanProject> testPlanProjects = testPlanProjectMapper.selectByExample(testPlanProjectExample);
|
||||
if (CollectionUtils.isEmpty(testPlanProjects)) {
|
||||
TestPlanExample testPlanExample = new TestPlanExample();
|
||||
testPlanExample.createCriteria().andProjectIdEqualTo(projectId);
|
||||
List<TestPlan> testPlans = testPlanMapper.selectByExample(testPlanExample);
|
||||
|
||||
if (CollectionUtils.isEmpty(testPlans)) {
|
||||
return null;
|
||||
}
|
||||
return testPlanProjects
|
||||
return testPlans
|
||||
.stream()
|
||||
.map(TestPlanProject::getTestPlanId)
|
||||
.map(TestPlan::getId)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -277,12 +277,16 @@ public class XmindCaseParser {
|
|||
|
||||
String tc = title.replace(":", ":");
|
||||
String[] tcArr = tc.split(":");
|
||||
if (tcArr.length != 2) {
|
||||
if (tcArr.length < 1) {
|
||||
process.add(Translator.get("test_case_name") + Translator.get("incorrect_format"), title);
|
||||
return;
|
||||
}
|
||||
// 用例名称
|
||||
testCase.setName(this.replace(tcArr[1], TC_REGEX));
|
||||
StringBuffer name = new StringBuffer();
|
||||
for (int i = 1; i < tcArr.length; i++) {
|
||||
name.append(tcArr[i]);
|
||||
}
|
||||
testCase.setName(name.toString());
|
||||
testCase.setNodePath(nodePath);
|
||||
|
||||
// 用例等级和用例性质处理
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
ALTER TABLE schedule
|
||||
MODIFY COLUMN id VARCHAR (255);
|
||||
ALTER TABLE message_task
|
||||
MODIFY COLUMN id VARCHAR (255);
|
|
@ -0,0 +1,4 @@
|
|||
ALTER TABLE schedule
|
||||
MODIFY COLUMN resource_id VARCHAR (255);
|
||||
ALTER TABLE message_task
|
||||
MODIFY COLUMN test_id VARCHAR (255);
|
|
@ -106,7 +106,7 @@
|
|||
</el-col>
|
||||
<el-col :span="3" class="ms-col-one ms-font">
|
||||
<el-link class="head" @click="showScenarioParameters">{{$t('api_test.automation.scenario_total')}}</el-link>
|
||||
:{{this.currentScenario.variables!=undefined?this.currentScenario.variables.length: 0}}
|
||||
:{{ getVariableSize() }}
|
||||
</el-col>
|
||||
<el-col :span="3" class="ms-col-one ms-font">
|
||||
<el-checkbox v-model="enableCookieShare">共享cookie</el-checkbox>
|
||||
|
@ -196,7 +196,7 @@
|
|||
</el-drawer>
|
||||
|
||||
<!--场景公共参数-->
|
||||
<ms-variable-list @setVariables="setVariables" ref="scenarioParameters"/>
|
||||
<ms-variable-list @setVariables="setVariables" ref="scenarioParameters" class="ms-sc-variable-header"/>
|
||||
<!--外部导入-->
|
||||
<api-import ref="apiImport" :saved="false" @refresh="apiImport"/>
|
||||
</div>
|
||||
|
@ -204,37 +204,44 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {API_STATUS, PRIORITY} from "../../definition/model/JsonData";
|
||||
import {WORKSPACE_ID} from '@/common/js/constants';
|
||||
import {Assertions, Extract, IfController, JSR223Processor, ConstantTimer, LoopController} from "../../definition/model/ApiTestModel";
|
||||
import {parseEnvironment} from "../../definition/model/EnvironmentModel";
|
||||
import {ELEMENTS, ELEMENT_TYPE} from "./Setting";
|
||||
import MsApiCustomize from "./ApiCustomize";
|
||||
import {getUUID, getCurrentProjectID} from "@/common/js/utils";
|
||||
import ApiEnvironmentConfig from "../../definition/components/environment/ApiEnvironmentConfig";
|
||||
import MsInputTag from "./MsInputTag";
|
||||
import MsRun from "./DebugRun";
|
||||
import MsApiReportDetail from "../report/ApiReportDetail";
|
||||
import MsVariableList from "./variable/VariableList";
|
||||
import ApiImport from "../../definition/components/import/ApiImport";
|
||||
import "@/common/css/material-icons.css"
|
||||
import OutsideClick from "@/common/js/outside-click";
|
||||
import ScenarioApiRelevance from "./api/ApiRelevance";
|
||||
import ScenarioRelevance from "./api/ScenarioRelevance";
|
||||
import MsComponentConfig from "./component/ComponentConfig";
|
||||
import {handleCtrlSEvent} from "../../../../../common/js/utils";
|
||||
import {API_STATUS, PRIORITY} from "../../definition/model/JsonData";
|
||||
import {WORKSPACE_ID} from '@/common/js/constants';
|
||||
import {
|
||||
Assertions,
|
||||
ConstantTimer,
|
||||
Extract,
|
||||
IfController,
|
||||
JSR223Processor,
|
||||
LoopController
|
||||
} from "../../definition/model/ApiTestModel";
|
||||
import {parseEnvironment} from "../../definition/model/EnvironmentModel";
|
||||
import {ELEMENT_TYPE, ELEMENTS} from "./Setting";
|
||||
import MsApiCustomize from "./ApiCustomize";
|
||||
import {getCurrentProjectID, getUUID} from "@/common/js/utils";
|
||||
import ApiEnvironmentConfig from "../../definition/components/environment/ApiEnvironmentConfig";
|
||||
import MsInputTag from "./MsInputTag";
|
||||
import MsRun from "./DebugRun";
|
||||
import MsApiReportDetail from "../report/ApiReportDetail";
|
||||
import MsVariableList from "./variable/VariableList";
|
||||
import ApiImport from "../../definition/components/import/ApiImport";
|
||||
import "@/common/css/material-icons.css"
|
||||
import OutsideClick from "@/common/js/outside-click";
|
||||
import ScenarioApiRelevance from "./api/ApiRelevance";
|
||||
import ScenarioRelevance from "./api/ScenarioRelevance";
|
||||
import MsComponentConfig from "./component/ComponentConfig";
|
||||
import {handleCtrlSEvent} from "../../../../../common/js/utils";
|
||||
|
||||
export default {
|
||||
name: "EditApiScenario",
|
||||
props: {
|
||||
moduleOptions: Array,
|
||||
currentScenario: {},
|
||||
},
|
||||
components: {
|
||||
MsVariableList,
|
||||
ScenarioRelevance,
|
||||
ScenarioApiRelevance,
|
||||
ApiEnvironmentConfig,
|
||||
export default {
|
||||
name: "EditApiScenario",
|
||||
props: {
|
||||
moduleOptions: Array,
|
||||
currentScenario: {},
|
||||
},
|
||||
components: {
|
||||
MsVariableList,
|
||||
ScenarioRelevance,
|
||||
ScenarioApiRelevance,
|
||||
ApiEnvironmentConfig,
|
||||
MsApiReportDetail,
|
||||
MsInputTag, MsRun,
|
||||
MsApiCustomize,
|
||||
|
@ -427,8 +434,9 @@
|
|||
getIdx(index) {
|
||||
return index - 0.33
|
||||
},
|
||||
setVariables(v) {
|
||||
setVariables(v, headers) {
|
||||
this.currentScenario.variables = v;
|
||||
this.currentScenario.headers = headers;
|
||||
if (this.path.endsWith("/update")) {
|
||||
// 直接更新场景防止编辑内容丢失
|
||||
this.editScenario();
|
||||
|
@ -503,7 +511,7 @@
|
|||
this.sort();
|
||||
},
|
||||
nodeClick(data, node) {
|
||||
if (data.referenced != 'REF' && data.referenced != 'Deleted') {
|
||||
if (data.referenced != 'REF' && data.referenced != 'Deleted' && !data.disabled) {
|
||||
this.operatingElements = ELEMENTS.get(data.type);
|
||||
} else {
|
||||
this.operatingElements = [];
|
||||
|
@ -678,9 +686,15 @@
|
|||
if (valid) {
|
||||
this.editScenario();
|
||||
this.debugData = {
|
||||
id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario",
|
||||
variables: this.currentScenario.variables, referenced: 'Created', enableCookieShare: this.enableCookieShare,
|
||||
environmentId: this.currentEnvironmentId, hashTree: this.scenarioDefinition
|
||||
id: this.currentScenario.id,
|
||||
name: this.currentScenario.name,
|
||||
type: "scenario",
|
||||
variables: this.currentScenario.variables,
|
||||
referenced: 'Created',
|
||||
enableCookieShare: this.enableCookieShare,
|
||||
headers: this.currentScenario.headers,
|
||||
environmentId: this.currentEnvironmentId,
|
||||
hashTree: this.scenarioDefinition
|
||||
};
|
||||
this.reportId = getUUID().substring(0, 8);
|
||||
}
|
||||
|
@ -863,6 +877,9 @@
|
|||
if (!this.currentScenario.variables) {
|
||||
this.currentScenario.variables = [];
|
||||
}
|
||||
if (!this.currentScenario.headers) {
|
||||
this.currentScenario.headers = [];
|
||||
}
|
||||
if (this.currentScenario.id) {
|
||||
this.result = this.$get("/api/automation/getApiScenario/" + this.currentScenario.id, response => {
|
||||
if (response.data) {
|
||||
|
@ -887,6 +904,9 @@
|
|||
}
|
||||
})
|
||||
}
|
||||
if (obj.headers) {
|
||||
this.currentScenario.headers = obj.headers;
|
||||
}
|
||||
this.enableCookieShare = obj.enableCookieShare;
|
||||
this.scenarioDefinition = obj.hashTree;
|
||||
}
|
||||
|
@ -905,8 +925,15 @@
|
|||
this.currentScenario.modulePath = this.getPath(this.currentScenario.apiScenarioModuleId);
|
||||
// 构建一个场景对象 方便引用处理
|
||||
let scenario = {
|
||||
id: this.currentScenario.id, enableCookieShare: this.enableCookieShare, name: this.currentScenario.name, variables: this.currentScenario.variables,
|
||||
type: "scenario", referenced: 'Created', environmentId: this.currentEnvironmentId, hashTree: this.scenarioDefinition
|
||||
id: this.currentScenario.id,
|
||||
enableCookieShare: this.enableCookieShare,
|
||||
name: this.currentScenario.name,
|
||||
type: "scenario",
|
||||
variables: this.currentScenario.variables,
|
||||
headers: this.currentScenario.headers,
|
||||
referenced: 'Created',
|
||||
environmentId: this.currentEnvironmentId,
|
||||
hashTree: this.scenarioDefinition
|
||||
};
|
||||
this.currentScenario.scenarioDefinition = scenario;
|
||||
if (this.currentScenario.tags instanceof Array) {
|
||||
|
@ -924,7 +951,7 @@
|
|||
this.loading = false;
|
||||
},
|
||||
showScenarioParameters() {
|
||||
this.$refs.scenarioParameters.open(this.currentScenario.variables);
|
||||
this.$refs.scenarioParameters.open(this.currentScenario.variables, this.currentScenario.headers);
|
||||
},
|
||||
apiImport(importData) {
|
||||
if (importData && importData.data) {
|
||||
|
@ -934,6 +961,16 @@
|
|||
this.sort();
|
||||
this.reload();
|
||||
}
|
||||
},
|
||||
getVariableSize() {
|
||||
let size = 0;
|
||||
if (this.currentScenario.variables) {
|
||||
size += this.currentScenario.variables.length;
|
||||
}
|
||||
if (this.currentScenario.headers && this.currentScenario.headers.length > 1) {
|
||||
size += this.currentScenario.headers.length - 1;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1066,4 +1103,8 @@
|
|||
content: "\e722";
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.ms-sc-variable-header >>> .el-dialog__body {
|
||||
padding: 0px 20px;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -107,7 +107,8 @@
|
|||
},
|
||||
methods: {
|
||||
active() {
|
||||
this.$set(this.data, 'active', !this.data.active);
|
||||
// 这种写法性能极差,不要再放开了
|
||||
//this.$set(this.data, 'active', !this.data.active);
|
||||
this.$emit('active');
|
||||
},
|
||||
copyRow() {
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
<template>
|
||||
<div>
|
||||
<div v-if="request.protocol === 'HTTP'">
|
||||
<el-input :placeholder="$t('api_test.definition.request.path_all_info')" v-if="request.url" v-model="request.url" style="width: 85%;margin-top: 10px" size="small">
|
||||
<el-input :placeholder="$t('api_test.definition.request.path_all_info')" v-if="request.url" v-model="request.url"
|
||||
style="width: 85%;margin-top: 10px" size="small" @blur="urlChange">
|
||||
<el-select v-model="request.method" slot="prepend" style="width: 100px" size="small">
|
||||
<el-option v-for="item in reqOptions" :key="item.id" :label="item.label" :value="item.id"/>
|
||||
</el-select>
|
||||
</el-input>
|
||||
<el-input :placeholder="$t('api_test.definition.request.path_all_info')" v-else v-model="request.path" style="width: 85%;margin-top: 10px" size="small">
|
||||
<el-input :placeholder="$t('api_test.definition.request.path_all_info')" v-else v-model="request.path"
|
||||
style="width: 85%;margin-top: 10px" size="small" @blur="pathChange">
|
||||
<el-select v-model="request.method" slot="prepend" style="width: 100px" size="small">
|
||||
<el-option v-for="item in reqOptions" :key="item.id" :label="item.label" :value="item.id"/>
|
||||
</el-select>
|
||||
|
@ -18,14 +20,14 @@
|
|||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item :label="$t('api_test.request.tcp.server')" prop="server">
|
||||
<el-input class="server-input" v-model="request.server" maxlength="300" show-word-limit size="small"/>
|
||||
<el-input class="server-input" v-model="request.server" maxlength="300" show-word-limit size="small"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item :label="$t('api_test.request.tcp.port')" prop="port" label-width="60px">
|
||||
<el-input-number v-model="request.port" controls-position="right" :min="0" :max="65535" size="small"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item :label="$t('api_test.request.tcp.port')" prop="port" label-width="60px">
|
||||
<el-input-number v-model="request.port" controls-position="right" :min="0" :max="65535" size="small"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</div>
|
||||
|
@ -34,6 +36,7 @@
|
|||
|
||||
<script>
|
||||
import {REQ_METHOD} from "@/business/components/api/definition/model/JsonData";
|
||||
import {KeyValue} from "../../../definition/model/ApiTestModel";
|
||||
|
||||
export default {
|
||||
name: "CustomizeReqInfo",
|
||||
|
@ -42,6 +45,43 @@ export default {
|
|||
return {
|
||||
reqOptions: REQ_METHOD,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
pathChange() {
|
||||
if (!this.request.path || this.request.path.indexOf('?') === -1) return;
|
||||
let url = this.getURL(this.addProtocol(this.request.path));
|
||||
if (url) {
|
||||
this.request.path = decodeURIComponent(this.request.path.substr(0, this.request.path.indexOf("?")));
|
||||
}
|
||||
},
|
||||
urlChange() {
|
||||
if (!this.request.url || this.request.url.indexOf('?') === -1) return;
|
||||
let url = this.getURL(this.addProtocol(this.request.url));
|
||||
if (url) {
|
||||
this.request.url = decodeURIComponent(this.request.url.substr(0, this.request.url.indexOf("?")));
|
||||
}
|
||||
},
|
||||
addProtocol(url) {
|
||||
if (url) {
|
||||
if (!url.toLowerCase().startsWith("https") && !url.toLowerCase().startsWith("http")) {
|
||||
return "https://" + url;
|
||||
}
|
||||
}
|
||||
return url;
|
||||
},
|
||||
getURL(urlStr) {
|
||||
try {
|
||||
let url = new URL(urlStr);
|
||||
url.searchParams.forEach((value, key) => {
|
||||
if (key && value) {
|
||||
this.request.arguments.splice(0, 0, new KeyValue({name: key, required: false, value: value}));
|
||||
}
|
||||
});
|
||||
return url;
|
||||
} catch (e) {
|
||||
this.$error(this.$t('api_test.request.url_invalid'), 2000);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
v-loading="loading"
|
||||
@copy="copyRow"
|
||||
@remove="remove"
|
||||
@active="active"
|
||||
:is-show-name-input="!isDeletedOrRef"
|
||||
:data="request"
|
||||
:draggable="true"
|
||||
|
@ -27,47 +28,60 @@
|
|||
|
||||
<customize-req-info :is-customize-req="isCustomizeReq" :request="request"/>
|
||||
|
||||
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
||||
<ms-api-request-form :isShowEnable="true" :referenced="true" :headers="request.headers " :request="request" v-if="request.protocol==='HTTP' || request.type==='HTTPSamplerProxy'"/>
|
||||
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
|
||||
<ms-api-request-form :isShowEnable="true" :referenced="true" :headers="request.headers " :request="request"
|
||||
v-if="request.protocol==='HTTP' || request.type==='HTTPSamplerProxy'"/>
|
||||
<ms-tcp-basis-parameters :request="request" v-if="request.protocol==='TCP'|| request.type==='TCPSampler'"/>
|
||||
<ms-sql-basis-parameters :request="request" v-if="request.protocol==='SQL'|| request.type==='JDBCSampler'" :showScript="false"/>
|
||||
<ms-dubbo-basis-parameters :request="request" v-if="request.protocol==='DUBBO' || request.protocol==='dubbo://'|| request.type==='DubboSampler'" :showScript="false"/>
|
||||
<ms-sql-basis-parameters :request="request" v-if="request.protocol==='SQL'|| request.type==='JDBCSampler'"
|
||||
:showScript="false"/>
|
||||
<ms-dubbo-basis-parameters :request="request"
|
||||
v-if="request.protocol==='DUBBO' || request.protocol==='dubbo://'|| request.type==='DubboSampler'"
|
||||
:showScript="false"/>
|
||||
|
||||
<p class="tip">{{$t('api_test.definition.request.res_param')}} </p>
|
||||
<api-response-component :currentProtocol="request.protocol" :result="request.requestResult"/>
|
||||
<p class="tip">{{ $t('api_test.definition.request.res_param') }} </p>
|
||||
<div v-if="request.result">
|
||||
<el-tabs v-model="request.activeName" closable class="ms-tabs">
|
||||
<el-tab-pane :label="item.name" :name="item.name" v-for="(item,index) in request.result.scenarios" :key="index">
|
||||
<div v-for="(result,i) in item.requestResults" :key="i" style="margin-bottom: 5px">
|
||||
<api-response-component v-if="result.name===request.name" :result="result"/>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
<api-response-component :currentProtocol="request.protocol" :result="request.requestResult" v-else/>
|
||||
|
||||
<!-- 保存操作 -->
|
||||
<el-button type="primary" size="small" style="margin: 20px; float: right" @click="saveTestCase(item)" v-if="!request.referenced">
|
||||
{{$t('commons.save')}}
|
||||
<el-button type="primary" size="small" style="margin: 20px; float: right" @click="saveTestCase(item)"
|
||||
v-if="!request.referenced">
|
||||
{{ $t('commons.save') }}
|
||||
</el-button>
|
||||
|
||||
</api-base-component>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MsSqlBasisParameters from "../../../definition/components/request/database/BasisParameters";
|
||||
import MsTcpBasisParameters from "../../../definition/components/request/tcp/TcpBasisParameters";
|
||||
import MsDubboBasisParameters from "../../../definition/components/request/dubbo/BasisParameters";
|
||||
import MsApiRequestForm from "../../../definition/components/request/http/ApiHttpRequestForm";
|
||||
import {REQ_METHOD} from "../../../definition/model/JsonData";
|
||||
import MsRequestResultTail from "../../../definition/components/response/RequestResultTail";
|
||||
import MsRun from "../../../definition/components/Run";
|
||||
import {getUUID} from "@/common/js/utils";
|
||||
import ApiBaseComponent from "../common/ApiBaseComponent";
|
||||
import ApiResponseComponent from "./ApiResponseComponent";
|
||||
import CustomizeReqInfo from "@/business/components/api/automation/scenario/common/CustomizeReqInfo";
|
||||
import MsSqlBasisParameters from "../../../definition/components/request/database/BasisParameters";
|
||||
import MsTcpBasisParameters from "../../../definition/components/request/tcp/TcpBasisParameters";
|
||||
import MsDubboBasisParameters from "../../../definition/components/request/dubbo/BasisParameters";
|
||||
import MsApiRequestForm from "../../../definition/components/request/http/ApiHttpRequestForm";
|
||||
import MsRequestResultTail from "../../../definition/components/response/RequestResultTail";
|
||||
import MsRun from "../../../definition/components/Run";
|
||||
import {getUUID} from "@/common/js/utils";
|
||||
import ApiBaseComponent from "../common/ApiBaseComponent";
|
||||
import ApiResponseComponent from "./ApiResponseComponent";
|
||||
import CustomizeReqInfo from "@/business/components/api/automation/scenario/common/CustomizeReqInfo";
|
||||
|
||||
export default {
|
||||
name: "MsApiComponent",
|
||||
props: {
|
||||
request: {},
|
||||
currentScenario: {},
|
||||
node: {},
|
||||
draggable: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
currentEnvironmentId: String,
|
||||
export default {
|
||||
name: "MsApiComponent",
|
||||
props: {
|
||||
request: {},
|
||||
currentScenario: {},
|
||||
node: {},
|
||||
draggable: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
currentEnvironmentId: String,
|
||||
},
|
||||
components: {
|
||||
CustomizeReqInfo,
|
||||
|
@ -155,7 +169,7 @@
|
|||
return true
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
remove() {
|
||||
|
@ -238,8 +252,8 @@
|
|||
this.request.customizeReq = this.isCustomizeReq;
|
||||
let debugData = {
|
||||
id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario",
|
||||
variables: this.currentScenario.variables, referenced: 'Created', enableCookieShare: this.enableCookieShare,
|
||||
environmentId: this.currentEnvironmentId, hashTree: [this.request]
|
||||
variables: this.currentScenario.variables, referenced: 'Created', headers: this.currentScenario.headers,
|
||||
enableCookieShare: this.enableCookieShare, environmentId: this.currentEnvironmentId, hashTree: [this.request]
|
||||
};
|
||||
this.runData.push(debugData);
|
||||
/*触发执行操作*/
|
||||
|
@ -247,6 +261,7 @@
|
|||
},
|
||||
runRefresh(data) {
|
||||
this.request.requestResult = data;
|
||||
this.request.result = undefined;
|
||||
this.loading = false;
|
||||
},
|
||||
reload() {
|
||||
|
@ -289,4 +304,9 @@
|
|||
.icon.is-active {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.ms-tabs >>> .el-icon-close:before {
|
||||
content: "";
|
||||
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
v-loading="loading"
|
||||
@copy="copyRow"
|
||||
@remove="remove"
|
||||
@active="active"
|
||||
:data="scenario"
|
||||
:show-collapse="false"
|
||||
:is-show-name-input="!isDeletedOrRef"
|
||||
|
@ -21,23 +22,23 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import MsSqlBasisParameters from "../../../definition/components/request/database/BasisParameters";
|
||||
import MsTcpBasisParameters from "../../../definition/components/request/tcp/TcpBasisParameters";
|
||||
import MsDubboBasisParameters from "../../../definition/components/request/dubbo/BasisParameters";
|
||||
import MsApiRequestForm from "../../../definition/components/request/http/ApiHttpRequestForm";
|
||||
import ApiBaseComponent from "../common/ApiBaseComponent";
|
||||
import MsSqlBasisParameters from "../../../definition/components/request/database/BasisParameters";
|
||||
import MsTcpBasisParameters from "../../../definition/components/request/tcp/TcpBasisParameters";
|
||||
import MsDubboBasisParameters from "../../../definition/components/request/dubbo/BasisParameters";
|
||||
import MsApiRequestForm from "../../../definition/components/request/http/ApiHttpRequestForm";
|
||||
import ApiBaseComponent from "../common/ApiBaseComponent";
|
||||
|
||||
export default {
|
||||
name: "ApiScenarioComponent",
|
||||
props: {
|
||||
scenario: {},
|
||||
node: {},
|
||||
draggable: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
export default {
|
||||
name: "ApiScenarioComponent",
|
||||
props: {
|
||||
scenario: {},
|
||||
node: {},
|
||||
draggable: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
watch: {},
|
||||
},
|
||||
watch: {},
|
||||
created() {
|
||||
if (this.scenario.id && this.scenario.referenced === 'REF' && !this.scenario.loaded) {
|
||||
this.result = this.$get("/api/automation/getApiScenario/" + this.scenario.id, response => {
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
<api-base-component
|
||||
@copy="copyRow"
|
||||
@remove="remove"
|
||||
@active="active"
|
||||
:data="jsr223Processor"
|
||||
:draggable="draggable"
|
||||
:color="color"
|
||||
:background-color="backgroundColor"
|
||||
:title="title">
|
||||
:title="title" v-loading="loading">
|
||||
|
||||
<jsr233-processor-content
|
||||
:jsr223-processor="jsr223Processor"
|
||||
|
@ -18,46 +19,59 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import MsCodeEdit from "../../../../common/components/MsCodeEdit";
|
||||
import MsInstructionsIcon from "../../../../common/components/MsInstructionsIcon";
|
||||
import MsDropdown from "../../../../common/components/MsDropdown";
|
||||
import ApiBaseComponent from "../common/ApiBaseComponent";
|
||||
import Jsr233ProcessorContent from "../common/Jsr233ProcessorContent";
|
||||
import MsCodeEdit from "../../../../common/components/MsCodeEdit";
|
||||
import MsInstructionsIcon from "../../../../common/components/MsInstructionsIcon";
|
||||
import MsDropdown from "../../../../common/components/MsDropdown";
|
||||
import ApiBaseComponent from "../common/ApiBaseComponent";
|
||||
import Jsr233ProcessorContent from "../common/Jsr233ProcessorContent";
|
||||
|
||||
export default {
|
||||
name: "MsJsr233Processor",
|
||||
components: {Jsr233ProcessorContent, ApiBaseComponent, MsDropdown, MsInstructionsIcon, MsCodeEdit},
|
||||
props: {
|
||||
draggable: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
isReadOnly: {
|
||||
type: Boolean,
|
||||
default:
|
||||
export default {
|
||||
name: "MsJsr233Processor",
|
||||
components: {Jsr233ProcessorContent, ApiBaseComponent, MsDropdown, MsInstructionsIcon, MsCodeEdit},
|
||||
props: {
|
||||
draggable: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
isReadOnly: {
|
||||
type: Boolean,
|
||||
default:
|
||||
false
|
||||
},
|
||||
jsr223Processor: {
|
||||
type: Object,
|
||||
},
|
||||
isPreProcessor: {
|
||||
type: Boolean,
|
||||
default:
|
||||
false
|
||||
},
|
||||
title: String,
|
||||
color: String,
|
||||
backgroundColor: String,
|
||||
node: {},
|
||||
isPreProcessor: {
|
||||
type: Boolean,
|
||||
default:
|
||||
false
|
||||
},
|
||||
methods: {
|
||||
remove() {
|
||||
this.$emit('remove', this.jsr223Processor, this.node);
|
||||
},
|
||||
copyRow() {
|
||||
this.$emit('copyRow', this.jsr223Processor, this.node);
|
||||
},
|
||||
}
|
||||
title: String,
|
||||
color: String,
|
||||
backgroundColor: String,
|
||||
node: {},
|
||||
},
|
||||
data() {
|
||||
return {loading: false}
|
||||
},
|
||||
methods: {
|
||||
remove() {
|
||||
this.$emit('remove', this.jsr223Processor, this.node);
|
||||
},
|
||||
copyRow() {
|
||||
this.$emit('copyRow', this.jsr223Processor, this.node);
|
||||
},
|
||||
reload() {
|
||||
this.loading = true
|
||||
this.$nextTick(() => {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
active() {
|
||||
this.jsr223Processor.active = !this.jsr223Processor.active;
|
||||
this.reload();
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -79,17 +79,17 @@
|
|||
<el-input-number size="small" v-model="controller.whileController.timeout" :placeholder="$t('commons.millisecond')" :max="1000*10000000" :min="3000" :step="1000"/>
|
||||
<span class="ms-span ms-radio">ms</span>
|
||||
</div>
|
||||
<p class="tip">{{$t('api_test.definition.request.res_param')}} </p>
|
||||
<div>
|
||||
<el-tabs v-model="activeName" closable class="ms-tabs">
|
||||
<el-tab-pane :label="item.name" :name="item.name" v-for="(item,index) in requestResult.scenarios" :key="index">
|
||||
<div v-for="(result,i) in item.requestResults" :key="i" style="margin-bottom: 5px">
|
||||
<api-response-component :result="result"/>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<!--<p class="tip">{{$t('api_test.definition.request.res_param')}} </p>-->
|
||||
<!--<div>-->
|
||||
<!--<el-tabs v-model="activeName" closable class="ms-tabs">-->
|
||||
<!--<el-tab-pane :label="item.name" :name="item.name" v-for="(item,index) in requestResult.scenarios" :key="index">-->
|
||||
<!--<div v-for="(result,i) in item.requestResults" :key="i" style="margin-bottom: 5px">-->
|
||||
<!--<api-response-component :result="result"/>-->
|
||||
<!--</div>-->
|
||||
<!--</el-tab-pane>-->
|
||||
<!--</el-tabs>-->
|
||||
|
||||
</div>
|
||||
<!--</div>-->
|
||||
|
||||
</api-base-component>
|
||||
|
||||
|
@ -97,27 +97,27 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import ApiBaseComponent from "../common/ApiBaseComponent";
|
||||
import ApiResponseComponent from "./ApiResponseComponent";
|
||||
import MsRun from "../DebugRun";
|
||||
import {getUUID, getCurrentProjectID} from "@/common/js/utils";
|
||||
import ApiBaseComponent from "../common/ApiBaseComponent";
|
||||
import ApiResponseComponent from "./ApiResponseComponent";
|
||||
import MsRun from "../DebugRun";
|
||||
import {getUUID} from "@/common/js/utils";
|
||||
|
||||
export default {
|
||||
name: "MsLoopController",
|
||||
components: {ApiBaseComponent, ApiResponseComponent, MsRun},
|
||||
props: {
|
||||
controller: {},
|
||||
currentEnvironmentId: String,
|
||||
currentScenario: {},
|
||||
node: {},
|
||||
index: Object,
|
||||
draggable: {
|
||||
type: Boolean,
|
||||
export default {
|
||||
name: "MsLoopController",
|
||||
components: {ApiBaseComponent, ApiResponseComponent, MsRun},
|
||||
props: {
|
||||
controller: {},
|
||||
currentEnvironmentId: String,
|
||||
currentScenario: {},
|
||||
node: {},
|
||||
index: Object,
|
||||
draggable: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.initResult();
|
||||
// this.initResult();
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
@ -202,12 +202,17 @@
|
|||
this.$warning("当前循环下没有请求,不能执行")
|
||||
return;
|
||||
}
|
||||
this.controller.active = true;
|
||||
this.loading = true;
|
||||
this.debugData = {
|
||||
id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario",
|
||||
variables: this.currentScenario.variables, referenced: 'Created', enableCookieShare: this.enableCookieShare,
|
||||
environmentId: this.currentEnvironmentId, hashTree: [this.controller]
|
||||
id: this.currentScenario.id,
|
||||
name: this.currentScenario.name,
|
||||
type: "scenario",
|
||||
variables: this.currentScenario.variables,
|
||||
headers: this.currentScenario.headers,
|
||||
referenced: 'Created',
|
||||
enableCookieShare: this.enableCookieShare,
|
||||
environmentId: this.currentEnvironmentId,
|
||||
hashTree: [this.controller]
|
||||
};
|
||||
this.reportId = getUUID().substring(0, 8);
|
||||
},
|
||||
|
@ -224,7 +229,7 @@
|
|||
},
|
||||
changeRadio() {
|
||||
this.controller.active = true;
|
||||
this.initResult();
|
||||
//this.initResult();
|
||||
this.reload();
|
||||
},
|
||||
change(value) {
|
||||
|
@ -258,6 +263,20 @@
|
|||
this.success = this.requestResult.scenarios && this.requestResult.scenarios != null ? this.requestResult.scenarios.length - this.error : 0;
|
||||
}
|
||||
},
|
||||
setResult(hashTree) {
|
||||
if (hashTree) {
|
||||
hashTree.forEach(item => {
|
||||
if (item.type === "HTTPSamplerProxy" || item.type === "DubboSampler" || item.type === "JDBCSampler" || item.type === "TCPSampler") {
|
||||
item.result = this.requestResult;
|
||||
item.activeName = this.activeName;
|
||||
item.requestResult = undefined;
|
||||
}
|
||||
if (item.hashTree && item.hashTree.length > 0) {
|
||||
this.setResult(item.hashTree);
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
getReport() {
|
||||
if (this.reportId) {
|
||||
let url = "/api/scenario/report/get/" + this.reportId;
|
||||
|
@ -285,11 +304,15 @@
|
|||
break;
|
||||
}
|
||||
this.getFails();
|
||||
this.activeName = this.requestResult && this.requestResult.scenarios && this.requestResult.scenarios != null && this.requestResult.scenarios.length > 0 ? this.requestResult.scenarios[0].name : "";
|
||||
// 把请求结果分给各个请求
|
||||
this.setResult(this.controller.hashTree);
|
||||
this.$emit('refReload');
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
this.loading = false;
|
||||
this.activeName = this.requestResult && this.requestResult.scenarios && this.requestResult.scenarios != null && this.requestResult.scenarios.length > 0 ? this.requestResult.scenarios[0].name : "";
|
||||
this.reload();
|
||||
} else {
|
||||
setTimeout(this.getReport, 2000)
|
||||
}
|
||||
|
@ -333,11 +356,6 @@
|
|||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.ms-tabs >>> .el-icon-close:before {
|
||||
content: "";
|
||||
|
||||
}
|
||||
|
||||
.icon.is-active {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
|
|
@ -1,88 +1,132 @@
|
|||
<template>
|
||||
<el-dialog :title="$t('api_test.scenario.variables')" :close-on-click-modal="false"
|
||||
<el-dialog title="场景变量" :close-on-click-modal="false"
|
||||
:visible.sync="visible" class="visible-dialog" width="60%"
|
||||
@close="close" v-loading="loading">
|
||||
<div>
|
||||
<el-input placeholder="变量名称搜索" style="width: 50%;margin: 0px 0px 10px" v-model="selectVariable" size="small" @change="filter" @keyup.enter="filter">
|
||||
<el-select v-model="searchType" slot="prepend" placeholder="类型" style="width: 90px" @change="filter">
|
||||
<el-option value="CONSTANT" label="常量"></el-option>
|
||||
<el-option value="LIST" label="列表"></el-option>
|
||||
<el-option value="CSV" label="CSV"></el-option>
|
||||
<el-option value="COUNTER" label="计数器"></el-option>
|
||||
<el-option value="RANDOM" label="随机数"></el-option>
|
||||
</el-select>
|
||||
</el-input>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<div style="border:1px #DCDFE6 solid; min-height: 400px;border-radius: 4px ;width: 100% ;">
|
||||
<el-table ref="table" border :data="variables" class="adjust-table" @select-all="select" @select="select"
|
||||
v-loading="loading" @row-click="edit" height="400px" :row-class-name="tableRowClassName">
|
||||
<el-table-column type="selection" width="38"/>
|
||||
<el-table-column prop="num" label="ID" sortable/>
|
||||
<el-table-column prop="name" :label="$t('api_test.variable_name')" sortable show-overflow-tooltip/>
|
||||
<el-table-column prop="type" :label="$t('test_track.case.type')">
|
||||
<template v-slot:default="scope">
|
||||
<span>{{types.get(scope.row.type)}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="value" :label="$t('api_test.value')" show-overflow-tooltip/>
|
||||
</el-table>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<ms-edit-constant v-if="editData.type=='CONSTANT'" ref="parameters" :editData.sync="editData"/>
|
||||
<ms-edit-counter v-if="editData.type=='COUNTER'" ref="counter" :editData.sync="editData"/>
|
||||
<ms-edit-random v-if="editData.type=='RANDOM'" ref="random" :editData.sync="editData"/>
|
||||
<ms-edit-list-value v-if="editData.type=='LIST'" ref="listValue" :editData="editData"/>
|
||||
<ms-edit-csv v-if="editData.type=='CSV'" ref="csv" :editData.sync="editData"/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
<el-tabs v-model="activeName">
|
||||
<el-tab-pane :label="$t('api_test.scenario.variables')" name="variable">
|
||||
<div style="margin-top: 10px">
|
||||
<el-row style="margin-bottom: 10px">
|
||||
<el-col :span="8">
|
||||
<el-input placeholder="变量名称搜索" v-model="selectVariable" size="small" @change="filter"
|
||||
@keyup.enter="filter">
|
||||
<el-select v-model="searchType" slot="prepend" placeholder="类型" style="width: 90px" @change="filter">
|
||||
<el-option value="CONSTANT" label="常量"></el-option>
|
||||
<el-option value="LIST" label="列表"></el-option>
|
||||
<el-option value="CSV" label="CSV"></el-option>
|
||||
<el-option value="COUNTER" label="计数器"></el-option>
|
||||
<el-option value="RANDOM" label="随机数"></el-option>
|
||||
</el-select>
|
||||
</el-input>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="6">
|
||||
<el-dropdown split-button type="primary" @command="handleClick" @click="handleClick('CONSTANT')"
|
||||
size="small" style="margin-left: 10px">
|
||||
{{ $t('commons.add') }}
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item command="CONSTANT">常量</el-dropdown-item>
|
||||
<el-dropdown-item command="LIST">列表</el-dropdown-item>
|
||||
<el-dropdown-item command="CSV">CSV</el-dropdown-item>
|
||||
<el-dropdown-item command="COUNTER">计数器</el-dropdown-item>
|
||||
<el-dropdown-item command="RANDOM">随机数</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
<el-button size="small" style="margin-left: 10px" @click="deleteVariable">{{ $t('commons.delete') }}
|
||||
</el-button>
|
||||
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<div style="border:1px #DCDFE6 solid; min-height: 400px;border-radius: 4px ;width: 100% ;">
|
||||
<el-table ref="table" border :data="variables" class="adjust-table" @select-all="select"
|
||||
@select="select"
|
||||
v-loading="loading" @row-click="edit" height="400px" :row-class-name="tableRowClassName">
|
||||
<el-table-column type="selection" width="38"/>
|
||||
<el-table-column prop="num" label="ID" sortable/>
|
||||
<el-table-column prop="name" :label="$t('api_test.variable_name')" sortable show-overflow-tooltip/>
|
||||
<el-table-column prop="type" :label="$t('test_track.case.type')">
|
||||
<template v-slot:default="scope">
|
||||
<span>{{ types.get(scope.row.type) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="value" :label="$t('api_test.value')" show-overflow-tooltip/>
|
||||
</el-table>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<ms-edit-constant v-if="editData.type=='CONSTANT'" ref="parameters" :editData.sync="editData"/>
|
||||
<ms-edit-counter v-if="editData.type=='COUNTER'" ref="counter" :editData.sync="editData"/>
|
||||
<ms-edit-random v-if="editData.type=='RANDOM'" ref="random" :editData.sync="editData"/>
|
||||
<ms-edit-list-value v-if="editData.type=='LIST'" ref="listValue" :editData="editData"/>
|
||||
<ms-edit-csv v-if="editData.type=='CSV'" ref="csv" :editData.sync="editData"/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
|
||||
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('api_test.scenario.headers')" name="headers">
|
||||
<!-- 请求头-->
|
||||
<el-tooltip class="item-tabs" effect="dark" :content="$t('api_test.request.headers')" placement="top-start"
|
||||
slot="label">
|
||||
<span>{{ $t('api_test.request.headers') }}
|
||||
<div class="el-step__icon is-text ms-api-col ms-variable-header" v-if="headers.length>1">
|
||||
<div class="el-step__icon-inner">{{ headers.length - 1 }}</div>
|
||||
</div>
|
||||
</span>
|
||||
</el-tooltip>
|
||||
<el-row>
|
||||
<el-link class="ms-variable-link" @click="batchAdd" style="color: #783887"> {{ $t("commons.batch_add") }}
|
||||
</el-link>
|
||||
</el-row>
|
||||
<div style="min-height: 400px">
|
||||
<ms-api-key-value :items="headers"/>
|
||||
<batch-add-parameter @batchSave="batchSave" ref="batchAddParameter"/>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<template v-slot:footer>
|
||||
<div>
|
||||
<el-button style="margin-right:10px" @click="deleteVariable">{{$t('commons.delete')}}</el-button>
|
||||
<el-dropdown split-button type="primary" @command="handleClick" @click="handleClick('CONSTANT')" placement="top-end">
|
||||
{{$t('commons.add')}}
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item command="CONSTANT">常量</el-dropdown-item>
|
||||
<el-dropdown-item command="LIST">列表</el-dropdown-item>
|
||||
<el-dropdown-item command="CSV">CSV</el-dropdown-item>
|
||||
<el-dropdown-item command="COUNTER">计数器</el-dropdown-item>
|
||||
<el-dropdown-item command="RANDOM">随机数</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
<el-button type="primary" @click="save">{{ $t('commons.confirm') }}</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MsEditConstant from "./EditConstant";
|
||||
import MsDialogFooter from "../../../../common/components/MsDialogFooter";
|
||||
import MsTableHeader from "@/business/components/common/components/MsTableHeader";
|
||||
import MsTablePagination from "@/business/components/common/pagination/TablePagination";
|
||||
import MsEditCounter from "./EditCounter";
|
||||
import MsEditRandom from "./EditRandom";
|
||||
import MsEditListValue from "./EditListValue";
|
||||
import MsEditCsv from "./EditCsv";
|
||||
import {getUUID} from "@/common/js/utils";
|
||||
import MsEditConstant from "./EditConstant";
|
||||
import MsDialogFooter from "../../../../common/components/MsDialogFooter";
|
||||
import MsTableHeader from "@/business/components/common/components/MsTableHeader";
|
||||
import MsTablePagination from "@/business/components/common/pagination/TablePagination";
|
||||
import MsEditCounter from "./EditCounter";
|
||||
import MsEditRandom from "./EditRandom";
|
||||
import MsEditListValue from "./EditListValue";
|
||||
import MsEditCsv from "./EditCsv";
|
||||
import {getUUID} from "@/common/js/utils";
|
||||
import MsApiKeyValue from "../../../definition/components/ApiKeyValue";
|
||||
import BatchAddParameter from "../../../definition/components/basis/BatchAddParameter";
|
||||
import {KeyValue} from "../../../definition/model/ApiTestModel";
|
||||
|
||||
export default {
|
||||
name: "MsVariableList",
|
||||
components: {
|
||||
MsEditConstant,
|
||||
MsDialogFooter,
|
||||
MsTableHeader,
|
||||
MsTablePagination,
|
||||
MsEditCounter,
|
||||
MsEditRandom,
|
||||
MsEditListValue,
|
||||
MsEditCsv
|
||||
},
|
||||
export default {
|
||||
name: "MsVariableList",
|
||||
components: {
|
||||
MsEditConstant,
|
||||
MsDialogFooter,
|
||||
MsTableHeader,
|
||||
MsTablePagination,
|
||||
MsEditCounter,
|
||||
MsEditRandom,
|
||||
MsEditListValue,
|
||||
MsEditCsv,
|
||||
MsApiKeyValue,
|
||||
BatchAddParameter
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
variables: [],
|
||||
headers: [],
|
||||
activeName: "variable",
|
||||
searchType: "",
|
||||
selectVariable: "",
|
||||
condition: {},
|
||||
|
@ -103,6 +147,37 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
batchAdd() {
|
||||
this.$refs.batchAddParameter.open();
|
||||
},
|
||||
batchSave(data) {
|
||||
if (data) {
|
||||
let params = data.split("\n");
|
||||
let keyValues = [];
|
||||
params.forEach(item => {
|
||||
let line = item.split(/,|,/);
|
||||
let required = false;
|
||||
if (line[1] === '必填' || line[1] === 'true') {
|
||||
required = true;
|
||||
}
|
||||
keyValues.push(new KeyValue({
|
||||
name: line[0],
|
||||
required: required,
|
||||
value: line[2],
|
||||
description: line[3],
|
||||
type: "text",
|
||||
valid: false,
|
||||
file: false,
|
||||
encode: true,
|
||||
enable: true,
|
||||
contentType: "text/plain"
|
||||
}));
|
||||
})
|
||||
keyValues.forEach(item => {
|
||||
this.headers.unshift(item);
|
||||
})
|
||||
}
|
||||
},
|
||||
handleClick(command) {
|
||||
this.editData = {};
|
||||
this.editData.type = command;
|
||||
|
@ -135,12 +210,16 @@
|
|||
isSelect(row) {
|
||||
return this.selection.includes(row.id)
|
||||
},
|
||||
open: function (variables) {
|
||||
open: function (variables, headers) {
|
||||
this.variables = variables;
|
||||
this.headers = headers;
|
||||
this.visible = true;
|
||||
this.editData = {type: "CONSTANT"};
|
||||
this.addParameters(this.editData);
|
||||
},
|
||||
save() {
|
||||
this.visible = false;
|
||||
},
|
||||
close() {
|
||||
this.visible = false;
|
||||
let saveVariables = [];
|
||||
|
@ -152,7 +231,7 @@
|
|||
})
|
||||
this.selectVariable = "";
|
||||
this.searchType = "";
|
||||
this.$emit('setVariables', saveVariables);
|
||||
this.$emit('setVariables', saveVariables, this.headers);
|
||||
},
|
||||
deleteVariable() {
|
||||
let ids = Array.from(this.selection);
|
||||
|
@ -205,7 +284,19 @@
|
|||
</script>
|
||||
|
||||
<style>
|
||||
.ms-variable-hidden-row {
|
||||
display: none;
|
||||
}
|
||||
.ms-variable-hidden-row {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.ms-variable-header {
|
||||
background: #783887;
|
||||
color: white;
|
||||
height: 18px;
|
||||
border-radius: 42%;
|
||||
}
|
||||
|
||||
.ms-variable-link {
|
||||
float: right;
|
||||
margin-right: 45px;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -52,31 +52,31 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import MsApiAssertionText from "./ApiAssertionText";
|
||||
import MsApiAssertionRegex from "./ApiAssertionRegex";
|
||||
import MsApiAssertionDuration from "./ApiAssertionDuration";
|
||||
import {ASSERTION_TYPE, JSONPath} from "../../model/ApiTestModel";
|
||||
import MsApiAssertionsEdit from "./ApiAssertionsEdit";
|
||||
import MsApiAssertionJsonPath from "./ApiAssertionJsonPath";
|
||||
import MsApiAssertionJsr223 from "./ApiAssertionJsr223";
|
||||
import MsApiJsonpathSuggestList from "./ApiJsonpathSuggestList";
|
||||
import MsApiAssertionXPath2 from "./ApiAssertionXPath2";
|
||||
import {getUUID} from "@/common/js/utils";
|
||||
import ApiJsonPathSuggestButton from "./ApiJsonPathSuggestButton";
|
||||
import MsApiJsonpathSuggest from "./ApiJsonpathSuggest";
|
||||
import ApiBaseComponent from "../../../automation/scenario/common/ApiBaseComponent";
|
||||
import MsApiAssertionText from "./ApiAssertionText";
|
||||
import MsApiAssertionRegex from "./ApiAssertionRegex";
|
||||
import MsApiAssertionDuration from "./ApiAssertionDuration";
|
||||
import {ASSERTION_TYPE, JSONPath} from "../../model/ApiTestModel";
|
||||
import MsApiAssertionsEdit from "./ApiAssertionsEdit";
|
||||
import MsApiAssertionJsonPath from "./ApiAssertionJsonPath";
|
||||
import MsApiAssertionJsr223 from "./ApiAssertionJsr223";
|
||||
import MsApiJsonpathSuggestList from "./ApiJsonpathSuggestList";
|
||||
import MsApiAssertionXPath2 from "./ApiAssertionXPath2";
|
||||
import {getUUID} from "@/common/js/utils";
|
||||
import ApiJsonPathSuggestButton from "./ApiJsonPathSuggestButton";
|
||||
import MsApiJsonpathSuggest from "./ApiJsonpathSuggest";
|
||||
import ApiBaseComponent from "../../../automation/scenario/common/ApiBaseComponent";
|
||||
|
||||
export default {
|
||||
name: "MsApiAssertions",
|
||||
components: {
|
||||
ApiBaseComponent,
|
||||
MsApiJsonpathSuggest,
|
||||
ApiJsonPathSuggestButton,
|
||||
MsApiAssertionXPath2,
|
||||
MsApiAssertionJsr223,
|
||||
MsApiJsonpathSuggestList,
|
||||
MsApiAssertionJsonPath,
|
||||
MsApiAssertionsEdit, MsApiAssertionDuration, MsApiAssertionRegex, MsApiAssertionText
|
||||
export default {
|
||||
name: "MsApiAssertions",
|
||||
components: {
|
||||
ApiBaseComponent,
|
||||
MsApiJsonpathSuggest,
|
||||
ApiJsonPathSuggestButton,
|
||||
MsApiAssertionXPath2,
|
||||
MsApiAssertionJsr223,
|
||||
MsApiJsonpathSuggestList,
|
||||
MsApiAssertionJsonPath,
|
||||
MsApiAssertionsEdit, MsApiAssertionDuration, MsApiAssertionRegex, MsApiAssertionText
|
||||
},
|
||||
props: {
|
||||
draggable: {
|
||||
|
@ -131,7 +131,7 @@
|
|||
})
|
||||
},
|
||||
active() {
|
||||
// item.active = !item.active;
|
||||
this.assertions.active = !this.assertions.active;
|
||||
this.reload();
|
||||
},
|
||||
remove() {
|
||||
|
|
|
@ -2,15 +2,18 @@
|
|||
|
||||
<div class="card-container" v-loading="loading">
|
||||
<el-card class="card-content">
|
||||
<el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand"
|
||||
<el-button v-if="scenario" style="float: right;margin-right: 20px" size="small" type="primary"
|
||||
@click="handleCommand"> {{ $t('commons.test') }}
|
||||
</el-button>
|
||||
<el-dropdown v-else split-button type="primary" class="ms-api-buttion" @click="handleCommand"
|
||||
@command="handleCommand" size="small" style="float: right;margin-right: 20px">
|
||||
{{$t('commons.test')}}
|
||||
{{ $t('commons.test') }}
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as_case')}}</el-dropdown-item>
|
||||
<el-dropdown-item command="save_as">{{ $t('api_test.definition.request.save_as_case') }}</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
|
||||
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
||||
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
|
||||
<!-- 请求参数 -->
|
||||
<ms-basis-parameters :request="request" ref="requestForm"/>
|
||||
|
||||
|
@ -33,29 +36,38 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import MsResponseResult from "../response/ResponseResult";
|
||||
import MsRequestMetric from "../response/RequestMetric";
|
||||
import {getUUID, getCurrentUser} from "@/common/js/utils";
|
||||
import MsResponseText from "../response/ResponseText";
|
||||
import MsRun from "../Run";
|
||||
import {createComponent} from "../jmeter/components";
|
||||
import {REQ_METHOD} from "../../model/JsonData";
|
||||
import MsRequestResultTail from "../response/RequestResultTail";
|
||||
import MsBasisParameters from "../request/dubbo/BasisParameters";
|
||||
import MsJmxStep from "../step/JmxStep";
|
||||
import MsApiCaseList from "../case/ApiCaseList";
|
||||
import MsResponseResult from "../response/ResponseResult";
|
||||
import MsRequestMetric from "../response/RequestMetric";
|
||||
import {getUUID} from "@/common/js/utils";
|
||||
import MsResponseText from "../response/ResponseText";
|
||||
import MsRun from "../Run";
|
||||
import {createComponent} from "../jmeter/components";
|
||||
import {REQ_METHOD} from "../../model/JsonData";
|
||||
import MsRequestResultTail from "../response/RequestResultTail";
|
||||
import MsBasisParameters from "../request/dubbo/BasisParameters";
|
||||
import MsJmxStep from "../step/JmxStep";
|
||||
import MsApiCaseList from "../case/ApiCaseList";
|
||||
|
||||
export default {
|
||||
name: "ApiConfig",
|
||||
components: {MsRequestResultTail, MsResponseResult, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters, MsJmxStep, MsApiCaseList},
|
||||
props: {
|
||||
currentProtocol: String,
|
||||
scenario: Boolean,
|
||||
testCase: {},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
rules: {
|
||||
export default {
|
||||
name: "ApiConfig",
|
||||
components: {
|
||||
MsRequestResultTail,
|
||||
MsResponseResult,
|
||||
MsRequestMetric,
|
||||
MsResponseText,
|
||||
MsRun,
|
||||
MsBasisParameters,
|
||||
MsJmxStep,
|
||||
MsApiCaseList
|
||||
},
|
||||
props: {
|
||||
currentProtocol: String,
|
||||
scenario: Boolean,
|
||||
testCase: {},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
rules: {
|
||||
method: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
|
||||
url: [{required: true, message: this.$t('api_test.definition.request.path_all_info'), trigger: 'blur'}],
|
||||
},
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button v-if="scenario" size="small" type="primary" @click="handleCommand"> {{ $t('commons.test') }}
|
||||
</el-button>
|
||||
<el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand"
|
||||
@command="handleCommand" size="small" v-if="testCase===undefined && !scenario">
|
||||
{{$t('commons.test')}}
|
||||
|
@ -47,30 +49,39 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
|
||||
import MsResponseResult from "../response/ResponseResult";
|
||||
import MsRequestMetric from "../response/RequestMetric";
|
||||
import {getUUID, getCurrentUser} from "@/common/js/utils";
|
||||
import MsResponseText from "../response/ResponseText";
|
||||
import MsRun from "../Run";
|
||||
import {createComponent} from "../jmeter/components";
|
||||
import {REQ_METHOD} from "../../model/JsonData";
|
||||
import MsRequestResultTail from "../response/RequestResultTail";
|
||||
import MsJmxStep from "../step/JmxStep";
|
||||
import {KeyValue} from "../../model/ApiTestModel";
|
||||
import MsApiCaseList from "../case/ApiCaseList";
|
||||
import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
|
||||
import MsResponseResult from "../response/ResponseResult";
|
||||
import MsRequestMetric from "../response/RequestMetric";
|
||||
import {getCurrentUser, getUUID} from "@/common/js/utils";
|
||||
import MsResponseText from "../response/ResponseText";
|
||||
import MsRun from "../Run";
|
||||
import {createComponent} from "../jmeter/components";
|
||||
import {REQ_METHOD} from "../../model/JsonData";
|
||||
import MsRequestResultTail from "../response/RequestResultTail";
|
||||
import MsJmxStep from "../step/JmxStep";
|
||||
import {KeyValue} from "../../model/ApiTestModel";
|
||||
import MsApiCaseList from "../case/ApiCaseList";
|
||||
|
||||
export default {
|
||||
name: "ApiConfig",
|
||||
components: {MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun, MsJmxStep, MsApiCaseList},
|
||||
props: {
|
||||
currentProtocol: String,
|
||||
testCase: {},
|
||||
scenario: Boolean,
|
||||
},
|
||||
data() {
|
||||
let validateURL = (rule, value, callback) => {
|
||||
try {
|
||||
export default {
|
||||
name: "ApiConfig",
|
||||
components: {
|
||||
MsRequestResultTail,
|
||||
MsResponseResult,
|
||||
MsApiRequestForm,
|
||||
MsRequestMetric,
|
||||
MsResponseText,
|
||||
MsRun,
|
||||
MsJmxStep,
|
||||
MsApiCaseList
|
||||
},
|
||||
props: {
|
||||
currentProtocol: String,
|
||||
testCase: {},
|
||||
scenario: Boolean,
|
||||
},
|
||||
data() {
|
||||
let validateURL = (rule, value, callback) => {
|
||||
try {
|
||||
new URL(this.debugForm.url);
|
||||
callback();
|
||||
} catch (e) {
|
||||
|
@ -198,7 +209,7 @@
|
|||
},
|
||||
urlChange() {
|
||||
if (!this.debugForm.url) return;
|
||||
let url = this.getURL(this.debugForm.url);
|
||||
let url = this.getURL(this.addProtocol(this.debugForm.url));
|
||||
if (url && url.pathname) {
|
||||
if (this.debugForm.url.indexOf('?') != -1) {
|
||||
this.debugForm.url = decodeURIComponent(this.debugForm.url.substr(0, this.debugForm.url.indexOf("?")));
|
||||
|
@ -209,7 +220,14 @@
|
|||
}
|
||||
|
||||
},
|
||||
|
||||
addProtocol(url) {
|
||||
if (url) {
|
||||
if (!url.toLowerCase().startsWith("https") && !url.toLowerCase().startsWith("http")) {
|
||||
return "https://" + url;
|
||||
}
|
||||
}
|
||||
return url;
|
||||
},
|
||||
getURL(urlStr) {
|
||||
try {
|
||||
let url = new URL(urlStr);
|
||||
|
|
|
@ -2,15 +2,19 @@
|
|||
|
||||
<div class="card-container" v-loading="loading">
|
||||
<el-card class="card-content">
|
||||
<el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand"
|
||||
<el-button v-if="scenario" style="float: right;margin-right: 20px" size="small" type="primary"
|
||||
@click="handleCommand"> {{ $t('commons.test') }}
|
||||
</el-button>
|
||||
|
||||
<el-dropdown v-else split-button type="primary" class="ms-api-buttion" @click="handleCommand"
|
||||
@command="handleCommand" size="small" style="float: right;margin-right: 20px">
|
||||
{{$t('commons.test')}}
|
||||
{{ $t('commons.test') }}
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as_case')}}</el-dropdown-item>
|
||||
<el-dropdown-item command="save_as">{{ $t('api_test.definition.request.save_as_case') }}</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
|
||||
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p>
|
||||
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
|
||||
<!-- JDBC 请求参数 -->
|
||||
<ms-basis-parameters :request="request" @callback="runDebug" ref="requestForm"/>
|
||||
|
||||
|
@ -35,31 +39,40 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import MsResponseResult from "../response/ResponseResult";
|
||||
import MsRequestMetric from "../response/RequestMetric";
|
||||
import {getUUID, getCurrentUser} from "@/common/js/utils";
|
||||
import MsResponseText from "../response/ResponseText";
|
||||
import MsRun from "../Run";
|
||||
import {createComponent} from "../jmeter/components";
|
||||
import {REQ_METHOD} from "../../model/JsonData";
|
||||
import MsRequestResultTail from "../response/RequestResultTail";
|
||||
import MsBasisParameters from "../request/database/BasisParameters";
|
||||
import MsJmxStep from "../step/JmxStep";
|
||||
import MsApiCaseList from "../case/ApiCaseList";
|
||||
import MsResponseResult from "../response/ResponseResult";
|
||||
import MsRequestMetric from "../response/RequestMetric";
|
||||
import {getUUID} from "@/common/js/utils";
|
||||
import MsResponseText from "../response/ResponseText";
|
||||
import MsRun from "../Run";
|
||||
import {createComponent} from "../jmeter/components";
|
||||
import {REQ_METHOD} from "../../model/JsonData";
|
||||
import MsRequestResultTail from "../response/RequestResultTail";
|
||||
import MsBasisParameters from "../request/database/BasisParameters";
|
||||
import MsJmxStep from "../step/JmxStep";
|
||||
import MsApiCaseList from "../case/ApiCaseList";
|
||||
|
||||
export default {
|
||||
name: "ApiConfig",
|
||||
components: {MsRequestResultTail, MsResponseResult, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters, MsJmxStep,MsApiCaseList},
|
||||
props: {
|
||||
currentProtocol: String,
|
||||
scenario: Boolean,
|
||||
testCase: {},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
rules: {
|
||||
method: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
|
||||
url: [{required: true, message: this.$t('api_test.definition.request.path_all_info'), trigger: 'blur'}],
|
||||
export default {
|
||||
name: "ApiConfig",
|
||||
components: {
|
||||
MsRequestResultTail,
|
||||
MsResponseResult,
|
||||
MsRequestMetric,
|
||||
MsResponseText,
|
||||
MsRun,
|
||||
MsBasisParameters,
|
||||
MsJmxStep,
|
||||
MsApiCaseList
|
||||
},
|
||||
props: {
|
||||
currentProtocol: String,
|
||||
scenario: Boolean,
|
||||
testCase: {},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
rules: {
|
||||
method: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
|
||||
url: [{required: true, message: this.$t('api_test.definition.request.path_all_info'), trigger: 'blur'}],
|
||||
},
|
||||
debugForm: {method: REQ_METHOD[0].id},
|
||||
options: [],
|
||||
|
|
|
@ -11,11 +11,15 @@
|
|||
<el-input-number v-model="request.port" controls-position="right" :min="0" :max="65535" size="small"/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand"
|
||||
<el-button v-if="scenario" size="small" type="primary" @click="handleCommand"> {{ $t('commons.test') }}
|
||||
</el-button>
|
||||
|
||||
<el-dropdown v-else split-button type="primary" class="ms-api-buttion" @click="handleCommand"
|
||||
@command="handleCommand" size="small" style="float: right;margin-right: 20px">
|
||||
{{$t('commons.test')}}
|
||||
{{ $t('commons.test') }}
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as_case')}}</el-dropdown-item>
|
||||
<el-dropdown-item command="save_as">{{ $t('api_test.definition.request.save_as_case') }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</el-form-item>
|
||||
|
@ -45,30 +49,30 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
|
||||
import MsResponseResult from "../response/ResponseResult";
|
||||
import MsRequestMetric from "../response/RequestMetric";
|
||||
import {getUUID, getCurrentUser} from "@/common/js/utils";
|
||||
import MsResponseText from "../response/ResponseText";
|
||||
import MsRun from "../Run";
|
||||
import {createComponent} from "../jmeter/components";
|
||||
import {REQ_METHOD} from "../../model/JsonData";
|
||||
import MsRequestResultTail from "../response/RequestResultTail";
|
||||
import TcpBasisParameters from "../request/tcp/TcpBasisParameters";
|
||||
import MsJmxStep from "../step/JmxStep";
|
||||
import MsApiCaseList from "../case/ApiCaseList";
|
||||
import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
|
||||
import MsResponseResult from "../response/ResponseResult";
|
||||
import MsRequestMetric from "../response/RequestMetric";
|
||||
import {getUUID} from "@/common/js/utils";
|
||||
import MsResponseText from "../response/ResponseText";
|
||||
import MsRun from "../Run";
|
||||
import {createComponent} from "../jmeter/components";
|
||||
import {REQ_METHOD} from "../../model/JsonData";
|
||||
import MsRequestResultTail from "../response/RequestResultTail";
|
||||
import TcpBasisParameters from "../request/tcp/TcpBasisParameters";
|
||||
import MsJmxStep from "../step/JmxStep";
|
||||
import MsApiCaseList from "../case/ApiCaseList";
|
||||
|
||||
export default {
|
||||
name: "ApiConfig",
|
||||
components: {
|
||||
MsJmxStep,
|
||||
TcpBasisParameters,
|
||||
MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun, MsApiCaseList
|
||||
},
|
||||
props: {
|
||||
currentProtocol: String,
|
||||
scenario: Boolean,
|
||||
testCase: {},
|
||||
export default {
|
||||
name: "ApiConfig",
|
||||
components: {
|
||||
MsJmxStep,
|
||||
TcpBasisParameters,
|
||||
MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun, MsApiCaseList
|
||||
},
|
||||
props: {
|
||||
currentProtocol: String,
|
||||
scenario: Boolean,
|
||||
testCase: {},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
|
|
@ -2,19 +2,21 @@
|
|||
<api-base-component
|
||||
@copy="copyRow"
|
||||
@remove="remove"
|
||||
@active="active"
|
||||
:data="extract"
|
||||
:draggable="draggable"
|
||||
color="#015478"
|
||||
background-color="#E6EEF2"
|
||||
:title="$t('api_test.definition.request.extract_param')">
|
||||
<div style="margin: 20px">
|
||||
<div style="margin: 20px" v-loading="loading">
|
||||
<div class="extract-description">
|
||||
{{$t('api_test.request.extract.description')}}
|
||||
{{ $t('api_test.request.extract.description') }}
|
||||
</div>
|
||||
<div class="extract-add">
|
||||
<el-row :gutter="10">
|
||||
<el-col :span="2">
|
||||
<el-select :disabled="isReadOnly" class="extract-item" v-model="type" :placeholder="$t('api_test.request.extract.select_type')"
|
||||
<el-select :disabled="isReadOnly" class="extract-item" v-model="type"
|
||||
:placeholder="$t('api_test.request.extract.select_type')"
|
||||
size="small">
|
||||
<el-option :label="$t('api_test.request.extract.regex')" :value="options.REGEX"/>
|
||||
<el-option label="JSONPath" :value="options.JSON_PATH"/>
|
||||
|
@ -25,7 +27,7 @@
|
|||
<ms-api-extract-common :is-read-only="isReadOnly" :extract-type="type" :list="list" v-if="type" :callback="after"/>
|
||||
</el-col>
|
||||
|
||||
<el-button v-if="!type" :disabled="true" type="primary" size="small">Add</el-button>
|
||||
<el-button v-if="!type" :disabled="true" type="primary" size="small">{{ $t('commons.add') }}</el-button>
|
||||
</el-row>
|
||||
</div>
|
||||
|
||||
|
@ -39,26 +41,26 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {EXTRACT_TYPE} from "../../model/ApiTestModel";
|
||||
import MsApiExtractEdit from "./ApiExtractEdit";
|
||||
import MsApiExtractCommon from "./ApiExtractCommon";
|
||||
import {getUUID} from "@/common/js/utils";
|
||||
import ApiJsonPathSuggestButton from "../assertion/ApiJsonPathSuggestButton";
|
||||
import MsApiJsonpathSuggest from "../assertion/ApiJsonpathSuggest";
|
||||
import {ExtractJSONPath} from "../../../test/model/ScenarioModel";
|
||||
import ApiBaseComponent from "../../../automation/scenario/common/ApiBaseComponent";
|
||||
import {EXTRACT_TYPE} from "../../model/ApiTestModel";
|
||||
import MsApiExtractEdit from "./ApiExtractEdit";
|
||||
import MsApiExtractCommon from "./ApiExtractCommon";
|
||||
import {getUUID} from "@/common/js/utils";
|
||||
import ApiJsonPathSuggestButton from "../assertion/ApiJsonPathSuggestButton";
|
||||
import MsApiJsonpathSuggest from "../assertion/ApiJsonpathSuggest";
|
||||
import {ExtractJSONPath} from "../../../test/model/ScenarioModel";
|
||||
import ApiBaseComponent from "../../../automation/scenario/common/ApiBaseComponent";
|
||||
|
||||
export default {
|
||||
name: "MsApiExtract",
|
||||
components: {
|
||||
ApiBaseComponent,
|
||||
MsApiJsonpathSuggest,
|
||||
ApiJsonPathSuggestButton,
|
||||
MsApiExtractCommon,
|
||||
MsApiExtractEdit,
|
||||
},
|
||||
props: {
|
||||
extract: {},
|
||||
export default {
|
||||
name: "MsApiExtract",
|
||||
components: {
|
||||
ApiBaseComponent,
|
||||
MsApiJsonpathSuggest,
|
||||
ApiJsonPathSuggestButton,
|
||||
MsApiExtractCommon,
|
||||
MsApiExtractEdit,
|
||||
},
|
||||
props: {
|
||||
extract: {},
|
||||
response: {},
|
||||
node: {},
|
||||
customizeStyle: {
|
||||
|
@ -99,8 +101,8 @@
|
|||
this.loading = false
|
||||
})
|
||||
},
|
||||
active(item) {
|
||||
item.active = !item.active;
|
||||
active() {
|
||||
this.extract.active = !this.extract.active;
|
||||
this.reload();
|
||||
},
|
||||
suggestJsonOpen() {
|
||||
|
@ -157,6 +159,10 @@
|
|||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.icon.is-active {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
/deep/ .el-card__body {
|
||||
padding: 15px;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {getUUID, uuid} from "@/common/js/utils";
|
||||
import {getUUID} from "@/common/js/utils";
|
||||
import MsApiCaseList from "../case/ApiCaseList";
|
||||
import MsContainer from "../../../../common/components/MsContainer";
|
||||
import MsBottomContainer from "../BottomContainer";
|
||||
|
@ -89,25 +89,25 @@ export default {
|
|||
reportId: "",
|
||||
}
|
||||
},
|
||||
props: {apiData: {}, currentProtocol: String,syncTabs: Array, projectId: String},
|
||||
methods: {
|
||||
handleCommand(e) {
|
||||
switch (e) {
|
||||
case "load_case":
|
||||
return this.loadCase();
|
||||
case "save_as_case":
|
||||
return this.saveAsCase();
|
||||
case "update_api":
|
||||
return this.updateApi();
|
||||
case "save_as_api":
|
||||
props: {apiData: {}, currentProtocol: String, syncTabs: Array, projectId: String},
|
||||
methods: {
|
||||
handleCommand(e) {
|
||||
switch (e) {
|
||||
case "load_case":
|
||||
return this.loadCase();
|
||||
case "save_as_case":
|
||||
return this.saveAsCase();
|
||||
case "update_api":
|
||||
return this.updateApi();
|
||||
case "save_as_api":
|
||||
return this.saveAsApi();
|
||||
default:
|
||||
return this.runTest();
|
||||
}
|
||||
},
|
||||
refresh(){
|
||||
this.$emit('refresh');
|
||||
},
|
||||
refresh() {
|
||||
this.$emit('refresh');
|
||||
},
|
||||
runTest() {
|
||||
this.loading = true;
|
||||
this.api.request.name = this.api.id;
|
||||
|
@ -161,8 +161,9 @@ export default {
|
|||
},
|
||||
saveAsApi() {
|
||||
let data = {};
|
||||
this.api.request.id = uuid();
|
||||
data.request = JSON.stringify(this.api.request);
|
||||
let req = this.api.request;
|
||||
req.id = getUUID();
|
||||
data.request = JSON.stringify(req);
|
||||
data.method = this.api.method;
|
||||
data.status = this.api.status;
|
||||
data.userId = this.api.userId;
|
||||
|
|
|
@ -71,27 +71,27 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
|
||||
import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils";
|
||||
import MsApiCaseList from "../case/ApiCaseList";
|
||||
import MsContainer from "../../../../common/components/MsContainer";
|
||||
import MsRequestResultTail from "../response/RequestResultTail";
|
||||
import MsRun from "../Run";
|
||||
import {REQ_METHOD} from "../../model/JsonData";
|
||||
import EnvironmentSelect from "../environment/EnvironmentSelect";
|
||||
import MsJmxStep from "../step/JmxStep";
|
||||
import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
|
||||
import {getUUID} from "@/common/js/utils";
|
||||
import MsApiCaseList from "../case/ApiCaseList";
|
||||
import MsContainer from "../../../../common/components/MsContainer";
|
||||
import MsRequestResultTail from "../response/RequestResultTail";
|
||||
import MsRun from "../Run";
|
||||
import {REQ_METHOD} from "../../model/JsonData";
|
||||
import EnvironmentSelect from "../environment/EnvironmentSelect";
|
||||
import MsJmxStep from "../step/JmxStep";
|
||||
|
||||
export default {
|
||||
name: "RunTestHTTPPage",
|
||||
components: {
|
||||
EnvironmentSelect,
|
||||
MsApiRequestForm,
|
||||
MsApiCaseList,
|
||||
MsContainer,
|
||||
MsRequestResultTail,
|
||||
MsRun,
|
||||
MsJmxStep
|
||||
},
|
||||
export default {
|
||||
name: "RunTestHTTPPage",
|
||||
components: {
|
||||
EnvironmentSelect,
|
||||
MsApiRequestForm,
|
||||
MsApiCaseList,
|
||||
MsContainer,
|
||||
MsRequestResultTail,
|
||||
MsRun,
|
||||
MsJmxStep
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
|
@ -186,11 +186,11 @@
|
|||
},
|
||||
saveAsApi() {
|
||||
let data = {};
|
||||
data.request = JSON.stringify(this.api.request);
|
||||
let req = this.api.request;
|
||||
req.id = getUUID();
|
||||
data.request = JSON.stringify(req);
|
||||
data.method = this.api.method;
|
||||
data.url = this.api.url;
|
||||
let id = getUUID();
|
||||
data.id = id;
|
||||
data.status = this.api.status;
|
||||
data.userId = this.api.userId;
|
||||
data.description = this.api.description;
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {getUUID, uuid} from "@/common/js/utils";
|
||||
import {getUUID} from "@/common/js/utils";
|
||||
import MsApiCaseList from "../case/ApiCaseList";
|
||||
import MsContainer from "../../../../common/components/MsContainer";
|
||||
import MsBottomContainer from "../BottomContainer";
|
||||
|
@ -160,8 +160,9 @@ export default {
|
|||
},
|
||||
saveAsApi() {
|
||||
let data = {};
|
||||
this.api.request.id = uuid();
|
||||
data.request = JSON.stringify(this.api.request);
|
||||
let req = this.api.request;
|
||||
req.id = getUUID();
|
||||
data.request = JSON.stringify(req);
|
||||
data.method = this.api.method;
|
||||
data.status = this.api.status;
|
||||
data.userId = this.api.userId;
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
|
||||
<script>
|
||||
import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
|
||||
import {getUUID, uuid} from "@/common/js/utils";
|
||||
import {getUUID} from "@/common/js/utils";
|
||||
import MsApiCaseList from "../case/ApiCaseList";
|
||||
import MsContainer from "../../../../common/components/MsContainer";
|
||||
import MsBottomContainer from "../BottomContainer";
|
||||
|
@ -98,25 +98,25 @@ export default {
|
|||
reportId: "",
|
||||
}
|
||||
},
|
||||
props: {apiData: {}, currentProtocol: String,syncTabs: Array, projectId: String},
|
||||
methods: {
|
||||
handleCommand(e) {
|
||||
switch (e) {
|
||||
case "load_case":
|
||||
return this.loadCase();
|
||||
case "save_as_case":
|
||||
return this.saveAsCase();
|
||||
case "update_api":
|
||||
return this.updateApi();
|
||||
case "save_as_api":
|
||||
props: {apiData: {}, currentProtocol: String, syncTabs: Array, projectId: String},
|
||||
methods: {
|
||||
handleCommand(e) {
|
||||
switch (e) {
|
||||
case "load_case":
|
||||
return this.loadCase();
|
||||
case "save_as_case":
|
||||
return this.saveAsCase();
|
||||
case "update_api":
|
||||
return this.updateApi();
|
||||
case "save_as_api":
|
||||
return this.saveAsApi();
|
||||
default:
|
||||
return this.$refs['requestForm'].validate();
|
||||
}
|
||||
},
|
||||
refresh(){
|
||||
this.$emit('refresh');
|
||||
},
|
||||
refresh() {
|
||||
this.$emit('refresh');
|
||||
},
|
||||
runTest() {
|
||||
this.$refs['apiData'].validate((valid) => {
|
||||
if (valid) {
|
||||
|
@ -173,8 +173,9 @@ export default {
|
|||
},
|
||||
saveAsApi() {
|
||||
let data = {};
|
||||
this.api.request.id = uuid();
|
||||
data.request = JSON.stringify(this.api.request);
|
||||
let req = this.api.request;
|
||||
req.id = getUUID();
|
||||
data.request = JSON.stringify(req);
|
||||
data.method = this.api.method;
|
||||
data.status = this.api.status;
|
||||
data.userId = this.api.userId;
|
||||
|
|
|
@ -148,7 +148,9 @@ export default {
|
|||
},
|
||||
tooltip: {
|
||||
show: true,
|
||||
trigger: 'axis'
|
||||
trigger: 'axis',
|
||||
// extraCssText: 'z-index: 999;',
|
||||
confine: true,
|
||||
},
|
||||
legend: {},
|
||||
xAxis: {},
|
||||
|
@ -226,7 +228,8 @@ export default {
|
|||
tooltip: {
|
||||
show: true,
|
||||
trigger: 'axis',
|
||||
extraCssText: 'z-index: 999;',
|
||||
// extraCssText: 'z-index: 999;',
|
||||
confine: true,
|
||||
formatter: function (params, ticket, callback) {
|
||||
let result = "";
|
||||
let name = params[0].name;
|
||||
|
@ -306,7 +309,8 @@ export default {
|
|||
tooltip: {
|
||||
show: true,
|
||||
trigger: 'axis',
|
||||
extraCssText: 'z-index: 999;',
|
||||
// extraCssText: 'z-index: 999;',
|
||||
confine: true,
|
||||
formatter: function (params, ticket, callback) {
|
||||
let result = "";
|
||||
let name = params[0].name;
|
||||
|
@ -376,7 +380,8 @@ export default {
|
|||
tooltip: {
|
||||
show: true,
|
||||
trigger: 'axis',
|
||||
extraCssText: 'z-index: 999;',
|
||||
// extraCssText: 'z-index: 999;',
|
||||
confine: true,
|
||||
formatter: function (params, ticket, callback) {
|
||||
let result = "";
|
||||
let name = params[0].name;
|
||||
|
|
Loading…
Reference in New Issue