Merge branch 'master' of https://github.com/metersphere/metersphere into master
This commit is contained in:
commit
204cf502b5
|
@ -242,12 +242,16 @@ public class ApiAutomationService {
|
||||||
JSONObject element = JSON.parseObject(item.getScenarioDefinition());
|
JSONObject element = JSON.parseObject(item.getScenarioDefinition());
|
||||||
MsScenario scenario = JSONObject.parseObject(item.getScenarioDefinition(), MsScenario.class);
|
MsScenario scenario = JSONObject.parseObject(item.getScenarioDefinition(), MsScenario.class);
|
||||||
// 多态JSON普通转换会丢失内容,需要通过 ObjectMapper 获取
|
// 多态JSON普通转换会丢失内容,需要通过 ObjectMapper 获取
|
||||||
LinkedList<MsTestElement> elements = mapper.readValue(element.getString("hashTree"),
|
if (StringUtils.isNotEmpty(element.getString("hashTree"))) {
|
||||||
new TypeReference<LinkedList<MsTestElement>>() {});
|
LinkedList<MsTestElement> elements = mapper.readValue(element.getString("hashTree"),
|
||||||
LinkedList<KeyValue> variables = mapper.readValue(element.getString("variables"),
|
new TypeReference<LinkedList<MsTestElement>>() {});
|
||||||
new TypeReference<LinkedList<KeyValue>>() {});
|
scenario.setHashTree(elements);
|
||||||
scenario.setHashTree(elements);
|
}
|
||||||
scenario.setVariables(variables);
|
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<>();
|
LinkedList<MsTestElement> scenarios = new LinkedList<>();
|
||||||
scenarios.add(scenario);
|
scenarios.add(scenario);
|
||||||
group.setHashTree(scenarios);
|
group.setHashTree(scenarios);
|
||||||
|
|
|
@ -154,7 +154,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleTabAdd(e) {
|
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);
|
this.handleTabsEdit(this.$t('api_test.definition.request.title'), e, api);
|
||||||
},
|
},
|
||||||
handleTabClose() {
|
handleTabClose() {
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label class="ms-api-label">{{$t('test_track.case.priority')}}</label>
|
<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-option v-for="grd in priorities" :key="grd.id" :label="grd.name" :value="grd.id"/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
@ -57,11 +57,11 @@
|
||||||
|
|
||||||
<el-col :span="4">
|
<el-col :span="4">
|
||||||
<ms-tip-button @click="singleRun(item)" :tip="$t('api_test.run')" icon="el-icon-video-play"
|
<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"
|
<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"
|
<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"/>
|
<ms-api-extend-btns :row="item"/>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
|
@ -222,7 +222,6 @@
|
||||||
this.$warning(this.$t('api_test.environment.select_environment'));
|
this.$warning(this.$t('api_test.environment.select_environment'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.loading = true;
|
|
||||||
if (this.apiCaseList.length > 0) {
|
if (this.apiCaseList.length > 0) {
|
||||||
this.apiCaseList.forEach(item => {
|
this.apiCaseList.forEach(item => {
|
||||||
if (item.type != "create") {
|
if (item.type != "create") {
|
||||||
|
@ -231,9 +230,13 @@
|
||||||
this.runData.push(item.request);
|
this.runData.push(item.request);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.loading = true;
|
if (this.runData.length > 0) {
|
||||||
/*触发执行操作*/
|
this.loading = true;
|
||||||
this.reportId = getUUID().substring(0, 8);
|
/*触发执行操作*/
|
||||||
|
this.reportId = getUUID().substring(0, 8);
|
||||||
|
} else {
|
||||||
|
this.$warning("没有可执行的用例!");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.$warning("没有可执行的用例!");
|
this.$warning("没有可执行的用例!");
|
||||||
}
|
}
|
||||||
|
@ -343,6 +346,11 @@
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
changePriority(row) {
|
||||||
|
if (row.type != 'create') {
|
||||||
|
this.saveTestCase(row);
|
||||||
|
}
|
||||||
|
},
|
||||||
saveTestCase(row) {
|
saveTestCase(row) {
|
||||||
if (this.validate(row)) {
|
if (this.validate(row)) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -64,7 +64,11 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (this.currentApi.response != null && this.currentApi.response != 'null' && this.currentApi.response != undefined) {
|
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 {
|
} else {
|
||||||
this.response = {headers: [], body: new Body(), statusCode: [], type: "HTTP"};
|
this.response = {headers: [], body: new Body(), statusCode: [], type: "HTTP"};
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
<el-col :span="3">
|
<el-col :span="3">
|
||||||
<div class="ms-api-header-select">
|
<div class="ms-api-header-select">
|
||||||
<el-input size="small" :placeholder="$t('api_test.definition.request.select_case')"
|
<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>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="2">
|
<el-col :span="2">
|
||||||
|
|
|
@ -236,7 +236,7 @@
|
||||||
let hasEnvironment = false;
|
let hasEnvironment = false;
|
||||||
for (let i in this.environments) {
|
for (let i in this.environments) {
|
||||||
if (this.environments[i].id === this.api.environmentId) {
|
if (this.environments[i].id === this.api.environmentId) {
|
||||||
this.api.environment = this.environments[i];
|
this.api.environmentId = this.environments[i];
|
||||||
hasEnvironment = true;
|
hasEnvironment = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,8 @@
|
||||||
environmentChange(value) {
|
environmentChange(value) {
|
||||||
for (let i in this.environments) {
|
for (let i in this.environments) {
|
||||||
if (this.environments[i].id === value) {
|
if (this.environments[i].id === value) {
|
||||||
this.api.request.useEnvironment = this.environments[i].id;
|
this.api.environmentId = value;
|
||||||
|
this.api.request.useEnvironment = value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue