fix(接口自动化):修复部分缺陷,合并sql 脚本
This commit is contained in:
parent
41146ad7d1
commit
5b6a4ddd82
|
@ -16,7 +16,7 @@ CREATE TABLE `api_scenario` (
|
|||
`follow_people` varchar(100) DEFAULT NULL COMMENT 'api scenario Follow people ',
|
||||
`schedule` varchar(255) DEFAULT NULL COMMENT 'Test schedule (cron list)',
|
||||
`scenario_definition` longtext COMMENT 'Test scenario_definition json',
|
||||
`description` varchar(255) DEFAULT NULL COMMENT 'api scenario description',
|
||||
`description` longtext DEFAULT NULL COMMENT 'api scenario description',
|
||||
`create_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
|
||||
`update_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
|
||||
`pass_rate` varchar(100) DEFAULT NULL,
|
||||
|
@ -43,12 +43,13 @@ CREATE TABLE `api_scenario_report` (
|
|||
`id` varchar(50) NOT NULL COMMENT 'Test report ID',
|
||||
`project_id` varchar(50) NOT NULL COMMENT 'scenario ID this test report belongs to',
|
||||
`name` varchar(64) NOT NULL COMMENT 'Test report name',
|
||||
`description` varchar(255) DEFAULT NULL COMMENT 'Test report name',
|
||||
`description` longtext DEFAULT NULL COMMENT 'Test report name',
|
||||
`create_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
|
||||
`update_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
|
||||
`status` varchar(64) NOT NULL COMMENT 'Status of this test run',
|
||||
`user_id` varchar(64) DEFAULT NULL,
|
||||
`trigger_mode` varchar(64) DEFAULT NULL,
|
||||
`execute_type` varchar(200) NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ CREATE TABLE IF NOT EXISTS `api_definition` (
|
|||
`protocol` varchar(255) NOT NULL COMMENT 'request protocol',
|
||||
`path` varchar(1000) DEFAULT NULL COMMENT 'request path',
|
||||
`module_path` varchar(1000) COMMENT 'module path',
|
||||
`description` varchar(255) DEFAULT NULL COMMENT 'Test description',
|
||||
`description` longtext DEFAULT NULL COMMENT 'Test description',
|
||||
`environment_id` varchar(50) DEFAULT NULL COMMENT 'environment id',
|
||||
`request` longtext COMMENT 'request (JSON format)',
|
||||
`response` longtext COMMENT 'request (JSON format)',
|
||||
|
@ -40,7 +40,7 @@ CREATE TABLE IF NOT EXISTS `api_test_case` (
|
|||
`name` varchar(64) NOT NULL COMMENT 'Test name',
|
||||
`priority` varchar(64) NOT NULL COMMENT 'priority',
|
||||
`api_definition_id` varchar(50) NOT NULL COMMENT 'api definition id',
|
||||
`description` varchar(255) DEFAULT NULL COMMENT 'Test description',
|
||||
`description` longtext DEFAULT NULL COMMENT 'Test description',
|
||||
`request` longtext COMMENT 'request (JSON format)',
|
||||
`response` longtext COMMENT 'response (JSON format)',
|
||||
`create_user_id` varchar(64) DEFAULT NULL COMMENT 'User ID',
|
||||
|
@ -59,6 +59,7 @@ CREATE TABLE IF NOT EXISTS `api_definition_exec_result` (
|
|||
`user_id` varchar(64) DEFAULT NULL COMMENT 'User ID',
|
||||
`start_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
|
||||
`end_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
|
||||
`create_time` bigint(13) NULL COMMENT 'Create time',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE api_definition_exec_result ADD create_time BIGINT(13) NULL;
|
|
@ -1,5 +0,0 @@
|
|||
ALTER TABLE api_scenario_report ADD execute_type varchar(200) NULL;
|
||||
ALTER TABLE api_definition MODIFY COLUMN description LONGTEXT NULL COMMENT 'Test description';
|
||||
ALTER TABLE api_test_case MODIFY COLUMN description LONGTEXT NULL COMMENT 'Test case description';
|
||||
ALTER TABLE api_scenario MODIFY COLUMN description LONGTEXT NULL COMMENT 'Api scenario description';
|
||||
ALTER TABLE api_scenario_report MODIFY COLUMN description LONGTEXT NULL COMMENT 'Api scenario report description';
|
|
@ -73,7 +73,6 @@
|
|||
methods: {
|
||||
active() {
|
||||
this.isActive = !this.isActive;
|
||||
console.log(this.request)
|
||||
//this.$emit("requestResult", {request: this.request, scenarioName: this.scenarioName});
|
||||
}
|
||||
},
|
||||
|
|
|
@ -59,7 +59,6 @@
|
|||
methods: {
|
||||
active() {
|
||||
this.isActive = !this.isActive;
|
||||
console.log(this.request)
|
||||
//this.$emit("requestResult", {request: this.request, scenarioName: this.scenarioName});
|
||||
}
|
||||
},
|
||||
|
|
|
@ -2,18 +2,18 @@
|
|||
<div v-loading="loading">
|
||||
<el-card>
|
||||
<el-row>
|
||||
<div class="el-step__icon is-text ms-api-col" v-if="request.referenced!=undefined && request.referenced==='Deleted' || request.referenced=='REF'">
|
||||
<div class="el-step__icon is-text ms-api-col" v-if="request.referenced!=undefined && request.referenced==='Deleted' || request.referenced=='REF' || request.referenced==='Copy'">
|
||||
<div class="el-step__icon-inner">{{request.index}}</div>
|
||||
</div>
|
||||
<div class="el-step__icon is-text ms-api-col-create" v-else>
|
||||
<div class="el-step__icon-inner">{{request.index}}</div>
|
||||
</div>
|
||||
|
||||
<el-button v-if="request.referenced!=undefined && request.referenced==='Deleted' || request.referenced=='REF'" class="ms-left-buttion" size="small">
|
||||
<el-button v-if="request.referenced!=undefined && request.referenced==='Deleted' || request.referenced=='REF' || request.referenced==='Copy'" class="ms-left-buttion" size="small">
|
||||
{{$t('api_test.automation.api_list_import')}}
|
||||
</el-button>
|
||||
|
||||
<el-button v-if="request.referenced==undefined || request.referenced==='Created' || request.referenced==='Copy'" class="ms-create-buttion" size="small">
|
||||
<el-button v-if="request.referenced==undefined || request.referenced==='Created' " class="ms-create-buttion" size="small">
|
||||
{{$t('api_test.automation.customize_req')}}
|
||||
</el-button>
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
|||
<el-input size="small" v-model="request.name" style="width: 40%;" :placeholder="$t('commons.input_name')" v-else/>
|
||||
|
||||
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag>
|
||||
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag>
|
||||
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced ==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
|
||||
<div style="margin-right: 20px; float: right">
|
||||
<i class="icon el-icon-arrow-right" :class="{'is-active': request.active}"
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<el-button class="ms-title-buttion" size="small">{{$t('api_test.automation.scenario_import')}}</el-button>
|
||||
{{scenario.name}}
|
||||
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag>
|
||||
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag>
|
||||
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
|
||||
<div style="margin-right: 20px; float: right">
|
||||
<el-switch v-model="scenario.enable" style="margin-left: 10px"/>
|
||||
|
|
|
@ -134,10 +134,10 @@
|
|||
:{{this.currentScenario.variables!=undefined?this.currentScenario.variables.length-1: 0}}
|
||||
</el-col>
|
||||
<el-col :span="3" class="ms-col-one ms-font">
|
||||
<el-checkbox v-model="enableCookieShare">{{ '共享cookie' }}</el-checkbox>
|
||||
<el-checkbox v-model="enableCookieShare">共享cookie</el-checkbox>
|
||||
</el-col>
|
||||
<el-col :span="7" class="ms-font">
|
||||
{{$t('api_test.definition.request.run_env')}}:
|
||||
{{$t('api_test.definition.request.run_env')}}:
|
||||
<el-select v-model="currentEnvironmentId" size="small" class="ms-htt-width"
|
||||
:placeholder="$t('api_test.definition.request.run_env')"
|
||||
clearable>
|
||||
|
@ -826,12 +826,13 @@
|
|||
margin-right: 10px;
|
||||
color: white;
|
||||
}
|
||||
.ms-font{
|
||||
|
||||
.ms-font {
|
||||
color: #303133;
|
||||
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", Arial, sans-serif;
|
||||
font-size: 13px;
|
||||
|
||||
}
|
||||
|
||||
.ms-col-one {
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
@ -921,6 +922,17 @@
|
|||
font-weight: normal;
|
||||
}
|
||||
|
||||
/deep/ .el-checkbox {
|
||||
color: #303133;
|
||||
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", Arial, sans-serif;
|
||||
font-size: 13px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
/deep/ .el-checkbox__label {
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.head {
|
||||
border-bottom: 1px solid #303133;
|
||||
color: #303133;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<div>
|
||||
<div style="min-width: 1000px;margin-bottom: 20px">
|
||||
<el-radio-group v-model="body.type" size="mini">
|
||||
<el-radio :disabled="isReadOnly" :label="type.FORM_DATA" @change="modeChange">
|
||||
{{ $t('api_test.definition.request.body_form_data') }}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<el-col :span="16">
|
||||
<el-form-item :label="$t('api_report.request')" prop="path">
|
||||
<el-input :placeholder="$t('api_test.definition.request.path_info')" v-model="httpForm.path"
|
||||
class="ms-http-input" size="small" style="margin-top: 5px">
|
||||
class="ms-http-input" size="small" style="margin-top: 5px" @change="urlChange">
|
||||
<el-select v-model="httpForm.method" slot="prepend" style="width: 100px" size="small">
|
||||
<el-option v-for="item in reqOptions" :key="item.id" :label="item.label" :value="item.id"/>
|
||||
</el-select>
|
||||
|
@ -95,6 +95,7 @@
|
|||
import {WORKSPACE_ID} from '../../../../../../common/js/constants';
|
||||
import {REQ_METHOD, API_STATUS} from "../../model/JsonData";
|
||||
import MsJsr233Processor from "../processor/Jsr233Processor";
|
||||
import {KeyValue} from "../../model/ApiTestModel";
|
||||
|
||||
export default {
|
||||
name: "MsAddCompleteHttpApi",
|
||||
|
@ -169,6 +170,35 @@
|
|||
});
|
||||
return path[0].path;
|
||||
},
|
||||
urlChange() {
|
||||
if (!this.httpForm.path) return;
|
||||
let url = this.getURL(this.addProtocol(this.httpForm.path));
|
||||
if (url) {
|
||||
this.httpForm.path = decodeURIComponent("/" + url.hostname + url.pathname);
|
||||
}
|
||||
},
|
||||
addProtocol(url) {
|
||||
if (url) {
|
||||
if (!url.toLowerCase().startsWith("https") && !url.toLowerCase().startsWith("http")) {
|
||||
return "https://" + url;
|
||||
}
|
||||
}
|
||||
return url;
|
||||
},
|
||||
getURL(urlStr) {
|
||||
try {
|
||||
let url = new URL(urlStr);
|
||||
console.log(urlStr)
|
||||
url.searchParams.forEach((value, key) => {
|
||||
if (key && value) {
|
||||
this.request.arguments.splice(0, 0, new KeyValue({name: key, required: false, value: value}));
|
||||
}
|
||||
});
|
||||
return url;
|
||||
} catch (e) {
|
||||
this.$error(this.$t('api_test.request.url_invalid'), 2000);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
created() {
|
||||
|
|
|
@ -18,9 +18,6 @@
|
|||
<span style="margin-right: 10px">
|
||||
<el-checkbox class="follow-redirects-item" v-model="request.followRedirects">{{$t('api_test.request.follow_redirects')}}</el-checkbox>
|
||||
</span>
|
||||
<span style="margin-right: 10px">
|
||||
<el-checkbox class="do-multipart-post" v-model="request.doMultipartPost">{{$t('api_test.request.do_multipart_post')}}</el-checkbox>
|
||||
</span>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
</el-tab-pane>
|
||||
|
||||
<!--请求体-->
|
||||
<el-tab-pane v-if="isBodyShow" :label="$t('api_test.request.body')" name="body">
|
||||
<el-tab-pane v-if="isBodyShow" :label="$t('api_test.request.body')" name="body" style="overflow: auto">
|
||||
<ms-api-body @headersChange="reloadBody" :is-read-only="isReadOnly" :isShowEnable="isShowEnable" :headers="headers" :body="request.body"/>
|
||||
</el-tab-pane>
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<ms-code-edit v-if="!isSqlType" :mode="mode" :read-only="true" :modes="modes" :data.sync="response.responseResult.body" ref="codeEdit"/>
|
||||
</el-tab-pane>
|
||||
<!--<el-tab-pane label="Cookie" name="cookie" class="pane cookie">-->
|
||||
<!--<pre>{{response.cookies}}</pre>-->
|
||||
<!--<pre>{{response.cookies}}</pre>-->
|
||||
<!--</el-tab-pane>-->
|
||||
|
||||
<el-tab-pane :label="$t('api_test.definition.request.console')" name="console" class="pane">
|
||||
|
@ -26,17 +26,21 @@
|
|||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane :label="$t('api_report.request_body')" name="request_body" class="pane">
|
||||
<div>
|
||||
{{$t('api_test.request.address')}} : {{ response.url }}
|
||||
<div class="ms-div">
|
||||
{{$t('api_test.request.address')}} :
|
||||
<pre>{{ response.url }}</pre>
|
||||
</div>
|
||||
<div>
|
||||
{{$t('api_test.scenario.headers')}} : {{ response.headers }}
|
||||
<div class="ms-div">
|
||||
{{$t('api_test.scenario.headers')}} :
|
||||
<pre>{{ response.headers }}</pre>
|
||||
</div>
|
||||
<div>
|
||||
Cookies : {{response.cookies}}
|
||||
<div class="ms-div">
|
||||
Cookies :
|
||||
<pre>{{response.cookies}}</pre>
|
||||
</div>
|
||||
<div>
|
||||
Body : {{response.body}}
|
||||
<div class="ms-div">
|
||||
Body :
|
||||
<pre>{{response.body}}</pre>
|
||||
</div>
|
||||
|
||||
</el-tab-pane>
|
||||
|
@ -45,7 +49,6 @@
|
|||
<template v-slot:label>
|
||||
<ms-dropdown v-if="currentProtocol==='SQL'" :commands="sqlModes" :default-command="mode" @command="sqlModeChange"/>
|
||||
<ms-dropdown v-else :commands="modes" :default-command="mode" @command="modeChange"/>
|
||||
|
||||
</template>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
@ -139,6 +142,10 @@
|
|||
height: 0px;
|
||||
}
|
||||
|
||||
.ms-div {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
pre {
|
||||
margin: 0;
|
||||
}
|
||||
|
|
|
@ -24,79 +24,83 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "MsSqlResultTable",
|
||||
data() {
|
||||
return {
|
||||
tables: [],
|
||||
titles: []
|
||||
}
|
||||
},
|
||||
props: {
|
||||
body: String
|
||||
},
|
||||
created() {
|
||||
if (!this.body) {
|
||||
return;
|
||||
}
|
||||
let rowArry = this.body.split("\n");
|
||||
this.getTableData(rowArry);
|
||||
if (this.tables.length > 1) {
|
||||
for (let i = 0; i < this.tables.length; i++) {
|
||||
if (this.tables[i].titles.length === 1 && i < this.tables.length - 1) {
|
||||
this.tables[i].tableData.splice(this.tables[i].tableData.length - 1, 1);
|
||||
}
|
||||
export default {
|
||||
name: "MsSqlResultTable",
|
||||
data() {
|
||||
return {
|
||||
tables: [],
|
||||
titles: []
|
||||
}
|
||||
},
|
||||
props: {
|
||||
body: String
|
||||
},
|
||||
created() {
|
||||
if (!this.body) {
|
||||
return;
|
||||
}
|
||||
let rowArry = this.body.split("\n");
|
||||
// 过多会有性能问题
|
||||
if (rowArry.length > 100) {
|
||||
rowArry = rowArry.slice(0, 100);
|
||||
}
|
||||
this.getTableData(rowArry);
|
||||
if (this.tables.length > 1) {
|
||||
for (let i = 0; i < this.tables.length; i++) {
|
||||
if (this.tables[i].titles.length === 1 && i < this.tables.length - 1) {
|
||||
this.tables[i].tableData.splice(this.tables[i].tableData.length - 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
let lastTable = this.tables[this.tables.length - 1];
|
||||
if (lastTable.titles.length === 1) {
|
||||
if (lastTable.tableData.length > 4) {
|
||||
lastTable.tableData.splice(lastTable.tableData.length - 4, 4);
|
||||
} else {
|
||||
this.tables.splice(this.tables.length - 1, 1);
|
||||
}
|
||||
let lastTable = this.tables[this.tables.length - 1];
|
||||
if (lastTable.titles.length === 1) {
|
||||
if (lastTable.tableData.length > 4) {
|
||||
lastTable.tableData.splice(lastTable.tableData.length - 4, 4);
|
||||
} else {
|
||||
this.tables.splice(this.tables.length - 1, 1);
|
||||
}
|
||||
} else {
|
||||
let table = this.tables[0];
|
||||
table.tableData.splice(table.tableData.length - 4, 4);
|
||||
this.tables.splice(this.tables.length - 1, 1);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getTableData(rowArry) {
|
||||
let titles;
|
||||
let result = [];
|
||||
for (let i = 0; i < rowArry.length; i++) {
|
||||
let colArray = rowArry[i].split("\t");
|
||||
if (i === 0) {
|
||||
titles = colArray;
|
||||
} else {
|
||||
if (colArray.length != titles.length) {
|
||||
// 创建新的表
|
||||
if (colArray.length === 1 && colArray[0] === '') {
|
||||
this.getTableData(rowArry.slice(i + 1));
|
||||
} else {
|
||||
this.getTableData(rowArry.slice(i));
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
let table = this.tables[0];
|
||||
table.tableData.splice(table.tableData.length - 4, 4);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getTableData(rowArry) {
|
||||
let titles;
|
||||
let result = [];
|
||||
for (let i = 0; i < rowArry.length; i++) {
|
||||
let colArray = rowArry[i].split("\t");
|
||||
if (i === 0) {
|
||||
titles = colArray;
|
||||
} else {
|
||||
if (colArray.length != titles.length) {
|
||||
// 创建新的表
|
||||
if (colArray.length === 1 && colArray[0] === '') {
|
||||
this.getTableData(rowArry.slice(i + 1));
|
||||
} else {
|
||||
let item = {};
|
||||
for (let j = 0; j < colArray.length; j++) {
|
||||
item[titles[j]] = (colArray[j] ? colArray[j] : "");
|
||||
}
|
||||
result.push(item);
|
||||
this.getTableData(rowArry.slice(i));
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
let item = {};
|
||||
for (let j = 0; j < colArray.length; j++) {
|
||||
item[titles[j]] = (colArray[j] ? colArray[j] : "");
|
||||
}
|
||||
result.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
this.tables.splice(0, 0, {
|
||||
titles: titles,
|
||||
tableData: result
|
||||
});
|
||||
}
|
||||
|
||||
this.tables.splice(0, 0, {
|
||||
titles: titles,
|
||||
tableData: result
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
@ -114,7 +118,7 @@
|
|||
}
|
||||
|
||||
.el-container {
|
||||
overflow:auto;
|
||||
overflow: auto;
|
||||
max-height: 500px;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue