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

This commit is contained in:
BugKing 2020-12-11 18:14:05 +08:00
commit 204cf502b5
6 changed files with 39 additions and 19 deletions

View File

@ -242,12 +242,16 @@ public class ApiAutomationService {
JSONObject element = JSON.parseObject(item.getScenarioDefinition());
MsScenario scenario = JSONObject.parseObject(item.getScenarioDefinition(), MsScenario.class);
// 多态JSON普通转换会丢失内容需要通过 ObjectMapper 获取
LinkedList<MsTestElement> elements = mapper.readValue(element.getString("hashTree"),
new TypeReference<LinkedList<MsTestElement>>() {});
LinkedList<KeyValue> variables = mapper.readValue(element.getString("variables"),
new TypeReference<LinkedList<KeyValue>>() {});
scenario.setHashTree(elements);
scenario.setVariables(variables);
if (StringUtils.isNotEmpty(element.getString("hashTree"))) {
LinkedList<MsTestElement> elements = mapper.readValue(element.getString("hashTree"),
new TypeReference<LinkedList<MsTestElement>>() {});
scenario.setHashTree(elements);
}
if (StringUtils.isNotEmpty(element.getString("variables"))) {
LinkedList<KeyValue> variables = mapper.readValue(element.getString("variables"),
new TypeReference<LinkedList<KeyValue>>() {});
scenario.setVariables(variables);
}
LinkedList<MsTestElement> scenarios = new LinkedList<>();
scenarios.add(scenario);
group.setHashTree(scenarios);

View File

@ -154,7 +154,10 @@
}
},
handleTabAdd(e) {
let api = {status: "Underway", method: "GET", userId: getCurrentUser().id, url: "", protocol: this.currentProtocol};
let api = {
status: "Underway", method: "GET", userId: getCurrentUser().id,
url: "", protocol: this.currentProtocol, environmentId: ""
};
this.handleTabsEdit(this.$t('api_test.definition.request.title'), e, api);
},
handleTabClose() {

View File

@ -29,7 +29,7 @@
</div>
<label class="ms-api-label">{{$t('test_track.case.priority')}}</label>
<el-select size="small" v-model="item.priority" class="ms-api-select">
<el-select size="small" v-model="item.priority" class="ms-api-select" @change="changePriority(item)">
<el-option v-for="grd in priorities" :key="grd.id" :label="grd.name" :value="grd.id"/>
</el-select>
</el-col>
@ -57,11 +57,11 @@
<el-col :span="4">
<ms-tip-button @click="singleRun(item)" :tip="$t('api_test.run')" icon="el-icon-video-play"
style="background-color: #409EFF;color: white" size="mini" circle/>
style="background-color: #409EFF;color: white" size="mini" :disabled="item.type=='create'" circle/>
<ms-tip-button @click="copyCase(item)" :tip="$t('commons.copy')" icon="el-icon-document-copy"
size="mini" circle/>
size="mini" :disabled="item.type=='create'" circle/>
<ms-tip-button @click="deleteCase(index,item)" :tip="$t('commons.delete')" icon="el-icon-delete"
size="mini" circle/>
size="mini" :disabled="item.type=='create'" circle/>
<ms-api-extend-btns :row="item"/>
</el-col>
@ -222,7 +222,6 @@
this.$warning(this.$t('api_test.environment.select_environment'));
return;
}
this.loading = true;
if (this.apiCaseList.length > 0) {
this.apiCaseList.forEach(item => {
if (item.type != "create") {
@ -231,9 +230,13 @@
this.runData.push(item.request);
}
})
this.loading = true;
/*触发执行操作*/
this.reportId = getUUID().substring(0, 8);
if (this.runData.length > 0) {
this.loading = true;
/*触发执行操作*/
this.reportId = getUUID().substring(0, 8);
} else {
this.$warning("没有可执行的用例!");
}
} else {
this.$warning("没有可执行的用例!");
}
@ -343,6 +346,11 @@
return true;
}
},
changePriority(row) {
if (row.type != 'create') {
this.saveTestCase(row);
}
},
saveTestCase(row) {
if (this.validate(row)) {
return;

View File

@ -64,7 +64,11 @@
break;
}
if (this.currentApi.response != null && this.currentApi.response != 'null' && this.currentApi.response != undefined) {
this.response = new ResponseFactory(JSON.parse(this.currentApi.response));
if (Object.prototype.toString.call(this.currentApi.response).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') {
this.response = this.currentApi.response;
} else {
this.response = new ResponseFactory(JSON.parse(this.currentApi.response));
}
} else {
this.response = {headers: [], body: new Body(), statusCode: [], type: "HTTP"};
}

View File

@ -48,7 +48,7 @@
<el-col :span="3">
<div class="ms-api-header-select">
<el-input size="small" :placeholder="$t('api_test.definition.request.select_case')"
v-model="condition.name" @blur="getApiTest"/>
v-model="condition.name" @blur="getApiTest" @keyup.enter.native="getApiTest"/>
</div>
</el-col>
<el-col :span="2">

View File

@ -236,7 +236,7 @@
let hasEnvironment = false;
for (let i in this.environments) {
if (this.environments[i].id === this.api.environmentId) {
this.api.environment = this.environments[i];
this.api.environmentId = this.environments[i];
hasEnvironment = true;
break;
}
@ -261,7 +261,8 @@
environmentChange(value) {
for (let i in this.environments) {
if (this.environments[i].id === value) {
this.api.request.useEnvironment = this.environments[i].id;
this.api.environmentId = value;
this.api.request.useEnvironment = value;
break;
}
}