fix: 解决冲突

This commit is contained in:
chenjianxing 2021-03-31 14:24:26 +08:00
commit 2c6ab9fe8d
18 changed files with 1131 additions and 1011 deletions

View File

@ -214,6 +214,8 @@ public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
samplerProxy.getBody().setKvs(keyValues); samplerProxy.getBody().setKvs(keyValues);
} }
samplerProxy.setProtocol(RequestType.HTTP); samplerProxy.setProtocol(RequestType.HTTP);
samplerProxy.setConnectTimeout(source.getConnectTimeout()+"");
samplerProxy.setResponseTimeout(source.getResponseTimeout()+"");
samplerProxy.setPort(source.getPropertyAsString("HTTPSampler.port")); samplerProxy.setPort(source.getPropertyAsString("HTTPSampler.port"));
samplerProxy.setDomain(source.getDomain()); samplerProxy.setDomain(source.getDomain());
if (source.getArguments() != null) { if (source.getArguments() != null) {
@ -239,6 +241,7 @@ public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
samplerProxy.setMethod(source.getMethod()); samplerProxy.setMethod(source.getMethod());
if (this.getUrl(source) != null) { if (this.getUrl(source) != null) {
samplerProxy.setUrl(this.getUrl(source)); samplerProxy.setUrl(this.getUrl(source));
samplerProxy.setPath(null);
} }
samplerProxy.setId(UUID.randomUUID().toString()); samplerProxy.setId(UUID.randomUUID().toString());
samplerProxy.setType("HTTPSamplerProxy"); samplerProxy.setType("HTTPSamplerProxy");

View File

@ -91,9 +91,6 @@ public class MsHTTPSamplerProxy extends MsTestElement {
@JSONField(ordinal = 36) @JSONField(ordinal = 36)
private MsAuthManager authManager; private MsAuthManager authManager;
@JSONField(ordinal = 37)
private boolean urlOrPath;
@Override @Override
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) { public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
// 非导出操作且不是启用状态则跳过执行 // 非导出操作且不是启用状态则跳过执行
@ -198,10 +195,11 @@ public class MsHTTPSamplerProxy extends MsTestElement {
} }
URL urlObject = new URL(url); URL urlObject = new URL(url);
sampler.setDomain(URLDecoder.decode(urlObject.getHost(), "UTF-8")); sampler.setDomain(URLDecoder.decode(urlObject.getHost(), "UTF-8"));
if (urlObject.getPort() > 0 && urlObject.getPort() != 10990 && StringUtils.isNotEmpty(this.getPort()) && this.getPort().startsWith("${")) { if (urlObject.getPort() > 0 && urlObject.getPort() == 10990 && StringUtils.isNotEmpty(this.getPort()) && this.getPort().startsWith("${")) {
sampler.setPort(urlObject.getPort());
} else {
sampler.setProperty("HTTPSampler.port", this.getPort()); sampler.setProperty("HTTPSampler.port", this.getPort());
} else {
sampler.setPort(urlObject.getPort());
} }
sampler.setProtocol(urlObject.getProtocol()); sampler.setProtocol(urlObject.getProtocol());
String envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getPath(); String envPath = StringUtils.equals(urlObject.getPath(), "/") ? "" : urlObject.getPath();

View File

@ -264,15 +264,7 @@ public class ApiDefinitionService {
test.setEnvironmentId(request.getEnvironmentId()); test.setEnvironmentId(request.getEnvironmentId());
test.setUserId(request.getUserId()); test.setUserId(request.getUserId());
test.setTags(request.getTags()); test.setTags(request.getTags());
if (StringUtils.isEmpty(request.getModuleId()) || "default-module".equals(request.getModuleId())) { this.setModule(test);
ApiModuleExample example = new ApiModuleExample();
example.createCriteria().andProjectIdEqualTo(test.getProjectId()).andProtocolEqualTo(test.getProtocol()).andNameEqualTo("默认模块");
List<ApiModule> modules = apiModuleMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(modules)) {
test.setModuleId(modules.get(0).getId());
test.setModulePath(modules.get(0).getName());
}
}
apiDefinitionMapper.updateByPrimaryKeySelective(test); apiDefinitionMapper.updateByPrimaryKeySelective(test);
return test; return test;
} }
@ -591,6 +583,17 @@ public class ApiDefinitionService {
return apiTestCaseMapper.selectByPrimaryKey(apiCaseId); return apiTestCaseMapper.selectByPrimaryKey(apiCaseId);
} }
private void setModule(ApiDefinitionWithBLOBs item) {
if (item != null && StringUtils.isEmpty(item.getModuleId()) || "default-module".equals(item.getModuleId())) {
ApiModuleExample example = new ApiModuleExample();
example.createCriteria().andProjectIdEqualTo(item.getProjectId()).andProtocolEqualTo(item.getProtocol()).andNameEqualTo("默认模块");
List<ApiModule> modules = apiModuleMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(modules)) {
item.setModuleId(modules.get(0).getId());
item.setModulePath(modules.get(0).getName());
}
}
}
public ApiDefinitionImport apiTestImport(MultipartFile file, ApiTestImportRequest request) { public ApiDefinitionImport apiTestImport(MultipartFile file, ApiTestImportRequest request) {
ApiImportParser apiImportParser = ApiDefinitionImportParserFactory.getApiImportParser(request.getPlatform()); ApiImportParser apiImportParser = ApiDefinitionImportParserFactory.getApiImportParser(request.getPlatform());
@ -616,15 +619,7 @@ public class ApiDefinitionService {
} }
for (int i = 0; i < data.size(); i++) { for (int i = 0; i < data.size(); i++) {
ApiDefinitionWithBLOBs item = data.get(i); ApiDefinitionWithBLOBs item = data.get(i);
if (StringUtils.isEmpty(item.getModuleId()) || "default-module".equals(item.getModuleId())) { this.setModule(item);
ApiModuleExample example = new ApiModuleExample();
example.createCriteria().andProjectIdEqualTo(item.getProjectId()).andProtocolEqualTo(item.getProtocol()).andNameEqualTo("默认模块");
List<ApiModule> modules = apiModuleMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(modules)) {
item.setModuleId(modules.get(0).getId());
item.setModulePath(modules.get(0).getName());
}
}
if (item.getName().length() > 255) { if (item.getName().length() > 255) {
item.setName(item.getName().substring(0, 255)); item.setName(item.getName().substring(0, 255));
} }

View File

@ -142,7 +142,7 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
public void saveData() { public void saveData() {
//excel中用例都有错误时就返回只要有用例可用于更新或者插入就不返回 //excel中用例都有错误时就返回只要有用例可用于更新或者插入就不返回
if (!errList.isEmpty() && list.size() == 0 && updateList.size() == 0) { if (!errList.isEmpty()) {
return; return;
} }
@ -231,6 +231,13 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
*/ */
public String modifyTagPattern(TestCaseExcelData data){ public String modifyTagPattern(TestCaseExcelData data){
String tags = data.getTags(); String tags = data.getTags();
try {
if (StringUtils.isNotBlank(tags)) {
JSONArray.parse(tags);
return tags;
}
return "[]";
} catch (Exception e) {
if (tags != null) { if (tags != null) {
Stream<String> stringStream = Arrays.stream(tags.split("[,;]")); //当标签值以中英文的逗号和分号分隔时才能正确解析 Stream<String> stringStream = Arrays.stream(tags.split("[,;]")); //当标签值以中英文的逗号和分号分隔时才能正确解析
List<String> tagList = stringStream.map(tag -> tag = "\"" + tag + "\"") List<String> tagList = stringStream.map(tag -> tag = "\"" + tag + "\"")
@ -238,8 +245,9 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
String modifiedTags = StringUtils.join(tagList, ","); String modifiedTags = StringUtils.join(tagList, ",");
modifiedTags = "[" + modifiedTags + "]"; modifiedTags = "[" + modifiedTags + "]";
return modifiedTags; return modifiedTags;
}else { } else {
return null; return "[]";
}
} }
} }

View File

@ -451,7 +451,7 @@ public class TestCaseService {
/** /**
* 把Excel中带ID的数据更新到数据库 * 把Excel中带ID的数据更新到数据库
* * feat(测试跟踪):通过Excel导入导出时有ID字段可通过Excel导入来更新用例 (#1727)
* @param testCases * @param testCases
* @param projectId * @param projectId
*/ */

View File

@ -1,30 +1,20 @@
/* //
* Licensed to the Apache Software Foundation (ASF) under one or more // Source code recreated from a .class file by IntelliJ IDEA
* contributor license agreements. See the NOTICE file distributed with // (powered by Fernflower decompiler)
* this work for additional information regarding copyright ownership. //
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.jmeter.assertions; package org.apache.jmeter.assertions;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.Predicate;
import java.io.Serializable; import java.io.Serializable;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.Map; import java.util.Map;
import java.util.function.Supplier;
import com.alibaba.fastjson.JSONArray; import net.minidev.json.JSONArray;
import com.alibaba.fastjson.JSONObject; import net.minidev.json.JSONObject;
import com.jayway.jsonpath.JsonPath;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.samplers.SampleResult; import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.testelement.AbstractTestElement; import org.apache.jmeter.testelement.AbstractTestElement;
@ -34,12 +24,6 @@ import org.apache.oro.text.regex.Pattern;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/**
* This is main class for JSONPath Assertion which verifies assertion on
* previous sample result using JSON path expression
*
* @since 4.0
*/
public class JSONPathAssertion extends AbstractTestElement implements Serializable, Assertion, ThreadListener { public class JSONPathAssertion extends AbstractTestElement implements Serializable, Assertion, ThreadListener {
private static final Logger log = LoggerFactory.getLogger(JSONPathAssertion.class); private static final Logger log = LoggerFactory.getLogger(JSONPathAssertion.class);
private static final long serialVersionUID = 2L; private static final long serialVersionUID = 2L;
@ -49,119 +33,118 @@ public class JSONPathAssertion extends AbstractTestElement implements Serializab
public static final String EXPECT_NULL = "EXPECT_NULL"; public static final String EXPECT_NULL = "EXPECT_NULL";
public static final String INVERT = "INVERT"; public static final String INVERT = "INVERT";
public static final String ISREGEX = "ISREGEX"; public static final String ISREGEX = "ISREGEX";
private static ThreadLocal<DecimalFormat> decimalFormatter = ThreadLocal.withInitial(JSONPathAssertion::createDecimalFormat);
private static ThreadLocal<DecimalFormat> decimalFormatter = public JSONPathAssertion() {
ThreadLocal.withInitial(JSONPathAssertion::createDecimalFormat); }
private static DecimalFormat createDecimalFormat() {
DecimalFormat decimalFormatter = new DecimalFormat("#.#");
decimalFormatter.setMaximumFractionDigits(340);
decimalFormatter.setMinimumFractionDigits(1);
return decimalFormatter;
}
public String getOption() { public String getOption() {
return getPropertyAsString("ASS_OPTION"); return getPropertyAsString("ASS_OPTION");
} }
private static DecimalFormat createDecimalFormat() {
DecimalFormat decimalFormatter = new DecimalFormat("#.#");
decimalFormatter.setMaximumFractionDigits(340); // java.text.DecimalFormat.DOUBLE_FRACTION_DIGITS == 340
decimalFormatter.setMinimumFractionDigits(1);
return decimalFormatter;
}
public String getJsonPath() { public String getJsonPath() {
return getPropertyAsString(JSONPATH); return this.getPropertyAsString("JSON_PATH");
} }
public void setJsonPath(String jsonPath) { public void setJsonPath(String jsonPath) {
setProperty(JSONPATH, jsonPath); this.setProperty("JSON_PATH", jsonPath);
} }
public String getExpectedValue() { public String getExpectedValue() {
return getPropertyAsString(EXPECTEDVALUE); return this.getPropertyAsString("EXPECTED_VALUE");
} }
public void setExpectedValue(String expectedValue) { public void setExpectedValue(String expectedValue) {
setProperty(EXPECTEDVALUE, expectedValue); this.setProperty("EXPECTED_VALUE", expectedValue);
} }
public void setJsonValidationBool(boolean jsonValidation) { public void setJsonValidationBool(boolean jsonValidation) {
setProperty(JSONVALIDATION, jsonValidation); this.setProperty("JSONVALIDATION", jsonValidation);
} }
public void setExpectNull(boolean val) { public void setExpectNull(boolean val) {
setProperty(EXPECT_NULL, val); this.setProperty("EXPECT_NULL", val);
} }
public boolean isExpectNull() { public boolean isExpectNull() {
return getPropertyAsBoolean(EXPECT_NULL); return this.getPropertyAsBoolean("EXPECT_NULL");
} }
public boolean isJsonValidationBool() { public boolean isJsonValidationBool() {
return getPropertyAsBoolean(JSONVALIDATION); return this.getPropertyAsBoolean("JSONVALIDATION");
} }
public void setInvert(boolean invert) { public void setInvert(boolean invert) {
setProperty(INVERT, invert); this.setProperty("INVERT", invert);
} }
public boolean isInvert() { public boolean isInvert() {
return getPropertyAsBoolean(INVERT); return this.getPropertyAsBoolean("INVERT");
} }
public void setIsRegex(boolean flag) { public void setIsRegex(boolean flag) {
setProperty(ISREGEX, flag); this.setProperty("ISREGEX", flag);
} }
public boolean isUseRegex() { public boolean isUseRegex() {
return getPropertyAsBoolean(ISREGEX, true); return this.getPropertyAsBoolean("ISREGEX", true);
} }
private void doAssert(String jsonString) { private void doAssert(String jsonString) {
Object value = JsonPath.read(jsonString, getJsonPath()); Object value = JsonPath.read(jsonString, this.getJsonPath(), new Predicate[0]);
if (this.isJsonValidationBool()) {
if (!isJsonValidationBool()) {
return;
}
if (value instanceof JSONArray) { if (value instanceof JSONArray) {
if (arrayMatched((JSONArray) value)) { if (this.arrayMatched((JSONArray) value)) {
return; return;
} }
} else { } else if (this.isExpectNull() && value == null || this.isEquals(value)) {
if ((isExpectNull() && value == null)
|| isEquals(value)) {
return; return;
} }
}
if (isExpectNull()) { if (this.isExpectNull()) {
throw new IllegalStateException(String.format("Value expected to be null, but found '%s'", value)); throw new IllegalStateException(String.format("Value expected to be null, but found '%s'", value));
} else { } else {
String msg; String msg;
if (isUseRegex()) { if (this.isUseRegex()) {
msg = "Value expected to match regexp '%s', but it did not match: '%s'"; msg = "Value expected to match regexp '%s', but it did not match: '%s'";
} else { } else {
msg = "Value expected to be '%s', but found '%s'"; msg = "Value expected to be '%s', but found '%s'";
} }
throw new IllegalStateException(String.format(msg, getExpectedValue(), objectToString(value)));
throw new IllegalStateException(String.format(msg, this.getExpectedValue(), objectToString(value)));
}
} }
} }
private boolean arrayMatched(JSONArray value) { private boolean arrayMatched(JSONArray value) {
if (value.isEmpty() && "[]".equals(getExpectedValue())) { if (value.isEmpty() && "[]".equals(this.getExpectedValue())) {
return true; return true;
} } else {
Object[] var2 = value.toArray();
int var3 = var2.length;
for (Object subj : value.toArray()) { for (int var4 = 0; var4 < var3; ++var4) {
if ((subj == null && isExpectNull()) Object subj = var2[var4];
|| isEquals(subj)) { if (subj == null && this.isExpectNull() || this.isEquals(subj)) {
return true; return true;
} }
} }
return isEquals(value); return this.isEquals(value);
}
} }
private boolean isEquals(Object subj) { private boolean isEquals(Object subj) {
String str = objectToString(subj); String str = objectToString(subj);
if (isUseRegex()) { if (this.isUseRegex()) {
Pattern pattern = JMeterUtils.getPatternCache().getPattern(getExpectedValue()); Pattern pattern = JMeterUtils.getPatternCache().getPattern(this.getExpectedValue());
return JMeterUtils.getMatcher().matches(str, pattern); return JMeterUtils.getMatcher().matches(str, pattern);
} else { } else {
if (StringUtils.isNotEmpty(getOption())) { if (StringUtils.isNotEmpty(getOption())) {
@ -182,70 +165,66 @@ public class JSONPathAssertion extends AbstractTestElement implements Serializab
} }
return refFlag; return refFlag;
} }
return str.equals(getExpectedValue()); return str.equals(this.getExpectedValue());
} }
} }
@Override
public AssertionResult getResult(SampleResult samplerResult) { public AssertionResult getResult(SampleResult samplerResult) {
AssertionResult result = new AssertionResult(getName()); AssertionResult result = new AssertionResult(this.getName());
String responseData = samplerResult.getResponseDataAsString(); String responseData = samplerResult.getResponseDataAsString();
if (responseData.isEmpty()) { if (responseData.isEmpty()) {
return result.setResultForNull(); return result.setResultForNull();
} } else {
result.setFailure(false); result.setFailure(false);
result.setFailureMessage(""); result.setFailureMessage("");
if (!this.isInvert()) {
try {
this.doAssert(responseData);
} catch (Exception var6) {
log.debug("Assertion failed", var6);
result.setFailure(true);
result.setFailureMessage(var6.getMessage());
}
} else {
try {
this.doAssert(responseData);
result.setFailure(true);
if (this.isJsonValidationBool()) {
if (this.isExpectNull()) {
result.setFailureMessage("Failed that JSONPath " + this.getJsonPath() + " not matches null");
} else {
result.setFailureMessage("Failed that JSONPath " + this.getJsonPath() + " not matches " + this.getExpectedValue());
}
} else {
result.setFailureMessage("Failed that JSONPath not exists: " + this.getJsonPath());
}
} catch (Exception var5) {
log.debug("Assertion failed, as expected", var5);
}
}
if (!isInvert()) {
try {
doAssert(responseData);
} catch (Exception e) {
log.debug("Assertion failed", e);
result.setFailure(true);
result.setFailureMessage(e.getMessage());
}
} else {
try {
doAssert(responseData);
result.setFailure(true);
if (isJsonValidationBool()) {
if (isExpectNull()) {
result.setFailureMessage("Failed that JSONPath " + getJsonPath() + " not matches null");
} else {
result.setFailureMessage("Failed that JSONPath " + getJsonPath() + " not matches " + getExpectedValue());
}
} else {
result.setFailureMessage("Failed that JSONPath not exists: " + getJsonPath());
}
} catch (Exception e) {
log.debug("Assertion failed, as expected", e);
}
}
return result; return result;
} }
}
public static String objectToString(Object subj) { public static String objectToString(Object subj) {
String str; String str;
if (subj == null) { if (subj == null) {
str = "null"; str = "null";
} else if (subj instanceof Map) { } else if (subj instanceof Map) {
//noinspection unchecked str = (new JSONObject((Map) subj)).toJSONString();
str = new JSONObject((Map<String, Object>) subj).toJSONString(); } else if (!(subj instanceof Double) && !(subj instanceof Float)) {
} else if (subj instanceof Double || subj instanceof Float) {
str = decimalFormatter.get().format(subj);
} else {
str = subj.toString(); str = subj.toString();
} else {
str = ((DecimalFormat) decimalFormatter.get()).format(subj);
} }
return str; return str;
} }
@Override
public void threadStarted() { public void threadStarted() {
// nothing to do on thread start
} }
@Override
public void threadFinished() { public void threadFinished() {
decimalFormatter.remove(); decimalFormatter.remove();
} }

View File

@ -441,18 +441,14 @@ export default {
} }
}); });
if (this.$refs.scenarioTable) {
setTimeout(() => {
this.$refs.scenarioTable.doLayout();
this.result.loading = false;
}, 500)
}
if (!this.condition.selectAll) { if (!this.condition.selectAll) {
this.condition.unSelectIds = response.data.listObject.map(s => s.id); this.condition.unSelectIds = response.data.listObject.map(s => s.id);
} }
this.$nextTick(function () { this.$nextTick(function () {
if (this.$refs.scenarioTable) {
setTimeout(this.$refs.scenarioTable.doLayout, 200)
}
this.checkTableRowIsSelect(); this.checkTableRowIsSelect();
}) })
}); });
@ -732,8 +728,8 @@ export default {
// let ids = [row.id]; // let ids = [row.id];
let param = {}; let param = {};
this.buildBatchParam(param); this.buildBatchParam(param);
if(param.ids && param.ids.length <=0){ if (param.ids && param.ids.length <= 0) {
param.ids =[row.id]; param.ids = [row.id];
} }
this.$post('/api/automation/removeToGcByBatch/', param, () => { this.$post('/api/automation/removeToGcByBatch/', param, () => {
// this.$post('/api/automation/removeToGc/', ids, () => { // this.$post('/api/automation/removeToGc/', ids, () => {
@ -838,4 +834,8 @@ export default {
/deep/ .el-card__header { /deep/ .el-card__header {
padding: 10px; padding: 10px;
} }
/deep/ .el-table__fixed-body-wrapper {
top: 60px !important;
}
</style> </style>

View File

@ -767,7 +767,7 @@
}, },
runDebug() { runDebug() {
/*触发执行操作*/ /*触发执行操作*/
let sign = this.$refs.envPopover.checkEnv(); let sign = this.$refs.envPopover.checkEnv(this.scenarioDefinition);
if (!sign) { if (!sign) {
return; return;
} }

View File

@ -44,8 +44,8 @@ export default {
setProjectEnvMap(map) { setProjectEnvMap(map) {
this.$emit("setProjectEnvMap", map); this.$emit("setProjectEnvMap", map);
}, },
checkEnv() { checkEnv(data) {
return this.$refs.envSelect.checkEnv(); return this.$refs.envSelect.checkEnv(data);
} }
} }

View File

@ -29,10 +29,11 @@
</template> </template>
<script> <script>
import {parseEnvironment} from "@/business/components/api/test/model/EnvironmentModel"; import {parseEnvironment} from "@/business/components/api/test/model/EnvironmentModel";
import ApiEnvironmentConfig from "@/business/components/api/definition/components/environment/ApiEnvironmentConfig"; import ApiEnvironmentConfig from "@/business/components/api/definition/components/environment/ApiEnvironmentConfig";
import {ELEMENTS} from "./Setting";
export default { export default {
name: "EnvironmentSelect", name: "EnvironmentSelect",
components: {ApiEnvironmentConfig}, components: {ApiEnvironmentConfig},
props: { props: {
@ -46,12 +47,15 @@ export default {
result: {}, result: {},
projects: [], projects: [],
environments: [], environments: [],
dialogVisible: false dialogVisible: false,
isFullUrl: true,
} }
}, },
methods: { methods: {
init() { init() {
this.projectIds.forEach(id => { this.projectIds.forEach(id => {
const project = this.projectList.find(p => p.id === id);
if (project) {
let item = {id: id, envs: [], selectEnv: ""}; let item = {id: id, envs: [], selectEnv: ""};
this.data.push(item); this.data.push(item);
this.result = this.$get('/api/environment/list/' + id, res => { this.result = this.$get('/api/environment/list/' + id, res => {
@ -64,8 +68,9 @@ export default {
temp.envs = envs; temp.envs = envs;
let envId = this.envMap.get(id); let envId = this.envMap.get(id);
// //
temp.selectEnv = envs.filter(e =>e.id === envId).length === 0 ? null : envId; temp.selectEnv = envs.filter(e => e.id === envId).length === 0 ? null : envId;
}) })
}
}) })
}, },
open() { open() {
@ -102,8 +107,125 @@ export default {
this.$emit('setProjectEnvMap', map); this.$emit('setProjectEnvMap', map);
this.$emit('close'); this.$emit('close');
}, },
checkEnv() { getApiInfo(request) {
if (request.id && request.referenced === 'REF') {
let requestResult = request.requestResult;
let url = request.refType && request.refType === 'CASE' ? "/api/testcase/get/" : "/api/definition/get/";
let enable = request.enable;
this.$get(url + request.id, response => {
if (response.data) {
Object.assign(request, JSON.parse(response.data.request));
request.name = response.data.name;
request.enable = enable;
if (response.data.path && response.data.path != null) {
request.path = response.data.path;
request.url = response.data.url;
this.setUrl(request.path);
}
if (response.data.method && response.data.method != null) {
request.method = response.data.method;
}
request.requestResult = requestResult;
request.id = response.data.id;
request.disabled = true;
request.root = true;
if (!request.projectId) {
request.projectId = response.data.projectId;
}
this.reload();
this.sort();
} else {
request.referenced = "Deleted";
}
})
}
},
getScenario(scenario) {
this.result = this.$get("/api/automation/getApiScenario/" + scenario.id, response => {
if (response.data) {
scenario.loaded = true;
let obj = {};
if (response.data.scenarioDefinition) {
obj = JSON.parse(response.data.scenarioDefinition);
scenario.hashTree = obj.hashTree;
}
//scenario.disabled = true;
scenario.name = response.data.name;
if (!scenario.projectId) {
scenario.projectId = response.data.projectId;
}
scenario.headers = obj.headers;
scenario.variables = obj.variables;
scenario.environmentMap = obj.environmentMap;
this.$emit('refReload');
} else {
scenario.referenced = "Deleted";
}
})
},
recursiveSorting(arr) {
for (let i in arr) {
if (arr[i].referenced === 'REF') {
//
if (arr[i].type === "HTTPSamplerProxy") {
//
this.getApiInfo(arr[i]);
//
if (!arr[i].url || (!arr[i].url.startsWith("http://") && !arr[i].url.startsWith("https://"))) {
this.isFullUrl = false;
}
} else if (arr[i].type === "scenario") {
this.getScenario(arr[i]);
}
} else {
if (arr[i].type === "HTTPSamplerProxy") {
//
if (arr[i].enable) {
if (!arr[i].url || (!arr[i].url.startsWith("http://") && !arr[i].url.startsWith("https://"))) {
this.isFullUrl = false;
}
}
}
}
if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) {
this.recursiveSorting(arr[i].hashTree);
}
}
},
checkFullUrl(scenarioDefinition) {
for (let i in scenarioDefinition) {
// ID
let request = scenarioDefinition[i];
if (request.referenced === 'REF') {
if (request.type === "HTTPSamplerProxy") {
this.getApiInfo(request);
//
if (!request.url || (!request.url.startsWith("http://") && !request.url.startsWith("https://"))) {
this.isFullUrl = false;
}
} else if (request.type === "scenario") {
this.getScenario(request);
}
} else {
if (request.type === "HTTPSamplerProxy") {
//
if (request.enable) {
if (!request.url || (!request.url.startsWith("http://") && !request.url.startsWith("https://"))) {
this.isFullUrl = false;
}
}
}
}
if (scenarioDefinition[i].hashTree != undefined && scenarioDefinition[i].hashTree.length > 0) {
this.recursiveSorting(scenarioDefinition[i].hashTree);
}
}
},
checkEnv(data) {
let sign = true; let sign = true;
this.isFullUrl = true;
if (this.data.length > 0) { if (this.data.length > 0) {
this.data.forEach(dt => { this.data.forEach(dt => {
if (!dt.selectEnv) { if (!dt.selectEnv) {
@ -123,6 +245,9 @@ export default {
} else { } else {
sign = false; sign = false;
} }
//
//this.checkFullUrl(data);
//sign = this.isFullUrl;
} }
if (!sign) { if (!sign) {
@ -135,27 +260,27 @@ export default {
// todo // todo
} }
} }
} }
</script> </script>
<style scoped> <style scoped>
.ms-scenario-button { .ms-scenario-button {
margin-left: 20px; margin-left: 20px;
} }
.env-confirm { .env-confirm {
margin-left: 20px; margin-left: 20px;
width: 360px; width: 360px;
margin-top: 10px; margin-top: 10px;
} }
.project-name { .project-name {
display:inline-block; display: inline-block;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
width: 150px; width: 150px;
margin-left: 8px; margin-left: 8px;
vertical-align:middle; vertical-align: middle;
} }
</style> </style>

View File

@ -226,7 +226,7 @@
this.headers = headers; this.headers = headers;
} }
this.visible = true; this.visible = true;
this.editData = {type: "CONSTANT"}; this.editData = {type: "CONSTANT", delimiter: ","};
this.addParameters(this.editData); this.addParameters(this.editData);
this.disabled = disabled; this.disabled = disabled;
}, },

View File

@ -313,7 +313,7 @@ export default {
this.condition.status = "Trash"; this.condition.status = "Trash";
this.condition.moduleIds = []; this.condition.moduleIds = [];
} }
if(!this.selectAll){ if (!this.selectAll) {
this.selectAll = false; this.selectAll = false;
this.unSelection = []; this.unSelection = [];
this.selectDataCounts = 0; this.selectDataCounts = 0;
@ -342,7 +342,7 @@ export default {
this.total = response.data.itemCount; this.total = response.data.itemCount;
this.tableData = response.data.listObject; this.tableData = response.data.listObject;
if(!this.selectAll){ if (!this.selectAll) {
this.unSelection = response.data.listObject.map(s => s.id); this.unSelection = response.data.listObject.map(s => s.id);
} }
@ -351,13 +351,11 @@ export default {
item.tags = JSON.parse(item.tags); item.tags = JSON.parse(item.tags);
} }
}) })
this.$nextTick(function () {
if (this.$refs.caseTable) { if (this.$refs.caseTable) {
setTimeout(() => { setTimeout(this.$refs.caseTable.doLayout, 200)
this.$refs.caseTable.doLayout();
this.result.loading = false;
}, 500)
} }
this.$nextTick(function(){
this.checkTableRowIsSelect(); this.checkTableRowIsSelect();
}) })
}); });
@ -365,20 +363,20 @@ export default {
getLabel(this, API_CASE_LIST); getLabel(this, API_CASE_LIST);
}, },
checkTableRowIsSelect(){ checkTableRowIsSelect() {
// //
if(this.selectAll){ if (this.selectAll) {
let unSelectIds = this.unSelection; let unSelectIds = this.unSelection;
this.tableData.forEach(row=>{ this.tableData.forEach(row => {
if(unSelectIds.indexOf(row.id)<0){ if (unSelectIds.indexOf(row.id) < 0) {
this.$refs.caseTable.toggleRowSelection(row,true); this.$refs.caseTable.toggleRowSelection(row, true);
//selectRows //selectRows
if (!this.selectRows.has(row)) { if (!this.selectRows.has(row)) {
this.$set(row, "showMore", true); this.$set(row, "showMore", true);
this.selectRows.add(row); this.selectRows.add(row);
} }
}else{ } else {
//selectRow //selectRow
if (this.selectRows.has(row)) { if (this.selectRows.has(row)) {
this.$set(row, "showMore", false); this.$set(row, "showMore", false);
@ -694,4 +692,8 @@ export default {
/deep/ .el-table__fixed { /deep/ .el-table__fixed {
height: 100% !important; height: 100% !important;
} }
/deep/ .el-table__fixed-body-wrapper {
top: 60px !important;
}
</style> </style>

View File

@ -116,7 +116,8 @@
min-width="120px" min-width="120px"
:key="index"> :key="index">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :show-tooltip="true" :content="itemName" style="margin-left: 0px; margin-right: 2px"/> <ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain" :show-tooltip="true" :content="itemName"
style="margin-left: 0px; margin-right: 2px"/>
</template> </template>
</el-table-column> </el-table-column>
@ -211,41 +212,45 @@
<script> <script>
import MsTableHeader from '../../../../common/components/MsTableHeader'; import MsTableHeader from '../../../../common/components/MsTableHeader';
import MsTableOperator from "../../../../common/components/MsTableOperator"; import MsTableOperator from "../../../../common/components/MsTableOperator";
import MsTableOperatorButton from "../../../../common/components/MsTableOperatorButton"; import MsTableOperatorButton from "../../../../common/components/MsTableOperatorButton";
import MsTableButton from "../../../../common/components/MsTableButton"; import MsTableButton from "../../../../common/components/MsTableButton";
import MsTablePagination from "../../../../common/pagination/TablePagination"; import MsTablePagination from "../../../../common/pagination/TablePagination";
import MsTag from "../../../../common/components/MsTag"; import MsTag from "../../../../common/components/MsTag";
import MsApiCaseList from "../case/ApiCaseList"; import MsApiCaseList from "../case/ApiCaseList";
import MsContainer from "../../../../common/components/MsContainer"; import MsContainer from "../../../../common/components/MsContainer";
import MsBottomContainer from "../BottomContainer"; import MsBottomContainer from "../BottomContainer";
import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn"; import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn";
import MsBatchEdit from "../basis/BatchEdit"; import MsBatchEdit from "../basis/BatchEdit";
import {API_METHOD_COLOUR, API_STATUS, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData"; import {API_METHOD_COLOUR, API_STATUS, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData";
import {checkoutTestManagerOrTestUser, downloadFile, getUUID} from "@/common/js/utils"; import {downloadFile} from "@/common/js/utils";
import {PROJECT_NAME} from '@/common/js/constants'; import {API_LIST, PROJECT_NAME, WORKSPACE_ID} from '@/common/js/constants';
import {API_LIST, TEST_CASE_LIST, WORKSPACE_ID} from '@/common/js/constants'; import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover";
import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover"; import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus";
import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus"; import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar";
import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar"; import {API_DEFINITION_CONFIGS} from "@/business/components/common/components/search/search-components";
import {API_DEFINITION_CONFIGS} from "@/business/components/common/components/search/search-components"; import MsTipButton from "@/business/components/common/components/MsTipButton";
import MsTipButton from "@/business/components/common/components/MsTipButton"; import CaseBatchMove from "@/business/components/api/definition/components/basis/BatchMove";
import CaseBatchMove from "@/business/components/api/definition/components/basis/BatchMove"; import {
import { _filter,
_handleSelect, _handleSelect,
_handleSelectAll, buildBatchParam, getLabel, _handleSelectAll,
getSelectDataCounts, initCondition, _sort,
setUnSelectIds, toggleAllSelection buildBatchParam,
} from "@/common/js/tableUtils"; getLabel,
import {_filter, _sort} from "@/common/js/tableUtils"; getSelectDataCounts,
import {Api_List} from "@/business/components/common/model/JsonData"; initCondition,
import HeaderCustom from "@/business/components/common/head/HeaderCustom"; setUnSelectIds,
import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate"; toggleAllSelection
import {Body} from "@/business/components/api/definition/model/ApiTestModel"; } from "@/common/js/tableUtils";
import {Api_List} from "@/business/components/common/model/JsonData";
import HeaderCustom from "@/business/components/common/head/HeaderCustom";
import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate";
import {Body} from "@/business/components/api/definition/model/ApiTestModel";
export default { export default {
name: "ApiList", name: "ApiList",
components: { components: {
HeaderLabelOperate, HeaderLabelOperate,
@ -385,11 +390,11 @@
}, },
watch: { watch: {
selectNodeIds() { selectNodeIds() {
initCondition(this.condition,false); initCondition(this.condition, false);
this.initTable(); this.initTable();
}, },
currentProtocol() { currentProtocol() {
initCondition(this.condition,false); initCondition(this.condition, false);
this.initTable(); this.initTable();
}, },
trashEnable() { trashEnable() {
@ -399,7 +404,7 @@
} else { } else {
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]}; this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
} }
initCondition(this.condition,false); initCondition(this.condition, false);
this.initTable(); this.initTable();
} }
}, },
@ -412,7 +417,7 @@
}, },
initTable() { initTable() {
this.selectRows = new Set(); this.selectRows = new Set();
initCondition(this.condition,this.condition.selectAll); initCondition(this.condition, this.condition.selectAll);
this.selectDataCounts = 0; this.selectDataCounts = 0;
this.condition.moduleIds = this.selectNodeIds; this.condition.moduleIds = this.selectNodeIds;
this.condition.projectId = this.projectId; this.condition.projectId = this.projectId;
@ -454,38 +459,32 @@
item.tags = JSON.parse(item.tags); item.tags = JSON.parse(item.tags);
} }
}) })
if (this.$refs.apiDefinitionTable) {
setTimeout(() => {
this.$refs.apiDefinitionTable.doLayout();
this.result.loading = false;
}, 500)
}
// nexttick: // nexttick:
this.$nextTick(function(){ this.$nextTick(function () {
// if (this.$refs.apiDefinitionTable) { if (this.$refs.apiDefinitionTable) {
// this.$refs.apiDefinitionTable.doLayout(); setTimeout(this.$refs.apiDefinitionTable.doLayout, 200)
// this.result.loading = false; }
// }
this.checkTableRowIsSelect(); this.checkTableRowIsSelect();
}) })
}); });
} }
getLabel(this, API_LIST); getLabel(this, API_LIST);
}, },
checkTableRowIsSelect(){ checkTableRowIsSelect() {
// //
if(this.condition.selectAll){ if (this.condition.selectAll) {
let unSelectIds = this.condition.unSelectIds; let unSelectIds = this.condition.unSelectIds;
this.tableData.forEach(row=>{ this.tableData.forEach(row => {
if(unSelectIds.indexOf(row.id)<0){ if (unSelectIds.indexOf(row.id) < 0) {
this.$refs.apiDefinitionTable.toggleRowSelection(row,true); this.$refs.apiDefinitionTable.toggleRowSelection(row, true);
//selectRows //selectRows
if (!this.selectRows.has(row)) { if (!this.selectRows.has(row)) {
this.$set(row, "showMore", true); this.$set(row, "showMore", true);
this.selectRows.add(row); this.selectRows.add(row);
} }
}else{ } else {
//selectRow //selectRow
if (this.selectRows.has(row)) { if (this.selectRows.has(row)) {
this.$set(row, "showMore", false); this.$set(row, "showMore", false);
@ -763,8 +762,7 @@
obj.protocol = this.currentProtocol; obj.protocol = this.currentProtocol;
this.buildApiPath(obj.data); this.buildApiPath(obj.data);
downloadFile("Metersphere_Api_" + localStorage.getItem(PROJECT_NAME) + ".json", JSON.stringify(obj)); downloadFile("Metersphere_Api_" + localStorage.getItem(PROJECT_NAME) + ".json", JSON.stringify(obj));
} } else {
else {
downloadFile("Swagger_Api_" + localStorage.getItem(PROJECT_NAME) + ".json", JSON.stringify(obj)); downloadFile("Swagger_Api_" + localStorage.getItem(PROJECT_NAME) + ".json", JSON.stringify(obj));
} }
}); });
@ -802,40 +800,44 @@
this.$refs.searchBar.open(); this.$refs.searchBar.open();
} }
}, },
} }
</script> </script>
<style scoped> <style scoped>
.operate-button > div { .operate-button > div {
display: inline-block; display: inline-block;
margin-left: 10px; margin-left: 10px;
} }
.request-method { .request-method {
padding: 0 5px; padding: 0 5px;
color: #1E90FF; color: #1E90FF;
} }
.api-el-tag { .api-el-tag {
color: white; color: white;
} }
.search-input { .search-input {
float: right; float: right;
width: 300px; width: 300px;
margin-right: 10px; margin-right: 10px;
} }
.el-tag { .el-tag {
margin-left: 10px; margin-left: 10px;
} }
.ms-select-all >>> th:first-child { .ms-select-all >>> th:first-child {
margin-top: 20px; margin-top: 20px;
} }
.ms-select-all >>> th:nth-child(2) .el-icon-arrow-down { .ms-select-all >>> th:nth-child(2) .el-icon-arrow-down {
top: -2px; top: -2px;
} }
/deep/ .el-table__fixed-body-wrapper {
top: 60px !important;
}
</style> </style>

