Merge remote-tracking branch 'origin/master'

This commit is contained in:
Captain.B 2021-01-18 14:35:41 +08:00
commit 4994ca3780
39 changed files with 640 additions and 585 deletions

View File

@ -114,6 +114,7 @@ public class ApiDefinitionController {
@PostMapping(value = "/run", consumes = {"multipart/form-data"}) @PostMapping(value = "/run", consumes = {"multipart/form-data"})
public String run(@RequestPart("request") RunDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) { public String run(@RequestPart("request") RunDefinitionRequest request, @RequestPart(value = "files") List<MultipartFile> bodyFiles) {
request.setReportId(null);
return apiDefinitionService.run(request, bodyFiles); return apiDefinitionService.run(request, bodyFiles);
} }

View File

@ -170,10 +170,8 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
apiReportService.complete(testResult, report); apiReportService.complete(testResult, report);
} else if (StringUtils.equals(this.runMode, ApiRunMode.DELIMIT.name())) { } else if (StringUtils.equals(this.runMode, ApiRunMode.DELIMIT.name())) {
// 调试操作不需要存储结果 // 调试操作不需要存储结果
if (!StringUtils.isBlank(debugReportId)) { apiDefinitionService.addResult(testResult);
apiDefinitionService.addResult(testResult); if (StringUtils.isBlank(debugReportId)) {
} else {
apiDefinitionService.addResult(testResult);
apiDefinitionExecResultService.saveApiResult(testResult, ApiRunMode.DELIMIT.name()); apiDefinitionExecResultService.saveApiResult(testResult, ApiRunMode.DELIMIT.name());
} }
} else if (StringUtils.equalsAny(this.runMode, ApiRunMode.API_PLAN.name(), ApiRunMode.SCHEDULE_API_PLAN.name())) { } else if (StringUtils.equalsAny(this.runMode, ApiRunMode.API_PLAN.name(), ApiRunMode.SCHEDULE_API_PLAN.name())) {

View File

@ -337,9 +337,6 @@ public class ApiDefinitionService {
if (StringUtils.isNotBlank(request.getType()) && StringUtils.equals(request.getType(), ApiRunMode.API_PLAN.name())) { if (StringUtils.isNotBlank(request.getType()) && StringUtils.equals(request.getType(), ApiRunMode.API_PLAN.name())) {
runMode = ApiRunMode.API_PLAN.name(); runMode = ApiRunMode.API_PLAN.name();
} }
MsTestPlan testPlan = new MsTestPlan();
System.out.println(testPlan.getJmx(hashTree));
// 调用执行方法 // 调用执行方法
jMeterService.runDefinition(request.getId(), hashTree, request.getReportId(), runMode); jMeterService.runDefinition(request.getId(), hashTree, request.getReportId(), runMode);
return request.getId(); return request.getId();

View File

@ -38,7 +38,14 @@
<el-tab-pane name="add"> <el-tab-pane name="add">
<template v-slot:label> <template v-slot:label>
<el-button type="primary" plain icon="el-icon-plus" size="mini" v-tester/> <el-dropdown @command="handleCommand" v-tester>
<el-button type="primary" plain icon="el-icon-plus" size="mini" v-tester/>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="ADD">{{ $t('api_test.definition.request.title') }}</el-dropdown-item>
<el-dropdown-item command="CLOSE_ALL">{{ $t('api_test.definition.request.close_all_label') }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template> </template>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
@ -48,150 +55,168 @@
<script> <script>
import MsContainer from "@/business/components/common/components/MsContainer"; import MsContainer from "@/business/components/common/components/MsContainer";
import MsAsideContainer from "@/business/components/common/components/MsAsideContainer"; import MsAsideContainer from "@/business/components/common/components/MsAsideContainer";
import MsMainContainer from "@/business/components/common/components/MsMainContainer"; import MsMainContainer from "@/business/components/common/components/MsMainContainer";
import MsApiScenarioList from "@/business/components/api/automation/scenario/ApiScenarioList"; import MsApiScenarioList from "@/business/components/api/automation/scenario/ApiScenarioList";
import {getUUID} from "@/common/js/utils"; import {getUUID} from "@/common/js/utils";
import MsApiScenarioModule from "@/business/components/api/automation/scenario/ApiScenarioModule"; import MsApiScenarioModule from "@/business/components/api/automation/scenario/ApiScenarioModule";
import MsEditApiScenario from "./scenario/EditApiScenario"; import MsEditApiScenario from "./scenario/EditApiScenario";
import {getCurrentProjectID} from "../../../../common/js/utils"; import {getCurrentProjectID} from "../../../../common/js/utils";
export default { export default {
name: "ApiAutomation", name: "ApiAutomation",
components: { components: {
MsApiScenarioModule, MsApiScenarioModule,
MsApiScenarioList, MsApiScenarioList,
MsMainContainer, MsMainContainer,
MsAsideContainer, MsAsideContainer,
MsContainer, MsContainer,
MsEditApiScenario MsEditApiScenario
},
comments: {},
computed: {
checkRedirectID: function () {
let redirectIDParam = this.$route.params.redirectID;
this.changeRedirectParam(redirectIDParam);
return redirectIDParam;
}, },
isRedirectEdit: function () { comments: {},
let redirectParam = this.$route.params.dataSelectRange; computed: {
this.checkRedirectEditPage(redirectParam); checkRedirectID: function () {
return redirectParam; let redirectIDParam = this.$route.params.redirectID;
} this.changeRedirectParam(redirectIDParam);
}, return redirectIDParam;
data() { },
return { isRedirectEdit: function () {
redirectID: '', let redirectParam = this.$route.params.dataSelectRange;
renderComponent: true, this.checkRedirectEditPage(redirectParam);
isHide: true, return redirectParam;
activeName: 'default', }
currentModule: null, },
moduleOptions: [], data() {
tabs: [], return {
trashEnable: false, redirectID: '',
selectNodeIds: [], renderComponent: true,
} isHide: true,
}, activeName: 'default',
watch: { currentModule: null,
redirectID() { moduleOptions: [],
this.renderComponent = false; tabs: [],
this.$nextTick(() => { trashEnable: false,
// DOM my-component selectNodeIds: [],
this.renderComponent = true; }
}); },
} watch: {
}, redirectID() {
methods: { this.renderComponent = false;
checkRedirectEditPage(redirectParam) { this.$nextTick(() => {
if(redirectParam!=null){ // DOM my-component
let selectParamArr = redirectParam.split("edit:"); this.renderComponent = true;
if (selectParamArr.length == 2) { });
let scenarioId = selectParamArr[1]; }
let projectId = getCurrentProjectID(); },
// methods: {
let url = "/api/automation/list/" + 1 + "/" + 1; checkRedirectEditPage(redirectParam) {
this.$post(url, {id:scenarioId,projectId:projectId}, response => { if (redirectParam != null) {
let data = response.data; let selectParamArr = redirectParam.split("edit:");
if(data!=null){ if (selectParamArr.length == 2) {
// let scenarioId = selectParamArr[1];
if(JSON.stringify(this.moduleOptions) === '{}' ){ let projectId = getCurrentProjectID();
this.$refs.nodeTree.list(); //
let url = "/api/automation/list/" + 1 + "/" + 1;
this.$post(url, {id: scenarioId, projectId: projectId}, response => {
let data = response.data;
if (data != null) {
//
if (JSON.stringify(this.moduleOptions) === '{}') {
this.$refs.nodeTree.list();
}
let row = data.listObject[0];
row.tags = JSON.parse(row.tags);
this.editScenario(row);
} }
let row = data.listObject[0]; });
row.tags = JSON.parse(row.tags); }
this.editScenario(row);
}
});
} }
} },
}, changeRedirectParam(redirectIDParam) {
changeRedirectParam(redirectIDParam) { this.redirectID = redirectIDParam;
this.redirectID = redirectIDParam; },
}, addTab(tab) {
addTab(tab) { if (!getCurrentProjectID()) {
if (!getCurrentProjectID()) { this.$warning(this.$t('commons.check_project_tip'));
this.$warning(this.$t('commons.check_project_tip')); return;
return;
}
if (tab.name === 'add') {
let label = this.$t('api_test.automation.add_scenario');
let name = getUUID().substring(0, 8);
this.activeName = name;
this.tabs.push({label: label, name: name, currentScenario: {apiScenarioModuleId: "", id: getUUID()}});
}
if (tab.name === 'edit') {
let label = this.$t('api_test.automation.add_scenario');
let name = getUUID().substring(0, 8);
this.activeName = name;
label = tab.currentScenario.name;
this.tabs.push({label: label, name: name, currentScenario: tab.currentScenario});
}
},
removeTab(targetName) {
this.tabs = this.tabs.filter(tab => tab.name !== targetName);
if (this.tabs.length > 0) {
this.activeName = this.tabs[this.tabs.length - 1].name;
} else {
this.activeName = "default"
}
},
setTabLabel(data) {
for (const tab of this.tabs) {
if (tab.name === this.activeName) {
tab.label = data.name;
break;
} }
} if (tab.name === 'add') {
}, let label = this.$t('api_test.automation.add_scenario');
selectModule(data) { let name = getUUID().substring(0, 8);
this.currentModule = data; this.activeName = name;
}, this.tabs.push({label: label, name: name, currentScenario: {apiScenarioModuleId: "", id: getUUID()}});
saveScenario(data) { }
this.setTabLabel(data); if (tab.name === 'edit') {
this.$refs.apiScenarioList.search(data); let label = this.$t('api_test.automation.add_scenario');
}, let name = getUUID().substring(0, 8);
refresh(data) { this.activeName = name;
this.$refs.apiScenarioList.search(data); label = tab.currentScenario.name;
}, this.tabs.push({label: label, name: name, currentScenario: tab.currentScenario});
editScenario(row) { }
this.addTab({name: 'edit', currentScenario: row}); },
}, handleTabClose() {
this.tabs = [];
this.activeName = "default";
this.refresh();
},
handleCommand(e) {
switch (e) {
case "ADD":
this.addTab({name: 'add'});
break;
case "CLOSE_ALL":
this.handleTabClose();
break;
default:
this.addTab({name: 'add'});
break;
}
},
removeTab(targetName) {
this.tabs = this.tabs.filter(tab => tab.name !== targetName);
if (this.tabs.length > 0) {
this.activeName = this.tabs[this.tabs.length - 1].name;
} else {
this.activeName = "default"
}
},
setTabLabel(data) {
for (const tab of this.tabs) {
if (tab.name === this.activeName) {
tab.label = data.name;
break;
}
}
},
selectModule(data) {
this.currentModule = data;
},
saveScenario(data) {
this.setTabLabel(data);
this.$refs.apiScenarioList.search(data);
},
refresh(data) {
this.$refs.apiScenarioList.search(data);
},
editScenario(row) {
this.addTab({name: 'edit', currentScenario: row});
},
nodeChange(node, nodeIds, pNodes) { nodeChange(node, nodeIds, pNodes) {
this.selectNodeIds = nodeIds; this.selectNodeIds = nodeIds;
}, },
setModuleOptions(data) { setModuleOptions(data) {
this.moduleOptions = data; this.moduleOptions = data;
}, },
changeSelectDataRangeAll(tableType) { changeSelectDataRangeAll(tableType) {
this.$route.params.dataSelectRange = 'all'; this.$route.params.dataSelectRange = 'all';
}, },
enableTrash(data) { enableTrash(data) {
this.trashEnable = data; this.trashEnable = data;
}
} }
} }
}
</script> </script>
<style scoped> <style scoped>

View File

@ -145,31 +145,12 @@
@node-expand="nodeExpand" @node-expand="nodeExpand"
@node-collapse="nodeCollapse" @node-collapse="nodeCollapse"
:allow-drop="allowDrop" @node-drag-end="allowDrag" @node-click="nodeClick" v-if="!loading" draggable> :allow-drop="allowDrop" @node-drag-end="allowDrag" @node-click="nodeClick" v-if="!loading" draggable>
<span class="custom-tree-node father" slot-scope="{ node, data}" style="width: 96%"> <span class="custom-tree-node father" slot-scope="{ node, data}" style="width: 96%">
<template> <!-- 步骤组件-->
<!-- 场景 --> <ms-component-config :type="data.type" :scenario="data" :response="response" :currentScenario="currentScenario"
<ms-api-scenario-component v-if="data.type==='scenario'" :scenario="data" :node="node" @remove="remove" @copyRow="copyRow"/> :currentEnvironmentId="currentEnvironmentId" :node="node"
<!--条件控制器--> @remove="remove" @copyRow="copyRow" @suggestClick="suggestClick"/>
<ms-if-controller :controller="data" :node="node" v-if="data.type==='IfController'" @remove="remove" @copyRow="copyRow"/> </span>
<!--循环控制器-->
<ms-loop-controller :controller="data" :node="node" v-if="data.type==='LoopController'" @remove="remove" @copyRow="copyRow"/>
<!--等待控制器-->
<ms-constant-timer :timer="data" :node="node" v-if="data.type==='ConstantTimer'" @remove="remove" @copyRow="copyRow"/>
<!--自定义脚本-->
<ms-jsr233-processor :draggable="true" v-if="data.type==='JSR223Processor'" @remove="remove" @copyRow="copyRow" :title="$t('api_test.automation.customize_script')" :jsr223-processor="data" :node="node"/>
<!--前置脚本-->
<ms-jsr233-processor :draggable="true" v-if="data.type==='JSR223PreProcessor'" @remove="remove" @copyRow="copyRow" :title="$t('api_test.definition.request.pre_script')" :jsr223-processor="data" :node="node"/>
<!--后置脚本-->
<ms-jsr233-processor :draggable="true" v-if="data.type==='JSR223PostProcessor'" @remove="remove" @copyRow="copyRow" :title="$t('api_test.definition.request.post_script')" :jsr223-processor="data" :node="node"/>
<!--断言规则-->
<ms-api-assertions :draggable="true" @suggestClick="suggestClick(node)" :response="response" v-if="data.type==='Assertions'" @remove="remove" @copyRow="copyRow" :assertions="data" :node="node"/>
<!--提取规则-->
<ms-api-extract :draggable="true" @suggestClick="suggestClick(node)" :response="response" @remove="remove" @copyRow="copyRow" v-if="data.type==='Extract'" :extract="data" :node="node"/>
<!--API 导入 -->
<ms-api-component :request="data" :currentScenario="currentScenario" :currentEnvironmentId="currentEnvironmentId" @remove="remove" @copyRow="copyRow"
v-if="data.type==='HTTPSamplerProxy'||data.type==='DubboSampler'||data.type==='JDBCSampler'||data.type==='TCPSampler'" :node="node"/>
</template>
</span>
</el-tree> </el-tree>
</div> </div>
</el-col> </el-col>
@ -227,21 +208,13 @@
import {API_STATUS, PRIORITY} from "../../definition/model/JsonData"; import {API_STATUS, PRIORITY} from "../../definition/model/JsonData";
import {WORKSPACE_ID} from '@/common/js/constants'; import {WORKSPACE_ID} from '@/common/js/constants';
import {Assertions, Extract, IfController, JSR223Processor, ConstantTimer, LoopController} from "../../definition/model/ApiTestModel"; import {Assertions, Extract, IfController, JSR223Processor, ConstantTimer, LoopController} from "../../definition/model/ApiTestModel";
import MsJsr233Processor from "./Jsr233Processor";
import {parseEnvironment} from "../../definition/model/EnvironmentModel"; import {parseEnvironment} from "../../definition/model/EnvironmentModel";
import MsConstantTimer from "./ConstantTimer";
import MsIfController from "./IfController";
import MsApiAssertions from "../../definition/components/assertion/ApiAssertions";
import MsApiExtract from "../../definition/components/extract/ApiExtract";
import MsApiComponent from "./ApiComponent";
import {ELEMENTS, ELEMENT_TYPE} from "./Setting"; import {ELEMENTS, ELEMENT_TYPE} from "./Setting";
import MsApiCustomize from "./ApiCustomize"; import MsApiCustomize from "./ApiCustomize";
import {getUUID, getCurrentProjectID} from "@/common/js/utils"; import {getUUID, getCurrentProjectID} from "@/common/js/utils";
import ApiEnvironmentConfig from "../../definition/components/environment/ApiEnvironmentConfig"; import ApiEnvironmentConfig from "../../definition/components/environment/ApiEnvironmentConfig";
import MsInputTag from "./MsInputTag"; import MsInputTag from "./MsInputTag";
import MsRun from "./DebugRun"; import MsRun from "./DebugRun";
import MsLoopController from "./LoopController";
import MsApiScenarioComponent from "./ApiScenarioComponent";
import MsApiReportDetail from "../report/ApiReportDetail"; import MsApiReportDetail from "../report/ApiReportDetail";
import MsVariableList from "./variable/VariableList"; import MsVariableList from "./variable/VariableList";
import ApiImport from "../../definition/components/import/ApiImport"; import ApiImport from "../../definition/components/import/ApiImport";
@ -250,6 +223,7 @@
import OutsideClick from "@/common/js/outside-click"; import OutsideClick from "@/common/js/outside-click";
import ScenarioApiRelevance from "./api/ApiRelevance"; import ScenarioApiRelevance from "./api/ApiRelevance";
import ScenarioRelevance from "./api/ScenarioRelevance"; import ScenarioRelevance from "./api/ScenarioRelevance";
import MsComponentConfig from "./component/ComponentConfig";
export default { export default {
name: "EditApiScenario", name: "EditApiScenario",
@ -264,17 +238,10 @@
ApiEnvironmentConfig, ApiEnvironmentConfig,
MsApiReportDetail, MsApiReportDetail,
MsInputTag, MsRun, MsInputTag, MsRun,
MsApiScenarioComponent,
MsJsr233Processor,
MsConstantTimer,
MsIfController,
MsApiAssertions,
MsApiExtract,
MsApiComponent,
MsApiCustomize, MsApiCustomize,
ApiImport, ApiImport,
InputTag, InputTag,
MsLoopController, MsComponentConfig,
}, },
data() { data() {
return { return {
@ -669,7 +636,12 @@
if (obj.name) { if (obj.name) {
obj.name = obj.name + '_copy'; obj.name = obj.name + '_copy';
} }
hashTree.push(obj); const index = hashTree.findIndex(d => d.resourceId === row.resourceId);
if (index != -1) {
hashTree.splice(index, 0, obj);
} else {
hashTree.push(obj);
}
this.sort(); this.sort();
this.reload(); this.reload();
} }

View File

@ -64,15 +64,15 @@
</template> </template>
<script> <script>
import MsSqlBasisParameters from "../../definition/components/request/database/BasisParameters"; import MsSqlBasisParameters from "../../../definition/components/request/database/BasisParameters";
import MsTcpBasisParameters from "../../definition/components/request/tcp/TcpBasisParameters"; import MsTcpBasisParameters from "../../../definition/components/request/tcp/TcpBasisParameters";
import MsDubboBasisParameters from "../../definition/components/request/dubbo/BasisParameters"; import MsDubboBasisParameters from "../../../definition/components/request/dubbo/BasisParameters";
import MsApiRequestForm from "../../definition/components/request/http/ApiRequestForm"; import MsApiRequestForm from "../../../definition/components/request/http/ApiHttpRequestForm";
import {REQ_METHOD} from "../../definition/model/JsonData"; import {REQ_METHOD} from "../../../definition/model/JsonData";
import MsRequestResultTail from "../../definition/components/response/RequestResultTail"; import MsRequestResultTail from "../../../definition/components/response/RequestResultTail";
import MsRun from "../../definition/components/Run"; import MsRun from "../../../definition/components/Run";
import {getUUID} from "@/common/js/utils"; import {getUUID} from "@/common/js/utils";
import ApiBaseComponent from "./common/ApiBaseComponent"; import ApiBaseComponent from "../common/ApiBaseComponent";
export default { export default {
name: "MsApiComponent", name: "MsApiComponent",
props: { props: {

View File

@ -28,11 +28,11 @@
</template> </template>
<script> <script>
import MsSqlBasisParameters from "../../definition/components/request/database/BasisParameters"; import MsSqlBasisParameters from "../../../definition/components/request/database/BasisParameters";
import MsTcpBasisParameters from "../../definition/components/request/tcp/TcpBasisParameters"; import MsTcpBasisParameters from "../../../definition/components/request/tcp/TcpBasisParameters";
import MsDubboBasisParameters from "../../definition/components/request/dubbo/BasisParameters"; import MsDubboBasisParameters from "../../../definition/components/request/dubbo/BasisParameters";
import MsApiRequestForm from "../../definition/components/request/http/ApiRequestForm"; import MsApiRequestForm from "../../../definition/components/request/http/ApiHttpRequestForm";
import ApiBaseComponent from "./common/ApiBaseComponent"; import ApiBaseComponent from "../common/ApiBaseComponent";
export default { export default {
name: "ApiScenarioComponent", name: "ApiScenarioComponent",

View File

@ -0,0 +1,113 @@
<template>
<div class="request-form">
<component :is="component" :scenario="scenario" :controller="scenario" :timer="scenario" :assertions="scenario" :extract="scenario" :jsr223-processor="scenario" :request="scenario" :currentScenario="currentScenario" :currentEnvironmentId="currentEnvironmentId" :node="node"
:draggable="true" :title="title" @suggestClick="suggestClick(node)" :response="response"
@remove="remove" @copyRow="copyRow"/>
</div>
</template>
<script>
import MsConstantTimer from "./ConstantTimer";
import MsIfController from "./IfController";
import {ELEMENT_TYPE} from "../Setting";
import MsJsr233Processor from "./Jsr233Processor";
import MsApiAssertions from "../../../definition/components/assertion/ApiAssertions";
import MsApiExtract from "../../../definition/components/extract/ApiExtract";
import MsApiComponent from "./ApiComponent";
import MsLoopController from "./LoopController";
import MsApiScenarioComponent from "./ApiScenarioComponent";
import {getUUID} from "@/common/js/utils";
export default {
name: "ComponentConfig",
components: {MsConstantTimer, MsIfController, MsJsr233Processor, MsApiAssertions, MsApiExtract, MsApiComponent, MsLoopController, MsApiScenarioComponent},
props: {
type: String,
scenario: {},
currentScenario: {},
currentEnvironmentId: String,
response: {},
node: {},
},
data() {
return {
title: this.$t('api_test.automation.customize_script'),
}
},
computed: {
component({type}) {
let name;
switch (type) {
case ELEMENT_TYPE.IfController:
name = "MsIfController";
break;
case ELEMENT_TYPE.ConstantTimer:
name = "MsConstantTimer";
break;
case ELEMENT_TYPE.JSR223Processor:
name = this.getComponent(ELEMENT_TYPE.JSR223Processor);
break;
case ELEMENT_TYPE.JSR223PreProcessor:
name = this.getComponent(ELEMENT_TYPE.JSR223PreProcessor);
break;
case ELEMENT_TYPE.JSR223PostProcessor:
name = this.getComponent(ELEMENT_TYPE.JSR223PostProcessor);
break;
case ELEMENT_TYPE.Assertions:
name = "MsApiAssertions";
break;
case ELEMENT_TYPE.Extract:
name = "MsApiExtract";
break;
case ELEMENT_TYPE.CustomizeReq:
name = "MsApiComponent";
break;
case ELEMENT_TYPE.LoopController:
name = "MsLoopController";
break;
case ELEMENT_TYPE.scenario:
name = "MsApiScenarioComponent";
break;
default:
name = "MsApiComponent";
break;
}
return name;
}
},
methods: {
getComponent(type) {
if (type === ELEMENT_TYPE.JSR223PreProcessor) {
this.title = this.$t('api_test.definition.request.pre_script');
return "MsJsr233Processor";
} else if (type === ELEMENT_TYPE.JSR223PostProcessor) {
this.title = this.$t('api_test.definition.request.post_script');
return "MsJsr233Processor";
} else {
this.title = this.$t('api_test.automation.customize_script');
return "MsJsr233Processor";
}
},
remove(row, node) {
this.$emit('remove',row,node);
},
copyRow(row, node) {
this.$emit('copyRow',row,node);
},
suggestClick(node) {
this.$emit('suggestClick',node);
},
}
}
</script>
<style scoped>
.request-form >>> .debug-button {
margin-left: auto;
display: block;
margin-right: 10px;
}
</style>

View File

@ -17,7 +17,7 @@
</template> </template>
<script> <script>
import ApiBaseComponent from "./common/ApiBaseComponent"; import ApiBaseComponent from "../common/ApiBaseComponent";
export default { export default {
name: "MsConstantTimer", name: "MsConstantTimer",
components: {ApiBaseComponent}, components: {ApiBaseComponent},

View File

@ -25,7 +25,7 @@
</template> </template>
<script> <script>
import ApiBaseComponent from "./common/ApiBaseComponent"; import ApiBaseComponent from "../common/ApiBaseComponent";
export default { export default {
name: "MsIfController", name: "MsIfController",
components: {ApiBaseComponent}, components: {ApiBaseComponent},

View File

@ -35,10 +35,10 @@
</template> </template>
<script> <script>
import MsCodeEdit from "../../../common/components/MsCodeEdit"; import MsCodeEdit from "../../../../common/components/MsCodeEdit";
import MsInstructionsIcon from "../../../common/components/MsInstructionsIcon"; import MsInstructionsIcon from "../../../../common/components/MsInstructionsIcon";
import MsDropdown from "../../../common/components/MsDropdown"; import MsDropdown from "../../../../common/components/MsDropdown";
import ApiBaseComponent from "./common/ApiBaseComponent"; import ApiBaseComponent from "../common/ApiBaseComponent";
export default { export default {
name: "MsJsr233Processor", name: "MsJsr233Processor",

View File

@ -70,7 +70,7 @@
</template> </template>
<script> <script>
import ApiBaseComponent from "./common/ApiBaseComponent"; import ApiBaseComponent from "../common/ApiBaseComponent";
export default { export default {
name: "MsLoopController", name: "MsLoopController",

View File

@ -15,20 +15,8 @@
</ms-aside-container> </ms-aside-container>
<ms-main-container> <ms-main-container>
<el-dropdown size="small" split-button type="primary" class="ms-api-buttion"
@click="handleCommand('ADD')"
@command="handleCommand" v-tester>
{{ $t('commons.add') }}
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="debug">{{ $t('api_test.definition.request.fast_debug') }}</el-dropdown-item>
<el-dropdown-item command="ADD">{{ $t('api_test.definition.request.title') }}</el-dropdown-item>
<el-dropdown-item command="CLOSE_ALL">{{ $t('api_test.definition.request.close_all_label') }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<!-- 主框架列表 --> <!-- 主框架列表 -->
<el-tabs v-model="apiDefaultTab" @edit="handleTabRemove"> <el-tabs v-model="apiDefaultTab" @edit="handleTabRemove" @tab-click="addTab">
<el-tab-pane v-for="(item) in apiTabs" <el-tab-pane v-for="(item) in apiTabs"
:key="item.name" :key="item.name"
:label="item.title" :label="item.title"
@ -98,313 +86,320 @@
@refresh="refresh" v-if="currentProtocol==='DUBBO'"/> @refresh="refresh" v-if="currentProtocol==='DUBBO'"/>
</div> </div>
</el-tab-pane> </el-tab-pane>
<el-tab-pane name="add">
<template v-slot:label>
<el-dropdown @command="handleCommand" v-tester>
<el-button type="primary" plain icon="el-icon-plus" size="mini" v-tester/>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="debug">{{ $t('api_test.definition.request.fast_debug') }}</el-dropdown-item>
<el-dropdown-item command="ADD">{{ $t('api_test.definition.request.title') }}</el-dropdown-item>
<el-dropdown-item command="CLOSE_ALL">{{ $t('api_test.definition.request.close_all_label') }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-tab-pane>
</el-tabs> </el-tabs>
</ms-main-container> </ms-main-container>
</ms-container> </ms-container>
</template> </template>
<script> <script>
import MsApiList from './components/list/ApiList'; import MsApiList from './components/list/ApiList';
import MsContainer from "../../common/components/MsContainer"; import MsContainer from "../../common/components/MsContainer";
import MsMainContainer from "../../common/components/MsMainContainer"; import MsMainContainer from "../../common/components/MsMainContainer";
import MsAsideContainer from "../../common/components/MsAsideContainer"; import MsAsideContainer from "../../common/components/MsAsideContainer";
import MsApiConfig from "./components/ApiConfig"; import MsApiConfig from "./components/ApiConfig";
import MsDebugHttpPage from "./components/debug/DebugHttpPage"; import MsDebugHttpPage from "./components/debug/DebugHttpPage";
import MsDebugJdbcPage from "./components/debug/DebugJdbcPage"; import MsDebugJdbcPage from "./components/debug/DebugJdbcPage";
import MsDebugTcpPage from "./components/debug/DebugTcpPage"; import MsDebugTcpPage from "./components/debug/DebugTcpPage";
import MsDebugDubboPage from "./components/debug/DebugDubboPage"; import MsDebugDubboPage from "./components/debug/DebugDubboPage";
import MsRunTestHttpPage from "./components/runtest/RunTestHTTPPage"; import MsRunTestHttpPage from "./components/runtest/RunTestHTTPPage";
import MsRunTestTcpPage from "./components/runtest/RunTestTCPPage"; import MsRunTestTcpPage from "./components/runtest/RunTestTCPPage";
import MsRunTestSqlPage from "./components/runtest/RunTestSQLPage"; import MsRunTestSqlPage from "./components/runtest/RunTestSQLPage";
import MsRunTestDubboPage from "./components/runtest/RunTestDubboPage"; import MsRunTestDubboPage from "./components/runtest/RunTestDubboPage";
import {downloadFile, getCurrentUser, getUUID, getCurrentProjectID} from "@/common/js/utils"; import {downloadFile, getCurrentUser, getUUID, getCurrentProjectID} from "@/common/js/utils";
import MsApiModule from "./components/module/ApiModule"; import MsApiModule from "./components/module/ApiModule";
import ApiCaseSimpleList from "./components/list/ApiCaseSimpleList"; import ApiCaseSimpleList from "./components/list/ApiCaseSimpleList";
import {PROJECT_NAME} from "../../../../common/js/constants"; import {PROJECT_NAME} from "../../../../common/js/constants";
export default { export default {
name: "ApiDefinition", name: "ApiDefinition",
computed: { computed: {
queryDataType: function () { queryDataType: function () {
let routeParam = this.$route.params.dataType; let routeParam = this.$route.params.dataType;
let redirectIDParam = this.$route.params.redirectID; let redirectIDParam = this.$route.params.redirectID;
this.changeRedirectParam(redirectIDParam); this.changeRedirectParam(redirectIDParam);
if (routeParam === 'apiTestCase') { if (routeParam === 'apiTestCase') {
this.isApiListEnableChange(false); this.isApiListEnableChange(false);
} else { } else {
this.isApiListEnableChange(true); this.isApiListEnableChange(true);
} }
return routeParam; return routeParam;
},
}, },
}, components: {
components: { ApiCaseSimpleList,
ApiCaseSimpleList, MsApiModule,
MsApiModule, MsApiList,
MsApiList, MsMainContainer,
MsMainContainer, MsContainer,
MsContainer, MsAsideContainer,
MsAsideContainer, MsApiConfig,
MsApiConfig, MsDebugHttpPage,
MsDebugHttpPage, MsRunTestHttpPage,
MsRunTestHttpPage, MsDebugJdbcPage,
MsDebugJdbcPage, MsDebugTcpPage,
MsDebugTcpPage, MsDebugDubboPage,
MsDebugDubboPage, MsRunTestTcpPage,
MsRunTestTcpPage, MsRunTestSqlPage,
MsRunTestSqlPage, MsRunTestDubboPage
MsRunTestDubboPage
},
props: {
visible: {
type: Boolean,
default: false,
}, },
currentRow: { props: {
type: Object, visible: {
} type: Boolean,
}, default: false,
data() { },
return { currentRow: {
redirectID: '', type: Object,
renderComponent: true,
selectDataRange: 'all',
showCasePage: true,
apiDefaultTab: 'default',
currentProtocol: null,
currentModule: null,
selectNodeIds: [],
currentApi: {},
moduleOptions: {},
trashEnable: false,
apiTabs: [{
title: this.$t('api_test.definition.api_title'),
name: 'default',
type: "list",
closable: false
}],
isApiListEnable: true
}
},
watch: {
currentProtocol() {
this.handleCommand("CLOSE_ALL");
},
redirectID() {
this.renderComponent = false;
this.$nextTick(() => {
// DOM my-component
this.renderComponent = true;
});
}
},
methods: {
changeRedirectParam(redirectIDParam) {
this.redirectID = redirectIDParam;
},
isApiListEnableChange(data) {
this.isApiListEnable = data;
},
handleCommand(e) {
switch (e) {
case "ADD":
this.handleTabAdd(e);
break;
case "TEST":
this.handleTabsEdit(this.$t("commons.api"), e);
break;
case "CLOSE_ALL":
this.handleTabClose();
break;
default:
this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug");
break;
} }
}, },
handleTabAdd(e) { data() {
if (!getCurrentProjectID()) { return {
this.$warning(this.$t('commons.check_project_tip')); redirectID: '',
return; renderComponent: true,
selectDataRange: 'all',
showCasePage: true,
apiDefaultTab: 'default',
currentProtocol: null,
currentModule: null,
selectNodeIds: [],
currentApi: {},
moduleOptions: {},
trashEnable: false,
apiTabs: [{
title: this.$t('api_test.definition.api_title'),
name: 'default',
type: "list",
closable: false
}],
isApiListEnable: true
} }
let api = {
status: "Underway", method: "GET", userId: getCurrentUser().id,
url: "", protocol: this.currentProtocol, environmentId: ""
};
this.handleTabsEdit(this.$t('api_test.definition.request.title'), e, api);
}, },
handleTabClose() { watch: {
let tabs = this.apiTabs[0]; currentProtocol() {
this.apiTabs = []; this.handleCommand("CLOSE_ALL");
this.apiDefaultTab = tabs.name; },
this.apiTabs.push(tabs); redirectID() {
this.refresh(); this.renderComponent = false;
}, this.$nextTick(() => {
handleTabRemove(targetName) { // DOM my-component
let tabs = this.apiTabs; this.renderComponent = true;
let activeName = this.apiDefaultTab;
if (activeName === targetName) {
tabs.forEach((tab, index) => {
if (tab.name === targetName) {
let nextTab = tabs[index + 1] || tabs[index - 1];
if (nextTab) {
activeName = nextTab.name;
}
}
}); });
} }
this.apiDefaultTab = activeName;
this.apiTabs = tabs.filter(tab => tab.name !== targetName);
this.refresh();
}, },
// methods: {
createRootModel() { changeRedirectParam(redirectIDParam) {
this.$refs.nodeTree.createRootModel(); this.redirectID = redirectIDParam;
}, },
handleTabsEdit(targetName, action, api) { isApiListEnableChange(data) {
if (!getCurrentProjectID()) { this.isApiListEnable = data;
this.$warning(this.$t('commons.check_project_tip')); },
return; addTab(tab) {
} if (tab.name === 'add') {
if (targetName === undefined || targetName === null) { this.handleCommand("ADD");
targetName = this.$t('api_test.definition.request.title'); }
} },
let newTabName = getUUID(); handleCommand(e) {
this.apiTabs.push({ switch (e) {
title: targetName, case "ADD":
name: newTabName, this.handleTabAdd(e);
closable: true, break;
type: action, case "TEST":
api: api, this.handleTabsEdit(this.$t("commons.api"), e);
}); break;
this.apiDefaultTab = newTabName; case "CLOSE_ALL":
}, this.handleTabClose();
debug(id) { break;
this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug", id); default:
}, this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug");
editApi(row) { break;
let name = this.$t('api_test.definition.request.edit_api'); }
if (row.name) { },
name = this.$t('api_test.definition.request.edit_api') + "-" + row.name; handleTabAdd(e) {
} if (!getCurrentProjectID()) {
this.handleTabsEdit(name, "ADD", row); this.$warning(this.$t('commons.check_project_tip'));
}, return;
handleCase(api) { }
this.currentApi = api; let api = {
this.showCasePage = false; status: "Underway", method: "GET", userId: getCurrentUser().id,
}, url: "", protocol: this.currentProtocol, environmentId: ""
apiCaseClose() { };
this.showCasePage = true; this.handleTabsEdit(this.$t('api_test.definition.request.title'), e, api);
}, },
exportAPI() { handleTabClose() {
if (!this.isApiListEnable) { let tabs = this.apiTabs[0];
this.$warning('用例列表暂不支持导出,请切换成接口列表'); this.apiTabs = [];
return; this.apiDefaultTab = tabs.name;
} this.apiTabs.push(tabs);
let obj = {projectName: getCurrentProjectID(), protocol: this.currentProtocol} this.refresh();
if (this.$refs.apiList[0].selectRows && this.$refs.apiList[0].selectRows.size > 0) { },
let arr = Array.from(this.$refs.apiList[0].selectRows); handleTabRemove(targetName) {
obj.data = arr; let tabs = this.apiTabs;
this.buildApiPath(obj.data); let activeName = this.apiDefaultTab;
downloadFile("Metersphere_Api_" + localStorage.getItem(PROJECT_NAME) + ".json", JSON.stringify(obj)); if (activeName === targetName) {
} else { tabs.forEach((tab, index) => {
let condition = {}; if (tab.name === targetName) {
let url = "/api/definition/list/all"; let nextTab = tabs[index + 1] || tabs[index - 1];
condition.filters = ["Prepare", "Underway", "Completed"]; if (nextTab) {
condition.projectId = getCurrentProjectID(); activeName = nextTab.name;
this.$post(url, condition, response => { }
obj.data = response.data; }
});
}
this.apiDefaultTab = activeName;
this.apiTabs = tabs.filter(tab => tab.name !== targetName);
this.refresh();
},
//
createRootModel() {
this.$refs.nodeTree.createRootModel();
},
handleTabsEdit(targetName, action, api) {
if (!getCurrentProjectID()) {
this.$warning(this.$t('commons.check_project_tip'));
return;
}
if (targetName === undefined || targetName === null) {
targetName = this.$t('api_test.definition.request.title');
}
let newTabName = getUUID();
this.apiTabs.push({
title: targetName,
name: newTabName,
closable: true,
type: action,
api: api,
});
this.apiDefaultTab = newTabName;
},
debug(id) {
this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug", id);
},
editApi(row) {
let name = this.$t('api_test.definition.request.edit_api');
if (row.name) {
name = this.$t('api_test.definition.request.edit_api') + "-" + row.name;
}
this.handleTabsEdit(name, "ADD", row);
},
handleCase(api) {
this.currentApi = api;
this.showCasePage = false;
},
apiCaseClose() {
this.showCasePage = true;
},
exportAPI() {
if (!this.isApiListEnable) {
this.$warning('用例列表暂不支持导出,请切换成接口列表');
return;
}
let obj = {projectName: getCurrentProjectID(), protocol: this.currentProtocol}
if (this.$refs.apiList[0].selectRows && this.$refs.apiList[0].selectRows.size > 0) {
let arr = Array.from(this.$refs.apiList[0].selectRows);
obj.data = arr;
this.buildApiPath(obj.data); this.buildApiPath(obj.data);
downloadFile("Metersphere_Api_" + localStorage.getItem(PROJECT_NAME) + ".json", JSON.stringify(obj)); downloadFile("Metersphere_Api_" + localStorage.getItem(PROJECT_NAME) + ".json", JSON.stringify(obj));
}); } else {
} let condition = {};
}, let url = "/api/definition/list/all";
buildApiPath(apis) { condition.filters = ["Prepare", "Underway", "Completed"];
apis.forEach((api) => { condition.projectId = getCurrentProjectID();
this.moduleOptions.forEach(item => { this.$post(url, condition, response => {
if (api.moduleId === item.id) { obj.data = response.data;
api.modulePath = item.path; this.buildApiPath(obj.data);
} downloadFile("Metersphere_Api_" + localStorage.getItem(PROJECT_NAME) + ".json", JSON.stringify(obj));
}); });
});
},
refresh(data) {
this.$refs.apiList[0].initTable(data);
},
setTabTitle(data) {
for (let index in this.apiTabs) {
let tab = this.apiTabs[index];
if (tab.name === this.apiDefaultTab) {
tab.title = this.$t('api_test.definition.request.edit_api') + "-" + data.name;
break;
} }
} },
}, buildApiPath(apis) {
runTest(data) { apis.forEach((api) => {
this.setTabTitle(data); this.moduleOptions.forEach(item => {
this.handleTabsEdit(this.$t("commons.api"), "TEST", data); if (api.moduleId === item.id) {
}, api.modulePath = item.path;
saveApi(data) { }
this.setTabTitle(data); });
this.refresh(data); });
}, },
refresh(data) {
this.$refs.apiList[0].initTable(data);
},
setTabTitle(data) {
for (let index in this.apiTabs) {
let tab = this.apiTabs[index];
if (tab.name === this.apiDefaultTab) {
tab.title = this.$t('api_test.definition.request.edit_api') + "-" + data.name;
break;
}
}
},
runTest(data) {
this.setTabTitle(data);
this.handleTabsEdit(this.$t("commons.api"), "TEST", data);
},
saveApi(data) {
this.setTabTitle(data);
this.refresh(data);
},
showExecResult(row) { showExecResult(row) {
this.debug(row); this.debug(row);
}, },
nodeChange(node, nodeIds, pNodes) { nodeChange(node, nodeIds, pNodes) {
this.selectNodeIds = nodeIds; this.selectNodeIds = nodeIds;
}, },
handleProtocolChange(protocol) { handleProtocolChange(protocol) {
this.currentProtocol = protocol; this.currentProtocol = protocol;
}, },
setModuleOptions(data) { setModuleOptions(data) {
this.moduleOptions = data; this.moduleOptions = data;
}, },
changeSelectDataRangeAll(tableType) { changeSelectDataRangeAll(tableType) {
this.$route.params.dataSelectRange = 'all'; this.$route.params.dataSelectRange = 'all';
}, },
enableTrash(data) { enableTrash(data) {
this.trashEnable = data; this.trashEnable = data;
}
} }
} }
}
</script> </script>
<style scoped> <style scoped>
.ms-api-buttion {
position: absolute;
top: 100px;
right: 4px;
padding: 0;
background: 0 0;
border: none;
outline: 0;
cursor: pointer;
margin-right: 10px;
font-size: 16px;
}
.ms-api-div { .ms-api-div {
overflow-y: auto; overflow-y: auto;
height: calc(100vh - 155px) height: calc(100vh - 155px)
} }
/deep/ .el-tabs__header { /deep/ .el-main {
margin: 0 0 5px; overflow: hidden;
width: calc(100% - 90px); }
}
/deep/ .el-main { /deep/ .el-tabs__header {
overflow: hidden; margin: 0 0 0px;
} /*width: calc(100% - 90px);*/
}
/deep/ .el-card { /deep/ .el-card {
/*border: 1px solid #EBEEF5;*/ /*border: 1px solid #EBEEF5;*/
/*border-style: none;*/ /*border-style: none;*/
border-top: none; border-top: none;
} }
/deep/ .api-component { /deep/ .api-component {
margin-top: 10px; margin-top: 10px;
} }
</style> </style>

View File

@ -68,9 +68,9 @@
let bodyFiles = getBodyUploadFiles(reqObj, this.runData); let bodyFiles = getBodyUploadFiles(reqObj, this.runData);
let url = ""; let url = "";
if (this.debug) { if (this.debug) {
reqObj.reportId = this.reportId;
url = "/api/definition/run/debug"; url = "/api/definition/run/debug";
} else { } else {
reqObj.reportId = "run";
url = "/api/definition/run"; url = "/api/definition/run";
} }
this.$fileUpload(url, null, bodyFiles, reqObj, response => { this.$fileUpload(url, null, bodyFiles, reqObj, response => {

View File

@ -57,7 +57,7 @@
<script> <script>
import {AssertionJSR223} from "../../model/ApiTestModel"; import {AssertionJSR223} from "../../model/ApiTestModel";
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter"; import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
import MsJsr233Processor from "../../../automation/scenario/Jsr233Processor"; import MsJsr233Processor from "../../../automation/scenario/component/Jsr233Processor";
export default { export default {
name: "MsApiAssertionJsr223", name: "MsApiAssertionJsr223",

View File

@ -55,7 +55,7 @@
import MsApiAssertionText from "./ApiAssertionText"; import MsApiAssertionText from "./ApiAssertionText";
import MsApiAssertionRegex from "./ApiAssertionRegex"; import MsApiAssertionRegex from "./ApiAssertionRegex";
import MsApiAssertionDuration from "./ApiAssertionDuration"; import MsApiAssertionDuration from "./ApiAssertionDuration";
import {ASSERTION_TYPE, JSONPath, Scenario} from "../../model/ApiTestModel"; import {ASSERTION_TYPE, JSONPath} from "../../model/ApiTestModel";
import MsApiAssertionsEdit from "./ApiAssertionsEdit"; import MsApiAssertionsEdit from "./ApiAssertionsEdit";
import MsApiAssertionJsonPath from "./ApiAssertionJsonPath"; import MsApiAssertionJsonPath from "./ApiAssertionJsonPath";
import MsApiAssertionJsr223 from "./ApiAssertionJsr223"; import MsApiAssertionJsr223 from "./ApiAssertionJsr223";
@ -91,7 +91,6 @@
type: String, type: String,
default: "margin-top: 10px" default: "margin-top: 10px"
}, },
scenario: Scenario,
isReadOnly: { isReadOnly: {
type: Boolean, type: Boolean,
default: false default: false

View File

@ -25,17 +25,13 @@
{{ $t('api_test.definition.request.body_binary') }} {{ $t('api_test.definition.request.body_binary') }}
</el-radio> </el-radio>
</el-radio-group> </el-radio-group>
<el-row v-if="body.type == 'Form Data' || body.type == 'WWW_FORM'">
<el-link class="ms-el-link" @click="batchAdd"> {{$t("commons.batch_add")}}</el-link>
</el-row>
<div style="min-width: 1200px;" v-if="body.type == 'Form Data' || body.type == 'WWW_FORM'"> <div style="min-width: 1200px;" v-if="body.type == 'Form Data' || body.type == 'WWW_FORM'">
<el-row v-if="body.type == 'Form Data' || body.type == 'WWW_FORM'">
<el-link class="ms-el-link" @click="batchAdd"> {{$t("commons.batch_add")}}</el-link>
</el-row>
<ms-api-variable :is-read-only="isReadOnly" <ms-api-variable :is-read-only="isReadOnly"
:parameters="body.kvs" :parameters="body.kvs"
:isShowEnable="isShowEnable" type="body" v-if="body.type == 'Form Data'"/> :isShowEnable="isShowEnable" type="body"/>
<ms-api-from-url-variable :is-read-only="isReadOnly"
:parameters="body.kvs"
type="body" v-if="body.type == 'WWW_FORM'"/>
</div> </div>
<div v-if="body.type == 'JSON'"> <div v-if="body.type == 'JSON'">
<div style="padding: 10px"> <div style="padding: 10px">

View File

@ -92,11 +92,11 @@
</template> </template>
<script> <script>
import {_getBodyUploadFiles, getCurrentProjectID, getUUID} from "../../../../../../common/js/utils"; import {_getBodyUploadFiles, getCurrentProjectID} from "../../../../../../common/js/utils";
import {PRIORITY, RESULT_MAP} from "../../model/JsonData"; import {PRIORITY, RESULT_MAP} from "../../model/JsonData";
import MsTag from "../../../../common/components/MsTag"; import MsTag from "../../../../common/components/MsTag";
import MsTipButton from "../../../../common/components/MsTipButton"; import MsTipButton from "../../../../common/components/MsTipButton";
import MsApiRequestForm from "../request/http/ApiRequestForm"; import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
import ApiEnvironmentConfig from "../environment/ApiEnvironmentConfig"; import ApiEnvironmentConfig from "../environment/ApiEnvironmentConfig";
import MsApiAssertions from "../assertion/ApiAssertions"; import MsApiAssertions from "../assertion/ApiAssertions";
import MsSqlBasisParameters from "../request/database/BasisParameters"; import MsSqlBasisParameters from "../request/database/BasisParameters";

View File

@ -108,13 +108,14 @@
</template> </template>
<script> <script>
import MsApiRequestForm from "../request/http/ApiRequestForm";
import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
import MsResponseText from "../response/ResponseText"; import MsResponseText from "../response/ResponseText";
import {WORKSPACE_ID} from '../../../../../../common/js/constants'; import {WORKSPACE_ID} from '../../../../../../common/js/constants';
import {API_STATUS, REQ_METHOD} from "../../model/JsonData"; import {API_STATUS, REQ_METHOD} from "../../model/JsonData";
import {KeyValue} from "../../model/ApiTestModel"; import {KeyValue} from "../../model/ApiTestModel";
import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag"; import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag";
import MsJsr233Processor from "../../../automation/scenario/Jsr233Processor"; import MsJsr233Processor from "../../../automation/scenario/component/Jsr233Processor";
export default { export default {
name: "MsAddCompleteHttpApi", name: "MsAddCompleteHttpApi",

View File

@ -29,7 +29,6 @@
</template> </template>
<script> <script>
import MsApiRequestForm from "../request/http/ApiRequestForm";
import MsResponseResult from "../response/ResponseResult"; import MsResponseResult from "../response/ResponseResult";
import MsRequestMetric from "../response/RequestMetric"; import MsRequestMetric from "../response/RequestMetric";
import {getUUID, getCurrentUser} from "@/common/js/utils"; import {getUUID, getCurrentUser} from "@/common/js/utils";
@ -42,7 +41,7 @@
export default { export default {
name: "ApiConfig", name: "ApiConfig",
components: {MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters}, components: {MsRequestResultTail, MsResponseResult, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters},
props: { props: {
currentProtocol: String, currentProtocol: String,
scenario: Boolean, scenario: Boolean,

View File

@ -44,7 +44,7 @@
</template> </template>
<script> <script>
import MsApiRequestForm from "../request/http/ApiRequestForm"; import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
import MsResponseResult from "../response/ResponseResult"; import MsResponseResult from "../response/ResponseResult";
import MsRequestMetric from "../response/RequestMetric"; import MsRequestMetric from "../response/RequestMetric";
import {getUUID, getCurrentUser} from "@/common/js/utils"; import {getUUID, getCurrentUser} from "@/common/js/utils";

View File

@ -31,7 +31,6 @@
</template> </template>
<script> <script>
import MsApiRequestForm from "../request/http/ApiRequestForm";
import MsResponseResult from "../response/ResponseResult"; import MsResponseResult from "../response/ResponseResult";
import MsRequestMetric from "../response/RequestMetric"; import MsRequestMetric from "../response/RequestMetric";
import {getUUID, getCurrentUser} from "@/common/js/utils"; import {getUUID, getCurrentUser} from "@/common/js/utils";
@ -44,7 +43,7 @@
export default { export default {
name: "ApiConfig", name: "ApiConfig",
components: {MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters}, components: {MsRequestResultTail, MsResponseResult, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters},
props: { props: {
currentProtocol: String, currentProtocol: String,
scenario: Boolean, scenario: Boolean,

View File

@ -40,7 +40,7 @@
</template> </template>
<script> <script>
import MsApiRequestForm from "../request/http/ApiRequestForm"; import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
import MsResponseResult from "../response/ResponseResult"; import MsResponseResult from "../response/ResponseResult";
import MsRequestMetric from "../response/RequestMetric"; import MsRequestMetric from "../response/RequestMetric";
import {getUUID, getCurrentUser} from "@/common/js/utils"; import {getUUID, getCurrentUser} from "@/common/js/utils";

View File

@ -112,7 +112,7 @@
import ApiEnvironmentConfig from "../../environment/ApiEnvironmentConfig"; import ApiEnvironmentConfig from "../../environment/ApiEnvironmentConfig";
import {getCurrentProjectID} from "@/common/js/utils"; import {getCurrentProjectID} from "@/common/js/utils";
import {getUUID} from "@/common/js/utils"; import {getUUID} from "@/common/js/utils";
import MsJsr233Processor from "../../../../automation/scenario/Jsr233Processor"; import MsJsr233Processor from "../../../../automation/scenario/component/Jsr233Processor";
export default { export default {
name: "MsDatabaseConfig", name: "MsDatabaseConfig",

View File

@ -89,7 +89,7 @@
import MsDubboConfigCenter from "../../request/dubbo/ConfigCenter"; import MsDubboConfigCenter from "../../request/dubbo/ConfigCenter";
import MsDubboConsumerService from "../../request/dubbo/ConsumerAndService"; import MsDubboConsumerService from "../../request/dubbo/ConsumerAndService";
import {getUUID} from "@/common/js/utils"; import {getUUID} from "@/common/js/utils";
import MsJsr233Processor from "../../../../automation/scenario/Jsr233Processor"; import MsJsr233Processor from "../../../../automation/scenario/component/Jsr233Processor";
export default { export default {
name: "MsDatabaseConfig", name: "MsDatabaseConfig",

View File

@ -14,6 +14,10 @@
</div> </div>
</span> </span>
</el-tooltip> </el-tooltip>
<el-row>
<el-link class="ms-el-link" @click="batchAdd"> {{$t("commons.batch_add")}}</el-link>
</el-row>
<ms-api-key-value :is-read-only="isReadOnly" :isShowEnable="isShowEnable" :suggestions="headerSuggestions" :items="headers"/> <ms-api-key-value :is-read-only="isReadOnly" :isShowEnable="isShowEnable" :suggestions="headerSuggestions" :items="headers"/>
</el-tab-pane> </el-tab-pane>
@ -115,7 +119,7 @@
import {getUUID} from "@/common/js/utils"; import {getUUID} from "@/common/js/utils";
import BatchAddParameter from "../../basis/BatchAddParameter"; import BatchAddParameter from "../../basis/BatchAddParameter";
import MsApiAdvancedConfig from "./ApiAdvancedConfig"; import MsApiAdvancedConfig from "./ApiAdvancedConfig";
import MsJsr233Processor from "../../../../automation/scenario/Jsr233Processor"; import MsJsr233Processor from "../../../../automation/scenario/component/Jsr233Processor";
export default { export default {
name: "MsApiHttpRequestForm", name: "MsApiHttpRequestForm",
@ -265,6 +269,9 @@
case "rest": case "rest":
this.request.rest.unshift(item); this.request.rest.unshift(item);
break; break;
case "headers":
this.request.headers.unshift(item);
break;
default: default:
break; break;
} }

View File

@ -1,49 +0,0 @@
<template>
<div class="request-form">
<component :is="component" :showScript="showScript" :is-read-only="isReadOnly" :referenced="referenced" :request="request" :response="response" :headers="headers" :isShowEnable="isShowEnable"/>
</div>
</template>
<script>
import MsApiHttpRequestForm from "./ApiHttpRequestForm";
export default {
name: "MsApiRequestForm",
components: {MsApiHttpRequestForm},
props: {
request: {},
response: {},
headers: Array,
isShowEnable: {
type: Boolean,
default: true
},
showScript: {
type: Boolean,
default: true,
},
referenced: {
type: Boolean,
default: false
},
isReadOnly: {
type: Boolean,
default: false
}
},
computed: {
component({request: {type}}) {
return "MsApiHttpRequestForm";
}
}
}
</script>
<style scoped>
.request-form >>> .debug-button {
margin-left: auto;
display: block;
margin-right: 10px;
}
</style>

View File

@ -43,7 +43,6 @@
</template> </template>
<script> <script>
import MsApiRequestForm from "../request/http/ApiRequestForm";
import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils"; import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils";
import MsApiCaseList from "../case/ApiCaseList"; import MsApiCaseList from "../case/ApiCaseList";
import MsContainer from "../../../../common/components/MsContainer"; import MsContainer from "../../../../common/components/MsContainer";
@ -58,7 +57,6 @@
export default { export default {
name: "RunTestDubboPage", name: "RunTestDubboPage",
components: { components: {
MsApiRequestForm,
MsApiCaseList, MsApiCaseList,
MsContainer, MsContainer,
MsBottomContainer, MsBottomContainer,

View File

@ -69,7 +69,7 @@
</template> </template>
<script> <script>
import MsApiRequestForm from "../request/http/ApiRequestForm"; import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils"; import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils";
import MsApiCaseList from "../case/ApiCaseList"; import MsApiCaseList from "../case/ApiCaseList";
import MsContainer from "../../../../common/components/MsContainer"; import MsContainer from "../../../../common/components/MsContainer";

View File

@ -42,7 +42,6 @@
</template> </template>
<script> <script>
import MsApiRequestForm from "../request/http/ApiRequestForm";
import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils"; import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils";
import MsApiCaseList from "../case/ApiCaseList"; import MsApiCaseList from "../case/ApiCaseList";
import MsContainer from "../../../../common/components/MsContainer"; import MsContainer from "../../../../common/components/MsContainer";
@ -57,7 +56,6 @@
export default { export default {
name: "RunTestSQLPage", name: "RunTestSQLPage",
components: { components: {
MsApiRequestForm,
MsApiCaseList, MsApiCaseList,
MsContainer, MsContainer,
MsBottomContainer, MsBottomContainer,

View File

@ -45,7 +45,7 @@
</template> </template>
<script> <script>
import MsApiRequestForm from "../request/http/ApiRequestForm"; import MsApiRequestForm from "../request/http/ApiHttpRequestForm";
import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils"; import {downloadFile, getUUID, getCurrentProjectID} from "@/common/js/utils";
import MsApiCaseList from "../case/ApiCaseList"; import MsApiCaseList from "../case/ApiCaseList";
import MsContainer from "../../../../common/components/MsContainer"; import MsContainer from "../../../../common/components/MsContainer";

View File

@ -57,7 +57,7 @@
<script> <script>
import {AssertionJSR223} from "../../model/ScenarioModel"; import {AssertionJSR223} from "../../model/ScenarioModel";
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter"; import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
import MsJsr233Processor from "../../../automation/scenario/Jsr233Processor"; import MsJsr233Processor from "../../../automation/scenario/component/Jsr233Processor";
export default { export default {
name: "MsApiAssertionJsr223", name: "MsApiAssertionJsr223",

View File

@ -65,7 +65,7 @@
import MsDubboRegistryCenter from "@/business/components/api/test/components/request/dubbo/RegistryCenter"; import MsDubboRegistryCenter from "@/business/components/api/test/components/request/dubbo/RegistryCenter";
import MsDubboConfigCenter from "@/business/components/api/test/components/request/dubbo/ConfigCenter"; import MsDubboConfigCenter from "@/business/components/api/test/components/request/dubbo/ConfigCenter";
import MsDubboConsumerService from "@/business/components/api/test/components/request/dubbo/ConsumerAndService"; import MsDubboConsumerService from "@/business/components/api/test/components/request/dubbo/ConsumerAndService";
import MsJsr233Processor from "../../../automation/scenario/Jsr233Processor"; import MsJsr233Processor from "../../../automation/scenario/component/Jsr233Processor";
export default { export default {
name: "MsApiDubboRequestForm", name: "MsApiDubboRequestForm",

View File

@ -94,7 +94,7 @@ import ApiRequestMethodSelect from "../collapse/ApiRequestMethodSelect";
import {REQUEST_HEADERS} from "@/common/js/constants"; import {REQUEST_HEADERS} from "@/common/js/constants";
import MsApiVariable from "@/business/components/api/test/components/ApiVariable"; import MsApiVariable from "@/business/components/api/test/components/ApiVariable";
import MsApiAdvancedConfig from "../ApiAdvancedConfig"; import MsApiAdvancedConfig from "../ApiAdvancedConfig";
import MsJsr233Processor from "../../../automation/scenario/Jsr233Processor"; import MsJsr233Processor from "../../../automation/scenario/component/Jsr233Processor";
export default { export default {
name: "MsApiHttpRequestForm", name: "MsApiHttpRequestForm",

View File

@ -78,7 +78,7 @@
import MsDubboConsumerService from "@/business/components/api/test/components/request/dubbo/ConsumerAndService"; import MsDubboConsumerService from "@/business/components/api/test/components/request/dubbo/ConsumerAndService";
import MsCodeEdit from "../../../../common/components/MsCodeEdit"; import MsCodeEdit from "../../../../common/components/MsCodeEdit";
import MsApiScenarioVariables from "../ApiScenarioVariables"; import MsApiScenarioVariables from "../ApiScenarioVariables";
import MsJsr233Processor from "../../../automation/scenario/Jsr233Processor"; import MsJsr233Processor from "../../../automation/scenario/component/Jsr233Processor";
export default { export default {
name: "MsApiSqlRequestForm", name: "MsApiSqlRequestForm",

View File

@ -120,7 +120,7 @@ import {Scenario, TCPConfig, TCPRequest} from "@/business/components/api/test/mo
import MsApiAssertions from "@/business/components/api/test/components/assertion/ApiAssertions"; import MsApiAssertions from "@/business/components/api/test/components/assertion/ApiAssertions";
import MsApiExtract from "@/business/components/api/test/components/extract/ApiExtract"; import MsApiExtract from "@/business/components/api/test/components/extract/ApiExtract";
import MsCodeEdit from "@/business/components/common/components/MsCodeEdit"; import MsCodeEdit from "@/business/components/common/components/MsCodeEdit";
import MsJsr233Processor from "../../../automation/scenario/Jsr233Processor"; import MsJsr233Processor from "../../../automation/scenario/component/Jsr233Processor";
export default { export default {
name: "MsApiTcpRequestForm", name: "MsApiTcpRequestForm",

View File

@ -31,7 +31,7 @@
body: {}, body: {},
}, },
created() { created() {
if (!this.body.jsonSchema && this.body.raw) { if (!this.body.jsonSchema && this.body.raw && this.checkIsJson(this.body.raw)) {
let obj = {"root": GenerateSchema(JSON.parse(this.body.raw))} let obj = {"root": GenerateSchema(JSON.parse(this.body.raw))}
this.schema = obj; this.schema = obj;
} }
@ -70,6 +70,14 @@
openOneClickOperation() { openOneClickOperation() {
this.$refs.importJson.openOneClickOperation(); this.$refs.importJson.openOneClickOperation();
}, },
checkIsJson(json) {
try {
JSON.parse(json);
return true;
} catch (e) {
return false;
}
},
jsonData(data) { jsonData(data) {
let obj = {"root": data} let obj = {"root": data}
this.schema = obj; this.schema = obj;

View File

@ -61,7 +61,6 @@
json5.parse(json); json5.parse(json);
return true; return true;
} catch (e) { } catch (e) {
alert(1);
return false; return false;
} }
}, },

View File

@ -289,7 +289,6 @@
for (const k in this.advancedValue) { for (const k in this.advancedValue) {
if (this.pickValue[k]) this.advancedValue[k] = this.pickValue[k] if (this.pickValue[k]) this.advancedValue[k] = this.pickValue[k]
} }
console.log(this.pickValue)
}, },
handleClose() { handleClose() {
this.modalVisible = false; this.modalVisible = false;