fix: TAPD缺陷修复

TAPD缺陷修复
This commit is contained in:
song-tianyang 2021-04-25 18:23:43 +08:00 committed by 刘瑞斌
parent fa8bb155fe
commit 4f0751788f
9 changed files with 182 additions and 147 deletions

View File

@ -413,7 +413,9 @@ public class ApiAutomationService {
http.setUrl(null); http.setUrl(null);
} else { } else {
ApiDefinition apiDefinition = apiDefinitionService.get(tr.getId()); ApiDefinition apiDefinition = apiDefinitionService.get(tr.getId());
http.setUrl(apiDefinition.getPath()); if (apiDefinition != null) {
http.setUrl(apiDefinition.getPath());
}
} }
if (http.isEnable()) { if (http.isEnable()) {
if (StringUtils.isBlank(http.getUrl()) || !tr.isURL(http.getUrl())) { if (StringUtils.isBlank(http.getUrl()) || !tr.isURL(http.getUrl())) {
@ -424,10 +426,14 @@ public class ApiAutomationService {
} else if (StringUtils.equals(tr.getType(), "JDBCSampler") || StringUtils.equals(tr.getType(), "TCPSampler")) { } else if (StringUtils.equals(tr.getType(), "JDBCSampler") || StringUtils.equals(tr.getType(), "TCPSampler")) {
if (StringUtils.equals(tr.getRefType(), "CASE")) { if (StringUtils.equals(tr.getRefType(), "CASE")) {
ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = apiTestCaseService.get(tr.getId()); ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = apiTestCaseService.get(tr.getId());
env.getProjectIds().add(apiTestCaseWithBLOBs.getProjectId()); if (apiTestCaseWithBLOBs != null) {
env.getProjectIds().add(apiTestCaseWithBLOBs.getProjectId());
}
} else { } else {
ApiDefinition apiDefinition = apiDefinitionService.get(tr.getId()); ApiDefinition apiDefinition = apiDefinitionService.get(tr.getId());
env.getProjectIds().add(apiDefinition.getProjectId()); if (apiDefinition != null) {
env.getProjectIds().add(apiDefinition.getProjectId());
}
} }
} else if (StringUtils.equals(tr.getType(), "scenario")) { } else if (StringUtils.equals(tr.getType(), "scenario")) {
if (tr.isEnable()) { if (tr.isEnable()) {

View File

@ -429,7 +429,8 @@
this.setTabTitle(data); this.setTabTitle(data);
}, },
mockConfig(data) { mockConfig(data) {
this.handleMockTabsConfig(this.$t("commons.mock"), "MOCK", data); let targetName = this.$t("commons.mock") + "-" + data.apiName;
this.handleMockTabsConfig(targetName, "MOCK", data);
}, },
saveApi(data) { saveApi(data) {
this.setTabTitle(data); this.setTabTitle(data);

View File

@ -2,7 +2,6 @@
<div class="card-container"> <div class="card-container">
<el-card class="card-content" v-loading="httpForm.loading"> <el-card class="card-content" v-loading="httpForm.loading">
<el-form :model="httpForm" :rules="rule" ref="httpForm" label-width="80px" label-position="right"> <el-form :model="httpForm" :rules="rule" ref="httpForm" label-width="80px" label-position="right">
<!-- 操作按钮 --> <!-- 操作按钮 -->
<div style="float: right;margin-right: 20px"> <div style="float: right;margin-right: 20px">
@ -190,6 +189,10 @@
return this.mockBaseUrl + "/mock/" + this.projectId; return this.mockBaseUrl + "/mock/" + this.projectId;
} else { } else {
let path = this.httpForm.path; let path = this.httpForm.path;
let prefix = "";
if (path.endsWith("/")) {
prefix = "/";
}
let protocol = this.httpForm.method; let protocol = this.httpForm.method;
if (protocol === 'GET' || protocol === 'DELETE') { if (protocol === 'GET' || protocol === 'DELETE') {
if (this.httpForm.request != null && this.httpForm.request.rest != null) { if (this.httpForm.request != null && this.httpForm.request.rest != null) {
@ -215,7 +218,8 @@
} }
} }
} }
return this.mockBaseUrl + "/mock/" + this.projectId + path;
return this.mockBaseUrl + "/mock/" + this.projectId + path + prefix;
} }
} }
}, },
@ -316,6 +320,7 @@
this.$post('/mockConfig/genMockConfig', mockParam, response => { this.$post('/mockConfig/genMockConfig', mockParam, response => {
let mockConfig = response.data; let mockConfig = response.data;
mockConfig.apiName = this.httpForm.name;
this.$emit('mockConfig', mockConfig); this.$emit('mockConfig', mockConfig);
}); });
} }

