refactor(场景自动化): 回退运行环境配置
This commit is contained in:
parent
3f4dda8ccb
commit
47120c97cb
|
@ -114,9 +114,7 @@
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<env-popover :env-map="projectEnvMap" :project-ids="projectIds" @setProjectEnvMap="setProjectEnvMap"
|
<env-popover :env-map="projectEnvMap" :project-ids="projectIds" @setProjectEnvMap="setProjectEnvMap"
|
||||||
:project-list="projectList" ref="envPopover"
|
:project-list="projectList" ref="envPopover"/>
|
||||||
:disabled="scenarioDefinition.length < 1"
|
|
||||||
:is-read-only="scenarioDefinition.length < 1"/>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="3">
|
<el-col :span="3">
|
||||||
<el-button :disabled="scenarioDefinition.length < 1" size="mini" type="primary" v-prevent-re-click @click="runDebug">{{$t('api_test.request.debug')}}</el-button>
|
<el-button :disabled="scenarioDefinition.length < 1" size="mini" type="primary" v-prevent-re-click @click="runDebug">{{$t('api_test.request.debug')}}</el-button>
|
||||||
|
@ -202,10 +200,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<maximize-scenario :scenario-definition="scenarioDefinition" :envMap="projectEnvMap" :moduleOptions="moduleOptions"
|
<maximize-scenario :scenario-definition="scenarioDefinition" :envMap="projectEnvMap" :moduleOptions="moduleOptions"
|
||||||
:currentScenario="currentScenario" :type="type" ref="maximizeScenario" @openScenario="openScenario"
|
:currentScenario="currentScenario" :type="type" ref="maximizeScenario" @openScenario="openScenario"/>
|
||||||
:isHaveExec.sync="isHaveExec" :isExecWithOutEnv.sync="isExecWithOutEnv" :projectList="projectList"
|
|
||||||
:projectIds.sync="projectIds"
|
|
||||||
/>
|
|
||||||
</ms-drawer>
|
</ms-drawer>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -320,8 +315,6 @@
|
||||||
projectList: [],
|
projectList: [],
|
||||||
debugResult: new Map,
|
debugResult: new Map,
|
||||||
drawer: false,
|
drawer: false,
|
||||||
isHaveExec: false,
|
|
||||||
isExecWithOutEnv: true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -596,25 +589,9 @@
|
||||||
if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].loopType === "LOOP_COUNT" && arr[i].hashTree && arr[i].hashTree.length > 1) {
|
if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].loopType === "LOOP_COUNT" && arr[i].hashTree && arr[i].hashTree.length > 1) {
|
||||||
arr[i].countController.proceed = true;
|
arr[i].countController.proceed = true;
|
||||||
}
|
}
|
||||||
|
if (!arr[i].projectId) {
|
||||||
let type = arr[i].type;
|
// 如果自身没有ID并且场景有ID则赋值场景ID,否则赋值当前项目ID
|
||||||
const canExec = this.checkCanExec(type);
|
arr[i].projectId = scenarioProjectId ? scenarioProjectId : this.projectId;
|
||||||
if (!this.isHaveExec) {
|
|
||||||
// 判断此步骤是否可执行
|
|
||||||
this.isHaveExec = canExec;
|
|
||||||
}
|
|
||||||
if (canExec) {
|
|
||||||
const execWithOutEnv = this.canExecWithOutEnv(type, arr[i].url);
|
|
||||||
if (!execWithOutEnv) {
|
|
||||||
if (!arr[i].projectId) {
|
|
||||||
// 如果自身没有ID并且场景有ID则赋值场景ID,否则赋值当前项目ID
|
|
||||||
arr[i].projectId = scenarioProjectId ? scenarioProjectId : this.projectId;
|
|
||||||
}
|
|
||||||
this.projectIds.add(arr[i].projectId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.isExecWithOutEnv) {
|
|
||||||
this.isExecWithOutEnv = this.canExecWithOutEnv(type, arr[i].url)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) {
|
if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) {
|
||||||
|
@ -626,24 +603,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
canExecWithOutEnv(type, path) {
|
|
||||||
if (type === ELEMENT_TYPE.HTTPSamplerProxy) {
|
|
||||||
return this.isHTTPFullPath(path);
|
|
||||||
}
|
|
||||||
return type === ELEMENT_TYPE.JSR223Processor ? true : !this.checkCanExec(type);
|
|
||||||
},
|
|
||||||
isHTTPFullPath(path) {
|
|
||||||
return path ? path.startsWith("http://") || path.startsWith("https://") : false;
|
|
||||||
},
|
|
||||||
checkCanExec(type) {
|
|
||||||
const allCanExecType = ELEMENTS.get("AllCanExecType");
|
|
||||||
const index = allCanExecType.indexOf(type);
|
|
||||||
return index !== -1;
|
|
||||||
},
|
|
||||||
sort() {
|
sort() {
|
||||||
this.projectIds.clear();
|
|
||||||
this.isHaveExec = false;
|
|
||||||
this.isExecWithOutEnv = true;
|
|
||||||
for (let i in this.scenarioDefinition) {
|
for (let i in this.scenarioDefinition) {
|
||||||
// 排序
|
// 排序
|
||||||
this.scenarioDefinition[i].index = Number(i) + 1;
|
this.scenarioDefinition[i].index = Number(i) + 1;
|
||||||
|
@ -657,22 +617,6 @@
|
||||||
this.scenarioDefinition[i].projectId = this.projectId;
|
this.scenarioDefinition[i].projectId = this.projectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
let type = this.scenarioDefinition[i].type;
|
|
||||||
const canExec = this.checkCanExec(type);
|
|
||||||
if (!this.isHaveExec) {
|
|
||||||
// 判断此步骤是否可执行
|
|
||||||
this.isHaveExec = canExec;
|
|
||||||
}
|
|
||||||
if (canExec) {
|
|
||||||
const execWithOutEnv = this.canExecWithOutEnv(type, this.scenarioDefinition[i].url);
|
|
||||||
if (!execWithOutEnv) {
|
|
||||||
this.projectIds.add(this.scenarioDefinition[i].projectId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.isExecWithOutEnv) {
|
|
||||||
this.isExecWithOutEnv = this.canExecWithOutEnv(type, this.scenarioDefinition[i].url)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.scenarioDefinition[i].hashTree != undefined && this.scenarioDefinition[i].hashTree.length > 0) {
|
if (this.scenarioDefinition[i].hashTree != undefined && this.scenarioDefinition[i].hashTree.length > 0) {
|
||||||
this.recursiveSorting(this.scenarioDefinition[i].hashTree, this.scenarioDefinition[i].projectId);
|
this.recursiveSorting(this.scenarioDefinition[i].hashTree, this.scenarioDefinition[i].projectId);
|
||||||
}
|
}
|
||||||
|
@ -693,6 +637,7 @@
|
||||||
this.customizeRequest = {};
|
this.customizeRequest = {};
|
||||||
this.sort();
|
this.sort();
|
||||||
this.reload();
|
this.reload();
|
||||||
|
this.initProjectIds();
|
||||||
},
|
},
|
||||||
addScenario(arr) {
|
addScenario(arr) {
|
||||||
if (arr && arr.length > 0) {
|
if (arr && arr.length > 0) {
|
||||||
|
@ -715,6 +660,7 @@
|
||||||
this.isBtnHide = false;
|
this.isBtnHide = false;
|
||||||
this.sort();
|
this.sort();
|
||||||
this.reload();
|
this.reload();
|
||||||
|
this.initProjectIds();
|
||||||
},
|
},
|
||||||
setApiParameter(item, refType, referenced) {
|
setApiParameter(item, refType, referenced) {
|
||||||
let request = {};
|
let request = {};
|
||||||
|
@ -756,6 +702,7 @@
|
||||||
this.isBtnHide = false;
|
this.isBtnHide = false;
|
||||||
this.sort();
|
this.sort();
|
||||||
this.reload();
|
this.reload();
|
||||||
|
this.initProjectIds();
|
||||||
},
|
},
|
||||||
getMaintainerOptions() {
|
getMaintainerOptions() {
|
||||||
let workspaceId = localStorage.getItem(WORKSPACE_ID);
|
let workspaceId = localStorage.getItem(WORKSPACE_ID);
|
||||||
|
@ -782,6 +729,7 @@
|
||||||
hashTree.splice(index, 1);
|
hashTree.splice(index, 1);
|
||||||
this.sort();
|
this.sort();
|
||||||
this.reload();
|
this.reload();
|
||||||
|
this.initProjectIds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -812,19 +760,11 @@
|
||||||
},
|
},
|
||||||
runDebug() {
|
runDebug() {
|
||||||
/*触发执行操作*/
|
/*触发执行操作*/
|
||||||
if (!this.isHaveExec) {
|
let sign = this.$refs.envPopover.checkEnv();
|
||||||
this.$warning("无可执行步骤!");
|
if (!sign) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 运行时是否需要检查环境
|
|
||||||
if (!this.isExecWithOutEnv) {
|
|
||||||
let sign = this.$refs.envPopover.checkEnv();
|
|
||||||
if (!sign) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$refs['currentScenario'].validate((valid) => {
|
this.$refs['currentScenario'].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
Promise.all([
|
Promise.all([
|
||||||
|
@ -1063,6 +1003,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.sort();
|
this.sort();
|
||||||
|
this.initProjectIds();
|
||||||
// this.getEnvironments();
|
// this.getEnvironments();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1132,8 +1073,19 @@
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
refReload() {
|
refReload() {
|
||||||
|
this.initProjectIds();
|
||||||
this.reload();
|
this.reload();
|
||||||
},
|
},
|
||||||
|
initProjectIds() {
|
||||||
|
// 加载环境配置
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.projectIds.clear();
|
||||||
|
this.scenarioDefinition.forEach(data => {
|
||||||
|
let arr = jsonPath.query(data, "$..projectId");
|
||||||
|
arr.forEach(a => this.projectIds.add(a));
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
detailRefresh(result) {
|
detailRefresh(result) {
|
||||||
// 把执行结果分发给各个请求
|
// 把执行结果分发给各个请求
|
||||||
this.debugResult = result;
|
this.debugResult = result;
|
||||||
|
|
|
@ -164,7 +164,6 @@
|
||||||
type: String,
|
type: String,
|
||||||
scenarioDefinition: Array,
|
scenarioDefinition: Array,
|
||||||
envMap: Map,
|
envMap: Map,
|
||||||
projectList: Array
|
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
MsVariableList,
|
MsVariableList,
|
||||||
|
@ -225,10 +224,8 @@
|
||||||
response: {},
|
response: {},
|
||||||
projectIds: new Set,
|
projectIds: new Set,
|
||||||
projectEnvMap: new Map,
|
projectEnvMap: new Map,
|
||||||
// projectList: [],
|
projectList: [],
|
||||||
debugResult: new Map,
|
debugResult: new Map,
|
||||||
isHaveExec: false,
|
|
||||||
isExecWithOutEnv: true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -502,27 +499,8 @@
|
||||||
if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].loopType === "LOOP_COUNT" && arr[i].hashTree && arr[i].hashTree.length > 1) {
|
if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].loopType === "LOOP_COUNT" && arr[i].hashTree && arr[i].hashTree.length > 1) {
|
||||||
arr[i].countController.proceed = true;
|
arr[i].countController.proceed = true;
|
||||||
}
|
}
|
||||||
let type = arr[i].type;
|
if (!arr[i].projectId) {
|
||||||
const canExec = this.checkCanExec(type);
|
arr[i].projectId = scenarioProjectId ? scenarioProjectId : this.projectId;
|
||||||
if (!this.isHaveExec) {
|
|
||||||
// 判断此步骤是否可执行
|
|
||||||
this.isHaveExec = canExec;
|
|
||||||
this.$emit("update:isHaveExec", canExec);
|
|
||||||
}
|
|
||||||
if (canExec) {
|
|
||||||
const execWithOutEnv = this.canExecWithOutEnv(type, arr[i].url);
|
|
||||||
if (!execWithOutEnv) {
|
|
||||||
if (!arr[i].projectId) {
|
|
||||||
// 如果自身没有ID并且场景有ID则赋值场景ID,否则赋值当前项目ID
|
|
||||||
arr[i].projectId = scenarioProjectId ? scenarioProjectId : this.projectId;
|
|
||||||
}
|
|
||||||
this.projectIds.add(arr[i].projectId);
|
|
||||||
this.$emit('update:projectIds', this.projectIds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.isExecWithOutEnv) {
|
|
||||||
this.isExecWithOutEnv = this.canExecWithOutEnv(type, arr[i].url);
|
|
||||||
this.$emit('update:isExecWithOutEnv', this.canExecWithOutEnv(type, arr[i].url))
|
|
||||||
}
|
}
|
||||||
if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) {
|
if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) {
|
||||||
this.recursiveSorting(arr[i].hashTree, arr[i].projectId);
|
this.recursiveSorting(arr[i].hashTree, arr[i].projectId);
|
||||||
|
@ -533,27 +511,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
canExecWithOutEnv(type, path) {
|
|
||||||
if (type === ELEMENT_TYPE.HTTPSamplerProxy) {
|
|
||||||
return this.isHTTPFullPath(path);
|
|
||||||
}
|
|
||||||
return type === ELEMENT_TYPE.JSR223Processor ? true : !this.checkCanExec(type);
|
|
||||||
},
|
|
||||||
isHTTPFullPath(path) {
|
|
||||||
return path ? path.startsWith("http://") || path.startsWith("https://") : false;
|
|
||||||
},
|
|
||||||
checkCanExec(type) {
|
|
||||||
const allCanExecType = ELEMENTS.get("AllCanExecType");
|
|
||||||
const index = allCanExecType.indexOf(type);
|
|
||||||
return index !== -1;
|
|
||||||
},
|
|
||||||
sort() {
|
sort() {
|
||||||
this.projectIds.clear();
|
|
||||||
this.$emit('update:projectIds', this.projectIds);
|
|
||||||
this.isHaveExec = false;
|
|
||||||
this.isExecWithOutEnv = true;
|
|
||||||
this.$emit('update:isHaveExec', false);
|
|
||||||
this.$emit('update:isExecWithOutEnv', true);
|
|
||||||
for (let i in this.scenarioDefinition) {
|
for (let i in this.scenarioDefinition) {
|
||||||
// 排序
|
// 排序
|
||||||
this.scenarioDefinition[i].index = Number(i) + 1;
|
this.scenarioDefinition[i].index = Number(i) + 1;
|
||||||
|
@ -567,25 +525,6 @@
|
||||||
this.scenarioDefinition[i].projectId = this.projectId;
|
this.scenarioDefinition[i].projectId = this.projectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
let type = this.scenarioDefinition[i].type;
|
|
||||||
const canExec = this.checkCanExec(type);
|
|
||||||
if (!this.isHaveExec) {
|
|
||||||
// 判断此步骤是否可执行
|
|
||||||
this.isHaveExec = canExec;
|
|
||||||
this.$emit('update:isHaveExec', canExec);
|
|
||||||
}
|
|
||||||
if (canExec) {
|
|
||||||
const execWithOutEnv = this.canExecWithOutEnv(type, this.scenarioDefinition[i].url);
|
|
||||||
if (!execWithOutEnv) {
|
|
||||||
this.projectIds.add(this.scenarioDefinition[i].projectId);
|
|
||||||
this.$emit('update:projectIds', this.projectIds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.isExecWithOutEnv) {
|
|
||||||
this.isExecWithOutEnv = this.canExecWithOutEnv(type, this.scenarioDefinition[i].url);
|
|
||||||
this.$emit('update:isExecWithOutEnv', this.canExecWithOutEnv(type, this.scenarioDefinition[i].url));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.scenarioDefinition[i].hashTree != undefined && this.scenarioDefinition[i].hashTree.length > 0) {
|
if (this.scenarioDefinition[i].hashTree != undefined && this.scenarioDefinition[i].hashTree.length > 0) {
|
||||||
this.recursiveSorting(this.scenarioDefinition[i].hashTree, this.scenarioDefinition[i].projectId);
|
this.recursiveSorting(this.scenarioDefinition[i].hashTree, this.scenarioDefinition[i].projectId);
|
||||||
}
|
}
|
||||||
|
@ -606,6 +545,7 @@
|
||||||
this.customizeRequest = {};
|
this.customizeRequest = {};
|
||||||
this.sort();
|
this.sort();
|
||||||
this.reload();
|
this.reload();
|
||||||
|
this.initProjectIds();
|
||||||
},
|
},
|
||||||
addScenario(arr) {
|
addScenario(arr) {
|
||||||
if (arr && arr.length > 0) {
|
if (arr && arr.length > 0) {
|
||||||
|
@ -623,6 +563,7 @@
|
||||||
}
|
}
|
||||||
this.sort();
|
this.sort();
|
||||||
this.reload();
|
this.reload();
|
||||||
|
this.initProjectIds();
|
||||||
this.scenarioVisible = false;
|
this.scenarioVisible = false;
|
||||||
},
|
},
|
||||||
setApiParameter(item, refType, referenced) {
|
setApiParameter(item, refType, referenced) {
|
||||||
|
@ -664,6 +605,7 @@
|
||||||
});
|
});
|
||||||
this.sort();
|
this.sort();
|
||||||
this.reload();
|
this.reload();
|
||||||
|
this.initProjectIds();
|
||||||
},
|
},
|
||||||
openTagConfig() {
|
openTagConfig() {
|
||||||
if (!this.projectId) {
|
if (!this.projectId) {
|
||||||
|
@ -684,6 +626,7 @@
|
||||||
hashTree.splice(index, 1);
|
hashTree.splice(index, 1);
|
||||||
this.sort();
|
this.sort();
|
||||||
this.reload();
|
this.reload();
|
||||||
|
this.initProjectIds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -980,8 +923,19 @@
|
||||||
refReload(data, node) {
|
refReload(data, node) {
|
||||||
this.selectedTreeNode = data;
|
this.selectedTreeNode = data;
|
||||||
this.selectedNode = node;
|
this.selectedNode = node;
|
||||||
|
this.initProjectIds();
|
||||||
this.reload();
|
this.reload();
|
||||||
},
|
},
|
||||||
|
initProjectIds() {
|
||||||
|
// 加载环境配置
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.projectIds.clear();
|
||||||
|
this.scenarioDefinition.forEach(data => {
|
||||||
|
let arr = jsonPath.query(data, "$..projectId");
|
||||||
|
arr.forEach(a => this.projectIds.add(a));
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
detailRefresh(result) {
|
detailRefresh(result) {
|
||||||
// 把执行结果分发给各个请求
|
// 把执行结果分发给各个请求
|
||||||
this.debugResult = result;
|
this.debugResult = result;
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
<el-checkbox v-model="cookieShare" @change="setCookieShare" style="margin-right: 20px">共享cookie</el-checkbox>
|
<el-checkbox v-model="cookieShare" @change="setCookieShare" style="margin-right: 20px">共享cookie</el-checkbox>
|
||||||
|
|
||||||
<env-popover :env-map="envMap" :project-ids="projectIds" @setProjectEnvMap="setProjectEnvMap"
|
<env-popover :env-map="envMap" :project-ids="projectIds" @setProjectEnvMap="setProjectEnvMap"
|
||||||
:disabled="scenarioDefinition.length < 1"
|
|
||||||
:is-read-only="scenarioDefinition.length < 1"
|
|
||||||
:project-list="projectList" ref="envPopover" class="ms-right"/>
|
:project-list="projectList" ref="envPopover" class="ms-right"/>
|
||||||
|
|
||||||
<el-button :disabled="scenarioDefinition.length < 1" size="mini" type="primary" v-prevent-re-click @click="runDebug">{{$t('api_test.request.debug')}}</el-button>
|
<el-button :disabled="scenarioDefinition.length < 1" size="mini" type="primary" v-prevent-re-click @click="runDebug">{{$t('api_test.request.debug')}}</el-button>
|
||||||
|
|
Loading…
Reference in New Issue