fix(接口自动化): 修复部分缺陷

This commit is contained in:
fit2-zhao 2021-01-22 18:12:05 +08:00
parent 8f45254225
commit 4e38c73ac5
8 changed files with 203 additions and 135 deletions

View File

@ -169,7 +169,7 @@
</include> </include>
</if> </if>
<if test="${condition}.creator != null"> <if test="${condition}.creator != null">
and t1.user_id and t1.create_user_id
<include refid="condition"> <include refid="condition">
<property name="object" value="${condition}.creator"/> <property name="object" value="${condition}.creator"/>
</include> </include>

View File

@ -42,7 +42,7 @@
"vue-papa-parse": "^2.0.0", "vue-papa-parse": "^2.0.0",
"vue-pdf": "^4.2.0", "vue-pdf": "^4.2.0",
"vue-router": "^3.1.3", "vue-router": "^3.1.3",
"vuedraggable": "^2.23.2", "vuedraggable": "^2.24.3",
"vuex": "^3.1.2", "vuex": "^3.1.2",
"xml-js": "^1.6.11", "xml-js": "^1.6.11",
"yan-progress": "^1.0.3" "yan-progress": "^1.0.3"

View File

@ -1028,4 +1028,16 @@
right: 50px; right: 50px;
z-index: 1; z-index: 1;
} }
/deep/ .el-tree-node__expand-icon.expanded {
color: #7C3985;
}
/deep/ .el-icon-caret-right {
color: #7C3985;
}
/deep/ .is-leaf {
color: transparent;
}
</style> </style>

View File

@ -4,7 +4,9 @@
:class="[size ? 'el-input-tag--' + size : '']" :class="[size ? 'el-input-tag--' + size : '']"
style="height: auto" style="height: auto"
@click="foucusTagInput"> @click="foucusTagInput">
<el-tag <el-tag
class="ms-top"
v-for="(tag, idx) in innerTags" v-for="(tag, idx) in innerTags"
v-bind="$attrs" v-bind="$attrs"
type="info" type="info"
@ -13,7 +15,7 @@
:closable="!readOnly" :closable="!readOnly"
:disable-transitions="false" :disable-transitions="false"
@close="remove(idx)"> @close="remove(idx)">
{{tag}} {{tag && tag.length>10? tag.substring(0,10)+"...":tag}}
</el-tag> </el-tag>
<input <input
v-if="!readOnly" v-if="!readOnly"
@ -167,4 +169,5 @@
height: 36px; height: 36px;
line-height: 36px; line-height: 36px;
} }
</style> </style>

View File

@ -1,6 +1,6 @@
<template> <template>
<el-dialog :close-on-click-modal="false" :title="$t('api_test.automation.scenario_ref')" :visible.sync="visible" <el-dialog :close-on-click-modal="false" :title="$t('api_test.automation.scenario_ref')" :visible.sync="visible"
width="45%" :destroy-on-close="true"> width="45%" :destroy-on-close="true" append-to-body>
<span>{{ $t('api_test.automation.scenario_ref') }}</span> <span>{{ $t('api_test.automation.scenario_ref') }}</span>
<div class="refs" v-loading="scenarioLoading"> <div class="refs" v-loading="scenarioLoading">
<div v-for="(item, index) in scenarioRefs" :key="index" class="el-button--text">{{ item.name }}</div> <div v-for="(item, index) in scenarioRefs" :key="index" class="el-button--text">{{ item.name }}</div>
@ -23,41 +23,41 @@
<script> <script>
export default { export default {
name: "MsReferenceView", name: "MsReferenceView",
components: {}, components: {},
data() { data() {
return { return {
visible: false, visible: false,
scenarioLoading: false, scenarioLoading: false,
scenarioRefs: [], scenarioRefs: [],
planRefs: [] planRefs: []
} }
},
methods: {
getReferenceData(row) {
this.scenarioLoading = true;
this.scenarioRefs = [];
this.$post("/api/automation/getReference/", row, response => {
this.scenarioRefs = response.data.scenarioList;
this.planRefs = response.data.testPlanList;
this.scenarioLoading = false;
})
}, },
open(row) { methods: {
this.getReferenceData(row); getReferenceData(row) {
this.visible = true this.scenarioLoading = true;
this.scenarioRefs = [];
this.$post("/api/automation/getReference/", row, response => {
this.scenarioRefs = response.data.scenarioList;
this.planRefs = response.data.testPlanList;
this.scenarioLoading = false;
})
},
open(row) {
this.getReferenceData(row);
this.visible = true
}
} }
} }
}
</script> </script>
<style scoped> <style scoped>
.refs { .refs {
min-height: 50px; min-height: 50px;
max-height: 200px; max-height: 200px;
overflow-y: auto; overflow-y: auto;
font-size: 12px; font-size: 12px;
padding-bottom: 10px; padding-bottom: 10px;
} }
</style> </style>

