fix(测试跟踪): 修复导出测试计划报告用例资源池环境显示不正确的缺陷

--bug=1021983 --user=王孝刚 【测试跟踪】导出测试计划报告-接口用例-运行环境和资源池显示有问题
https://www.tapd.cn/55049933/s/1327574
This commit is contained in:
wxg0103 2023-01-16 14:24:59 +08:00 committed by wxg0103
parent b6ec1692d1
commit 26c4537417
4 changed files with 49 additions and 12 deletions

View File

@ -4,6 +4,7 @@ import com.alibaba.nacos.common.utils.CollectionUtils;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import io.metersphere.api.dto.ApiCaseRelevanceRequest; import io.metersphere.api.dto.ApiCaseRelevanceRequest;
import io.metersphere.api.dto.ApiReportEnvConfigDTO;
import io.metersphere.api.dto.EnvironmentType; import io.metersphere.api.dto.EnvironmentType;
import io.metersphere.api.dto.QueryReferenceRequest; import io.metersphere.api.dto.QueryReferenceRequest;
import io.metersphere.api.dto.automation.TestPlanDTO; import io.metersphere.api.dto.automation.TestPlanDTO;
@ -413,7 +414,11 @@ public class TestPlanApiCaseService {
try { try {
Map content = JSON.parseMap(contentStr); Map content = JSON.parseMap(contentStr);
if (StringUtils.isNotEmpty(contentStr)) { if (StringUtils.isNotEmpty(contentStr)) {
content.put("envName", apiDefinitionService.getEnvNameByEnvConfig(result.getProjectId(), result.getEnvConfig())); ApiReportEnvConfigDTO envConfig = apiDefinitionService.getEnvNameByEnvConfig(result.getProjectId(), result.getEnvConfig());
if (envConfig != null) {
content.put("envName", envConfig.getEnvName());
content.put("poolName", envConfig.getResourcePoolName());
}
} }
contentStr = JSON.toJSONString(content); contentStr = JSON.toJSONString(content);
apiCase.setResponse(contentStr); apiCase.setResponse(contentStr);
@ -442,7 +447,11 @@ public class TestPlanApiCaseService {
LogUtil.error("转换content失败!", e); LogUtil.error("转换content失败!", e);
} }
if (StringUtils.isNotEmpty(execResult.getEnvConfig())) { if (StringUtils.isNotEmpty(execResult.getEnvConfig())) {
responseObj.put("envName", apiDefinitionService.getEnvNameByEnvConfig(execResult.getProjectId(), execResult.getEnvConfig())); ApiReportEnvConfigDTO envConfig = apiDefinitionService.getEnvNameByEnvConfig(execResult.getProjectId(), execResult.getEnvConfig());
if (envConfig != null) {
responseObj.put("envName", envConfig.getEnvName());
responseObj.put("poolName", envConfig.getResourcePoolName());
}
} }
/* /*
* 之前这里的写法是responseObj.toString() * 之前这里的写法是responseObj.toString()

View File

@ -11,6 +11,7 @@
:is-template="isTemplate" :is-template="isTemplate"
:debug="debug" :debug="debug"
:report="report" :report="report"
:pool-name="poolName"
:project-env-map="projectEnvMap" :project-env-map="projectEnvMap"
@reportExport="handleExport" @reportExport="handleExport"
@reportSave="handleSave"/> @reportSave="handleSave"/>
@ -97,6 +98,7 @@
:project-env-map="projectEnvMap" :project-env-map="projectEnvMap"
:title="report.name" :title="report.name"
:content="content" :content="content"
:pool-name="poolName"
:report="report" :report="report"
:total-time="totalTime"/> :total-time="totalTime"/>
</main> </main>
@ -119,7 +121,6 @@ import {getUUID, windowPrint} from "metersphere-frontend/src/utils";
import {hasLicense} from "metersphere-frontend/src/utils/permission"; import {hasLicense} from "metersphere-frontend/src/utils/permission";
import {STEP} from "metersphere-frontend/src/model/Setting"; import {STEP} from "metersphere-frontend/src/model/Setting";
import MsCodeEdit from "metersphere-frontend/src/components/MsCodeEdit"; import MsCodeEdit from "metersphere-frontend/src/components/MsCodeEdit";
export default { export default {
name: "MsApiReport", name: "MsApiReport",
components: { components: {
@ -151,7 +152,8 @@ export default {
exportReportIsOk: false, exportReportIsOk: false,
tempResult: [], tempResult: [],
projectEnvMap: {}, projectEnvMap: {},
showCancel: false showCancel: false,
poolName: '',
} }
}, },
activated() { activated() {
@ -412,6 +414,9 @@ export default {
if (report.projectEnvMap) { if (report.projectEnvMap) {
this.projectEnvMap = report.projectEnvMap; this.projectEnvMap = report.projectEnvMap;
} }
if (report.poolName) {
this.poolName = report.poolName;
}
this.content = report; this.content = report;
this.fullTreeNodes = report.steps; this.fullTreeNodes = report.steps;
this.content.console = report.console; this.content.console = report.console;

View File

@ -25,7 +25,18 @@
</span> </span>
</el-col> </el-col>
</el-row> </el-row>
<el-row v-if="showProjectEnv" type="flex"> <el-row type="flex" style="margin-top: 5px">
<el-col v-if="this.poolName">
<div style="float: left">
<span> {{ $t('load_test.select_resource_pool') + ':' }} </span>
</div>
<div style="color: #61c550; margin-left: 10px; float: left">
{{ this.poolName }}
</div>
</el-col>
<el-col></el-col>
</el-row>
<el-row v-if="showProjectEnv" type="flex" style="margin-top: 5px">
<span> {{ $t('commons.environment') + ':' }} </span> <span> {{ $t('commons.environment') + ':' }} </span>
<div v-for="(values,key) in projectEnvMap" :key="key" style="margin-right: 10px"> <div v-for="(values,key) in projectEnvMap" :key="key" style="margin-right: 10px">
{{ key + ":" }} {{ key + ":" }}
@ -62,6 +73,7 @@ export default {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
poolName: String,
isPlan: Boolean isPlan: Boolean
}, },
computed: { computed: {

View File

@ -47,13 +47,24 @@
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
<el-row type="flex" v-if="response && response.envName"> <el-row type="flex" style="margin-top: 5px">
<div style="font-size: 14px;color: #AAAAAA;float: left"> <el-col v-if="response && response.poolName">
<span> {{ $t('commons.environment') + ':' }} </span> <div style="font-size: 14px; color: #aaaaaa; float: left">
</div> <span> {{ $t('load_test.select_resource_pool') + ':' }} </span>
<div style="font-size: 14px;color:#61C550; margin-left:10px;float: left"> </div>
{{ response.envName }} <div style="font-size: 14px; color: #61c550; margin-left: 10px; float: left">
</div> {{ response.poolName }}
</div>
</el-col>
<el-col type="flex" v-if="response && response.envName">
<div style="font-size: 14px; color: #aaaaaa; float: left">
<span> {{ $t('commons.environment') + ':' }} </span>
</div>
<div style="font-size: 14px; color: #61c550; margin-left: 10px; float: left">
{{ response.envName }}
</div>
</el-col>
<el-col></el-col>
</el-row> </el-row>
</div> </div>
</template> </template>