Merge branch 'master' of github.com:metersphere/metersphere

This commit is contained in:
chenjianxing 2021-03-11 20:28:24 +08:00
commit 5ec898a4fb
10 changed files with 103 additions and 96 deletions

View File

@ -52,6 +52,9 @@ public class MsDubboSampler extends MsTestElement {
@JSONField(ordinal = 59)
private List<KeyValue> attachmentArgs;
@JSONField(ordinal = 60)
private String useEnvironment;
// @JSONField(ordinal = 60)
// private Object requestResult;

View File

@ -53,6 +53,9 @@ public class MsJDBCSampler extends MsTestElement {
@JSONField(ordinal = 29)
private String protocol = "SQL";
@JSONField(ordinal = 30)
private String useEnvironment;
@Override
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
if (this.getReferenced() != null && MsTestElementConstants.REF.name().equals(this.getReferenced())) {

View File

@ -50,7 +50,7 @@ public class TestCaseExcelDataCn extends TestCaseExcelData {
@ColumnWidth(50)
@ExcelProperty("前置条件")
@Length(min = 0, max = 1000)
@Length(min = 0, max = 500)
private String prerequisite;
@ColumnWidth(50)

View File

@ -5,7 +5,7 @@
<!--操作按钮-->
<div class="ms-opt-btn">
<el-button id="inputDelay" type="primary" size="small" @click="editScenario" title="ctrl + s">
<el-button id="inputDelay" type="primary" size="small" v-prevent-re-click @click="editScenario" title="ctrl + s">
{{ $t('commons.save') }}
</el-button>
</div>
@ -119,7 +119,7 @@
:project-list="projectList" ref="envPopover"/>
</el-col>
<el-col :span="2">
<el-button :disabled="scenarioDefinition.length < 1" size="small" type="primary" @click="runDebug">{{$t('api_test.request.debug')}}</el-button>
<el-button :disabled="scenarioDefinition.length < 1" size="small" type="primary" v-prevent-re-click @click="runDebug">{{$t('api_test.request.debug')}}</el-button>
</el-col>
</el-row>
</div>
@ -707,29 +707,29 @@
},
runDebug() {
/*触发执行操作*/
// if (!this.currentEnvironmentId) {
// this.$error(this.$t('api_test.environment.select_environment'));
// return;
// }
let sign = this.$refs.envPopover.checkEnv();
if (!sign) {
return;
}
this.$refs['currentScenario'].validate((valid) => {
if (valid) {
this.editScenario();
this.debugData = {
id: this.currentScenario.id,
name: this.currentScenario.name,
type: "scenario",
variables: this.currentScenario.variables,
referenced: 'Created',
enableCookieShare: this.enableCookieShare,
headers: this.currentScenario.headers,
environmentMap: this.projectEnvMap,
hashTree: this.scenarioDefinition
};
this.reportId = getUUID().substring(0, 8);
Promise.all([
this.editScenario()]).then(val => {
if (val) {
this.debugData = {
id: this.currentScenario.id,
name: this.currentScenario.name,
type: "scenario",
variables: this.currentScenario.variables,
referenced: 'Created',
enableCookieShare: this.enableCookieShare,
headers: this.currentScenario.headers,
environmentMap: this.projectEnvMap,
hashTree: this.scenarioDefinition
};
this.reportId = getUUID().substring(0, 8);
}
});
}
})
},
@ -884,24 +884,27 @@
return bodyUploadFiles;
},
editScenario() {
document.getElementById("inputDelay").focus(); // input
this.$refs['currentScenario'].validate((valid) => {
if (valid) {
this.setParameter();
let bodyFiles = this.getBodyUploadFiles(this.currentScenario);
this.$fileUpload(this.path, null, bodyFiles, this.currentScenario, response => {
this.$success(this.$t('commons.save_success'));
this.path = "/api/automation/update";
if (response.data) {
this.currentScenario.id = response.data.id;
}
if (this.currentScenario.tags instanceof String) {
this.currentScenario.tags = JSON.parse(this.currentScenario.tags);
}
this.$emit('refresh', this.currentScenario);
})
}
})
return new Promise((resolve, reject) => {
document.getElementById("inputDelay").focus(); // input
this.$refs['currentScenario'].validate((valid) => {
if (valid) {
this.setParameter();
let bodyFiles = this.getBodyUploadFiles(this.currentScenario);
this.$fileUpload(this.path, null, bodyFiles, this.currentScenario, response => {
this.$success(this.$t('commons.save_success'));
this.path = "/api/automation/update";
if (response.data) {
this.currentScenario.id = response.data.id;
}
if (this.currentScenario.tags instanceof String) {
this.currentScenario.tags = JSON.parse(this.currentScenario.tags);
}
this.$emit('refresh', this.currentScenario);
resolve();
})
}
})
});
},
getApiScenario() {
if (this.currentScenario.tags != undefined && !(this.currentScenario.tags instanceof Array)) {

View File

@ -47,6 +47,7 @@
<ms-environment-select
:project-id="projectId"
:is-read-only="isReadOnly"
:useEnvironment='useEnvironment'
@setEnvironment="setEnvironment"/>
</div>
</el-col>
@ -65,7 +66,6 @@
<script>
import ApiEnvironmentConfig from "../../../test/components/ApiEnvironmentConfig";
import {parseEnvironment} from "../../../test/model/EnvironmentModel";
import MsTag from "../../../../common/components/MsTag";
import MsEnvironmentSelect from "./MsEnvironmentSelect";
import {API_METHOD_COLOUR} from "../../model/JsonData";
@ -76,8 +76,6 @@
components: {MsEnvironmentSelect, MsTag, ApiEnvironmentConfig, MsTableAdvSearchBar},
data() {
return {
environments: [],
environment: {},
methodColorMap: new Map(API_METHOD_COLOUR),
isSelectAll: false
}
@ -88,6 +86,7 @@
priorities: Array,
apiCaseList: Array,
isReadOnly: Boolean,
useEnvironment: String,
isCaseEdit: Boolean,
condition: {
type: Object,
@ -97,50 +96,15 @@
}
},
created() {
this.environment = undefined;
this.getEnvironments();
},
watch: {
environment() {
this.$emit('setEnvironment', this.environment);
},
isSelectAll() {
this.$emit('selectAll', this.isSelectAll);
}
},
},
methods: {
getEnvironments() {
if (this.projectId) {
this.$get('/api/environment/list/' + this.projectId, response => {
this.environments = response.data;
this.environments.forEach(environment => {
parseEnvironment(environment);
});
});
} else {
this.environment = undefined;
}
},
openEnvironmentConfig() {
if (!this.projectId) {
this.$error(this.$t('api_test.select_project'));
return;
}
this.$refs.environmentConfig.open(this.projectId);
},
environmentChange(value) {
for (let i in this.environments) {
if (this.environments[i].id === value) {
this.environment = this.environments[i];
break;
}
}
},
environmentConfigClose() {
this.getEnvironments();
},
setEnvironment(data) {
this.$emit('setEnvironment', data);
this.$emit('setEnvironment', data.id);
},
search() {
if (this.priorities && this.condition.order) {

View File

@ -79,14 +79,14 @@
</div>
</el-col>
</el-row>
<el-divider ></el-divider>
<el-divider></el-divider>
</div>
<!-- 请求参数-->
<el-collapse-transition>
<div v-if="apiCase.active||type==='detail'">
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
<ms-api-request-form :isShowEnable="true" :showScript="true" :is-read-only="isReadOnly" :headers="apiCase.request.headers " :request="apiCase.request" v-if="api.protocol==='HTTP'"/>
<ms-api-request-form :isShowEnable="true" :showScript="true" :is-read-only="isReadOnly" :headers="apiCase.request.headers " :request="apiCase.request" v-if="api.protocol==='HTTP'"/>
<ms-tcp-basis-parameters :showScript="true" :request="apiCase.request" v-if="api.protocol==='TCP'"/>
<ms-sql-basis-parameters :showScript="true" :request="apiCase.request" v-if="api.protocol==='SQL'"/>
<ms-dubbo-basis-parameters :showScript="true" :request="apiCase.request" v-if="api.protocol==='DUBBO'"/>
@ -169,7 +169,7 @@
return {}
},
},
environment: {},
environment: String,
index: {
type: Number,
default() {
@ -182,7 +182,7 @@
return {}
}
},
type:String,
type: String,
isCaseEdit: Boolean,
},
watch: {},
@ -207,7 +207,12 @@
});
},
singleRun(data) {
if (!this.environment) {
this.$warning(this.$t('api_test.environment.select_environment'));
return;
}
data.message = true;
data.request.useEnvironment = this.environment;
this.saveTestCase(data);
this.$emit('singleRun', data);
},