View File

@ -133,11 +133,16 @@
this.data.forEach(node => { this.data.forEach(node => {
buildTree(node, {path: ''}); buildTree(node, {path: ''});
}); });
this.$emit('setModuleOptions', this.data);
this.$emit('setNodeTree', this.data); this.$emit('setNodeTree', this.data);
if (this.$refs.nodeTree) { if (this.$refs.nodeTree) {
this.$refs.nodeTree.filter(this.condition.filterText); this.$refs.nodeTree.filter(this.condition.filterText);
} }
let moduleOptions = [];
this.data.forEach(node => {
buildNodePath(node, {path: ''}, moduleOptions);
});
this.moduleOptions = moduleOptions;
this.$emit('setModuleOptions', moduleOptions);
} }
}); });
}, },

View File

@ -173,11 +173,12 @@ export default {
updateTime: row.lastModified, updateTime: row.lastModified,
}); });
} }
//
if (this.loadType === 'resource') {
rows.forEach(row => { rows.forEach(row => {
this.fileList.push(row); this.fileList.push(row);
}) })
if (this.loadType === 'resource') {
this.$success(this.$t('test_track.case.import.success')); this.$success(this.$t('test_track.case.import.success'));
this.close(); this.close();
return; return;
@ -197,8 +198,6 @@ export default {
tg.options = {}; tg.options = {};
this.scenarios.push(tg); this.scenarios.push(tg);
}); });
let file = new File([d.jmx], d.name);
this.uploadList.push(file);
}); });
this.$emit('fileChange', this.scenarios); this.$emit('fileChange', this.scenarios);

