fix(接口测试): 修复插件数据源不能动态切换问题

This commit is contained in:
fit2-zhao 2022-04-21 14:07:08 +08:00 committed by fit2-zhao
parent 9ad0401fe3
commit fc1d966cb2
5 changed files with 18 additions and 11 deletions

View File

@ -210,6 +210,7 @@ public class ApiScenarioImportUtil {
object.put("resourceId", test.getId()); object.put("resourceId", test.getId());
object.put("projectId", projectId); object.put("projectId", projectId);
object.put("useEnvironment",""); object.put("useEnvironment","");
object.put("environmentId","");
object.put("url",""); object.put("url","");
JSONObject objectNew = JSONObject.parseObject(object.toJSONString(), Feature.DisableSpecialKeyDetect); JSONObject objectNew = JSONObject.parseObject(object.toJSONString(), Feature.DisableSpecialKeyDetect);
objectNew.remove("refType"); objectNew.remove("refType");
@ -252,6 +253,7 @@ public class ApiScenarioImportUtil {
object.put("resourceId", apiTestCase.getId()); object.put("resourceId", apiTestCase.getId());
object.put("projectId", projectId); object.put("projectId", projectId);
object.put("useEnvironment",""); object.put("useEnvironment","");
object.put("environmentId","");
JSONObject objectNew = JSONObject.parseObject(object.toJSONString(),Feature.DisableSpecialKeyDetect); JSONObject objectNew = JSONObject.parseObject(object.toJSONString(),Feature.DisableSpecialKeyDetect);
objectNew.remove("refType"); objectNew.remove("refType");
objectNew.remove("referenced"); objectNew.remove("referenced");

View File

@ -43,7 +43,7 @@
<div class="el-step__icon-inner">{{ request.preSize }}</div> <div class="el-step__icon-inner">{{ request.preSize }}</div>
</div> </div>
</span> </span>
<ms-jmx-step :request="request" :apiId="request.id" :response="response" :tab-type="'pre'" ref="preStep"/> <ms-jmx-step :request="request" :apiId="request.id" :is-scenario="true" :response="response" :tab-type="'pre'" ref="preStep"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="$t('api_test.definition.request.post_operation')" name="postOperate"> <el-tab-pane :label="$t('api_test.definition.request.post_operation')" name="postOperate">
<span class="item-tabs" effect="dark" placement="top-start" slot="label"> <span class="item-tabs" effect="dark" placement="top-start" slot="label">
@ -52,7 +52,7 @@
<div class="el-step__icon-inner">{{ request.postSize }}</div> <div class="el-step__icon-inner">{{ request.postSize }}</div>
</div> </div>
</span> </span>
<ms-jmx-step :request="request" :apiId="request.id" :response="response" :tab-type="'post'" ref="postStep"/> <ms-jmx-step :request="request" :apiId="request.id" :is-scenario="true" :response="response" :tab-type="'post'" ref="postStep"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="$t('api_test.definition.request.assertions_rule')" name="assertionsRule"> <el-tab-pane :label="$t('api_test.definition.request.assertions_rule')" name="assertionsRule">
<span class="item-tabs" effect="dark" placement="top-start" slot="label"> <span class="item-tabs" effect="dark" placement="top-start" slot="label">
@ -62,7 +62,7 @@
</div> </div>
</span> </span>
<div style="margin-right: 20px"> <div style="margin-right: 20px">
<ms-jmx-step :request="request" :apiId="request.id" :response="response" @reload="reload" :tab-type="'assertionsRule'" ref="assertionsRule"/> <ms-jmx-step :request="request" :apiId="request.id" :is-scenario="true" :response="response" @reload="reload" :tab-type="'assertionsRule'" ref="assertionsRule"/>
</div> </div>
</el-tab-pane> </el-tab-pane>

View File

@ -348,11 +348,15 @@ export default {
}); });
}, },
singleRun(data) { singleRun(data) {
if (this.api.protocol !== "SQL" && this.api.protocol != "DUBBO" && this.api.protocol != "dubbo://" && !this.environment) { if (data.apiMethod !== "SQL" && data.apiMethod !== "DUBBO" && data.apiMethod !== "dubbo://" && data.apiMethod !== "TCP" && !this.environment) {
this.$warning(this.$t('api_test.environment.select_environment')); this.$warning(this.$t('api_test.environment.select_environment'));
return; return;
} }
if (data.apiMethod !== "SQL" && data.apiMethod !== "DUBBO" && data.apiMethod !== "dubbo://" && data.apiMethod !== "TCP") {
data.request.useEnvironment = this.environment; data.request.useEnvironment = this.environment;
} else {
data.request.useEnvironment = data.request.environmentId;
}
this.$emit('singleRun', data); this.$emit('singleRun', data);
}, },
stop(data) { stop(data) {

View File

@ -386,7 +386,7 @@ export default {
this.$emit('showExecResult', row); this.$emit('showExecResult', row);
}, },
singleRun(row) { singleRun(row) {
if (this.currentApi.protocol !== "SQL" && this.currentApi.protocol !== "DUBBO" && this.currentApi.protocol !== "dubbo://" && !this.environment) { if (row.apiMethod !== "SQL" && row.apiMethod !== "DUBBO" && row.apiMethod !== "dubbo://" && row.apiMethod !== "TCP" && !this.environment) {
this.$warning(this.$t('api_test.environment.select_environment')); this.$warning(this.$t('api_test.environment.select_environment'));
return; return;
} }
@ -394,7 +394,11 @@ export default {
this.singleLoading = true; this.singleLoading = true;
this.singleRunId = row.id; this.singleRunId = row.id;
row.request.name = row.id; row.request.name = row.id;
if (row.apiMethod !== "SQL" && row.apiMethod !== "DUBBO" && row.apiMethod !== "dubbo://" && row.apiMethod !== "TCP") {
row.request.useEnvironment = this.environment; row.request.useEnvironment = this.environment;
} else {
row.request.useEnvironment = row.request.environmentId;
}
row.request.projectId = this.projectId; row.request.projectId = this.projectId;
row.request.id = row.id; row.request.id = row.id;
this.runData.push(row.request); this.runData.push(row.request);

View File

@ -63,10 +63,7 @@
:description="$t('api_test.scenario.kv_description')"/> :description="$t('api_test.scenario.kv_description')"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="$t('api_test.request.sql.sql_script')" name="sql"> <el-tab-pane :label="$t('api_test.request.sql.sql_script')" name="sql">
<div class="sql-content"> <ms-code-edit mode="sql" :read-only="isReadOnly" :modes="['sql']" :data.sync="request.query" :height="200" theme="eclipse" ref="codeEdit"/>
<ms-code-edit mode="sql" :read-only="isReadOnly" :modes="['sql']" :data.sync="request.query"
theme="eclipse" ref="codeEdit"/>
</div>
</el-tab-pane> </el-tab-pane>
<!-- 脚本步骤/断言步骤 --> <!-- 脚本步骤/断言步骤 -->
<el-tab-pane :label="$t('api_test.definition.request.pre_operation')" name="preOperate" v-if="showScript"> <el-tab-pane :label="$t('api_test.definition.request.pre_operation')" name="preOperate" v-if="showScript">