View File

@ -26,15 +26,21 @@
@keyup.enter.native="initApiDocSimpleList()" v-model="apiSearch.name"/> @keyup.enter.native="initApiDocSimpleList()" v-model="apiSearch.name"/>
<api-document-batch-share v-xpack v-if="showXpackCompnent" @shareApiDocument="shareApiDocument" :project-id="projectId" :share-url="batchShareUrl" style="float: right;margin: 6px;font-size: 17px"/> <api-document-batch-share v-xpack v-if="showXpackCompnent" @shareApiDocument="shareApiDocument" :project-id="projectId" :share-url="batchShareUrl" style="float: right;margin: 6px;font-size: 17px"/>
</el-row> </el-row>
<el-row v-else style="margin-top: 0px;position: fixed;float: right;margin-right: 0px;margin-left: 400px;top: 150px; right: 90px;"> <el-row v-else
<el-select size="small" :placeholder="$t('api_test.definition.document.order')" v-model="apiSearch.orderCondition" style="float: right;width: 180px;margin-right: 5px" style="margin-top: 0px;position: fixed;float: right;margin-right: 0px;margin-left: 400px;top: 150px; right: 90px; z-index: 9999">
<el-select size="small" :placeholder="$t('api_test.definition.document.order')"
v-model="apiSearch.orderCondition" style="float: right;width: 180px;margin-right: 5px"
class="ms-api-header-select" @change="initApiDocSimpleList" clearable> class="ms-api-header-select" @change="initApiDocSimpleList" clearable>
<el-option key="createTimeDesc" :label="$t('api_test.definition.document.create_time_sort')" value="createTimeDesc" /> <el-option key="createTimeDesc" :label="$t('api_test.definition.document.create_time_sort')"
<el-option key="editTimeAsc" :label="$t('api_test.definition.document.edit_time_positive_sequence')" value="editTimeAsc"/> value="createTimeDesc"/>
<el-option key="editTimeDesc" :label="$t('api_test.definition.document.edit_time_Reverse_order')" value="editTimeDesc"/> <el-option key="editTimeAsc" :label="$t('api_test.definition.document.edit_time_positive_sequence')"
value="editTimeAsc"/>
<el-option key="editTimeDesc" :label="$t('api_test.definition.document.edit_time_Reverse_order')"
value="editTimeDesc"/>
</el-select> </el-select>
<el-select size="small" :placeholder="$t('api_test.definition.document.request_method')" v-model="apiSearch.type" style="float: right;width: 180px;margin-right: 5px" <el-select size="small" :placeholder="$t('api_test.definition.document.request_method')"
v-model="apiSearch.type" style="float: right;width: 180px;margin-right: 5px"
class="ms-api-header-select" @change="initApiDocSimpleList" clearable> class="ms-api-header-select" @change="initApiDocSimpleList" clearable>
<el-option key="ALL" :label="$t('api_test.definition.document.data_set.all')" value="ALL"/> <el-option key="ALL" :label="$t('api_test.definition.document.data_set.all')" value="ALL"/>
<el-option key="GET" :label="'GET '+$t('api_test.definition.document.request_interface')" value="GET"/> <el-option key="GET" :label="'GET '+$t('api_test.definition.document.request_interface')" value="GET"/>

View File

