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.PageHelper;
import io.metersphere.api.dto.ApiCaseRelevanceRequest;
import io.metersphere.api.dto.ApiReportEnvConfigDTO;
import io.metersphere.api.dto.EnvironmentType;
import io.metersphere.api.dto.QueryReferenceRequest;
import io.metersphere.api.dto.automation.TestPlanDTO;
@ -413,7 +414,11 @@ public class TestPlanApiCaseService {
try {
Map content = JSON.parseMap(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);
apiCase.setResponse(contentStr);
@ -442,7 +447,11 @@ public class TestPlanApiCaseService {
LogUtil.error("转换content失败!", e);
}
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()

View File

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

View File

@ -25,7 +25,18 @@
</span>
</el-col>
</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>
<div v-for="(values,key) in projectEnvMap" :key="key" style="margin-right: 10px">
{{ key + ":" }}
@ -62,6 +73,7 @@ export default {
type: Boolean,
default: false,
},
poolName: String,
isPlan: Boolean
},
computed: {

View File

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