View File

@ -13,6 +13,7 @@
:apiCaseList="apiCaseList"
:is-read-only="isReadOnly"
:project-id="projectId"
:useEnvironment="useEnvironment"
:is-case-edit="isCaseEdit"
ref="header"
/>
@ -38,7 +39,7 @@
</ms-drawer>
<!-- 执行组件 -->
<ms-run :debug="false" :environment="environment" :reportId="reportId" :run-data="runData" :env-map="envMap"
<ms-run :debug="false" :reportId="reportId" :run-data="runData" :env-map="envMap"
@runRefresh="runRefresh" ref="runTest"/>
<!--批量编辑-->
<ms-batch-edit ref="batchEdit" @batchEdit="batchEdit" :typeArr="typeArr" :value-arr="valueArr"/>
@ -77,7 +78,7 @@
return {
result: {},
grades: [],
environment: {},
environment: "",
isReadOnly: false,
selectedEvent: Object,
priorities: CASE_ORDER,
@ -111,7 +112,8 @@
priority: CASE_PRIORITY,
method: REQ_METHOD,
},
envMap: new Map
envMap: new Map,
useEnvironment: "",
}
},
watch: {
@ -190,8 +192,13 @@
this.$set(item, 'selected', false);
})
}
this.$success(this.$t('organization.integration.successful_operation'));
//
let cases = this.apiCaseList[0];
cases.request.useEnvironment = this.environment;
cases.message = true;
this.$refs.apiCaseItem[0].saveCase(cases);
this.refresh();
this.$success(this.$t('organization.integration.successful_operation'));
},
refresh() {
@ -204,12 +211,13 @@
})
},
getApiTest(addCase) {
this.useEnvironment = "";
if (this.api) {
this.condition.projectId = this.projectId;
if (this.isCaseEdit) {
this.condition.id = this.testCaseId;
}
if(this.api){
if (this.api) {
this.condition.apiDefinitionId = this.api.id;
}
@ -226,7 +234,12 @@
if (!apiCase.request.hashTree) {
apiCase.request.hashTree = [];
}
})
if (!this.useEnvironment && this.apiCaseList[0].request && this.apiCaseList[0].request.useEnvironment) {
this.useEnvironment = this.apiCaseList[0].request.useEnvironment;
this.environment = this.useEnvironment;
}
if (addCase && this.apiCaseList.length == 0 && !this.loaded) {
this.addCase();
}
@ -264,7 +277,7 @@
},
singleRun(row) {
if (!this.environment || !this.environment) {
if (!this.environment) {
this.$warning(this.$t('api_test.environment.select_environment'));
return;
}
@ -274,7 +287,7 @@
row.request.name = row.id;
this.$get('/api/definition/get/' + row.request.id, response => {
row.request.path = response.data.path; // pathpath
row.request.useEnvironment = this.environment.id;
row.request.useEnvironment = this.environment;
row.request.projectId = getCurrentProjectID();
this.runData.push(row.request);
/*触发执行操作*/
@ -293,7 +306,7 @@
this.apiCaseList.forEach(item => {
if (item.selected && item.id) {
item.request.name = item.id;
item.request.useEnvironment = this.environment.id;
item.request.useEnvironment = this.environment;
this.runData.push(item.request);
this.batchLoadingIds.push(item.id);
}

View File

@ -35,7 +35,7 @@
environmentId: ""
}
},
props:['projectId','isReadOnly'],
props:['projectId','isReadOnly','useEnvironment'],
created() {
this.getEnvironments();
},
@ -49,6 +49,9 @@
environmentId() {
this.environmentChange(this.environmentId);
},
useEnvironment(){
this.environmentId = this.useEnvironment;
}
// planEnvironmentId() {
// this.environmentId = this.planEnvironmentId;
// }
@ -60,9 +63,9 @@
this.environments = response.data;
this.environments.forEach(environment => {
parseEnvironment(environment);
// if (this.planEnvironmentId && environment.id === this.planEnvironmentId) {
// this.planEnvironmentId = environment.id;
// }
if (this.useEnvironment && this.useEnvironment.id === environment.id) {
this.environmentId = this.useEnvironment;
}
});
});
} else {

View File

@ -373,7 +373,7 @@ export default {
testId: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}],
method: [{required: true, message: this.$t('test_track.case.input_method'), trigger: 'change'}],
prerequisite: [{max: 500, message: this.$t('test_track.length_less_than') + '500', trigger: 'blur'}],
remark: [{max: 500, message: this.$t('test_track.length_less_than') + '500', trigger: 'blur'}]
remark: [{max: 1000, message: this.$t('test_track.length_less_than') + '1000', trigger: 'blur'}]
},
formLabelWidth: "120px",
operationType: '',
@ -767,7 +767,7 @@ export default {
this.getModuleOptions();
this.getMaintainerOptions();
this.getTestOptions();
this.getDemandOptions()
// this.getDemandOptions()
},
resetForm() {

View File

@ -59,6 +59,19 @@ Vue.directive('tester', tester);
Vue.directive('left-to-right-drag', left2RightDrag);
Vue.directive('right-to-left-drag', right2LeftDrag);
Vue.directive('bottom-to-top-drag', bottom2TopDrag);
// 防止重复点击
Vue.directive('preventReClick', {
inserted(el, binding) {
el.addEventListener('click', () => {
if (!el.disabled) {
el.disabled = true
setTimeout(() => {
el.disabled = false
}, binding.value || 2000)
}
})
}
})
new Vue({
el: '#app',