View File

@ -1,16 +1,19 @@
<template> <template>
<el-dropdown @command="handleCommand" class="scenario-ext-btn"> <div>
<el-link type="primary" :underline="false"> <el-dropdown @command="handleCommand" class="scenario-ext-btn">
<el-icon class="el-icon-more"></el-icon> <el-link type="primary" :underline="false">
</el-link> <el-icon class="el-icon-more"></el-icon>
<el-dropdown-menu slot="dropdown"> </el-link>
<el-dropdown-item command="ref">{{ $t('api_test.automation.view_ref') }}</el-dropdown-item> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="schedule" v-tester>{{ $t('api_test.automation.schedule') }}</el-dropdown-item> <el-dropdown-item command="ref">{{ $t('api_test.automation.view_ref') }}</el-dropdown-item>
<el-dropdown-item command="create_performance" v-tester>{{ $t('api_test.create_performance_test') }}</el-dropdown-item> <el-dropdown-item command="schedule" v-tester>{{ $t('api_test.automation.schedule') }}</el-dropdown-item>
</el-dropdown-menu> <el-dropdown-item command="create_performance" v-tester>{{ $t('api_test.create_performance_test') }}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<ms-reference-view ref="viewRef"/> <ms-reference-view ref="viewRef"/>
<ms-schedule-maintain ref="scheduleMaintain" @refreshTable="refreshTable" /> <ms-schedule-maintain ref="scheduleMaintain" @refreshTable="refreshTable"/>
</el-dropdown>
</div>
</template> </template>
<script> <script>
@ -20,7 +23,7 @@
export default { export default {
name: "MsScenarioExtendButtons", name: "MsScenarioExtendButtons",
components: { MsReferenceView,MsScheduleMaintain}, components: {MsReferenceView, MsScheduleMaintain},
props: { props: {
row: Object row: Object
}, },
@ -61,7 +64,7 @@
}) })
}); });
}, },
refreshTable(){ refreshTable() {
} }
} }

View File

@ -3,41 +3,50 @@
<span class="kv-description" v-if="description"> <span class="kv-description" v-if="description">
{{ description }} {{ description }}
</span> </span>
<div class="kv-row" v-for="(item, index) in items" :key="index"> <ms-draggable element="ul" @update="endChange"
<el-row type="flex" :gutter="20" justify="space-between" align="middle"> v-model="keyValues" v-bind="{draggable:'.item'}">
<el-col class="kv-checkbox" v-if="isShowEnable"> <div class="kv-row item" v-for="(item, index) in keyValues" :key="index">
<input type="checkbox" v-if="!isDisable(index)" v-model="item.enable" <el-row type="flex" :gutter="20" justify="space-between" align="middle">
:disabled="isReadOnly"/> <el-button icon="el-icon-sort" circle size="mini"/>
</el-col>
<el-col> <el-col class="kv-checkbox" v-if="isShowEnable">
<el-input v-if="!suggestions" :disabled="isReadOnly" v-model="item.name" size="small" maxlength="200" <input type="checkbox" v-if="!isDisable(index)" v-model="item.enable"
@change="change" :disabled="isReadOnly"/>
:placeholder="keyText" show-word-limit/> </el-col>
<el-autocomplete :disabled="isReadOnly" :maxlength="200" v-if="suggestions" v-model="item.name" size="small"
:fetch-suggestions="querySearch" @change="change" :placeholder="keyText"
show-word-limit/>
</el-col> <el-col class="item">
<el-input v-if="!suggestions" :disabled="isReadOnly" v-model="item.name" size="small" maxlength="200"
@change="change"
:placeholder="keyText" show-word-limit/>
<el-autocomplete :disabled="isReadOnly" :maxlength="200" v-if="suggestions" v-model="item.name" size="small"
:fetch-suggestions="querySearch" @change="change" :placeholder="keyText"
show-word-limit/>
<el-col> </el-col>
<el-input :disabled="isReadOnly" v-model="item.value" size="small" @change="change"
:placeholder="valueText" show-word-limit/> <el-col class="item">
</el-col> <el-input :disabled="isReadOnly" v-model="item.value" size="small" @change="change"
<el-col class="kv-delete"> :placeholder="valueText" show-word-limit/>
<el-button size="mini" class="el-icon-delete-solid" circle @click="remove(index)" </el-col>
:disabled="isDisable(index) || isReadOnly"/> <el-col class="item kv-delete">
</el-col> <el-button size="mini" class="el-icon-delete-solid" circle @click="remove(index)"
</el-row> :disabled="isDisable(index) || isReadOnly"/>
</div> </el-col>
</el-row>
</div>
</ms-draggable>
</div> </div>
</template> </template>
<script> <script>
import {KeyValue} from "../model/ApiTestModel"; import {KeyValue} from "../model/ApiTestModel";
import MsDraggable from 'vuedraggable'
export default { export default {
name: "MsApiKeyValue", name: "MsApiKeyValue",
components: {
MsDraggable
},
props: { props: {
keyPlaceholder: String, keyPlaceholder: String,
@ -55,7 +64,9 @@
suggestions: Array, suggestions: Array,
}, },
data() { data() {
return {} return {
keyValues: [],
}
}, },
computed: { computed: {
keyText() { keyText() {
@ -104,11 +115,27 @@
return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0); return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
}; };
}, },
endChange(env) {
if (env.newIndex == env.oldIndex) {
return;
}
let newItem = this.keyValues[env.newIndex];
let oldItem = this.keyValues[env.oldIndex];
this.$set(this.keyValues, env.oldIndex, oldItem);
this.$set(this.keyValues, env.newIndex, newItem)
this.items.forEach(item => {
this.items.splice(0);
})
this.keyValues.forEach(item => {
this.items.push(item);
})
}
}, },
created() { created() {
if (this.items.length === 0 || this.items[this.items.length - 1].name) { if (this.items.length === 0 || this.items[this.items.length - 1].name) {
this.items.push(new KeyValue({enable: true})); this.items.push(new KeyValue({enable: true}));
} }
this.keyValues = this.items;
} }
} }
</script> </script>

