fix(接口自动化): 修复场景变量 header 输入提示功能,修复报告显示顺序问题

This commit is contained in:
fit2-zhao 2021-02-22 18:05:17 +08:00
parent 13f1198a5f
commit 8771e82ba1
6 changed files with 57 additions and 74 deletions

View File

@ -81,9 +81,6 @@ public class MsScenario extends MsTestElement {
ex.printStackTrace();
}
}
config.setStep(this.getName());
config.setStepType("SCENARIO");
config.setEnableCookieShare(enableCookieShare);
if (StringUtils.isNotEmpty(environmentId)) {
ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);

View File

@ -256,14 +256,15 @@ public abstract class MsTestElement {
}
}
public MsTestElement getRootParent(MsTestElement element) {
public void getFullPath(MsTestElement element, StringBuilder path) {
if (element.getParent() == null) {
return element;
return;
}
if (MsTestElementConstants.LoopController.name().equals(element.getType())) {
return element;
return;
}
return getRootParent(element.getParent());
path.append(element.getResourceId()).append("/");
getFullPath(element.getParent(), path);
}
protected String getParentName(MsTestElement parent, ParameterConfig config) {
@ -280,13 +281,11 @@ public abstract class MsTestElement {
return "次数循环-" + "${LoopCounterConfigXXX}";
}
}
return parent.getName();
} else if (config != null && StringUtils.isNotEmpty(config.getStep())) {
if (MsTestElementConstants.SCENARIO.name().equals(config.getStepType())) {
return config.getStep();
} else {
return config.getStep() + "-" + "${LoopCounterConfigXXX}";
}
// 获取全路径以备后面使用
StringBuilder fullPath = new StringBuilder();
getFullPath(parent, fullPath);
return fullPath + "<->" + parent.getName();
}
return "";
}

View File

@ -20,12 +20,6 @@ public class ParameterConfig {
* 公共Cookie
*/
private boolean enableCookieShare;
/**
* 步骤
*/
private String step;
private String stepType;
/**
* 是否是导入/导出操作

View File

@ -44,18 +44,6 @@ public class MsLoopController extends MsTestElement {
@Override
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
if (StringUtils.equals(this.loopType, LoopConstants.WHILE.name()) && this.whileController != null) {
config.setStep("While 循环");
}
if (StringUtils.equals(this.loopType, LoopConstants.FOREACH.name()) && this.forEachController != null) {
config.setStep("ForEach 循环");
}
if (StringUtils.equals(this.loopType, LoopConstants.LOOP_COUNT.name()) && this.countController != null) {
config.setStep("次数循环");
}
config.setStepType("LOOP");
final HashTree groupTree = controller(tree);
if (CollectionUtils.isNotEmpty(config.getVariables())) {
this.addCsvDataSet(groupTree, config.getVariables());

View File

@ -48,8 +48,8 @@ public class TestResult {
result.getRequestResults().forEach(item -> {
if (StringUtils.isNotEmpty(item.getName()) && item.getName().indexOf(SEPARATOR) != -1) {
String array[] = item.getName().split(SEPARATOR);
String scenarioName = array[array.length - 1];
item.setName(item.getName().replace(SEPARATOR + scenarioName, ""));
String scenarioName = item.getName().replace(array[0] + SEPARATOR, "");
item.setName(array[0]);
if (requestResultMap.containsKey(scenarioName)) {
requestResultMap.get(scenarioName).add(item);
} else {
@ -80,6 +80,9 @@ public class TestResult {
ScenarioResult scenarioResult = new ScenarioResult();
BeanUtils.copyBean(scenarioResult, result);
scenarioResult.setName(k);
if (k.indexOf(SEPARATOR) != -1) {
scenarioResult.setName(k.split(SEPARATOR)[1]);
}
scenarioResult.setRequestResults(v);
scenarios.add(scenarioResult);
});

View File

@ -81,7 +81,7 @@
</el-link>
</el-row>
<div style="min-height: 400px">
<ms-api-key-value :items="headers"/>
<ms-api-key-value :items="headers" :suggestions="headerSuggestions"/>
<batch-add-parameter @batchSave="batchSave" ref="batchAddParameter"/>
</div>
</el-tab-pane>
@ -95,33 +95,34 @@
</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 MsApiKeyValue from "../../../definition/components/ApiKeyValue";
import BatchAddParameter from "../../../definition/components/basis/BatchAddParameter";
import {KeyValue} from "../../../definition/model/ApiTestModel";
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";
import {REQUEST_HEADERS} from "@/common/js/constants";
export default {
name: "MsVariableList",
components: {
MsEditConstant,
MsDialogFooter,
MsTableHeader,
MsTablePagination,
MsEditCounter,
MsEditRandom,
MsEditListValue,
MsEditCsv,
MsApiKeyValue,
BatchAddParameter
},
export default {
name: "MsVariableList",
components: {
MsEditConstant,
MsDialogFooter,
MsTableHeader,
MsTablePagination,
MsEditCounter,
MsEditRandom,
MsEditListValue,
MsEditCsv,
MsApiKeyValue,
BatchAddParameter
},
data() {
return {
variables: [],
@ -144,6 +145,7 @@ export default {
editData: {},
pageSize: 10,
total: 0,
headerSuggestions: REQUEST_HEADERS,
}
},
methods: {
@ -285,19 +287,19 @@ export default {
</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-header {
background: #783887;
color: white;
height: 18px;
border-radius: 42%;
}
.ms-variable-link {
float: right;
margin-right: 45px;
}
.ms-variable-link {
float: right;
margin-right: 45px;
}
</style>