Merge remote-tracking branch 'origin/v1.3' into v1.3

This commit is contained in:
wenyann 2020-09-28 09:46:15 +08:00
commit 8f672752fc
2 changed files with 14 additions and 7 deletions

View File

@ -115,6 +115,9 @@ export default {
watch: {
test() {
this.initScenarioEnvironment();
},
projectId() {
this.initScenarioEnvironment();
}
},
methods: {
@ -208,9 +211,13 @@ export default {
let env = environmentMap.get(scenario.environmentId);
if (!env) {
scenario.environmentId = undefined;
scenario.environment = undefined;
} else {
scenario.environment = env;
}
} else {
scenario.environmentId = undefined;
scenario.environment = undefined;
}
});
});

View File

@ -26,7 +26,7 @@
<el-form-item v-if="request.useEnvironment" :label="$t('api_test.request.address')" class="adjust-margin-bottom">
<el-tag class="environment-display">
<span class="environment-name">{{ request.environment ? request.environment.name + ': ' : '' }}</span>
<span class="environment-name">{{ scenario.environment ? scenario.environment.name + ': ' : '' }}</span>
<span class="environment-url">{{ displayUrl }}</span>
<span v-if="!displayUrl"
class="environment-url-tip">{{ $t('api_test.request.please_configure_socket_in_environment') }}</span>
@ -49,7 +49,7 @@
<el-tab-pane :label="$t('api_test.request.parameters')" name="parameters">
<ms-api-variable :is-read-only="isReadOnly"
:parameters="request.parameters"
:environment="request.environment"
:environment="scenario.environment"
:scenario="scenario"
:extract="request.extract"
:description="$t('api_test.request.parameters_desc')"/>
@ -62,7 +62,7 @@
:body="request.body"
:scenario="scenario"
:extract="request.extract"
:environment="request.environment"/>
:environment="scenario.environment"/>
</el-tab-pane>
<el-tab-pane :label="$t('api_test.request.assertions.label')" name="assertions">
<ms-api-assertions :is-read-only="isReadOnly" :assertions="request.assertions"/>
@ -148,7 +148,7 @@ export default {
if (!this.request.path) return;
let url = this.getURL(this.displayUrl);
let urlStr = url.origin + url.pathname;
let envUrl = this.request.environment.config.httpConfig.protocol + '://' + this.request.environment.config.httpConfig.socket;
let envUrl = this.scenario.environment.config.httpConfig.protocol + '://' + this.scenario.environment.config.httpConfig.socket;
this.request.path = decodeURIComponent(urlStr.substring(envUrl.length, urlStr.length));
},
getURL(urlStr) {
@ -170,7 +170,7 @@ export default {
}
},
useEnvironmentChange(value) {
if (value && !this.request.environment) {
if (value && !this.scenario.environment) {
this.$error(this.$t('api_test.request.please_add_environment_to_scenario'), 2000);
this.request.useEnvironment = false;
}
@ -191,8 +191,8 @@ export default {
computed: {
displayUrl() {
return (this.request.environment && this.request.environment.config.httpConfig.socket) ?
this.request.environment.config.httpConfig.protocol + '://' + this.request.environment.config.httpConfig.socket + (this.request.path ? this.request.path : '')
return (this.scenario.environment && this.scenario.environment.config.httpConfig.socket) ?
this.scenario.environment.config.httpConfig.protocol + '://' + this.scenario.environment.config.httpConfig.socket + (this.request.path ? this.request.path : '')
: '';
}
}