fix(接口自动化) 修复场景停止错误问题

--bug=1006759 --user=赵勇 【接口自动化】调试场景,点击终止过程中,报错“e.websocket.close is not a function” https://www.tapd.cn/55049933/s/1049332
This commit is contained in:
fit2-zhao 2021-09-22 15:52:31 +08:00 committed by fit2-zhao
parent 4dd9594329
commit 0963ee55b6
6 changed files with 68 additions and 48 deletions

View File

@ -98,6 +98,8 @@ export function saveScenario(url, scenario, scenarioDefinition, _this,success) {
if (success) { if (success) {
success(response); success(response);
} }
}, error => {
_this.$emit('errorRefresh', {});
}); });
} }

View File

@ -258,7 +258,7 @@
<!--执行组件--> <!--执行组件-->
<ms-run :debug="true" v-if="type!=='detail'" :environment="projectEnvMap" :reportId="reportId" :saved="!debug" <ms-run :debug="true" v-if="type!=='detail'" :environment="projectEnvMap" :reportId="reportId" :saved="!debug"
:run-data="debugData" :run-data="debugData"
@runRefresh="runRefresh" ref="runTest"/> @runRefresh="runRefresh" @errorRefresh="errorRefresh" ref="runTest"/>
<!-- 调试结果 --> <!-- 调试结果 -->
<el-drawer v-if="type!=='detail'" :visible.sync="debugVisible" :destroy-on-close="true" direction="ltr" <el-drawer v-if="type!=='detail'" :visible.sync="debugVisible" :destroy-on-close="true" direction="ltr"
:withHeader="true" :modal="false" size="90%"> :withHeader="true" :modal="false" size="90%">
@ -553,6 +553,7 @@ export default {
let url = "/api/automation/stop/" + this.reportId; let url = "/api/automation/stop/" + this.reportId;
this.$get(url, response => { this.$get(url, response => {
this.debugLoading = false; this.debugLoading = false;
try {
if (this.websocket) { if (this.websocket) {
this.websocket.close(); this.websocket.close();
} }
@ -563,6 +564,9 @@ export default {
this.clearDebug(); this.clearDebug();
this.$success(this.$t('report.test_stop_success')); this.$success(this.$t('report.test_stop_success'));
this.reload(); this.reload();
} catch (e) {
this.debugLoading = false;
}
}); });
}, },
clearDebug() { clearDebug() {
@ -1391,6 +1395,13 @@ export default {
this.initMessageSocket(); this.initMessageSocket();
} }
}, },
errorRefresh() {
this.debug = false;
this.isTop = false;
this.debugLoading = false;
this.debugVisible = false;
this.loading = false;
},
showScenarioParameters() { showScenarioParameters() {
this.$refs.scenarioParameters.open(this.currentScenario.variables, this.currentScenario.headers); this.$refs.scenarioParameters.open(this.currentScenario.variables, this.currentScenario.headers);
}, },

View File

@ -2,19 +2,21 @@
<div class="card-container"> <div class="card-container">
<el-card class="card-content"> <el-card class="card-content">
<el-button size="small" type="primary" class="ms-api-button" style="float: right;margin-right: 20px" @click="stop" v-if="isStop">
{{ $t('report.stop_btn') }}
</el-button>
<div v-else>
<el-button v-if="scenario" style="float: right;margin-right: 20px" size="small" type="primary" <el-button v-if="scenario" style="float: right;margin-right: 20px" size="small" type="primary"
@click="handleCommand"> {{ $t('commons.test') }} @click="handleCommand"> {{ $t('commons.test') }}
</el-button> </el-button>
<el-dropdown v-else split-button type="primary" class="ms-api-buttion" @click="handleCommand" <el-dropdown v-else split-button type="primary" class="ms-api-button" @click="handleCommand"
@command="handleCommand" size="small" style="float: right;margin-right: 20px"> @command="handleCommand" size="small" style="float: right;margin-right: 20px">
{{ $t('commons.test') }} {{ $t('commons.test') }}
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="save_as">{{ $t('api_test.definition.request.save_as_case') }}</el-dropdown-item> <el-dropdown-item command="save_as">{{ $t('api_test.definition.request.save_as_case') }}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
<el-button size="small" type="primary" class="ms-api-buttion" style="float: right;margin-right: 20px" @click="stop" v-if="isStop"> </div>
{{ $t('report.stop_btn') }}
</el-button>
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p> <p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
<div v-loading="loading"> <div v-loading="loading">
<!-- 请求参数 --> <!-- 请求参数 -->