@ -1,145 +1,148 @@
<template> <template>
<div> <div class="card-container">
<p class="tip">期望列表</p> <el-card class="card-content" v-loading="mockConfigData.loading">
<div class="card"> <p class="tip">期望列表</p>
<el-input :placeholder="$t('commons.search_by_name')" class="search-input" size="small"
:clearable="serchInputClearable"
v-model="tableSearch"/>
<el-table ref="table" border
:data="mockConfigData.mockExpectConfigList.filter(data=>!tableSearch || data.name.toLowerCase().includes(tableSearch.toLowerCase()))"
@row-click="clickRow"
row-key="id" class="test-content" :height="screenHeight">
<el-table-column :label="$t('api_test.mock.table.name')" min-width="160px" prop="name"></el-table-column>
<el-table-column :label="$t('api_test.mock.table.tag')" min-width="200px" prop="tags">
<template v-slot:default="scope">
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain"
:show-tooltip="true" :content="itemName"
style="margin-left: 0px; margin-right: 2px"/>
</template>
</el-table-column>
<el-table-column :label="$t('api_test.mock.table.creator')" min-width="160px"
prop="createUserId"></el-table-column>
<el-table-column :label="$t('api_test.mock.table.status')" min-width="80px" prop="status">
<template v-slot:default="scope">
<div>
<el-switch
v-model="scope.row.status"
class="captcha-img"
@change="changeStatus(scope.row)"
></el-switch>
</div>
</template>
</el-table-column>
<el-table-column :label="$t('api_test.mock.table.update_time')" min-width="160px" prop="updateTime">
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template>
</el-table-column>
<el-table-column fixed="right" min-width="100" align="center" :label="$t('commons.operating')">
<template v-slot:default="scope">
<ms-table-operator-button :tip="$t('commons.copy')" icon="el-icon-copy-document"
@exec="copyExpect(scope.row)"
v-tester/>
<ms-table-operator-button :tip="$t('commons.edit')" icon="el-icon-delete" @exec="removeExpect(scope.row)"
v-tester/>
</template>
</el-table-column>
</el-table>
</div>
<!-- 期望详情 -->
<p class="tip">{{ $t('api_test.mock.expect_detail') }}</p>
<el-form :model="mockExpectConfig" :rules="rule" ref="mockExpectForm" label-width="80px" label-position="right">
<div class="card"> <div class="card">
<div class="base-info"> <el-input :placeholder="$t('commons.search_by_name')" class="search-input" size="small"
<el-row> :clearable="serchInputClearable"
<el-col>{{ $t('api_test.mock.base_info') }}</el-col> v-model="tableSearch"/>
</el-row> <el-table ref="table" border
<el-row> :data="mockConfigData.mockExpectConfigList.filter(data=>!tableSearch || data.name.toLowerCase().includes(tableSearch.toLowerCase()))"
<el-col :span="12"> @row-click="clickRow"
<el-form-item :label="$t('commons.name')" prop="name"> row-key="id" class="test-content" :height="screenHeight">
<el-input class="ms-http-input" size="small" v-model="mockExpectConfig.name"/> <el-table-column :label="$t('api_test.mock.table.name')" min-width="160px" prop="name"></el-table-column>
</el-form-item> <el-table-column :label="$t('api_test.mock.table.tag')" min-width="200px" prop="tags">
</el-col> <template v-slot:default="scope">
<el-col :span="12"> <ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain"
<el-form-item :label="$t('commons.tag')" prop="tag"> :show-tooltip="true" :content="itemName"
<ms-input-tag :currentScenario="mockExpectConfig" v-if="showHeadTable" ref="tag"/> style="margin-left: 0px; margin-right: 2px"/>
</el-form-item> </template>
</el-col> </el-table-column>
</el-row> <el-table-column :label="$t('api_test.mock.table.creator')" min-width="160px"
prop="createUserId"></el-table-column>
<el-table-column :label="$t('api_test.mock.table.status')" min-width="80px" prop="status">
<template v-slot:default="scope">
<div>
<el-switch
v-model="scope.row.status"
class="captcha-img"
@change="changeStatus(scope.row)"
></el-switch>
</div>
</template>
</el-table-column>
<el-table-column :label="$t('api_test.mock.table.update_time')" min-width="160px" prop="updateTime">
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template>
</el-table-column>
<el-table-column fixed="right" min-width="100" align="center" :label="$t('commons.operating')">
<template v-slot:default="scope">
<ms-table-operator-button :tip="$t('commons.copy')" icon="el-icon-copy-document"
@exec="copyExpect(scope.row)"
v-tester/>
<ms-table-operator-button :tip="$t('commons.edit')" icon="el-icon-delete" @exec="removeExpect(scope.row)"
v-tester/>
</template>
</el-table-column>
</el-table>
</div>
<el-row> <!-- 期望详情 -->
<el-col>{{ $t('api_test.mock.req_param') }}</el-col> <p class="tip">{{ $t('api_test.mock.expect_detail') }}</p>
</el-row> <el-form :model="mockExpectConfig" :rules="rule" ref="mockExpectForm" label-width="80px" label-position="right">
<el-row>
<el-col style="margin: 10px">
<el-switch v-model="mockExpectConfig.request.jsonParam">
</el-switch>
JSON
</el-col>
</el-row>
<el-row>
<div v-if="mockExpectConfig.request.jsonParam">
<ms-code-edit height="400px" :mode="'json'" ref="codeEdit" :data.sync="mockExpectConfig.request.jsonData"
style="margin-top: 10px;"/>
</div>
<div v-else>
<mock-row-variables :show-copy="false" v-if="showHeadTable" :header-suggestions="apiParams"
:items="mockExpectConfig.request.variables" ref="reqHttpHead"/>
</div>
</el-row>
<el-row style="margin-top: 10px;"> <div class="card">
<el-col>{{ $t('api_test.mock.rsp_param') }}</el-col> <div class="base-info">
</el-row> <el-row>
<el-row> <el-col>{{ $t('api_test.mock.base_info') }}</el-col>
<el-col :span="12"> </el-row>
<el-form-item label="HTTP Code" label-width="100px" prop="response.httpCode"> <el-row>
<el-input class="ms-http-input" size="small" v-model="mockExpectConfig.response.httpCode"/> <el-col :span="12">
</el-form-item> <el-form-item :label="$t('commons.name')" prop="name">
</el-col> <el-input class="ms-http-input" size="small" v-model="mockExpectConfig.name"/>
<el-col :span="6"> </el-form-item>
<el-form-item label="延时 (ms)" prop="response.delayed"> </el-col>
<el-input-number v-model="mockExpectConfig.response.delayed" :min="0"> <el-col :span="12">
<template slot="append">ms</template> <el-form-item :label="$t('commons.tag')" prop="tag">
</el-input-number> <ms-input-tag :currentScenario="mockExpectConfig" v-if="showHeadTable" ref="tag"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row>
<el-row>
<el-col>{{ $t('api_test.mock.req_param') }}</el-col>
</el-row>
<el-row>
<el-col style="margin: 10px">
<el-switch v-model="mockExpectConfig.request.jsonParam">
</el-switch>
JSON
</el-col>
</el-row>
<el-row>
<div v-if="mockExpectConfig.request.jsonParam">
<ms-code-edit height="400px" :mode="'json'" ref="codeEdit"
:data.sync="mockExpectConfig.request.jsonData"
style="margin-top: 10px;"/>
</div>
<div v-else>
<mock-row-variables :show-copy="false" v-if="showHeadTable" :header-suggestions="apiParams"
:items="mockExpectConfig.request.variables" ref="reqHttpHead"/>
</div>
</el-row>
<el-row style="margin-top: 10px;">
<el-col>{{ $t('api_test.mock.rsp_param') }}</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="HTTP Code" label-width="100px" prop="response.httpCode">
<el-input class="ms-http-input" size="small" v-model="mockExpectConfig.response.httpCode"/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="延时 (ms)" prop="response.delayed">
<el-input-number v-model="mockExpectConfig.response.delayed" :min="0">
<template slot="append">ms</template>
</el-input-number>
</el-form-item>
</el-col>
</el-row>
<el-row>
<span style="margin: 10px;font-size: 13px"> <span style="margin: 10px;font-size: 13px">
HTTP头: HTTP头:
</span> </span>
</el-row> </el-row>
<el-row> <el-row>
<mock-row-variables v-if="showHeadTable" :show-copy="false" :header-suggestions="headerSuggestions" <mock-row-variables v-if="showHeadTable" :show-copy="false" :header-suggestions="headerSuggestions"
:items="mockExpectConfig.response.httpHeads" ref="rspHttpHead"/> :items="mockExpectConfig.response.httpHeads" ref="rspHttpHead"/>
</el-row> </el-row>
<el-row style="margin-top: 10px;"> <el-row style="margin-top: 10px;">
<el-form-item label="Body:" label-width="50px"> <el-form-item label="Body:" label-width="50px">
<ms-code-edit height="200px" :mode="'txt'" ref="codeEdit" :data.sync="mockExpectConfig.response.body" <ms-code-edit height="200px" :mode="'txt'" ref="codeEdit" :data.sync="mockExpectConfig.response.body"
style="margin-top: 10px;"/> style="margin-top: 10px;"/>
</el-form-item> </el-form-item>
</el-row> </el-row>
<el-row> <el-row>
<div style="float: right;margin-right: 20px"> <div style="float: right;margin-right: 20px">
<el-button type="primary" size="small" @click="saveMockExpectConfig" title="ctrl + s">{{ <el-button type="primary" size="small" @click="saveMockExpectConfig" title="ctrl + s">{{
$t('commons.add') $t('commons.add')
}} }}
</el-button> </el-button>
<el-button type="primary" size="small" @click="cleanMockExpectConfig">{{ <el-button type="primary" size="small" @click="cleanMockExpectConfig">{{
$t('commons.clear') $t('commons.clear')
}} }}
</el-button> </el-button>
<el-button type="primary" size="small" v-if="mockExpectConfig.id != '' && mockExpectConfig.id != null" <el-button type="primary" size="small" v-if="mockExpectConfig.id != '' && mockExpectConfig.id != null"
@click="updateMockExpectConfig">{{ $t('commons.update') }} @click="updateMockExpectConfig">{{ $t('commons.update') }}
</el-button> </el-button>
</div> </div>
</el-row> </el-row>
</div>
</div> </div>
</div> </el-form>
</el-form> </el-card>
</div> </div>
</template> </template>
@ -195,7 +198,7 @@ export default {
{max: 100, message: this.$t('test_track.length_less_than') + '100', trigger: 'blur'} {max: 100, message: this.$t('test_track.length_less_than') + '100', trigger: 'blur'}
], ],
response: { response: {
httpCode: [{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},], httpCode: [{required: true, message: this.$t('api_test.mock.rule.input_code'), trigger: 'blur'},],
delayed: [{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},], delayed: [{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},],
}, },
}, },

