fix(接口测试): 引用的场景支持禁用启用

This commit is contained in:
chenjianxing 2020-11-27 17:57:23 +08:00
parent c0329ce42a
commit c53fe5ac4a
5 changed files with 36 additions and 9 deletions

View File

@ -21,4 +21,5 @@ public class Scenario {
private TCPConfig tcpConfig;
private List<DatabaseConfig> databaseConfigs;
private Boolean enable;
private Boolean referenceEnable;
}

View File

@ -171,7 +171,11 @@ export default {
let scenarios = [];
this.test.scenarioDefinition.forEach(scenario => {
if (scenario.isReference()) {
if (scenarioMap[scenario.id]) scenarios.push(scenarioMap[scenario.id]);
if (scenarioMap[scenario.id]) {
let item = scenarioMap[scenario.id];
item.referenceEnable = scenario.referenceEnable;
scenarios.push(item);
}
} else {
scenarios.push(scenario);
}

View File

@ -5,7 +5,7 @@
<ms-api-collapse v-model="activeName" @change="handleChange">
<draggable :list="scenarios" group="Scenario" class="scenario-draggable" ghost-class="scenario-ghost">
<ms-api-collapse-item v-for="(scenario, index) in scenarios" :key="index"
:title="scenario.name" :name="index" :class="{'disable-scenario': !scenario.enable}">
:title="scenario.name" :name="index" :class="{'disable-scenario': !scenario.isEnable()}">
<template slot="title">
<div class="scenario-name">
<el-tag type="info" size="small" v-if="scenario.isReference()">{{
@ -26,11 +26,11 @@
<el-dropdown-item :disabled="isReadOnly" :command="{type:'delete', index:index}">
{{ $t('api_test.scenario.delete') }}
</el-dropdown-item>
<el-dropdown-item v-if="scenario.enable" :disabled="isReadOnly"
<el-dropdown-item v-if="scenario.isEnable()" :disabled="isReadOnly"
:command="{type:'disable', index:index}">
{{ $t('api_test.scenario.disable') }}
</el-dropdown-item>
<el-dropdown-item v-if="!scenario.enable" :disabled="isReadOnly"
<el-dropdown-item v-if="!scenario.isEnable()" :disabled="isReadOnly"
:command="{type:'enable', index:index}">
{{ $t('api_test.scenario.enable') }}
</el-dropdown-item>
@ -156,10 +156,20 @@ export default {
}
},
disableScenario(index) {
this.scenarios[index].enable = false;
let scenario = this.scenarios[index];
if (scenario.isReference()) {
scenario.referenceEnable = false;
} else {
scenario.enable = false;
}
},
enableScenario(index) {
this.scenarios[index].enable = true;
let scenario = this.scenarios[index];
if (scenario.isReference()) {
scenario.referenceEnable = true;
} else {
scenario.enable = true;
}
},
handleChange(index) {
this.select(this.scenarios[index]);

View File

@ -3,7 +3,7 @@
<draggable :list="this.scenario.requests" group="Request" class="request-draggable" ghost-class="request-ghost"
:disabled="isReference">
<div class="request-item" v-for="(request, index) in this.scenario.requests" :key="index" @click="select(request)"
:class="{'selected': isSelected(request), 'disable-request': !request.enable || !scenario.enable}">
:class="{'selected': isSelected(request), 'disable-request': isEnable(request)}">
<ms-condition-label :request="request"/>
<el-row type="flex" align="middle">
<div class="request-type">
@ -180,7 +180,10 @@ export default {
request.dubboConfig = this.scenario.dubboConfig;
this.selected = request;
this.$emit("select", request, this.scenario);
}
},
isEnable(request) {
return !request.enable || !this.scenario.isEnable();
},
},
created() {

View File

@ -230,6 +230,7 @@ export class Scenario extends BaseConfig {
this.databaseConfigs = [];
this.tcpConfig = undefined;
this.assertions = undefined;
this.referenceEnable = undefined;
this.set(options);
this.sets({
@ -271,6 +272,14 @@ export class Scenario extends BaseConfig {
isReference() {
return this.id.indexOf("#") !== -1
}
isEnable() {
if (this.isReference()) {
return this.referenceEnable;
} else {
return this.enable;
}
}
}
class DubboConfig extends BaseConfig {
@ -1144,7 +1153,7 @@ class JMXGenerator {
addScenarios(testPlan, testId, scenarios) {
scenarios.forEach(s => {
if (s.enable) {
if (s.isEnable()) {
let scenario = s.clone();
let threadGroup = new ThreadGroup(scenario.name || "");