View File

@ -3,80 +3,85 @@
<span class="kv-description" v-if="description"> <span class="kv-description" v-if="description">
{{ description }} {{ description }}
</span> </span>
<ms-draggable element="ul" @update="endChange"
v-model="keyValues" v-bind="{draggable:'.item'}">
<div class="kv-row" v-for="(item, index) in parameters" :key="index"> <div class="item kv-row" v-for="(item, index) in keyValues" :key="index">
<el-row type="flex" :gutter="20" justify="space-between" align="middle"> <el-row type="flex" :gutter="20" justify="space-between" align="middle">
<el-col class="kv-checkbox" v-if="isShowEnable"> <el-button icon="el-icon-sort" circle size="mini"/>
<input type="checkbox" v-if="!isDisable(index)" v-model="item.enable"
:disabled="isReadOnly"/>
</el-col>
<el-col> <el-col class="kv-checkbox" v-if="isShowEnable">
<el-input v-if="!suggestions" :disabled="isReadOnly" v-model="item.name" size="small" maxlength="200" <input type="checkbox" v-if="!isDisable(index)" v-model="item.enable"
@change="change" :placeholder="keyText" show-word-limit> :disabled="isReadOnly"/>
<template v-slot:prepend> </el-col>
<el-select v-if="type === 'body'" :disabled="isReadOnly" class="kv-type" v-model="item.type"
@change="typeChange(item)">
<el-option value="text"/>
<el-option value="file"/>
</el-select>
</template>
</el-input>
<el-autocomplete :disabled="isReadOnly" v-if="suggestions" v-model="item.name" size="small" <el-col class="item">
:fetch-suggestions="querySearch" @change="change" :placeholder="keyText" show-word-limit/> <el-input v-if="!suggestions" :disabled="isReadOnly" v-model="item.name" size="small" maxlength="200"
@change="change" :placeholder="keyText" show-word-limit>
<template v-slot:prepend>
<el-select v-if="type === 'body'" :disabled="isReadOnly" class="kv-type" v-model="item.type"
@change="typeChange(item)">
<el-option value="text"/>
<el-option value="file"/>
</el-select>
</template>
</el-input>
</el-col> <el-autocomplete :disabled="isReadOnly" v-if="suggestions" v-model="item.name" size="small"
:fetch-suggestions="querySearch" @change="change" :placeholder="keyText" show-word-limit/>
<el-col class="kv-select"> </el-col>
<el-select v-model="item.required" size="small">
<el-option v-for="req in requireds" :key="req.id" :label="req.name" :value="req.id"/>
</el-select>
</el-col>
<el-col v-if="item.type !== 'file'"> <el-col class="item kv-select">
<el-autocomplete <el-select v-model="item.required" size="small">
:disabled="isReadOnly" <el-option v-for="req in requireds" :key="req.id" :label="req.name" :value="req.id"/>
size="small" </el-select>
class="input-with-autocomplete" </el-col>
v-model="item.value"
:fetch-suggestions="funcSearch"
:placeholder="valueText"
value-key="name"
highlight-first-item
@select="change">
<i slot="suffix" class="el-input__icon el-icon-edit pointer" @click="advanced(item)"></i>
</el-autocomplete>
</el-col>
<el-col> <el-col class="item" v-if="item.type !== 'file'">
<el-input v-model="item.description" size="small" maxlength="200" <el-autocomplete
:placeholder="$t('commons.description')" show-word-limit> :disabled="isReadOnly"
</el-input> size="small"
class="input-with-autocomplete"
v-model="item.value"
:fetch-suggestions="funcSearch"
:placeholder="valueText"
value-key="name"
highlight-first-item
@select="change">
<i slot="suffix" class="el-input__icon el-icon-edit pointer" @click="advanced(item)"></i>
</el-autocomplete>
</el-col>
<el-autocomplete :disabled="isReadOnly" v-if="suggestions" v-model="item.name" size="small" <el-col class="item">
:fetch-suggestions="querySearch" @change="change" :placeholder="keyText" show-word-limit/> <el-input v-model="item.description" size="small" maxlength="200"
:placeholder="$t('commons.description')" show-word-limit>
</el-input>
</el-col> <el-autocomplete :disabled="isReadOnly" v-if="suggestions" v-model="item.name" size="small"
:fetch-suggestions="querySearch" @change="change" :placeholder="keyText" show-word-limit/>
<el-col v-if="item.type === 'file'"> </el-col>
<ms-api-body-file-upload :parameter="item"/>
</el-col>
<el-col v-if="type === 'body'" class="kv-select"> <el-col v-if="item.type === 'file'" class="item">
<el-input :disabled="isReadOnly" v-model="item.contentType" size="small" <ms-api-body-file-upload :parameter="item"/>
@change="change" :placeholder="$t('api_test.request.content_type')" show-word-limit> </el-col>
</el-input>
</el-col>
<el-col class="kv-delete"> <el-col v-if="type === 'body'" class="item kv-select">
<el-button size="mini" class="el-icon-delete-solid" circle @click="remove(index)" <el-input :disabled="isReadOnly" v-model="item.contentType" size="small"
:disabled="isDisable(index) || isReadOnly"/> @change="change" :placeholder="$t('api_test.request.content_type')" show-word-limit>
</el-col> </el-input>
</el-col>
<el-col class="item kv-delete">
<el-button size="mini" class="el-icon-delete-solid" circle @click="remove(index)"
:disabled="isDisable(index) || isReadOnly"/>
</el-col>
</el-row> </el-row>
</div> </div>
</ms-draggable>
<ms-api-variable-advance ref="variableAdvance" :environment="environment" :scenario="scenario" <ms-api-variable-advance ref="variableAdvance" :environment="environment" :scenario="scenario"
:parameters="parameters" :parameters="parameters"
:current-item="currentItem"/> :current-item="currentItem"/>
@ -89,10 +94,11 @@
import MsApiVariableAdvance from "./ApiVariableAdvance"; import MsApiVariableAdvance from "./ApiVariableAdvance";
import MsApiBodyFileUpload from "./body/ApiBodyFileUpload"; import MsApiBodyFileUpload from "./body/ApiBodyFileUpload";
import {REQUIRED} from "../model/JsonData"; import {REQUIRED} from "../model/JsonData";
import MsDraggable from 'vuedraggable'
export default { export default {
name: "MsApiVariable", name: "MsApiVariable",
components: {MsApiBodyFileUpload, MsApiVariableAdvance}, components: {MsApiBodyFileUpload, MsApiVariableAdvance, MsDraggable},
props: { props: {
keyPlaceholder: String, keyPlaceholder: String,
valuePlaceholder: String, valuePlaceholder: String,
@ -118,7 +124,8 @@
data() { data() {
return { return {
currentItem: null, currentItem: null,
requireds: REQUIRED requireds: REQUIRED,
keyValues: [],
} }
}, },
computed: { computed: {
@ -196,6 +203,21 @@
} else { } else {
item.contentType = 'text/plain'; item.contentType = 'text/plain';
} }
},
endChange(env) {
if (env.newIndex == env.oldIndex) {
return;
}
let newItem = this.keyValues[env.newIndex];
let oldItem = this.keyValues[env.oldIndex];
this.$set(this.keyValues, env.oldIndex, oldItem);
this.$set(this.keyValues, env.newIndex, newItem)
this.parameters.forEach(item => {
this.parameters.splice(0);
})
this.keyValues.forEach(item => {
this.parameters.push(item);
})
} }
}, },
created() { created() {
@ -208,6 +230,7 @@
contentType: 'text/plain' contentType: 'text/plain'
})); }));
} }
this.keyValues = this.parameters;
} }
} }
</script> </script>