View File

@ -46,6 +46,11 @@ export function setUnSelectIds(tableData, condition, selectRows) {
return ids.indexOf(val) === -1; return ids.indexOf(val) === -1;
}); });
if (condition.unSelectIds) { if (condition.unSelectIds) {
//首先将选择的ID从unSelectIds中排除
condition.unSelectIds = condition.unSelectIds.filter(function (val) {
return ids.indexOf(val) === -1;
});
//去掉unselectIds中存在的ID
let needPushIds = thisUnSelectIds.filter(function (val) { let needPushIds = thisUnSelectIds.filter(function (val) {
return condition.unSelectIds.indexOf(val) === -1; return condition.unSelectIds.indexOf(val) === -1;
}); });

View File

@ -615,6 +615,9 @@ export default {
req_param: "Request params", req_param: "Request params",
rsp_param: "Response Params", rsp_param: "Response Params",
delete_mock_expect: "Confirm to delete this expect info ?", delete_mock_expect: "Confirm to delete this expect info ?",
rule: {
input_code: "Please input HTTP Code"
}
}, },
definition: { definition: {
api_title: "Api test", api_title: "Api test",

View File

@ -624,6 +624,9 @@ export default {
req_param: "请求参数", req_param: "请求参数",
rsp_param: "响应内容", rsp_param: "响应内容",
delete_mock_expect: "确认删除这条预期吗?", delete_mock_expect: "确认删除这条预期吗?",
rule: {
input_code: "请输入 HTTP Code"
}
}, },
definition: { definition: {
api_title: "接口列表", api_title: "接口列表",

View File

@ -614,6 +614,9 @@ export default {
req_param: "請求參賽", req_param: "請求參賽",
rsp_param: "響應內容", rsp_param: "響應內容",
delete_mock_expect: "確認刪除這條預期嗎?", delete_mock_expect: "確認刪除這條預期嗎?",
rule: {
input_code: "請輸入 HTTP Code"
}
}, },
definition: { definition: {
api_title: "接口列表", api_title: "接口列表",