View File

@ -19,18 +19,18 @@
{{ $t('report.stop_btn') }} {{ $t('report.stop_btn') }}
</el-button> </el-button>
<div v-else> <div v-else>
<el-dropdown split-button type="primary" class="ms-api-buttion" @click="handleCommand" <el-dropdown split-button type="primary" class="ms-api-button" @click="handleCommand"
@command="handleCommand" size="small" v-if="testCase===undefined && !scenario"> @command="handleCommand" size="small" v-if="testCase===undefined && !scenario">
{{ $t('commons.test') }} {{ $t('commons.test') }}
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="save_as">{{ $t('api_test.definition.request.save_as_case') }}</el-dropdown-item> <el-dropdown-item command="save_as">{{ $t('api_test.definition.request.save_as_case') }}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</div>
<el-button v-if="scenario" size="small" type="primary" @click="handleCommand"> <el-button v-if="scenario" size="small" type="primary" @click="handleCommand">
{{ $t('commons.test') }} {{ $t('commons.test') }}
</el-button> </el-button>
</div>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div v-loading="loading"> <div v-loading="loading">

View File

@ -2,19 +2,21 @@
<div class="card-container"> <div class="card-container">
<el-card class="card-content"> <el-card class="card-content">
<el-button size="small" type="primary" class="ms-api-button" style="float: right;margin-right: 20px" @click="stop" v-if="isStop">
{{ $t('report.stop_btn') }}
</el-button>
<div v-else>
<el-button v-if="scenario" style="float: right;margin-right: 20px" size="small" type="primary" <el-button v-if="scenario" style="float: right;margin-right: 20px" size="small" type="primary"
@click="handleCommand"> {{ $t('commons.test') }} @click="handleCommand"> {{ $t('commons.test') }}
</el-button> </el-button>
<el-dropdown v-else split-button type="primary" class="ms-api-buttion" @click="handleCommand" <el-dropdown v-else split-button type="primary" class="ms-api-button" @click="handleCommand"
@command="handleCommand" size="small" style="float: right;margin-right: 20px"> @command="handleCommand" size="small" style="float: right;margin-right: 20px">
{{ $t('commons.test') }} {{ $t('commons.test') }}
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="save_as">{{ $t('api_test.definition.request.save_as_case') }}</el-dropdown-item> <el-dropdown-item command="save_as">{{ $t('api_test.definition.request.save_as_case') }}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
<el-button size="small" type="primary" class="ms-api-buttion" style="float: right;margin-right: 20px" @click="stop" v-if="isStop"> </div>
{{ $t('report.stop_btn') }}
</el-button>
<p class="tip">{{ $t('api_test.definition.request.req_param') }} </p> <p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
<div v-loading="loading"> <div v-loading="loading">
<!-- JDBC 请求参数 --> <!-- JDBC 请求参数 -->

View File

@ -11,9 +11,14 @@
<el-input-number v-model="request.port" controls-position="right" :min="0" :max="65535" size="small"/> <el-input-number v-model="request.port" controls-position="right" :min="0" :max="65535" size="small"/>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button size="small" type="primary" @click="stop" v-if="isStop">
{{ $t('report.stop_btn') }}
</el-button>
<div v-else>
<el-button v-if="scenario" size="small" type="primary" @click="handleCommand"> {{ $t('commons.test') }} <el-button v-if="scenario" size="small" type="primary" @click="handleCommand"> {{ $t('commons.test') }}
</el-button> </el-button>
<el-dropdown v-else split-button type="primary" class="ms-api-buttion" @click="handleCommand" <el-dropdown v-else split-button type="primary" class="ms-api-button" @click="handleCommand"
@command="handleCommand" size="small" style="float: right;margin-right: 20px"> @command="handleCommand" size="small" style="float: right;margin-right: 20px">
{{ $t('commons.test') }} {{ $t('commons.test') }}
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
@ -21,9 +26,7 @@
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
<el-button size="small" type="primary" @click="stop" v-if="isStop"> </div>
{{ $t('report.stop_btn') }}
</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div v-loading="loading"> <div v-loading="loading">