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);
} else {
ApiDefinition apiDefinition = apiDefinitionService.get(tr.getId());
http.setUrl(apiDefinition.getPath());
if (apiDefinition != null) {
http.setUrl(apiDefinition.getPath());
}
}
if (http.isEnable()) {
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")) {
if (StringUtils.equals(tr.getRefType(), "CASE")) {
ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = apiTestCaseService.get(tr.getId());
env.getProjectIds().add(apiTestCaseWithBLOBs.getProjectId());
if (apiTestCaseWithBLOBs != null) {
env.getProjectIds().add(apiTestCaseWithBLOBs.getProjectId());
}
} else {
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")) {
if (tr.isEnable()) {

View File

@ -429,7 +429,8 @@
this.setTabTitle(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) {
this.setTabTitle(data);

View File

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

View File

@ -26,15 +26,21 @@
@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"/>
</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-select size="small" :placeholder="$t('api_test.definition.document.order')" v-model="apiSearch.orderCondition" style="float: right;width: 180px;margin-right: 5px"
<el-row v-else
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>
<el-option key="createTimeDesc" :label="$t('api_test.definition.document.create_time_sort')" value="createTimeDesc" />
<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-option key="createTimeDesc" :label="$t('api_test.definition.document.create_time_sort')"
value="createTimeDesc"/>
<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 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>
<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"/>

View File

@ -1,145 +1,148 @@
<template>
<div>
<p class="tip">期望列表</p>
<div class="card">
<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-container">
<el-card class="card-content" v-loading="mockConfigData.loading">
<p class="tip">期望列表</p>
<div class="card">
<div class="base-info">
<el-row>
<el-col>{{ $t('api_test.mock.base_info') }}</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item :label="$t('commons.name')" prop="name">
<el-input class="ms-http-input" size="small" v-model="mockExpectConfig.name"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :label="$t('commons.tag')" prop="tag">
<ms-input-tag :currentScenario="mockExpectConfig" v-if="showHeadTable" ref="tag"/>
</el-form-item>
</el-col>
</el-row>
<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>
<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>
<!-- 期望详情 -->
<p class="tip">{{ $t('api_test.mock.expect_detail') }}</p>
<el-form :model="mockExpectConfig" :rules="rule" ref="mockExpectForm" label-width="80px" label-position="right">
<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>
<div class="card">
<div class="base-info">
<el-row>
<el-col>{{ $t('api_test.mock.base_info') }}</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item :label="$t('commons.name')" prop="name">
<el-input class="ms-http-input" size="small" v-model="mockExpectConfig.name"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item :label="$t('commons.tag')" prop="tag">
<ms-input-tag :currentScenario="mockExpectConfig" v-if="showHeadTable" ref="tag"/>
</el-form-item>
</el-col>
</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">
HTTP头:
</span>
</el-row>
<el-row>
<mock-row-variables v-if="showHeadTable" :show-copy="false" :header-suggestions="headerSuggestions"
:items="mockExpectConfig.response.httpHeads" ref="rspHttpHead"/>
</el-row>
<el-row style="margin-top: 10px;">
<el-form-item label="Body:" label-width="50px">
<ms-code-edit height="200px" :mode="'txt'" ref="codeEdit" :data.sync="mockExpectConfig.response.body"
style="margin-top: 10px;"/>
</el-form-item>
</el-row>
<el-row>
<div style="float: right;margin-right: 20px">
<el-button type="primary" size="small" @click="saveMockExpectConfig" title="ctrl + s">{{
$t('commons.add')
}}
</el-button>
<el-button type="primary" size="small" @click="cleanMockExpectConfig">{{
$t('commons.clear')
}}
</el-button>
<el-button type="primary" size="small" v-if="mockExpectConfig.id != '' && mockExpectConfig.id != null"
@click="updateMockExpectConfig">{{ $t('commons.update') }}
</el-button>
</div>
</el-row>
</el-row>
<el-row>
<mock-row-variables v-if="showHeadTable" :show-copy="false" :header-suggestions="headerSuggestions"
:items="mockExpectConfig.response.httpHeads" ref="rspHttpHead"/>
</el-row>
<el-row style="margin-top: 10px;">
<el-form-item label="Body:" label-width="50px">
<ms-code-edit height="200px" :mode="'txt'" ref="codeEdit" :data.sync="mockExpectConfig.response.body"
style="margin-top: 10px;"/>
</el-form-item>
</el-row>
<el-row>
<div style="float: right;margin-right: 20px">
<el-button type="primary" size="small" @click="saveMockExpectConfig" title="ctrl + s">{{
$t('commons.add')
}}
</el-button>
<el-button type="primary" size="small" @click="cleanMockExpectConfig">{{
$t('commons.clear')
}}
</el-button>
<el-button type="primary" size="small" v-if="mockExpectConfig.id != '' && mockExpectConfig.id != null"
@click="updateMockExpectConfig">{{ $t('commons.update') }}
</el-button>
</div>
</el-row>
</div>
</div>
</div>
</el-form>
</el-form>
</el-card>
</div>
</template>
@ -195,7 +198,7 @@ export default {
{max: 100, message: this.$t('test_track.length_less_than') + '100', trigger: 'blur'}
],
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'},],
},
},

View File

@ -46,6 +46,11 @@ export function setUnSelectIds(tableData, condition, selectRows) {
return ids.indexOf(val) === -1;
});
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) {
return condition.unSelectIds.indexOf(val) === -1;
});

View File

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

View File

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

View File

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