Merge remote-tracking branch 'origin/master'

This commit is contained in:
song.tianyang 2021-03-24 17:38:57 +08:00
commit 27db2f0153
8 changed files with 71 additions and 53 deletions

View File

@ -140,7 +140,7 @@ public class MsScenario extends MsTestElement {
if (arguments != null) {
tree.add(config.valueSupposeMock(arguments));
}
this.addCsvDataSet(tree, variables);
this.addCsvDataSet(tree, variables,config);
this.addCounter(tree, variables);
this.addRandom(tree, variables);
if (CollectionUtils.isNotEmpty(this.headers)) {

View File

@ -201,7 +201,7 @@ public abstract class MsTestElement {
return null;
}
protected void addCsvDataSet(HashTree tree, List<ScenarioVariable> variables) {
protected void addCsvDataSet(HashTree tree, List<ScenarioVariable> variables,ParameterConfig config) {
if (CollectionUtils.isNotEmpty(variables)) {
List<ScenarioVariable> list = variables.stream().filter(ScenarioVariable::isCSVValid).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(list)) {
@ -213,7 +213,7 @@ public abstract class MsTestElement {
csvDataSet.setName(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName());
csvDataSet.setProperty("fileEncoding", StringUtils.isEmpty(item.getEncoding()) ? "UTF-8" : item.getEncoding());
if (CollectionUtils.isNotEmpty(item.getFiles())) {
if (new File(BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName()).exists()) {
if (!config.isOperating() && new File(BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName()).exists()) {
MSException.throwException(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName() + "[ CSV文件不存在 ]");
}
csvDataSet.setProperty("filename", BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName());

View File

@ -56,7 +56,7 @@ public class MsLoopController extends MsTestElement {
}
final HashTree groupTree = controller(tree);
if (CollectionUtils.isNotEmpty(config.getVariables())) {
this.addCsvDataSet(groupTree, config.getVariables());
this.addCsvDataSet(groupTree, config.getVariables(),config);
this.addCounter(groupTree, config.getVariables());
this.addRandom(groupTree, config.getVariables());
}

View File

@ -58,7 +58,7 @@ public class MsJmeterElement extends MsTestElement {
LogUtil.info(((ThreadGroup) scriptWrapper).getName() + "是被禁用线程组不加入执行");
} else {
// CSV数据检查文件路径是否还存在
if (scriptWrapper instanceof CSVDataSet) {
if (!config.isOperating() && scriptWrapper instanceof CSVDataSet) {
String path = ((CSVDataSet) scriptWrapper).getPropertyAsString("filename");
if (!new File(path).exists()) {
MSException.throwException(StringUtils.isEmpty(((CSVDataSet) scriptWrapper).getName()) ? "CSVDataSet" : ((CSVDataSet) scriptWrapper).getName() + "[ CSV文件不存在 ]");

View File

@ -1,6 +1,6 @@
<template>
<div>
<el-card class="table-card" v-loading="loading">
<el-card class="table-card" v-loading="result.loading">
<template v-slot:header>
<ms-table-header :condition.sync="condition" @search="selectByParam" title=""
:show-create="false" :tip="$t('commons.search_by_id_name_tag')"/>
@ -246,10 +246,10 @@
},
data() {
return {
result: {},
type: API_SCENARIO_LIST,
headerItems: Api_Scenario_List,
tableLabel: Api_Scenario_List,
loading: false,
screenHeight: document.documentElement.clientHeight - 280,//,
condition: {
components: API_SCENARIO_CONFIGS
@ -358,7 +358,7 @@
this.search();
},
batchReportId() {
this.loading = true;
this.result.loading = true;
this.getReport();
}
},
@ -418,7 +418,7 @@
this.selectDataCounts = 0;
let url = "/api/automation/list/" + this.currentPage + "/" + this.pageSize;
if (this.condition.projectId) {
this.loading = true;
this.result.loading = true;
this.$post(url, this.condition, response => {
let data = response.data;
this.total = data.itemCount;
@ -428,7 +428,7 @@
item.tags = JSON.parse(item.tags);
}
});
this.loading = false;
this.result.loading = false;
this.unSelection = data.listObject.map(s => s.id);
if (this.$refs.scenarioTable) {
this.$refs.scenarioTable.doLayout()
@ -550,13 +550,13 @@
} catch (e) {
throw e;
}
this.loading = false;
this.result.loading = false;
this.$success("批量执行成功,请到报告页面查看详情!");
} else {
setTimeout(this.getReport, 2000)
}
} else {
this.loading = false;
this.result.loading = false;
this.$error(this.$t('api_report.not_exist'));
}
});
@ -723,9 +723,9 @@
this.$warning(this.$t("api_test.automation.scenario.check_case"));
return;
}
this.loading = true;
this.result.loading = true;
this.result = this.$post("/api/automation/export", param, response => {
this.loading = false;
this.result.loading = false;
let obj = response.data;
this.buildApiPath(obj.data);
downloadFile("Metersphere_Scenario_" + localStorage.getItem(PROJECT_NAME) + ".json", JSON.stringify(obj));
@ -738,9 +738,9 @@
this.$warning(this.$t("api_test.automation.scenario.check_case"));
return;
}
this.loading = true;
this.result.loading = true;
this.result = this.$post("/api/automation/export/jmx", param, response => {
this.loading = false;
this.result.loading = false;
let obj = response.data;
if (obj && obj.length > 0) {
obj.forEach(item => {

View File

@ -20,28 +20,29 @@
<template v-slot:append>
<el-dropdown v-if="!isReadOnly" size="small" split-button type="primary" class="ms-api-button" @click="handleCommand('add-api')"
v-tester
@command="handleCommand">
@command="handleCommand" trigger="click">
<el-button icon="el-icon-folder-add" @click="addScenario"></el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="add-scenario">{{ $t('api_test.automation.add_scenario') }}</el-dropdown-item>
<el-dropdown-item command="import">{{ $t('api_test.api_import.label') }}</el-dropdown-item>
<el-dropdown-item command="export">{{ $t('report.export') }}MS</el-dropdown-item>
<el-dropdown-item command="exportJmx">{{ $t('report.export') }}JMX</el-dropdown-item>
<el-dropdown-item command="exports">
<el-dropdown placement="right-start" @command="chooseExportType">
<span>
{{ $t('report.export') }} <i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<template>
<el-dropdown-item command="export">{{ $t('report.export_to_ms_format') }}</el-dropdown-item>
<el-dropdown-item command="exportJmx">{{ $t('report.export') }} JMETER 格式</el-dropdown-item>
</template>
</el-dropdown-menu>
</el-dropdown>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-input>
<module-trash-button v-if="!isReadOnly" :condition="condition" :exe="enableTrash"/>
<!-- 是否保留这个 -->
<!--<api-scenario-module-header-->
<!--:condition="condition"-->
<!--:current-module="currentModule"-->
<!--:is-read-only="isReadOnly"-->
<!--:project-id="projectId"-->
<!--@exportAPI="exportAPI"-->
<!--@addScenario="addScenario"-->
<!--@refreshTable="$emit('refreshTable')"-->
<!--@refresh="refresh"/>-->
</template>
</ms-node-tree>
@ -150,6 +151,16 @@
break;
}
},
chooseExportType(e) {
switch (e) {
case "export":
this.$emit('exportAPI');
break;
case "exportJmx":
this.$emit('exportJmx');
break;
}
},
list(projectId) {
let url = undefined;
if (this.isPlanModel) {

View File

@ -28,7 +28,7 @@
<div class="header-right" @click.stop>
<slot name="message"></slot>
<el-tooltip :content="$t('test_resource_pool.enable_disable')" placement="top" v-if="showBtn">
<el-switch v-model="data.enable" class="enable-switch" size="mini" :disabled="data.disabled"/>
<el-switch v-model="data.enable" class="enable-switch" size="mini" :disabled="data.disabled && !data.root"/>
</el-tooltip>
<slot name="button"></slot>
<step-extend-btns style="display: contents" :data="data" @copy="copyRow" @remove="remove" @openScenario="openScenario" v-if="showBtn && (!data.disabled || data.root)"/>

View File

@ -5,9 +5,13 @@
<!--操作按钮-->
<div class="ms-opt-btn">
<el-button v-if="type!='add'" id="inputDelay" type="primary" size="small" @click="saveCase" title="ctrl + s">
{{ $t('commons.save') }}
</el-button>
<ms-table-button v-if="type!='add'" :is-tester-permission="true"
id="inputDelay"
type="primary"
:content="$t('commons.save')"
size="small" @exec="saveCase"
icon=""
title="ctrl + s"/>
<el-dropdown v-else split-button type="primary" class="ms-api-buttion" @click="handleCommand"
@command="handleCommand" size="small" style="float: right;margin-right: 20px">
{{ $t('commons.save') }}
@ -297,10 +301,12 @@ import {ELEMENTS} from "@/business/components/api/automation/scenario/Setting";
import TestCaseComment from "@/business/components/track/case/components/TestCaseComment";
import ReviewCommentItem from "@/business/components/track/review/commom/ReviewCommentItem";
import {API_STATUS, REVIEW_STATUS, TEST} from "@/business/components/api/definition/model/JsonData";
import MsTableButton from "@/business/components/common/components/MsTableButton";
export default {
name: "TestCaseEdit",
components: {
MsTableButton,
ReviewCommentItem,
TestCaseComment, MsPreviousNextButton, MsInputTag, CaseComment, MsDialogFooter, TestCaseAttachment
@ -311,8 +317,8 @@ export default {
multiple: true,
lazy: true,
lazyLoad: ((node, resolve) => {
const { level } = node;
if(node.level==0){
const {level} = node;
if (node.level == 0) {
const nodes = TEST
.map(item => ({
value: item.id,
@ -321,10 +327,10 @@ export default {
}));
resolve(nodes)
}
if(node.level==1){
if (node.level == 1) {
this.testOptions = [];
let url = '';
this.form.type=node.data.value
this.form.type = node.data.value
if (this.form.type === 'testcase' || this.form.type === 'automation') {
url = '/api/' + this.form.type + '/list/' + this.projectId
} else if (this.form.type === 'performance' || this.form.type === 'api') {
@ -347,7 +353,7 @@ export default {
}),
},
options: REVIEW_STATUS,
statuOptions:API_STATUS,
statuOptions: API_STATUS,
comments: [],
result: {},
dialogFormVisible: false,
@ -366,13 +372,13 @@ export default {
desc: '',
result: ''
}],
selected: [],
selected: [],
remark: '',
tags: [],
demandId: '',
demandName: '',
status:'Prepare',
reviewStatus:'Prepare',
status: 'Prepare',
reviewStatus: 'Prepare',
},
readOnly: false,
moduleOptions: [],
@ -465,14 +471,15 @@ export default {
this.saveCase();
} else {
this.saveCase();
let tab={}
tab.name='add'
this.$emit('addTab',tab)}
let tab = {}
tab.name = 'add'
this.$emit('addTab', tab)
}
})
}else {
} else {
this.saveCase();
}
},
},
openComment() {
this.$refs.testCaseComment.open()
},
@ -649,9 +656,9 @@ export default {
this.dialogFormVisible = false;
},
saveCase() {
/*
document.getElementById("inputDelay").focus();
*/
/*
document.getElementById("inputDelay").focus();
*/
// input
this.$refs['caseFrom'].validate((valid) => {
@ -703,7 +710,7 @@ export default {
if (this.form.tags instanceof Array) {
this.form.tags = JSON.stringify(this.form.tags);
}
param.testId=JSON.stringify(this.form.selected)
param.testId = JSON.stringify(this.form.selected)
param.tags = this.form.tags;
param.type = 'functional'
return param;
@ -797,14 +804,14 @@ export default {
},
getDemandOptions() {
if (this.demandOptions.length === 0) {
this.result = {loading : true};
this.result = {loading: true};
this.$get("demand/list/" + this.projectId).then(response => {
this.demandOptions = response.data.data;
this.demandOptions.unshift({id: 'other', name: this.$t('test_track.case.other'), platform: 'Other'})
this.result = {loading : false};
this.result = {loading: false};
}).catch(() => {
this.demandOptions.unshift({id: 'other', name: this.$t('test_track.case.other'), platform: 'Other'})
this.result = {loading : false};
this.result = {loading: false};
})
}
},