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,16 +553,20 @@ 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;
if (this.websocket) { try {
this.websocket.close(); if (this.websocket) {
this.websocket.close();
}
if (this.messageWebSocket) {
this.messageWebSocket.close();
}
this.clearNodeStatus(this.$refs.stepTree.root.childNodes);
this.clearDebug();
this.$success(this.$t('report.test_stop_success'));
this.reload();
} catch (e) {
this.debugLoading = false;
} }
if (this.messageWebSocket) {
this.messageWebSocket.close();
}
this.clearNodeStatus(this.$refs.stepTree.root.childNodes);
this.clearDebug();
this.$success(this.$t('report.test_stop_success'));
this.reload();
}); });
}, },
clearDebug() { clearDebug() {
@ -889,9 +893,9 @@ export default {
}, },
fabClick() { fabClick() {
if (this.operatingElements && this.operatingElements.length < 1) { if (this.operatingElements && this.operatingElements.length < 1) {
if(this.selectedTreeNode && this.selectedTreeNode.referenced === 'REF' || this.selectedTreeNode.disabled) { if (this.selectedTreeNode && this.selectedTreeNode.referenced === 'REF' || this.selectedTreeNode.disabled) {
this.$warning("引用的场景步骤及子步骤都无法添加其他步骤"); this.$warning("引用的场景步骤及子步骤都无法添加其他步骤");
}else{ } else {
this.$warning("当前步骤下不能添加其他步骤"); this.$warning("当前步骤下不能添加其他步骤");
} }
} }
@ -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 v-if="scenario" style="float: right;margin-right: 20px" size="small" type="primary" <el-button size="small" type="primary" class="ms-api-button" style="float: right;margin-right: 20px" @click="stop" v-if="isStop">
@click="handleCommand"> {{ $t('commons.test') }}
</el-button>
<el-dropdown v-else split-button type="primary" class="ms-api-buttion" @click="handleCommand"
@command="handleCommand" size="small" style="float: right;margin-right: 20px">
{{ $t('commons.test') }}
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="save_as">{{ $t('api_test.definition.request.save_as_case') }}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<el-button size="small" type="primary" class="ms-api-buttion" style="float: right;margin-right: 20px" @click="stop" v-if="isStop">
{{ $t('report.stop_btn') }} {{ $t('report.stop_btn') }}
</el-button> </el-button>
<div v-else>
<el-button v-if="scenario" style="float: right;margin-right: 20px" size="small" type="primary"
@click="handleCommand"> {{ $t('commons.test') }}
</el-button>
<el-dropdown v-else split-button type="primary" class="ms-api-button" @click="handleCommand"
@command="handleCommand" size="small" style="float: right;margin-right: 20px">
{{ $t('commons.test') }}
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="save_as">{{ $t('api_test.definition.request.save_as_case') }}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
<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>
<el-button v-if="scenario" size="small" type="primary" @click="handleCommand">
{{ $t('commons.test') }}
</el-button>
</div> </div>
<el-button v-if="scenario" size="small" type="primary" @click="handleCommand">
{{ $t('commons.test') }}
</el-button>
</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 v-if="scenario" style="float: right;margin-right: 20px" size="small" type="primary" <el-button size="small" type="primary" class="ms-api-button" style="float: right;margin-right: 20px" @click="stop" v-if="isStop">
@click="handleCommand"> {{ $t('commons.test') }}
</el-button>
<el-dropdown v-else split-button type="primary" class="ms-api-buttion" @click="handleCommand"
@command="handleCommand" size="small" style="float: right;margin-right: 20px">
{{ $t('commons.test') }}
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="save_as">{{ $t('api_test.definition.request.save_as_case') }}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<el-button size="small" type="primary" class="ms-api-buttion" style="float: right;margin-right: 20px" @click="stop" v-if="isStop">
{{ $t('report.stop_btn') }} {{ $t('report.stop_btn') }}
</el-button> </el-button>
<div v-else>
<el-button v-if="scenario" style="float: right;margin-right: 20px" size="small" type="primary"
@click="handleCommand"> {{ $t('commons.test') }}
</el-button>
<el-dropdown v-else split-button type="primary" class="ms-api-button" @click="handleCommand"
@command="handleCommand" size="small" style="float: right;margin-right: 20px">
{{ $t('commons.test') }}
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="save_as">{{ $t('api_test.definition.request.save_as_case') }}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
<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,19 +11,22 @@
<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 v-if="scenario" size="small" type="primary" @click="handleCommand"> {{ $t('commons.test') }}
</el-button>
<el-dropdown v-else split-button type="primary" class="ms-api-buttion" @click="handleCommand"
@command="handleCommand" size="small" style="float: right;margin-right: 20px">
{{ $t('commons.test') }}
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="save_as">{{ $t('api_test.definition.request.save_as_case') }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<el-button size="small" type="primary" @click="stop" v-if="isStop"> <el-button size="small" type="primary" @click="stop" v-if="isStop">
{{ $t('report.stop_btn') }} {{ $t('report.stop_btn') }}
</el-button> </el-button>
<div v-else>
<el-button v-if="scenario" size="small" type="primary" @click="handleCommand"> {{ $t('commons.test') }}
</el-button>
<el-dropdown v-else split-button type="primary" class="ms-api-button" @click="handleCommand"
@command="handleCommand" size="small" style="float: right;margin-right: 20px">
{{ $t('commons.test') }}
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="save_as">{{ $t('api_test.definition.request.save_as_case') }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div v-loading="loading"> <div v-loading="loading">