fix(接口测试): 修复加载用例只加载最近一条的缺陷

--bug=1013172 --user=王孝刚 [接口测试]github#13585v接口定义-TEST-加载用例只显示最新的一条
https://www.tapd.cn/55049933/s/1158552
This commit is contained in:
wxg0103 2022-05-16 15:55:27 +08:00 committed by 刘瑞斌
parent cd362a07a2
commit c0d2913cef
2 changed files with 46 additions and 30 deletions

View File

@ -469,6 +469,7 @@ export default {
this.currentApi.request = item.request; this.currentApi.request = item.request;
this.currentApi.request.changeId = getUUID(); this.currentApi.request.changeId = getUUID();
} }
this.$emit("setSelectedCaseId", item.id);
}, },
changePriority(row) { changePriority(row) {
if (row.id) { if (row.id) {

View File

@ -3,38 +3,41 @@
<ms-drawer :size="60" @close="apiCaseClose" direction="bottom" ref="testCaseDrawer"> <ms-drawer :size="60" @close="apiCaseClose" direction="bottom" ref="testCaseDrawer">
<template v-slot:header> <template v-slot:header>
<api-case-header <api-case-header
:api="api" :api="api"
@setEnvironment="setEnvironment" @setEnvironment="setEnvironment"
@addCase="addCase" @addCase="addCase"
@saveCase="saveCase(apiCaseList[0])" @saveCase="saveCase"
:condition="condition" :condition="condition"
:priorities="priorities" :priorities="priorities"
:project-id="projectId" :project-id="projectId"
:useEnvironment="environment" :useEnvironment="environment"
:is-case-edit="isCaseEdit" :is-case-edit="isCaseEdit"
:button-text="saveButtonText" :button-text="saveButtonText"
ref="header"/> ref="header"/>
</template> </template>
<el-container v-if="!result.loading"> <el-container v-if="!result.loading">
<el-main> <el-main>
<api-case-item <div v-for="item in apiCaseList" :key="item.id ? item.id : item.uuid">
:loading="singleLoading && singleRunId === apiCaseList[0].id || batchLoadingIds.indexOf(apiCaseList[0].id) > -1" <api-case-item
@refresh="refresh" :loading="singleLoading && singleRunId ===item.id || batchLoadingIds.indexOf(item.id) > -1"
@singleRun="singleRun" @refresh="refresh"
@stop="stop" @singleRun="singleRun"
@refreshModule="refreshModule" @stop="stop"
@copyCase="copyCase" @refreshModule="refreshModule"
@showExecResult="showExecResult" @copyCase="copyCase"
@showHistory="showHistory" @showExecResult="showExecResult"
@reLoadCase="reLoadCase" @showHistory="showHistory"
:environment="environment" @reLoadCase="reLoadCase"
:is-case-edit="isCaseEdit" :environment="environment"
:api="api" @setSelectedCaseId="setSelectedCaseId"
:currentApi="currentApi" :is-case-edit="isCaseEdit"
:loaded="loaded" :api="api"
:maintainerOptions="maintainerOptions" :currentApi="currentApi"
:api-case="apiCaseList[0]" ref="apiCaseItem"/> :loaded="loaded"
:maintainerOptions="maintainerOptions"
:api-case="item" ref="apiCaseItem"/>
</div>
</el-main> </el-main>
</el-container> </el-container>
</ms-drawer> </ms-drawer>
@ -204,8 +207,20 @@ export default {
} }
this.visible = true; this.visible = true;
}, },
saveCase(item, hideAlert) { setSelectedCaseId(caseId) {
this.$refs.apiCaseItem.saveTestCase(item, hideAlert); this.selectCaseId = caseId;
},
saveCase(hideAlert) {
let index = 0;
if (this.selectCaseId && this.selectCaseId !== '') {
for (let i = 0; i < this.apiCaseList.length; i++) {
if (this.apiCaseList[i].id === this.selectCaseId) {
index = i;
}
}
}
let item = this.apiCaseList[index];
this.$refs.apiCaseItem[index].saveTestCase(item, hideAlert);
}, },
saveApiAndCase(api) { saveApiAndCase(api) {
if (api && api.url) { if (api && api.url) {