Merge branch 'master' of https://github.com/metersphere/metersphere
This commit is contained in:
commit
ccd209880f
|
@ -0,0 +1,5 @@
|
|||
package io.metersphere.excel.domain;
|
||||
|
||||
public interface ExcelDataFactory {
|
||||
Object getExcelDataByLocal();
|
||||
}
|
|
@ -1,65 +1,31 @@
|
|||
package io.metersphere.excel.domain;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
@Data
|
||||
@ColumnWidth(15)
|
||||
@Getter
|
||||
@Setter
|
||||
public class TestCaseExcelData {
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@Length(max = 50)
|
||||
@ExcelProperty("{test_case_name}")
|
||||
@ExcelIgnore
|
||||
private String name;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@Length(max = 1000)
|
||||
@ExcelProperty("{test_case_module}")
|
||||
@ColumnWidth(30)
|
||||
@Pattern(regexp = "^(?!.*//).*$", message = "{incorrect_format}")
|
||||
@ExcelIgnore
|
||||
private String nodePath;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("{test_case_type}")
|
||||
@Pattern(regexp = "(^functional$)|(^performance$)|(^api$)", message = "{test_case_type_validate}")
|
||||
@ExcelIgnore
|
||||
private String type;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("{test_case_maintainer}")
|
||||
@ExcelIgnore
|
||||
private String maintainer;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("{test_case_priority}")
|
||||
@Pattern(regexp = "(^P0$)|(^P1$)|(^P2$)|(^P3$)", message = "{test_case_priority_validate}")
|
||||
@ExcelIgnore
|
||||
private String priority;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("{test_case_method}")
|
||||
@Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}")
|
||||
@ExcelIgnore
|
||||
private String method;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("{test_case_prerequisite}")
|
||||
@Length(min = 0, max = 1000)
|
||||
@ExcelIgnore
|
||||
private String prerequisite;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("{test_case_remark}")
|
||||
@Length(max = 1000)
|
||||
@ExcelIgnore
|
||||
private String remark;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("{test_case_step_desc}")
|
||||
@Length(max = 1000)
|
||||
@ExcelIgnore
|
||||
private String stepDesc;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("{test_case_step_result}")
|
||||
@Length(max = 1000)
|
||||
@ExcelIgnore
|
||||
private String stepResult;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package io.metersphere.excel.domain;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
@Data
|
||||
@ColumnWidth(15)
|
||||
public class TestCaseExcelDataCn extends TestCaseExcelData {
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@Length(max = 50)
|
||||
@ExcelProperty("用例名称")
|
||||
private String name;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@Length(max = 1000)
|
||||
@ExcelProperty("所属模块")
|
||||
@ColumnWidth(30)
|
||||
@Pattern(regexp = "^(?!.*//).*$", message = "{incorrect_format}")
|
||||
private String nodePath;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("用例类型")
|
||||
@Pattern(regexp = "(^functional$)|(^performance$)|(^api$)", message = "{test_case_type_validate}")
|
||||
private String type;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("维护人")
|
||||
private String maintainer;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("用例等级")
|
||||
@Pattern(regexp = "(^P0$)|(^P1$)|(^P2$)|(^P3$)", message = "{test_case_priority_validate}")
|
||||
private String priority;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("测试方式")
|
||||
@Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}")
|
||||
private String method;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("前置条件")
|
||||
@Length(min = 0, max = 1000)
|
||||
private String prerequisite;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("备注")
|
||||
@Length(max = 1000)
|
||||
private String remark;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("步骤描述")
|
||||
@Length(max = 1000)
|
||||
private String stepDesc;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("预期结果")
|
||||
@Length(max = 1000)
|
||||
private String stepResult;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package io.metersphere.excel.domain;
|
||||
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class TestCaseExcelDataFactory implements ExcelDataFactory {
|
||||
@Override
|
||||
public Class getExcelDataByLocal() {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (Locale.US.toString().equalsIgnoreCase(locale.toString())) {
|
||||
return TestCaseExcelDataUs.class;
|
||||
} else if (Locale.TRADITIONAL_CHINESE.toString().equalsIgnoreCase(locale.toString())) {
|
||||
return TestCaseExcelDataTw.class;
|
||||
}
|
||||
return TestCaseExcelDataCn.class;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package io.metersphere.excel.domain;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
@Data
|
||||
@ColumnWidth(15)
|
||||
public class TestCaseExcelDataTw extends TestCaseExcelData {
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@Length(max = 50)
|
||||
@ExcelProperty("用例名稱")
|
||||
private String name;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@Length(max = 1000)
|
||||
@ExcelProperty("所屬模塊")
|
||||
@ColumnWidth(30)
|
||||
@Pattern(regexp = "^(?!.*//).*$", message = "{incorrect_format}")
|
||||
private String nodePath;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("用例類型")
|
||||
@Pattern(regexp = "(^functional$)|(^performance$)|(^api$)", message = "{test_case_type_validate}")
|
||||
private String type;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("維護人")
|
||||
private String maintainer;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("用例等級")
|
||||
@Pattern(regexp = "(^P0$)|(^P1$)|(^P2$)|(^P3$)", message = "{test_case_priority_validate}")
|
||||
private String priority;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("測試方式")
|
||||
@Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}")
|
||||
private String method;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("前置條件")
|
||||
@Length(min = 0, max = 1000)
|
||||
private String prerequisite;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("備註")
|
||||
@Length(max = 1000)
|
||||
private String remark;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("步驟描述")
|
||||
@Length(max = 1000)
|
||||
private String stepDesc;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("預期結果")
|
||||
@Length(max = 1000)
|
||||
private String stepResult;
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package io.metersphere.excel.domain;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
@Data
|
||||
@ColumnWidth(15)
|
||||
public class TestCaseExcelDataUs extends TestCaseExcelData {
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@Length(max = 50)
|
||||
@ExcelProperty("Name")
|
||||
private String name;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@Length(max = 1000)
|
||||
@ExcelProperty("Module")
|
||||
@ColumnWidth(30)
|
||||
@Pattern(regexp = "^(?!.*//).*$", message = "{incorrect_format}")
|
||||
private String nodePath;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("Type")
|
||||
@Pattern(regexp = "(^functional$)|(^performance$)|(^api$)", message = "{test_case_type_validate}")
|
||||
private String type;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("Maintainer")
|
||||
private String maintainer;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("Priority")
|
||||
@Pattern(regexp = "(^P0$)|(^P1$)|(^P2$)|(^P3$)", message = "{test_case_priority_validate}")
|
||||
private String priority;
|
||||
|
||||
@NotBlank(message = "{cannot_be_null}")
|
||||
@ExcelProperty("Method")
|
||||
@Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}")
|
||||
private String method;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("Prerequisite")
|
||||
@Length(min = 0, max = 1000)
|
||||
private String prerequisite;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("Remark")
|
||||
@Length(max = 1000)
|
||||
private String remark;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("Step description")
|
||||
@Length(max = 1000)
|
||||
private String stepDesc;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("Step result")
|
||||
@Length(max = 1000)
|
||||
private String stepResult;
|
||||
}
|
|
@ -8,7 +8,6 @@ import com.alibaba.excel.util.StringUtils;
|
|||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.excel.domain.ExcelErrData;
|
||||
import io.metersphere.excel.domain.TestCaseExcelData;
|
||||
import io.metersphere.excel.utils.EasyExcelI18nTranslator;
|
||||
import io.metersphere.excel.utils.ExcelValidateHelper;
|
||||
import io.metersphere.i18n.Translator;
|
||||
|
||||
|
@ -17,14 +16,12 @@ import java.lang.reflect.ParameterizedType;
|
|||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class EasyExcelListener<T> extends AnalysisEventListener<T> implements AutoCloseable {
|
||||
public abstract class EasyExcelListener<T> extends AnalysisEventListener<T> {
|
||||
|
||||
protected List<ExcelErrData<T>> errList = new ArrayList<>();
|
||||
|
||||
protected List<T> list = new ArrayList<>();
|
||||
|
||||
protected EasyExcelI18nTranslator easyExcelI18nTranslator;
|
||||
|
||||
protected List<TestCaseExcelData> excelDataList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
|
@ -37,11 +34,6 @@ public abstract class EasyExcelListener<T> extends AnalysisEventListener<T> impl
|
|||
public EasyExcelListener() {
|
||||
Type type = getClass().getGenericSuperclass();
|
||||
this.clazz = (Class<T>) ((ParameterizedType) type).getActualTypeArguments()[0];
|
||||
//防止多线程修改运行时类注解后,saveOriginalExcelProperty保存的是修改后的值
|
||||
synchronized (EasyExcelI18nTranslator.class) {
|
||||
this.easyExcelI18nTranslator = new EasyExcelI18nTranslator(this.clazz);
|
||||
this.easyExcelI18nTranslator.translateExcelProperty();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -153,9 +145,4 @@ public abstract class EasyExcelListener<T> extends AnalysisEventListener<T> impl
|
|||
return errList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
this.easyExcelI18nTranslator.resetExcelProperty();
|
||||
}
|
||||
}
|
|
@ -12,20 +12,12 @@ import java.io.UnsupportedEncodingException;
|
|||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
public class EasyExcelExporter implements AutoCloseable {
|
||||
|
||||
EasyExcelI18nTranslator easyExcelI18nTranslator;
|
||||
public class EasyExcelExporter {
|
||||
|
||||
private Class clazz;
|
||||
|
||||
public EasyExcelExporter(Class clazz) {
|
||||
this.clazz = clazz;
|
||||
//防止多线程修改运行时类注解后,saveOriginalExcelProperty保存的是修改后的值
|
||||
synchronized (EasyExcelI18nTranslator.class) {
|
||||
easyExcelI18nTranslator = new EasyExcelI18nTranslator(clazz);
|
||||
easyExcelI18nTranslator.translateExcelProperty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void export(HttpServletResponse response, List data, String fileName, String sheetName) {
|
||||
|
@ -46,9 +38,4 @@ public class EasyExcelExporter implements AutoCloseable {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
easyExcelI18nTranslator.resetExcelProperty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
package io.metersphere.excel.utils;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.excel.domain.TestCaseExcelData;
|
||||
import io.metersphere.exception.ExcelException;
|
||||
import io.metersphere.i18n.Translator;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 表头国际化
|
||||
* 先调用 saveOriginalExcelProperty 存储原表头注解值
|
||||
* 再调用 translateExcelProperty 获取国际化的值
|
||||
* 最后调用 resetExcelProperty 重置为原来值,防止切换语言后无法国际化
|
||||
*/
|
||||
public class EasyExcelI18nTranslator {
|
||||
|
||||
private Map<String, List<String>> excelPropertyMap = new HashMap<>();
|
||||
|
||||
private Class clazz;
|
||||
|
||||
public EasyExcelI18nTranslator(Class clazz) {
|
||||
this.clazz = clazz;
|
||||
saveOriginalExcelProperty();
|
||||
}
|
||||
|
||||
private void readExcelProperty(Class clazz, BiConsumer<String, Map<String, Object>> operate) {
|
||||
Field field;
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
try {
|
||||
field = clazz.getDeclaredField(fields[i].getName());
|
||||
field.setAccessible(true);
|
||||
ExcelProperty excelProperty = field.getAnnotation(ExcelProperty.class);
|
||||
if (excelProperty != null) {
|
||||
InvocationHandler invocationHandler = Proxy.getInvocationHandler(excelProperty);
|
||||
Field fieldValue = invocationHandler.getClass().getDeclaredField("memberValues");
|
||||
fieldValue.setAccessible(true);
|
||||
Map<String, Object> memberValues = null;
|
||||
try {
|
||||
memberValues = (Map<String, Object>) fieldValue.get(invocationHandler);
|
||||
} catch (IllegalAccessException e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
throw new ExcelException(e.getMessage());
|
||||
}
|
||||
|
||||
operate.accept(field.getName(), memberValues);
|
||||
|
||||
}
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void saveOriginalExcelProperty() {
|
||||
readExcelProperty(clazz, (fieldName, memberValues) -> {
|
||||
List<String> values = Arrays.asList((String[]) memberValues.get("value"));
|
||||
List<String> copyValues = new ArrayList<>();
|
||||
values.forEach(value -> {
|
||||
copyValues.add(value);
|
||||
});
|
||||
excelPropertyMap.put(fieldName, copyValues);
|
||||
});
|
||||
}
|
||||
|
||||
public void translateExcelProperty() {
|
||||
readExcelProperty(TestCaseExcelData.class, (fieldName, memberValues) -> {
|
||||
String[] values = (String[]) memberValues.get("value");
|
||||
for (int j = 0; j < values.length; j++) {
|
||||
if (Pattern.matches("^\\{.+\\}$", values[j])) {
|
||||
values[j] = Translator.get(values[j].substring(1, values[j].length() - 1));
|
||||
}
|
||||
}
|
||||
memberValues.put("value", values);
|
||||
});
|
||||
}
|
||||
|
||||
public void resetExcelProperty() {
|
||||
readExcelProperty(clazz, (fieldName, memberValues) -> {
|
||||
String[] values = (String[]) memberValues.get("value");
|
||||
List<String> list = excelPropertyMap.get(fieldName);
|
||||
for (int j = 0; j < values.length; j++) {
|
||||
values[j] = list.get(j);
|
||||
}
|
||||
memberValues.put("value", values);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -4,8 +4,10 @@ import io.metersphere.base.domain.ApiTestReport;
|
|||
import io.metersphere.base.domain.LoadTestWithBLOBs;
|
||||
import io.metersphere.base.domain.SystemParameter;
|
||||
import io.metersphere.base.domain.TestCaseWithBLOBs;
|
||||
import io.metersphere.commons.constants.APITestStatus;
|
||||
import io.metersphere.commons.constants.NoticeConstants;
|
||||
import io.metersphere.commons.constants.ParamConstants;
|
||||
import io.metersphere.commons.constants.PerformanceTestStatus;
|
||||
import io.metersphere.commons.utils.EncryptUtils;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.dto.BaseSystemConfigDTO;
|
||||
|
@ -46,12 +48,13 @@ public class MailService {
|
|||
context.put("title", "Performance" + Translator.get("timing_task_result_notification"));
|
||||
context.put("testName", loadTest.getName());
|
||||
context.put("id", loadTest.getId());
|
||||
context.put("type", "performance");
|
||||
context.put("url", baseSystemConfigDTO.getUrl());
|
||||
String performanceTemplate = "";
|
||||
try {
|
||||
if (status.equals("Completed")) {
|
||||
if (StringUtils.equals(status, PerformanceTestStatus.Completed.name())) {
|
||||
performanceTemplate = IOUtils.toString(this.getClass().getResource("/mail/successPerformance.html"), StandardCharsets.UTF_8);
|
||||
} else if (status.equals("Error")) {
|
||||
} else if (StringUtils.equals(status, PerformanceTestStatus.Error.name())) {
|
||||
performanceTemplate = IOUtils.toString(this.getClass().getResource("/mail/failPerformance.html"), StandardCharsets.UTF_8);
|
||||
}
|
||||
sendHtmlTimeTasks(noticeList, status, context, performanceTemplate);
|
||||
|
@ -65,14 +68,14 @@ public class MailService {
|
|||
Map<String, String> context = new HashMap<>();
|
||||
context.put("title", "api" + Translator.get("timing_task_result_notification"));
|
||||
context.put("testName", apiTestReport.getName());
|
||||
context.put("type", "Api");
|
||||
context.put("type", "api");
|
||||
context.put("url", baseSystemConfigDTO.getUrl());
|
||||
context.put("id", apiTestReport.getId());
|
||||
String apiTemplate = "";
|
||||
try {
|
||||
if (apiTestReport.getStatus().equals("Success")) {
|
||||
if (StringUtils.equals(APITestStatus.Success.name(), apiTestReport.getStatus())) {
|
||||
apiTemplate = IOUtils.toString(this.getClass().getResource("/mail/success.html"), StandardCharsets.UTF_8);
|
||||
} else if (apiTestReport.getStatus().equals("Error")) {
|
||||
} else if (StringUtils.equals(APITestStatus.Error.name(), apiTestReport.getStatus())) {
|
||||
apiTemplate = IOUtils.toString(this.getClass().getResource("/mail/fail.html"), StandardCharsets.UTF_8);
|
||||
}
|
||||
sendHtmlTimeTasks(noticeList, apiTestReport.getStatus(), context, apiTemplate);
|
||||
|
@ -183,17 +186,21 @@ public class MailService {
|
|||
javaMailSender.setDefaultEncoding("UTF-8");
|
||||
javaMailSender.setProtocol("smtps");
|
||||
for (SystemParameter p : paramList) {
|
||||
if (p.getParamKey().equals("smtp.host")) {
|
||||
javaMailSender.setHost(p.getParamValue());
|
||||
}
|
||||
if (p.getParamKey().equals("smtp.port")) {
|
||||
javaMailSender.setPort(Integer.parseInt(p.getParamValue()));
|
||||
}
|
||||
if (p.getParamKey().equals("smtp.account")) {
|
||||
javaMailSender.setUsername(p.getParamValue());
|
||||
}
|
||||
if (p.getParamKey().equals("smtp.password")) {
|
||||
javaMailSender.setPassword(EncryptUtils.aesDecrypt(p.getParamValue()).toString());
|
||||
switch (p.getParamKey()) {
|
||||
case "smtp.host":
|
||||
javaMailSender.setHost(p.getParamValue());
|
||||
break;
|
||||
case "smtp.port":
|
||||
javaMailSender.setPort(Integer.parseInt(p.getParamValue()));
|
||||
break;
|
||||
case "smtp.account":
|
||||
javaMailSender.setUsername(p.getParamValue());
|
||||
break;
|
||||
case "smtp.password":
|
||||
javaMailSender.setPassword(EncryptUtils.aesDecrypt(p.getParamValue()).toString());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
Properties props = new Properties();
|
||||
|
@ -223,10 +230,10 @@ public class MailService {
|
|||
List<String> failEmailList = new ArrayList<>();
|
||||
if (noticeList.size() > 0) {
|
||||
for (NoticeDetail n : noticeList) {
|
||||
if (n.getEnable().equals("true") && n.getEvent().equals(NoticeConstants.EXECUTE_SUCCESSFUL)) {
|
||||
if (StringUtils.equals(n.getEnable(), "true") && StringUtils.equals(n.getEvent(), NoticeConstants.EXECUTE_SUCCESSFUL)) {
|
||||
successEmailList = userService.queryEmail(n.getNames());
|
||||
}
|
||||
if (n.getEnable().equals("true") && n.getEvent().equals(NoticeConstants.EXECUTE_FAILED)) {
|
||||
if (StringUtils.equals(n.getEnable(), "true") && StringUtils.equals(n.getEvent(), NoticeConstants.EXECUTE_FAILED)) {
|
||||
failEmailList = userService.queryEmail(n.getNames());
|
||||
}
|
||||
}
|
||||
|
@ -234,7 +241,7 @@ public class MailService {
|
|||
LogUtil.error("Recipient information is empty");
|
||||
}
|
||||
|
||||
if (status.equals("Success") || status.equals("Completed")) {
|
||||
if (StringUtils.equalsAny(status, PerformanceTestStatus.Completed.name(), APITestStatus.Success.name())) {
|
||||
recipientEmails = successEmailList.toArray(new String[0]);
|
||||
} else {
|
||||
recipientEmails = failEmailList.toArray(new String[0]);
|
||||
|
|
|
@ -230,7 +230,7 @@ public class TestCaseNodeService {
|
|||
return list;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private List<TestCaseNodeDTO> getNodeDTO(String projectId, String planId) {
|
||||
TestPlanTestCaseExample testPlanTestCaseExample = new TestPlanTestCaseExample();
|
||||
testPlanTestCaseExample.createCriteria().andPlanIdEqualTo(planId);
|
||||
|
@ -355,50 +355,45 @@ public class TestCaseNodeService {
|
|||
}
|
||||
|
||||
public Map<String, String> createNodeByTestCases(List<TestCaseWithBLOBs> testCases, String projectId) {
|
||||
|
||||
List<TestCaseNodeDTO> nodeTrees = getNodeTreeByProjectId(projectId);
|
||||
|
||||
Map<String, String> pathMap = new HashMap<>();
|
||||
|
||||
List<String> nodePaths = testCases.stream()
|
||||
.map(TestCase::getNodePath)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
nodePaths.forEach(path -> {
|
||||
return this.createNodes(nodePaths, projectId);
|
||||
}
|
||||
|
||||
if (path == null) {
|
||||
public Map<String, String> createNodes(List<String> nodePaths, String projectId) {
|
||||
List<TestCaseNodeDTO> nodeTrees = getNodeTreeByProjectId(projectId);
|
||||
Map<String, String> pathMap = new HashMap<>();
|
||||
for(String item : nodePaths){
|
||||
if (item == null) {
|
||||
throw new ExcelException(Translator.get("test_case_module_not_null"));
|
||||
}
|
||||
List<String> nodeNameList = new ArrayList<>(Arrays.asList(path.split("/")));
|
||||
Iterator<String> pathIterator = nodeNameList.iterator();
|
||||
|
||||
List<String> nodeNameList = new ArrayList<>(Arrays.asList(item.split("/")));
|
||||
Iterator<String> itemIterator = nodeNameList.iterator();
|
||||
Boolean hasNode = false;
|
||||
String rootNodeName = null;
|
||||
|
||||
if (nodeNameList.size() <= 1) {
|
||||
throw new ExcelException(Translator.get("test_case_create_module_fail") + ":" + path);
|
||||
throw new ExcelException(Translator.get("test_case_create_module_fail") + ":" + item);
|
||||
} else {
|
||||
pathIterator.next();
|
||||
pathIterator.remove();
|
||||
|
||||
rootNodeName = pathIterator.next().trim();
|
||||
itemIterator.next();
|
||||
itemIterator.remove();
|
||||
rootNodeName = itemIterator.next().trim();
|
||||
//原来没有,新建的树nodeTrees也不包含
|
||||
for (TestCaseNodeDTO nodeTree : nodeTrees) {
|
||||
if (StringUtils.equals(rootNodeName, nodeTree.getName())) {
|
||||
hasNode = true;
|
||||
createNodeByPathIterator(pathIterator, "/" + rootNodeName, nodeTree,
|
||||
createNodeByPathIterator(itemIterator, "/" + rootNodeName, nodeTree,
|
||||
pathMap, projectId, 2);
|
||||
}
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!hasNode) {
|
||||
createNodeByPath(pathIterator, rootNodeName, null, projectId, 1, "", pathMap);
|
||||
createNodeByPath(itemIterator, rootNodeName, null, projectId, 1, "", pathMap);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
return pathMap;
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import io.metersphere.controller.request.OrderRequest;
|
|||
import io.metersphere.excel.domain.ExcelErrData;
|
||||
import io.metersphere.excel.domain.ExcelResponse;
|
||||
import io.metersphere.excel.domain.TestCaseExcelData;
|
||||
import io.metersphere.excel.domain.TestCaseExcelDataFactory;
|
||||
import io.metersphere.excel.listener.EasyExcelListener;
|
||||
import io.metersphere.excel.listener.TestCaseDataListener;
|
||||
import io.metersphere.excel.utils.EasyExcelExporter;
|
||||
|
@ -284,6 +285,9 @@ public class TestCaseService {
|
|||
errList.add(excelErrData);
|
||||
excelResponse.setErrList(errList);
|
||||
} else {
|
||||
if (!xmindParser.getNodePaths().isEmpty()) {
|
||||
testCaseNodeService.createNodes(xmindParser.getNodePaths(), projectId);
|
||||
}
|
||||
if (!xmindParser.getTestCase().isEmpty()) {
|
||||
this.saveImportData(xmindParser.getTestCase(), projectId);
|
||||
xmindParser.clear();
|
||||
|
@ -302,8 +306,9 @@ public class TestCaseService {
|
|||
|
||||
Set<String> userIds = userRoleMapper.selectByExample(userRoleExample).stream().map(UserRole::getUserId).collect(Collectors.toSet());
|
||||
|
||||
try (EasyExcelListener easyExcelListener = new TestCaseDataListener(this, projectId, testCaseNames, userIds)) {
|
||||
EasyExcelFactory.read(multipartFile.getInputStream(), TestCaseExcelData.class, easyExcelListener).sheet().doRead();
|
||||
try {
|
||||
EasyExcelListener easyExcelListener = new TestCaseDataListener(this, projectId, testCaseNames, userIds);
|
||||
EasyExcelFactory.read(multipartFile.getInputStream(), new TestCaseExcelDataFactory().getExcelDataByLocal(), easyExcelListener).sheet().doRead();
|
||||
errList = easyExcelListener.getErrList();
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
|
@ -341,7 +346,8 @@ public class TestCaseService {
|
|||
}
|
||||
|
||||
public void testCaseTemplateExport(HttpServletResponse response) {
|
||||
try (EasyExcelExporter easyExcelExporter = new EasyExcelExporter(TestCaseExcelData.class)) {
|
||||
try {
|
||||
EasyExcelExporter easyExcelExporter = new EasyExcelExporter(new TestCaseExcelDataFactory().getExcelDataByLocal());
|
||||
easyExcelExporter.export(response, generateExportTemplate(),
|
||||
Translator.get("test_case_import_template_name"), Translator.get("test_case_import_template_sheet"));
|
||||
} catch (Exception e) {
|
||||
|
@ -419,10 +425,12 @@ public class TestCaseService {
|
|||
}
|
||||
|
||||
public void testCaseExport(HttpServletResponse response, TestCaseBatchRequest request) {
|
||||
try (EasyExcelExporter easyExcelExporter = new EasyExcelExporter(TestCaseExcelData.class)) {
|
||||
try {
|
||||
EasyExcelExporter easyExcelExporter = new EasyExcelExporter(new TestCaseExcelDataFactory().getExcelDataByLocal());
|
||||
easyExcelExporter.export(response, generateTestCaseExcel(request),
|
||||
Translator.get("test_case_import_template_name"), Translator.get("test_case_import_template_sheet"));
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
MSException.throwException(e);
|
||||
}
|
||||
}
|
||||
|
@ -470,7 +478,7 @@ public class TestCaseService {
|
|||
} else if (t.getMethod().equals("auto") && t.getType().equals("api")) {
|
||||
data.setStepDesc("");
|
||||
data.setStepResult("");
|
||||
if (t.getTestId().equals("other")) {
|
||||
if (t.getTestId() != null && t.getTestId().equals("other")) {
|
||||
data.setRemark(t.getOtherTestName());
|
||||
} else {
|
||||
data.setRemark(t.getApiName());
|
||||
|
@ -479,7 +487,7 @@ public class TestCaseService {
|
|||
} else if (t.getMethod().equals("auto") && t.getType().equals("performance")) {
|
||||
data.setStepDesc("");
|
||||
data.setStepResult("");
|
||||
if (t.getTestId().equals("other")) {
|
||||
if (t.getTestId() != null && t.getTestId().equals("other")) {
|
||||
data.setRemark(t.getOtherTestName());
|
||||
} else {
|
||||
data.setRemark(t.getPerformName());
|
||||
|
|
|
@ -40,6 +40,9 @@ public class XmindCaseParser {
|
|||
// 案例详情重写了hashCode方法去重用
|
||||
private List<TestCaseExcelData> compartDatas;
|
||||
|
||||
// 记录没有用例的目录
|
||||
private List<String> nodePaths;
|
||||
|
||||
public XmindCaseParser(TestCaseService testCaseService, String userId, String projectId, Set<String> testCaseNames) {
|
||||
this.testCaseService = testCaseService;
|
||||
this.maintainer = userId;
|
||||
|
@ -48,6 +51,7 @@ public class XmindCaseParser {
|
|||
testCases = new LinkedList<>();
|
||||
compartDatas = new ArrayList<>();
|
||||
process = new StringBuffer();
|
||||
nodePaths = new ArrayList<>();
|
||||
}
|
||||
|
||||
// 这里清理是为了 加快jvm 回收
|
||||
|
@ -55,26 +59,55 @@ public class XmindCaseParser {
|
|||
compartDatas.clear();
|
||||
testCases.clear();
|
||||
testCaseNames.clear();
|
||||
nodePaths.clear();
|
||||
}
|
||||
|
||||
public List<TestCaseWithBLOBs> getTestCase() {
|
||||
return this.testCases;
|
||||
}
|
||||
|
||||
public List<String> getNodePaths() {
|
||||
return this.nodePaths;
|
||||
}
|
||||
|
||||
private final Map<String, String> caseTypeMap = ImmutableMap.of("功能测试", "functional", "性能测试", "performance", "接口测试", "api");
|
||||
|
||||
public void validate() {
|
||||
nodePaths.forEach(nodePath -> {
|
||||
String[] nodes = nodePath.split("/");
|
||||
if (nodes.length > TestCaseConstants.MAX_NODE_DEPTH + 1) {
|
||||
process.append(Translator.get("test_case_node_level_tip") +
|
||||
TestCaseConstants.MAX_NODE_DEPTH + Translator.get("test_case_node_level") + "; ");
|
||||
}
|
||||
for (int i = 0; i < nodes.length; i++) {
|
||||
if (i != 0 && StringUtils.equals(nodes[i].trim(), "")) {
|
||||
process.append(Translator.get("module_not_null") + "; ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 递归处理案例数据
|
||||
private void recursion(StringBuffer processBuffer, Attached parent, int level, String nodePath, List<Attached> attacheds) {
|
||||
private void recursion(StringBuffer processBuffer, Attached parent, int level, List<Attached> attacheds) {
|
||||
for (Attached item : attacheds) {
|
||||
if (isAvailable(item.getTitle(), "(?:tc:|tc:|tc)")) { // 用例
|
||||
item.setParent(parent);
|
||||
this.newTestCase(item.getTitle(), parent.getPath(), item.getChildren() != null ? item.getChildren().getAttached() : null);
|
||||
} else {
|
||||
nodePath = parent.getPath() + "/" + item.getTitle();
|
||||
String nodePath = parent.getPath() + "/" + item.getTitle();
|
||||
item.setPath(nodePath);
|
||||
item.setParent(parent);
|
||||
if (item.getChildren() != null && !item.getChildren().getAttached().isEmpty()) {
|
||||
item.setParent(parent);
|
||||
recursion(processBuffer, item, level + 1, nodePath, item.getChildren().getAttached());
|
||||
recursion(processBuffer, item, level + 1, item.getChildren().getAttached());
|
||||
} else {
|
||||
if (!nodePath.startsWith("/")) {
|
||||
nodePath = "/" + nodePath;
|
||||
}
|
||||
if (nodePath.endsWith("/")) {
|
||||
nodePath = nodePath.substring(0, nodePath.length() - 1);
|
||||
}
|
||||
nodePaths.add(nodePath); // 没有用例的路径
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -243,11 +276,12 @@ public class XmindCaseParser {
|
|||
item.setPath(item.getTitle());
|
||||
if (item.getChildren() != null && !item.getChildren().getAttached().isEmpty()) {
|
||||
item.setPath(item.getTitle());
|
||||
recursion(processBuffer, item, 1, item.getPath(), item.getChildren().getAttached());
|
||||
recursion(processBuffer, item, 1, item.getChildren().getAttached());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.validate();
|
||||
} catch (Exception ex) {
|
||||
processBuffer.append(Translator.get("incorrect_format"));
|
||||
LogUtil.error(ex.getMessage());
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<body>
|
||||
<div>
|
||||
<p style="text-align: left">${creator} 发起的:<br>
|
||||
${reviewName}<br>
|
||||
${reviewName}已完成<br>
|
||||
计划开始时间是:${start}<br>
|
||||
计划结束时间为:${end}<br>
|
||||
已完成<br>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<body>
|
||||
<div>
|
||||
<p style="text-align: left">${creator} 发起的:<br>
|
||||
${reviewName}<br>
|
||||
${reviewName}待开始<br>
|
||||
计划开始时间是:${start}<br>
|
||||
计划结束时间为:${end}<br>
|
||||
请跟进<br>
|
||||
|
|
|
@ -115,6 +115,9 @@ export default {
|
|||
watch: {
|
||||
test() {
|
||||
this.initScenarioEnvironment();
|
||||
},
|
||||
projectId() {
|
||||
this.initScenarioEnvironment();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -208,9 +211,13 @@ export default {
|
|||
let env = environmentMap.get(scenario.environmentId);
|
||||
if (!env) {
|
||||
scenario.environmentId = undefined;
|
||||
scenario.environment = undefined;
|
||||
} else {
|
||||
scenario.environment = env;
|
||||
}
|
||||
} else {
|
||||
scenario.environmentId = undefined;
|
||||
scenario.environment = undefined;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
<el-form-item v-if="request.useEnvironment" :label="$t('api_test.request.address')" class="adjust-margin-bottom">
|
||||
<el-tag class="environment-display">
|
||||
<span class="environment-name">{{ request.environment ? request.environment.name + ': ' : '' }}</span>
|
||||
<span class="environment-name">{{ scenario.environment ? scenario.environment.name + ': ' : '' }}</span>
|
||||
<span class="environment-url">{{ displayUrl }}</span>
|
||||
<span v-if="!displayUrl"
|
||||
class="environment-url-tip">{{ $t('api_test.request.please_configure_socket_in_environment') }}</span>
|
||||
|
@ -49,7 +49,7 @@
|
|||
<el-tab-pane :label="$t('api_test.request.parameters')" name="parameters">
|
||||
<ms-api-variable :is-read-only="isReadOnly"
|
||||
:parameters="request.parameters"
|
||||
:environment="request.environment"
|
||||
:environment="scenario.environment"
|
||||
:scenario="scenario"
|
||||
:extract="request.extract"
|
||||
:description="$t('api_test.request.parameters_desc')"/>
|
||||
|
@ -62,7 +62,7 @@
|
|||
:body="request.body"
|
||||
:scenario="scenario"
|
||||
:extract="request.extract"
|
||||
:environment="request.environment"/>
|
||||
:environment="scenario.environment"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('api_test.request.assertions.label')" name="assertions">
|
||||
<ms-api-assertions :is-read-only="isReadOnly" :assertions="request.assertions"/>
|
||||
|
@ -148,7 +148,7 @@ export default {
|
|||
if (!this.request.path) return;
|
||||
let url = this.getURL(this.displayUrl);
|
||||
let urlStr = url.origin + url.pathname;
|
||||
let envUrl = this.request.environment.config.httpConfig.protocol + '://' + this.request.environment.config.httpConfig.socket;
|
||||
let envUrl = this.scenario.environment.config.httpConfig.protocol + '://' + this.scenario.environment.config.httpConfig.socket;
|
||||
this.request.path = decodeURIComponent(urlStr.substring(envUrl.length, urlStr.length));
|
||||
},
|
||||
getURL(urlStr) {
|
||||
|
@ -170,7 +170,7 @@ export default {
|
|||
}
|
||||
},
|
||||
useEnvironmentChange(value) {
|
||||
if (value && !this.request.environment) {
|
||||
if (value && !this.scenario.environment) {
|
||||
this.$error(this.$t('api_test.request.please_add_environment_to_scenario'), 2000);
|
||||
this.request.useEnvironment = false;
|
||||
}
|
||||
|
@ -191,8 +191,8 @@ export default {
|
|||
|
||||
computed: {
|
||||
displayUrl() {
|
||||
return (this.request.environment && this.request.environment.config.httpConfig.socket) ?
|
||||
this.request.environment.config.httpConfig.protocol + '://' + this.request.environment.config.httpConfig.socket + (this.request.path ? this.request.path : '')
|
||||
return (this.scenario.environment && this.scenario.environment.config.httpConfig.socket) ?
|
||||
this.scenario.environment.config.httpConfig.protocol + '://' + this.scenario.environment.config.httpConfig.socket + (this.request.path ? this.request.path : '')
|
||||
: '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,10 @@
|
|||
<el-input :disabled="isReadOnly" v-model="form.cronValue" class="inp"
|
||||
:placeholder="$t('schedule.please_input_cron_expression')"/>
|
||||
<!-- <el-button type="primary" @click="showCronDialog">{{$t('schedule.generate_expression')}}</el-button>-->
|
||||
<el-button :disabled="isReadOnly" type="primary" @click="saveCron">{{ $t('commons.save') }}</el-button>
|
||||
<el-button :disabled="isReadOnly" type="primary" @click="saveCron">{{
|
||||
$t('commons.save')
|
||||
}}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-link :disabled="isReadOnly" type="primary" @click="showCronDialog">
|
||||
|
@ -21,8 +24,10 @@
|
|||
</el-form-item>
|
||||
<crontab-result :ex="form.cronValue" ref="crontabResult"/>
|
||||
</el-form>
|
||||
<el-dialog width="60%" :title="$t('schedule.generate_expression')" :visible.sync="showCron" :modal="false">
|
||||
<crontab @hide="showCron=false" @fill="crontabFill" :expression="schedule.value" ref="crontab"/>
|
||||
<el-dialog width="60%" :title="$t('schedule.generate_expression')" :visible.sync="showCron"
|
||||
:modal="false">
|
||||
<crontab @hide="showCron=false" @fill="crontabFill" :expression="schedule.value"
|
||||
ref="crontab"/>
|
||||
</el-dialog>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('schedule.task_notification')" name="second">
|
||||
|
@ -42,11 +47,12 @@
|
|||
<el-table-column
|
||||
prop="name"
|
||||
:label="$t('schedule.receiver')"
|
||||
width="200"
|
||||
width="240"
|
||||
>
|
||||
<template v-slot:default="{row}">
|
||||
<el-select v-model="row.names" filterable multiple :placeholder="$t('commons.please_select')"
|
||||
@click.native="userList()">
|
||||
<el-select v-model="row.names" filterable multiple
|
||||
:placeholder="$t('commons.please_select')"
|
||||
@click.native="userList()" style="width: 100%;">
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.id"
|
||||
|
@ -269,4 +275,10 @@ export default {
|
|||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
/deep/ .el-select__tags {
|
||||
flex-wrap: unset;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
|
|
@ -165,7 +165,7 @@
|
|||
this.$refs[form].validate(valid => {
|
||||
if (valid) {
|
||||
|
||||
let formatUrl = this.form.url;
|
||||
let formatUrl = this.form.url.trim();
|
||||
if (!formatUrl.endsWith('/')) {
|
||||
formatUrl = formatUrl + '/';
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
:content="$t('test_track.plan_view.create_report')" @click="openTestReport"/>
|
||||
<ms-table-button :is-tester-permission="true" v-if="testPlan.reportId" icon="el-icon-document"
|
||||
:content="$t('test_track.plan_view.view_report')" @click="openReport"/>
|
||||
<ms-table-button :is-tester-permission="true" icon="el-icon-document-remove"
|
||||
:content="$t('test_track.plan_view.cancel_all_relevance')" @click="handleDeleteBatch"/>
|
||||
</template>
|
||||
</ms-table-header>
|
||||
</template>
|
||||
|
@ -413,26 +415,47 @@
|
|||
});
|
||||
},
|
||||
handleDeleteBatch() {
|
||||
if (this.tableData.length < 1) {
|
||||
this.$warning(this.$t('test_track.plan_view.no_case_relevance'));
|
||||
return;
|
||||
}
|
||||
this.$alert(this.$t('test_track.plan_view.confirm_cancel_relevance') + " ?", '', {
|
||||
confirmButtonText: this.$t('commons.confirm'),
|
||||
callback: (action) => {
|
||||
if (action === 'confirm') {
|
||||
let ids = Array.from(this.selectRows).map(row => row.id);
|
||||
this.$post('/test/plan/case/batch/delete', {ids: ids}, () => {
|
||||
// this.selectIds.clear();
|
||||
this.selectRows.clear();
|
||||
this.$emit("refresh");
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
});
|
||||
if (this.selectRows.size > 0) {
|
||||
let ids = Array.from(this.selectRows).map(row => row.id);
|
||||
this._handleBatchDelete(ids);
|
||||
} else {
|
||||
if (this.planId) {
|
||||
this.condition.planId = this.planId;
|
||||
}
|
||||
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
|
||||
this.condition.nodeIds = this.selectNodeIds;
|
||||
}
|
||||
// 根据条件查询计划下所有的关联用例
|
||||
this.$post('/test/plan/case/list/all', this.condition, res => {
|
||||
let data = res.data;
|
||||
let ids = data.map(d => d.id);
|
||||
this._handleBatchDelete(ids);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
_handleBatchDelete(ids) {
|
||||
this.result = this.$post('/test/plan/case/batch/delete', {ids:ids}, () => {
|
||||
this.selectRows.clear();
|
||||
this.$emit("refresh");
|
||||
this.$success(this.$t('test_track.cancel_relevance_success'));
|
||||
});
|
||||
},
|
||||
_handleDelete(testCase) {
|
||||
let testCaseId = testCase.id;
|
||||
this.$post('/test/plan/case/delete/' + testCaseId, {}, () => {
|
||||
this.result = this.$post('/test/plan/case/delete/' + testCaseId, {}, () => {
|
||||
this.$emit("refresh");
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
this.$success(this.$t('test_track.cancel_relevance_success'));
|
||||
});
|
||||
},
|
||||
handleSelectAll(selection) {
|
||||
|
|
|
@ -2,16 +2,18 @@
|
|||
<div class="main">
|
||||
<div class="comment-left">
|
||||
<div class="icon-title">
|
||||
{{comment.author.substring(0,1)}}
|
||||
{{ comment.author.substring(0, 1) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="comment-right">
|
||||
<span style="font-size: 14px;color: #909399;font-weight: bold">{{comment.author}}</span>
|
||||
<span style="font-size: 14px;color: #909399;font-weight: bold">{{ comment.author }}</span>
|
||||
<span style="color: #8a8b8d; margin-left: 8px; font-size: 12px">
|
||||
{{comment.createTime | timestampFormatDate}}
|
||||
{{ comment.createTime | timestampFormatDate }}
|
||||
</span>
|
||||
<br/>
|
||||
<div class="comment-desc" style="font-size: 10px;color: #303133">{{comment.description}}</div>
|
||||
<div class="comment-desc" style="font-size: 10px;color: #303133">
|
||||
<pre>{{ comment.description }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -29,41 +31,45 @@ export default {
|
|||
</script>
|
||||
|
||||
<style scoped>
|
||||
.main {
|
||||
overflow-y: scroll;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.main {
|
||||
overflow-y: scroll;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.comment-left {
|
||||
float: left;
|
||||
width: 50px;
|
||||
height: 100%;
|
||||
}
|
||||
.comment-left {
|
||||
float: left;
|
||||
width: 50px;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.comment-right {
|
||||
float: left;
|
||||
width: 90%;
|
||||
padding: 0;
|
||||
line-height: 25px;
|
||||
}
|
||||
.comment-right {
|
||||
float: left;
|
||||
width: 90%;
|
||||
padding: 0;
|
||||
line-height: 25px;
|
||||
}
|
||||
|
||||
.icon-title {
|
||||
color: #fff;
|
||||
width: 30px;
|
||||
background-color: #72dc91;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
text-align: center;
|
||||
border-radius: 30px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.icon-title {
|
||||
color: #fff;
|
||||
width: 30px;
|
||||
background-color: #72dc91;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
text-align: center;
|
||||
border-radius: 30px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
|
||||
.comment-desc {
|
||||
overflow-wrap: break-word;
|
||||
word-break: break-all;
|
||||
border-bottom: 1px solid #ced3de;
|
||||
}
|
||||
.comment-desc {
|
||||
overflow-wrap: break-word;
|
||||
word-break: break-all;
|
||||
border-bottom: 1px solid #ced3de;
|
||||
}
|
||||
|
||||
pre {
|
||||
margin: 0 0;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
:placeholder="$t('test_track.review.input_review_project')"
|
||||
multiple
|
||||
style="width: 100%"
|
||||
collapse-tags
|
||||
filterable>
|
||||
<el-option
|
||||
v-for="item in projects"
|
||||
|
@ -49,7 +48,6 @@
|
|||
v-model="form.userIds"
|
||||
:placeholder="$t('test_track.review.input_reviewer')"
|
||||
filterable multiple
|
||||
collapse-tags
|
||||
>
|
||||
<el-option
|
||||
v-for="item in reviewerOptions"
|
||||
|
|
|
@ -798,6 +798,7 @@ export default {
|
|||
plan_view: {
|
||||
plan: "Plan",
|
||||
relevance_test_case: "Relevance case",
|
||||
cancel_all_relevance: "Unlink all",
|
||||
executor: "Executor",
|
||||
execute_result: "Result",
|
||||
pass: "Pass",
|
||||
|
@ -842,7 +843,8 @@ export default {
|
|||
report_template: "Report template",
|
||||
test_detail: "Test detail",
|
||||
failure_case: "Failure case",
|
||||
export_report: "Export Report"
|
||||
export_report: "Export Report",
|
||||
no_case_relevance: "No related use cases",
|
||||
},
|
||||
issue: {
|
||||
issue: "Issue",
|
||||
|
|
|
@ -804,6 +804,7 @@ export default {
|
|||
plan_view: {
|
||||
plan: "计划",
|
||||
relevance_test_case: "关联测试用例",
|
||||
cancel_all_relevance: "取消全部关联",
|
||||
executor: "执行人",
|
||||
execute_result: "执行结果",
|
||||
pass: "通过",
|
||||
|
@ -848,7 +849,8 @@ export default {
|
|||
report_template: "测试报告模版",
|
||||
test_detail: "测试详情",
|
||||
failure_case: "失败用例",
|
||||
export_report: "导出报告"
|
||||
export_report: "导出报告",
|
||||
no_case_relevance: "没有关联用例",
|
||||
},
|
||||
issue: {
|
||||
issue: "缺陷",
|
||||
|
|
|
@ -800,6 +800,7 @@ export default {
|
|||
plan_view: {
|
||||
plan: "計劃",
|
||||
relevance_test_case: "關聯測試用例",
|
||||
cancel_all_relevance: "取消全部關聯",
|
||||
executor: "執行人",
|
||||
execute_result: "執行結果",
|
||||
pass: "通過",
|
||||
|
@ -844,7 +845,8 @@ export default {
|
|||
report_template: "測試報告模版",
|
||||
test_detail: "測試詳情",
|
||||
failure_case: "失敗用例",
|
||||
export_report: "導出報告"
|
||||
export_report: "導出報告",
|
||||
no_case_relevance: "沒有關聯用例",
|
||||
},
|
||||
issue: {
|
||||
issue: "缺陷",
|
||||
|
|
Loading…
Reference in New Issue