View File

@ -160,15 +160,17 @@ import {
_filter, _filter,
_handleSelect, _handleSelect,
_handleSelectAll, _handleSelectAll,
_sort, buildBatchParam, getLabel, _sort,
getSelectDataCounts, initCondition, buildBatchParam,
getLabel,
getSelectDataCounts,
initCondition,
setUnSelectIds, setUnSelectIds,
toggleAllSelection toggleAllSelection
} from "@/common/js/tableUtils"; } from "@/common/js/tableUtils";
import BatchMove from "./BatchMove"; import BatchMove from "./BatchMove";
import {Track_Test_Case} from "@/business/components/common/model/JsonData"; import {Track_Test_Case} from "@/business/components/common/model/JsonData";
import HeaderCustom from "@/business/components/common/head/HeaderCustom"; import HeaderCustom from "@/business/components/common/head/HeaderCustom";
import i18n from "@/i18n/i18n";
import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate"; import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate";
import PlanStatusTableItem from "@/business/components/track/common/tableItems/plan/PlanStatusTableItem"; import PlanStatusTableItem from "@/business/components/track/common/tableItems/plan/PlanStatusTableItem";
@ -314,7 +316,7 @@ export default {
watch: { watch: {
selectNodeIds() { selectNodeIds() {
this.currentPage = 1; this.currentPage = 1;
initCondition(this.condition,false); initCondition(this.condition, false);
this.initTableData(); this.initTableData();
}, },
condition() { condition() {
@ -334,7 +336,7 @@ export default {
this.condition.planId = ""; this.condition.planId = "";
this.condition.nodeIds = []; this.condition.nodeIds = [];
//initCondition(this.condition); //initCondition(this.condition);
initCondition(this.condition,this.condition.selectAll); initCondition(this.condition, this.condition.selectAll);
this.selectDataCounts = 0; this.selectDataCounts = 0;
if (this.planId) { if (this.planId) {
// param.planId = this.planId; // param.planId = this.planId;
@ -392,33 +394,30 @@ export default {
this.tableData.forEach((item) => { this.tableData.forEach((item) => {
item.tags = JSON.parse(item.tags); item.tags = JSON.parse(item.tags);
}) })
if (this.$refs.table) {
setTimeout(() => {
this.$refs.table.doLayout();
this.result.loading = false;
}, 500)
}
this.$nextTick(function(){ this.$nextTick(() => {
if (this.$refs.table) {
setTimeout(this.$refs.table.doLayout, 200)
}
this.checkTableRowIsSelect(); this.checkTableRowIsSelect();
}) })
}); });
} }
}, },
checkTableRowIsSelect(){ checkTableRowIsSelect() {
// //
if(this.condition.selectAll){ if (this.condition.selectAll) {
let unSelectIds = this.condition.unSelectIds; let unSelectIds = this.condition.unSelectIds;
this.tableData.forEach(row=>{ this.tableData.forEach(row => {
if(unSelectIds.indexOf(row.id)<0){ if (unSelectIds.indexOf(row.id) < 0) {
this.$refs.table.toggleRowSelection(row,true); this.$refs.table.toggleRowSelection(row, true);
//selectRows //selectRows
if (!this.selectRows.has(row)) { if (!this.selectRows.has(row)) {
this.$set(row, "showMore", true); this.$set(row, "showMore", true);
this.selectRows.add(row); this.selectRows.add(row);
} }
}else{ } else {
//selectRow //selectRow
if (this.selectRows.has(row)) { if (this.selectRows.has(row)) {
this.$set(row, "showMore", false); this.$set(row, "showMore", false);
@ -446,7 +445,7 @@ export default {
handleCopy(testCase) { handleCopy(testCase) {
this.$get('test/case/get/' + testCase.id, response => { this.$get('test/case/get/' + testCase.id, response => {
let testCase = response.data; let testCase = response.data;
testCase.name='copy_'+testCase.name testCase.name = 'copy_' + testCase.name
this.$emit('testCaseCopy', testCase); this.$emit('testCaseCopy', testCase);
}); });
}, },
@ -662,4 +661,8 @@ export default {
.el-tag { .el-tag {
margin-left: 10px; margin-left: 10px;
} }
/deep/ .el-table__fixed-body-wrapper {
top: 60px !important;
}
</style> </style>

View File

@ -473,10 +473,7 @@ export default {
} }
this.selectRows.clear(); this.selectRows.clear();
if (this.$refs.table) { if (this.$refs.table) {
setTimeout(() => { setTimeout(this.$refs.table.doLayout, 200)
this.$refs.table.doLayout();
this.result.loading = false;
}, 500)
} }
}); });
} }
@ -718,4 +715,8 @@ export default {
.ms-table-header >>> .table-title { .ms-table-header >>> .table-title {
height: 0px; height: 0px;
} }
/deep/ .el-table__fixed-body-wrapper {
top: 60px !important;
}
</style> </style>

@ -1 +1 @@
Subproject commit 07951ba17aef6f29e50cfd68e40de3266f9a60cd Subproject commit a37e6bb56ffaa7ecc4ee128640e9415304ad41b6