refactor(接口测试): 增加接口用例保存并继续添加功能

--story=1013901 --user=赵勇 【接口测试】接口case新增“保存并继续添加”按钮 https://www.tapd.cn/55049933/s/1439638

Signed-off-by: fit2-zhao <yong.zhao@fit2cloud.com>
This commit is contained in:
fit2-zhao 2023-11-27 15:45:56 +08:00 committed by Craftsman
parent e77efa3a19
commit abf8af1c3d
6 changed files with 43 additions and 13 deletions

View File

@ -16,7 +16,7 @@
<el-col :span="9">
<div class="variable-combine">{{ api.name }}</div>
</el-col>
<el-col :span="8">
<el-col :span="6">
<div class="variable-combine" style="margin-left: 10px">
{{ api.path === null ? ' ' : api.path }}
</div>
@ -30,7 +30,7 @@
ref="environmentSelect"
v-if="api.protocol === 'HTTP' || api.protocol === 'TCP'" />
</el-col>
<el-col :span="2">
<el-col :span="4">
<!-- 保存操作 -->
<el-button
v-if="!isXpack || !showUpdateRule"
@ -38,16 +38,30 @@
size="small"
@click="saveTestCase()"
v-prevent-re-click
v-permission="['PROJECT_API_DEFINITION:READ+EDIT_CASE']">
v-permission="['PROJECT_API_DEFINITION:READ+EDIT_CASE']"
style="margin-left: -20px">
{{ saveButtonText }}
</el-button>
<el-button
v-if="!isXpack || !showUpdateRule"
type="primary"
size="small"
@click="saveAndCreate()"
v-prevent-re-click
v-permission="['PROJECT_API_DEFINITION:READ+EDIT_CASE']"
style="margin-left: 2px">
{{ $t('home.dashboard.api_case.save_and_create') }}
</el-button>
<el-dropdown
v-else
style="margin-left: -15px"
style="margin-left: -17px"
v-permission="[
'PROJECT_API_DEFINITION:READ+EDIT_CASE',
'PROJECT_API_DEFINITION:READ+CREATE_CASE',
'PROJECT_API_DEFINITION:READ+COPY_CASE']"
'PROJECT_API_DEFINITION:READ+COPY_CASE',
]"
split-button
type="primary"
size="small"
@ -159,6 +173,9 @@ export default {
saveTestCase() {
this.$emit('saveCase');
},
saveAndCreate() {
this.$emit('saveCase', false, true);
},
handleCommand(command) {
if (command === 'openSyncRule') {
this.$EventBus.$emit('showXpackCaseSet', false);

View File

@ -31,7 +31,7 @@
<i class="el-icon-edit" style="cursor: pointer" @click="showInput(apiCase)" />
</span>
</span>
<div v-if="apiCase.id" style="color: #999999; font-size: 12px;margin-top: 8px;">
<div v-if="apiCase.id" style="color: #999999; font-size: 12px; margin-top: 8px">
<span style="margin-left: 10px">
{{ apiCase.updateTime | datetimeFormat }}
{{ apiCase.updateUser }}
@ -676,7 +676,7 @@ export default {
}
}
},
saveCase(row, hideAlert) {
saveCase(row, hideAlert, created) {
this.isSave = true;
let tmp = JSON.parse(JSON.stringify(row));
this.isShowInput = false;
@ -737,13 +737,16 @@ export default {
if (!hideAlert) {
this.$emit('refresh');
}
if (created) {
this.$emit('addCase');
}
},
(error) => {
this.isSave = false;
}
);
},
saveTestCase(row, hideAlert) {
saveTestCase(row, hideAlert, created) {
if (this.validate(row)) {
return;
}
@ -762,7 +765,7 @@ export default {
} else {
this.api.source = 'editCase';
if (!this.isSave) {
this.saveCase(row, hideAlert);
this.saveCase(row, hideAlert, created);
}
}
}

View File

@ -37,6 +37,7 @@
@showExecResult="showExecResult"
@showHistory="showHistory"
@reLoadCase="reLoadCase"
@addCase="addCase"
:environment="environment"
:case-item-height="caseItemHeight"
@setSelectedCaseId="setSelectedCaseId"
@ -244,7 +245,7 @@ export default {
setSelectedCaseId(caseId) {
this.selectCaseId = caseId;
},
saveCase(hideAlert) {
saveCase(hideAlert, created) {
if (this.loaded) {
this.close();
}
@ -258,7 +259,7 @@ export default {
}
if (this.apiCaseList && this.apiCaseList.length !== 0) {
let item = this.apiCaseList[index];
this.$refs.apiCaseItem[index].saveTestCase(item, hideAlert);
this.$refs.apiCaseItem[index].saveTestCase(item, hideAlert, created);
}
},
saveApiAndCase(api) {
@ -450,7 +451,13 @@ export default {
if (this.$refs.apiCaseItem && this.$refs.apiCaseItem[0]) {
this.$refs.apiCaseItem[0].reload();
}
store.currentApiCase = { refresh: true, id: data.id, status: status, passRate: passRate, reportId: data.threadName };
store.currentApiCase = {
refresh: true,
id: data.id,
status: status,
passRate: passRate,
reportId: data.threadName,
};
});
}
},
@ -607,6 +614,7 @@ export default {
};
request.projectId = getCurrentProjectID();
obj.request = request;
this.apiCaseList = [];
this.apiCaseList.unshift(obj);
}
},
@ -645,7 +653,6 @@ export default {
row.request.projectId = this.projectId;
row.request.id = row.id;
this.runData.push(row.request);
/*触发执行操作*/
this.reportId = getUUID().substring(0, 8);
this.testCaseId = row.id ? row.id : row.request.id;
this.$emit('refreshCase', this.testCaseId);

View File

@ -85,6 +85,7 @@ const message = {
covered_rate: 'Api covered rate',
executed_rate: 'Executed rate',
pass_rate: 'Pass rate',
save_and_create: 'Save and add',
},
scenario: {
title: 'Scenario amount',

View File

@ -81,6 +81,7 @@ const message = {
covered_rate: '接口覆盖率',
executed_rate: '用例执行率',
pass_rate: '用例通过率',
save_and_create: '保存并继续添加',
},
scenario: {
title: '场景用例数量统计',

View File

@ -81,6 +81,7 @@ const message = {
covered_rate: '接口覆蓋率',
executed_rate: '用例執行率',
pass_rate: '用例通過率',
save_and_create: '保存並繼續添加',
},
scenario: {
title: '場景用例數量統計',