diff --git a/frontend/src/business/components/api/definition/components/case/ApiCaseHeader.vue b/frontend/src/business/components/api/definition/components/case/ApiCaseHeader.vue
index 342d6e11b8..5357272d7c 100644
--- a/frontend/src/business/components/api/definition/components/case/ApiCaseHeader.vue
+++ b/frontend/src/business/components/api/definition/components/case/ApiCaseHeader.vue
@@ -27,7 +27,7 @@
- {{ $t('commons.save') }}
+ {{ saveButtonText }}
@@ -50,6 +50,7 @@ export default {
data() {
return {
methodColorMap: new Map(API_METHOD_COLOUR),
+ saveButtonText: this.$t('commons.save'),
}
},
props: {
@@ -59,6 +60,7 @@ export default {
isReadOnly: Boolean,
useEnvironment: String,
isCaseEdit: Boolean,
+ buttonText: String,
condition: {
type: Object,
default() {
@@ -78,6 +80,11 @@ export default {
beforeDestroy() {
window.removeEventListener('keydown', this.keyDown) // 在页面销毁的时候记得解除
},
+ created() {
+ if (this.buttonText) {
+ this.saveButtonText = this.buttonText;
+ }
+ },
methods: {
keyDown(e) {
if (!(e.keyCode === 83 && (e.ctrlKey || e.metaKey))) {
diff --git a/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue b/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue
index ed874534b3..f9d36dde68 100644
--- a/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue
+++ b/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue
@@ -12,6 +12,7 @@
:project-id="projectId"
:useEnvironment="environment"
:is-case-edit="isCaseEdit"
+ :button-text="saveButtonText"
ref="header"/>
@@ -68,6 +69,7 @@ export default {
type: Boolean,
default: false
},
+ saveButtonText:String,
refreshSign: String,
currentApi: {
type: Object
diff --git a/frontend/src/business/components/api/definition/components/runtest/RunTestDubboPage.vue b/frontend/src/business/components/api/definition/components/runtest/RunTestDubboPage.vue
index 5590c47587..4b76062fa6 100644
--- a/frontend/src/business/components/api/definition/components/runtest/RunTestDubboPage.vue
+++ b/frontend/src/business/components/api/definition/components/runtest/RunTestDubboPage.vue
@@ -18,7 +18,9 @@
{{ $t('api_test.definition.request.save_as') }}
- {{ $t('report.stop_btn') }}
+
+ {{ $t('report.stop_btn') }}
+
@@ -35,6 +37,7 @@
@@ -77,6 +80,7 @@ export default {
loaded: false,
loading: false,
currentRequest: {},
+ loadCaseConfirmButton: this.$t("commons.confirm"),
createCase: "",
refreshSign: "",
responseData: {type: 'HTTP', responseResult: {}, subRequestResults: []},
diff --git a/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue b/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue
index bc07bff00e..db76aca4ee 100644
--- a/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue
+++ b/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue
@@ -78,6 +78,7 @@
:refreshSign="refreshSign"
:createCase="createCase"
:currentApi="api"
+ :save-button-text="loadCaseConfirmButton"
ref="caseList"/>
@@ -118,6 +119,7 @@ export default {
createCase: "",
currentRequest: {},
refreshSign: "",
+ loadCaseConfirmButton:this.$t("commons.confirm"),
responseData: {type: 'HTTP', responseResult: {}, subRequestResults: []},
reqOptions: REQ_METHOD,
rules: {
diff --git a/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue b/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue
index 01c6fccdd4..82394701c3 100644
--- a/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue
+++ b/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue
@@ -8,33 +8,36 @@
- {{$t('commons.test')}}
+ {{ $t('commons.test') }}
- {{$t('api_test.definition.request.load_case')}}
+ {{ $t('api_test.definition.request.load_case') }}
- {{$t('api_test.definition.request.save_as_case')}}
+ {{ $t('api_test.definition.request.save_as_case') }}
- {{$t('api_test.definition.request.update_api')}}
- {{$t('api_test.definition.request.save_as')}}
+ {{ $t('api_test.definition.request.update_api') }}
+ {{ $t('api_test.definition.request.save_as') }}
-
{{ $t('report.stop_btn') }}
-
{{$t('api_test.definition.request.req_param')}}
+
+ {{ $t('report.stop_btn') }}
+
+
{{ $t('api_test.definition.request.req_param') }}
-
{{$t('api_test.definition.request.res_param')}}
+
{{ $t('api_test.definition.request.res_param') }}
-
@@ -69,235 +72,236 @@ export default {
ApiEnvironmentConfig,
MsRun,
MsBasisParameters
- },
- data() {
- return {
- visible: false,
- api: {},
- loaded: false,
- loading: false,
- currentRequest: {},
- responseData: {type: 'HTTP', responseResult: {}, subRequestResults: []},
- reqOptions: REQ_METHOD,
- refreshSign: "",
- createCase: "",
- environments: [],
- rules: {
- method: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
- url: [{required: true, message: this.$t('api_test.definition.request.path_info'), trigger: 'blur'}],
- environmentId: [{required: true, message: this.$t('api_test.definition.request.run_env'), trigger: 'change'}],
- },
- runData: [],
- reportId: "",
- runLoading: false,
- versionEnable: false,
+ },
+ data() {
+ return {
+ loadCaseConfirmButton: this.$t("commons.confirm"),
+ visible: false,
+ api: {},
+ loaded: false,
+ loading: false,
+ currentRequest: {},
+ responseData: {type: 'HTTP', responseResult: {}, subRequestResults: []},
+ reqOptions: REQ_METHOD,
+ refreshSign: "",
+ createCase: "",
+ environments: [],
+ rules: {
+ method: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
+ url: [{required: true, message: this.$t('api_test.definition.request.path_info'), trigger: 'blur'}],
+ environmentId: [{required: true, message: this.$t('api_test.definition.request.run_env'), trigger: 'change'}],
+ },
+ runData: [],
+ reportId: "",
+ runLoading: false,
+ versionEnable: false,
+ }
+ },
+ props: {apiData: {}, currentProtocol: String, syncTabs: Array, projectId: String},
+ methods: {
+ handleCommand(e) {
+ switch (e) {
+ case "load_case":
+ return this.loadCase();
+ case "save_as_case":
+ return this.saveAsCase();
+ case "update_api":
+ return this.updateApi();
+ case "save_as_api":
+ return this.saveAsApi();
+ default:
+ return this.$refs['requestForm'].validate();
}
},
- props: {apiData: {}, currentProtocol: String,syncTabs: Array, projectId: String},
- methods: {
- handleCommand(e) {
- switch (e) {
- case "load_case":
- return this.loadCase();
- case "save_as_case":
- return this.saveAsCase();
- case "update_api":
- return this.updateApi();
- case "save_as_api":
- return this.saveAsApi();
- default:
- return this.$refs['requestForm'].validate();
- }
- },
- refresh(){
- this.$emit('refresh');
- },
- errorRefresh(){
- this.loading = false;
- this.runLoading = false;
- },
- runTest() {
- this.runLoading = true;
- this.loading = true;
- this.api.request.name = this.api.id;
- this.api.protocol = this.currentProtocol;
- this.runData = [];
- this.runData.push(this.api.request);
- /*触发执行操作*/
- this.reportId = getUUID().substring(0, 8);
- },
- runRefresh(data) {
- this.responseData = data;
- this.loading = false;
- this.runLoading = false;
- },
- saveAs() {
- this.$emit('saveAs', this.api);
- },
- loadCase() {
- this.refreshSign = getUUID();
- this.$refs.caseList.open();
- this.visible = true;
- },
- apiCaseClose() {
- this.visible = false;
- },
- getBodyUploadFiles() {
- let bodyUploadFiles = [];
- this.api.bodyUploadIds = [];
- let request = this.api.request;
- if (request.body) {
- request.body.kvs.forEach(param => {
- if (param.files) {
- param.files.forEach(item => {
- if (item.file) {
- let fileId = getUUID().substring(0, 8);
- item.name = item.file.name;
- item.id = fileId;
- this.api.bodyUploadIds.push(fileId);
- bodyUploadFiles.push(item.file);
- }
- });
- }
- });
- }
- return bodyUploadFiles;
- },
- saveAsCase() {
- this.$emit('saveAsCase', this.api);
- },
- saveAsApi() {
- let data = {};
- let req = this.api.request;
- req.id = getUUID();
- data.request = JSON.stringify(req);
- data.method = this.api.method;
- data.status = this.api.status;
- data.userId = this.api.userId;
- data.description = this.api.description;
- this.$emit('saveAsApi', data);
- this.$emit('refresh');
- },
- compatibleHistory(stepArray) {
- if (stepArray) {
- for (let i in stepArray) {
- if (!stepArray[i].clazzName) {
- stepArray[i].clazzName = TYPE_TO_C.get(stepArray[i].type);
- }
- if (stepArray[i].hashTree && stepArray[i].hashTree.length > 0) {
- this.compatibleHistory(stepArray[i].hashTree);
- }
- }
- }
- },
- updateApi() {
- let url = "/api/definition/update";
- let bodyFiles = this.getBodyUploadFiles();
- if (Object.prototype.toString.call(this.api.response).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'object') {
- this.api.response = JSON.parse(this.api.response);
- }
- if (this.api.tags instanceof Array) {
- this.api.tags = JSON.stringify(this.api.tags);
- }
- // 历史数据兼容处理
- if (this.api.request) {
- this.api.request.clazzName = TYPE_TO_C.get(this.api.request.type);
- this.compatibleHistory(this.api.request.hashTree);
- }
- this.$fileUpload(url, null, bodyFiles, this.api, () => {
- this.$success(this.$t('commons.save_success'));
- if (this.syncTabs.indexOf(this.api.id) === -1) {
- this.syncTabs.push(this.api.id);
- }
- this.$emit('refresh');
- });
- },
- selectTestCase(item) {
- if (item != null) {
- this.api.request = item.request;
- } else {
- this.api.request = this.currentRequest;
- }
- },
- getEnvironments() {
- this.$get('/api/environment/list/' + this.projectId, response => {
- this.environments = response.data;
- this.environments.forEach(environment => {
- parseEnvironment(environment);
- });
- let hasEnvironment = false;
- for (let i in this.environments) {
- if (this.environments[i].id === this.api.environmentId) {
- this.api.environment = this.environments[i];
- hasEnvironment = true;
- break;
- }
- }
- if (!hasEnvironment) {
- this.api.environmentId = '';
- this.api.environment = undefined;
+ refresh() {
+ this.$emit('refresh');
+ },
+ errorRefresh() {
+ this.loading = false;
+ this.runLoading = false;
+ },
+ runTest() {
+ this.runLoading = true;
+ this.loading = true;
+ this.api.request.name = this.api.id;
+ this.api.protocol = this.currentProtocol;
+ this.runData = [];
+ this.runData.push(this.api.request);
+ /*触发执行操作*/
+ this.reportId = getUUID().substring(0, 8);
+ },
+ runRefresh(data) {
+ this.responseData = data;
+ this.loading = false;
+ this.runLoading = false;
+ },
+ saveAs() {
+ this.$emit('saveAs', this.api);
+ },
+ loadCase() {
+ this.refreshSign = getUUID();
+ this.$refs.caseList.open();
+ this.visible = true;
+ },
+ apiCaseClose() {
+ this.visible = false;
+ },
+ getBodyUploadFiles() {
+ let bodyUploadFiles = [];
+ this.api.bodyUploadIds = [];
+ let request = this.api.request;
+ if (request.body) {
+ request.body.kvs.forEach(param => {
+ if (param.files) {
+ param.files.forEach(item => {
+ if (item.file) {
+ let fileId = getUUID().substring(0, 8);
+ item.name = item.file.name;
+ item.id = fileId;
+ this.api.bodyUploadIds.push(fileId);
+ bodyUploadFiles.push(item.file);
+ }
+ });
}
});
- },
- openEnvironmentConfig() {
- this.$refs.environmentConfig.open(this.projectId);
- },
- environmentChange(value) {
+ }
+ return bodyUploadFiles;
+ },
+ saveAsCase() {
+ this.$emit('saveAsCase', this.api);
+ },
+ saveAsApi() {
+ let data = {};
+ let req = this.api.request;
+ req.id = getUUID();
+ data.request = JSON.stringify(req);
+ data.method = this.api.method;
+ data.status = this.api.status;
+ data.userId = this.api.userId;
+ data.description = this.api.description;
+ this.$emit('saveAsApi', data);
+ this.$emit('refresh');
+ },
+ compatibleHistory(stepArray) {
+ if (stepArray) {
+ for (let i in stepArray) {
+ if (!stepArray[i].clazzName) {
+ stepArray[i].clazzName = TYPE_TO_C.get(stepArray[i].type);
+ }
+ if (stepArray[i].hashTree && stepArray[i].hashTree.length > 0) {
+ this.compatibleHistory(stepArray[i].hashTree);
+ }
+ }
+ }
+ },
+ updateApi() {
+ let url = "/api/definition/update";
+ let bodyFiles = this.getBodyUploadFiles();
+ if (Object.prototype.toString.call(this.api.response).match(/\[object (\w+)\]/)[1].toLowerCase() !== 'object') {
+ this.api.response = JSON.parse(this.api.response);
+ }
+ if (this.api.tags instanceof Array) {
+ this.api.tags = JSON.stringify(this.api.tags);
+ }
+ // 历史数据兼容处理
+ if (this.api.request) {
+ this.api.request.clazzName = TYPE_TO_C.get(this.api.request.type);
+ this.compatibleHistory(this.api.request.hashTree);
+ }
+ this.$fileUpload(url, null, bodyFiles, this.api, () => {
+ this.$success(this.$t('commons.save_success'));
+ if (this.syncTabs.indexOf(this.api.id) === -1) {
+ this.syncTabs.push(this.api.id);
+ }
+ this.$emit('refresh');
+ });
+ },
+ selectTestCase(item) {
+ if (item != null) {
+ this.api.request = item.request;
+ } else {
+ this.api.request = this.currentRequest;
+ }
+ },
+ getEnvironments() {
+ this.$get('/api/environment/list/' + this.projectId, response => {
+ this.environments = response.data;
+ this.environments.forEach(environment => {
+ parseEnvironment(environment);
+ });
+ let hasEnvironment = false;
for (let i in this.environments) {
- if (this.environments[i].id === value) {
- this.api.request.useEnvironment = this.environments[i].id;
+ if (this.environments[i].id === this.api.environmentId) {
+ this.api.environment = this.environments[i];
+ hasEnvironment = true;
break;
}
}
- },
- environmentConfigClose() {
- this.getEnvironments();
- },
- getResult() {
- if (this.api.id) {
- let url = "/api/definition/report/getReport/" + this.api.id;
- this.$get(url, response => {
- if (response.data) {
- let data = JSON.parse(response.data.content);
- this.responseData = data;
- }
- });
+ if (!hasEnvironment) {
+ this.api.environmentId = '';
+ this.api.environment = undefined;
}
- },
- stop() {
- let url = "/api/automation/stop/" + this.reportId;
- this.$get(url, () => {
- this.runLoading = false;
- this.loading = false;
- this.$success(this.$t('report.test_stop_success'));
- });
- },
- checkVersionEnable() {
- if (!this.projectId) {
- return;
- }
- if (hasLicense()) {
- this.$get('/project/version/enable/' + this.projectId, response => {
- this.versionEnable = response.data;
- });
+ });
+ },
+ openEnvironmentConfig() {
+ this.$refs.environmentConfig.open(this.projectId);
+ },
+ environmentChange(value) {
+ for (let i in this.environments) {
+ if (this.environments[i].id === value) {
+ this.api.request.useEnvironment = this.environments[i].id;
+ break;
}
}
},
- created() {
- // 深度复制
- this.api = JSON.parse(JSON.stringify(this.apiData));
- this.api.protocol = this.currentProtocol;
- this.currentRequest = this.api.request;
- this.runLoading = false;
+ environmentConfigClose() {
this.getEnvironments();
- this.getResult();
- this.checkVersionEnable();
+ },
+ getResult() {
+ if (this.api.id) {
+ let url = "/api/definition/report/getReport/" + this.api.id;
+ this.$get(url, response => {
+ if (response.data) {
+ let data = JSON.parse(response.data.content);
+ this.responseData = data;
+ }
+ });
+ }
+ },
+ stop() {
+ let url = "/api/automation/stop/" + this.reportId;
+ this.$get(url, () => {
+ this.runLoading = false;
+ this.loading = false;
+ this.$success(this.$t('report.test_stop_success'));
+ });
+ },
+ checkVersionEnable() {
+ if (!this.projectId) {
+ return;
+ }
+ if (hasLicense()) {
+ this.$get('/project/version/enable/' + this.projectId, response => {
+ this.versionEnable = response.data;
+ });
+ }
}
+ },
+ created() {
+ // 深度复制
+ this.api = JSON.parse(JSON.stringify(this.apiData));
+ this.api.protocol = this.currentProtocol;
+ this.currentRequest = this.api.request;
+ this.runLoading = false;
+ this.getEnvironments();
+ this.getResult();
+ this.checkVersionEnable();
}
+}
diff --git a/frontend/src/business/components/api/definition/components/runtest/RunTestTCPPage.vue b/frontend/src/business/components/api/definition/components/runtest/RunTestTCPPage.vue
index 55a8865e24..96fc81d899 100644
--- a/frontend/src/business/components/api/definition/components/runtest/RunTestTCPPage.vue
+++ b/frontend/src/business/components/api/definition/components/runtest/RunTestTCPPage.vue
@@ -33,21 +33,21 @@
-
-
-
{{ $t('api_test.definition.request.req_param') }}
-
-
-
-
{{ $t('api_test.definition.request.res_param') }}
-
-
-
-
{{ $t('api_test.definition.request.req_param') }}
-
-
+
+
+
{{ $t('api_test.definition.request.req_param') }}
+
+
+
+
{{ $t('api_test.definition.request.res_param') }}
+
+
+
+
{{ $t('api_test.definition.request.req_param') }}
+
+
@@ -62,6 +62,7 @@
@@ -103,6 +104,7 @@ export default {
},
data() {
return {
+ loadCaseConfirmButton: this.$t("commons.confirm"),
visible: false,
api: {},
loaded: false,