fix(测试用例,接口定义,接口自动化): 增加默认模块,默认创建用例都放到默认模块下

This commit is contained in:
fit2-zhao 2021-03-30 13:55:32 +08:00
parent cc07843e12
commit 6303bcb42e
10 changed files with 68 additions and 45 deletions

View File

@ -190,7 +190,7 @@
this.activeName = name;
let currentScenario = {
status: "Underway", principal: getCurrentUser().id,
apiScenarioModuleId: "root", id: getUUID(),
apiScenarioModuleId: "default-module", id: getUUID(),
modulePath: "/" + this.$t("commons.module_title")
};
if (this.nodeTree && this.nodeTree.length > 0) {

View File

@ -117,6 +117,9 @@
if (this.currentModule && this.currentModule.id != "root") {
this.scenarioForm.modulePath = this.currentModule.method !== undefined ? this.currentModule.method : null;
this.scenarioForm.apiScenarioModuleId = this.currentModule.id;
}else{
this.scenarioForm.modulePath = this.$t("commons.module_title");
this.scenarioForm.apiScenarioModuleId = "default-module";
}
},
getMaintainerOptions() {

View File

@ -29,7 +29,7 @@
@refresh="refresh"
ref="basisScenario"/>
<api-import ref="apiImport" :moduleOptions="extendTreeNodes" @refreshAll="$emit('refreshAll')"/>
<api-import ref="apiImport" :moduleOptions="data" @refreshAll="$emit('refreshAll')"/>
</div>
</template>
@ -82,9 +82,7 @@
trashEnable: false
},
data: [],
extendTreeNodes: [],
currentModule: undefined,
moduleOptions: [],
operators: [
{
label: this.$t('api_test.automation.add_scenario'),
@ -141,11 +139,16 @@
this.result = this.$get("/api/automation/module/list/" + this.projectId, response => {
if (response.data != undefined && response.data != null) {
this.data = response.data;
let moduleOptions = [];
this.data.forEach(node => {
buildNodePath(node, {path: ''}, moduleOptions);
this.data.unshift({
"id": "default-module",
"name": this.$t('commons.module_title'),
"level": 0,
"path": "/" + this.$t('commons.module_title'),
"children": [],
});
this.data.forEach(node => {
buildTree(node, {path: ''});
});
this.moduleOptions = moduleOptions
}
});
this.$refs.apiImport.open(this.currentModule);
@ -163,11 +166,16 @@
this.result = this.$get("/api/automation/module/list/" + this.projectId, response => {
if (response.data != undefined && response.data != null) {
this.data = response.data;
let moduleOptions = [];
this.data.forEach(node => {
buildNodePath(node, {path: ''}, moduleOptions);
this.data.unshift({
"id": "default-module",
"name": this.$t('commons.module_title'),
"level": 0,
"path": "/" + this.$t('commons.module_title'),
"children": [],
});
this.data.forEach(node => {
buildTree(node, {path: ''});
});
this.moduleOptions = moduleOptions
}
});
this.$refs.apiImport.open(this.currentModule);
@ -188,17 +196,17 @@
this.result = this.$get(url, response => {
if (response.data != undefined && response.data != null) {
this.data = response.data;
this.extendTreeNodes = [];
this.extendTreeNodes.unshift({
"id": "root",
this.data.unshift({
"id": "default-module",
"name": this.$t('commons.module_title'),
"level": 0,
"children": this.data,
"path": "/" + this.$t('commons.module_title'),
"children": [],
});
this.extendTreeNodes.forEach(node => {
this.data.forEach(node => {
buildTree(node, {path: ''});
});
this.$emit('setModuleOptions', this.extendTreeNodes);
this.$emit('setModuleOptions', this.data);
this.$emit('setNodeTree', this.data);
if (this.$refs.nodeTree) {
this.$refs.nodeTree.filter(this.condition.filterText);

View File

@ -84,7 +84,7 @@
callback();
};
return {
httpForm: {environmentId: "", moduleId: "root"},
httpForm: {environmentId: "", moduleId: "default-module"},
moduleOptions: [],
httpVisible: false,
currentModule: {},
@ -251,13 +251,13 @@
let url = "/api/module/list/" + getCurrentProjectID() + "/" + data.protocol;
this.result = this.$get(url, response => {
if (response.data != undefined && response.data != null) {
let data = response.data;
this.moduleOptions = [];
this.moduleOptions = response.data;
this.moduleOptions.unshift({
"id": "root",
"id": "default-module",
"name": this.$t('commons.module_title'),
"level": 0,
"children": data,
"path": "/" + this.$t('commons.module_title'),
"children": [],
});
this.moduleOptions.forEach(node => {
buildTree(node, {path: ''});
@ -282,7 +282,7 @@
data.protocol = "DUBBO";
}
data.id = getUUID();
this.httpForm = {id: data.id, name: data.name, protocol: data.protocol, path: data.path, method: api.method, userId: getCurrentUser().id, request: data, moduleId: "root"};
this.httpForm = {id: data.id, name: data.name, protocol: data.protocol, path: data.path, method: api.method, userId: getCurrentUser().id, request: data, moduleId: "default-module"};
this.getMaintainerOptions();
this.list(data);
this.httpVisible = true;

View File

@ -32,7 +32,7 @@
</el-tooltip>
<slot name="button"></slot>
<el-tooltip content="Copy" placement="top">
<el-button size="mini" icon="el-icon-copy-document" circle @click="copyRow" style="padding: 5px"/>
<el-button size="mini" icon="el-icon-copy-document" circle @click="copyRow" style="padding: 5px" :disabled="data.disabled && !data.root"/>
</el-tooltip>
<step-extend-btns style="display: contents" :data="data" @copy="copyRow" @remove="remove" @openScenario="openScenario" v-if="showBtn && (!data.disabled || data.root)"/>
</div>

View File

@ -154,6 +154,9 @@
if (this.currentModule != null) {
this.httpForm.modulePath = this.currentModule.method != undefined ? this.currentModule.method : null;
this.httpForm.moduleId = this.currentModule.id;
} else {
this.httpForm.modulePath = this.$t("commons.module_title");
this.httpForm.moduleId = "default-module";
}
},

View File

@ -114,8 +114,8 @@ export default {
this.testCaseForm.nodePath = this.currentModule.path;
this.testCaseForm.nodeId = this.currentModule.id;
} else {
this.testCaseForm.nodePath = "/全部用例"
this.testCaseForm.nodeId = "root"
this.testCaseForm.nodePath = "/默认模块"
this.testCaseForm.nodeId = "default-module"
}
this.result = this.$post(path, this.testCaseForm, response => {
this.testCaseForm.id = response.data.id

View File

@ -35,7 +35,7 @@
<el-col :span="7">
<el-form-item :label="$t('test_track.case.module')" :label-width="formLabelWidth" prop="module">
<ms-select-tree :disabled="readOnly" :data="moduleOptions" :defaultKey="form.module" :obj="moduleObj"
<ms-select-tree :disabled="readOnly" :data="treeNodes" :defaultKey="form.module" :obj="moduleObj"
@getValue="setModule" clearable checkStrictly size="small" />
</el-form-item>
</el-col>
@ -314,7 +314,7 @@ export default {
dialogFormVisible: false,
form: {
name: '',
module: 'root',
module: 'default-module',
nodePath:'',
maintainer: getCurrentUser().id,
priority: 'P0',
@ -416,10 +416,6 @@ export default {
};
});
}, 1000);
if(this.selectNode && this.selectNode.data){
this.form.module = this.selectNode.data.id;
this.form.nodePath = this.selectNode.data.path;
}
},
watch: {
treeNodes() {
@ -432,7 +428,14 @@ export default {
created() {
this.loadOptions();
this.addListener(); // ctrl s
if(this.selectNode && this.selectNode.data && this.form.id){
this.form.module = this.selectNode.data.id;
this.form.nodePath = this.selectNode.data.path;
}
if (this.type === 'edit' || this.type === 'copy') {
this.form.module = this.currentTestCaseInfo.nodeId;
this.form.nodePath = this.currentTestCaseInfo.nodePath;
}
},
methods: {
setModule(id,data) {
@ -836,16 +839,11 @@ export default {
this.getTestOptions()
},
getModuleOptions() {
this.moduleOptions = [];
this.moduleOptions.unshift({
"id": "root",
"name": this.$t('commons.module_title'),
"level": 0,
"children": this.treeNodes,
});
this.moduleOptions.forEach(node => {
buildTree(node, {path: ''});
let moduleOptions = [];
this.treeNodes.forEach(node => {
buildNodePath(node, {path: ''}, moduleOptions);
});
this.moduleOptions = moduleOptions;
},
getMaintainerOptions() {
let workspaceId = localStorage.getItem(WORKSPACE_ID);

View File

@ -32,7 +32,7 @@
<span v-if="!disabled" class="node-operate child">
<el-tooltip
v-if="data.id != 'root'"
v-if="data.id != 'root' && data.id !='default-module'"
class="item"
effect="dark"
:open-delay="200"
@ -49,7 +49,7 @@
<i @click.stop="append(node, data)" class="el-icon-circle-plus-outline"></i>
</el-tooltip>
<el-tooltip
v-if="data.id != 'root'"
v-if="data.id != 'root' && data.id !='default-module'"
class="item" effect="dark"
:open-delay="200"
:content="$t('commons.delete')"

View File

@ -37,6 +37,7 @@ import MsNodeTree from "./NodeTree";
import TestCaseCreate from "@/business/components/track/case/components/TestCaseCreate";
import TestCaseImport from "@/business/components/track/case/components/TestCaseImport";
import MsSearchBar from "@/business/components/common/components/search/MsSearchBar";
import {buildTree} from "../../api/definition/model/NodeTree";
export default {
name: "TestCaseNodeTree",
@ -115,6 +116,16 @@ export default {
if (this.projectId) {
this.result = this.$get("/case/node/list/" + this.projectId, response => {
this.treeNodes = response.data;
this.treeNodes.unshift({
"id": "default-module",
"name": this.$t('commons.module_title'),
"level": 0,
"path": "/" + this.$t('commons.module_title'),
"children": [],
});
this.treeNodes.forEach(node => {
buildTree(node, {path: ''});
});
if (this.$refs.nodeTree) {
this.$refs.nodeTree.filter();
}