feat(测试跟踪): UI测试计划报告导出

--bug=1015194 --user=陈建星 【测试跟踪】分享/导出测试计划报告,ui用例统计分析,ui用例展示的其实是接口用例 https://www.tapd.cn/55049933/s/1212180
This commit is contained in:
chenjianxing 2022-07-26 16:10:09 +08:00 committed by zhangdahai112
parent 5be7e35b07
commit 6b110b4fbe
17 changed files with 358 additions and 316 deletions

View File

@ -2,7 +2,7 @@ package io.metersphere.base.mapper.ext;
import io.metersphere.api.dto.automation.TestPlanScenarioRequest;
import io.metersphere.base.domain.TestPlanUiScenario;
import io.metersphere.dto.TestPlanFailureUiScenarioDTO;
import io.metersphere.dto.TestPlanUiScenarioDTO;
import io.metersphere.dto.UiScenarioDTO;
import io.metersphere.track.dto.PlanReportCaseDTO;
import org.apache.ibatis.annotations.Param;
@ -29,9 +29,9 @@ public interface ExtTestPlanUiScenarioCaseMapper {
List<PlanReportCaseDTO> selectForPlanReport(String planId);
List<TestPlanFailureUiScenarioDTO> getFailureList(@Param("planId") String planId, @Param("status") String status);
List<TestPlanUiScenarioDTO> getPlanUiScenarioByStatusList(@Param("planId") String planId, @Param("statusList") List<String> statusList);
List<TestPlanFailureUiScenarioDTO> getFailureListByIds(@Param("ids") Collection<String> ids,@Param("status") String status);
List<TestPlanUiScenarioDTO> getFailureListByIds(@Param("ids") Collection<String> ids, @Param("status") String status);
List<Integer> getUnderwaySteps(@Param("ids") List<String> underwayIds);

View File

@ -237,31 +237,7 @@
SELECT id FROM ui_scenario where status is null or status != 'Trash'
)
</select>
<select id="getFailureList" resultType="io.metersphere.dto.TestPlanFailureUiScenarioDTO">
select
t.id, t.last_result, t.report_id, c.user_id, c.module_path, c.name, c.level,c.create_user,c.principal,
c.status,c.step_total, c.step_total, c.project_id,
c.num, c.custom_num
from
test_plan_ui_scenario t
inner join
ui_scenario c
on t.ui_scenario_id = c.id and (c.status != 'Trash' or c.status is null)
and t.test_plan_id = #{planId}
<if test="status != null and status != 'Fail' and status != 'unExecute'">
and t.last_result = #{status}
</if>
<if test="status == 'unExecute'">
and (t.last_result in ('Stop','unExecute') or t.last_result IS NULL)
</if>
<if test="status == 'Fail'">
and t.last_result in ('Fail','Error')
</if>
where t.test_plan_id = #{planId}
ORDER BY t.order DESC
</select>
<select id="getFailureListByIds" resultType="io.metersphere.dto.TestPlanFailureUiScenarioDTO">
<select id="getFailureListByIds" resultType="io.metersphere.dto.TestPlanUiScenarioDTO">
select
t.id, t.last_result, t.report_id, c.user_id, c.module_path, c.name, c.level,c.create_user,c.principal,
c.status,c.step_total, c.step_total, c.project_id,
@ -319,6 +295,26 @@
order by `order` desc limit 1;
</select>
<select id="getPlanUiScenarioByStatusList" resultType="io.metersphere.dto.TestPlanUiScenarioDTO">
select
t.id, t.last_result, t.report_id, c.user_id, c.module_path, c.name, c.level,c.create_user,c.principal,
c.status,c.step_total, c.step_total, c.project_id,
c.num, c.custom_num
from
test_plan_ui_scenario t
inner join
ui_scenario c
on t.ui_scenario_id = c.id and (c.status != 'Trash' or c.status is null)
and t.test_plan_id = #{planId}
<if test="statusList != null and statusList.size() > 0">
and t.last_result in
<foreach collection="statusList" item="status" separator="," open="(" close=")">
#{status}
</foreach>
</if>
ORDER BY t.order DESC
</select>
<sql id="queryVersionCondition">
<if test="request.versionId != null">
and ${versionTable}.version_id = #{request.versionId}

View File

@ -0,0 +1,5 @@
package io.metersphere.commons.constants;
public enum TestPlanUiResultStatus {
Error, Success, UnExecute
}

View File

@ -159,28 +159,11 @@ public class ShareController {
return testPlanScenarioCaseService.getUnExecuteCases(planId);
}
@GetMapping("/test/plan/uiScenario/case/list/failure/{shareId}/{planId}")
public List<TestPlanFailureUiScenarioDTO> getUiScenarioFailureList(@PathVariable String shareId, @PathVariable String planId) {
@PostMapping("/test/plan/uiScenario/case/list/all/{shareId}/{planId}")
public List<TestPlanUiScenarioDTO> getUiScenarioAllList(@PathVariable String shareId, @PathVariable String planId,
@RequestBody(required = false) List<String> statusList) {
shareInfoService.validate(shareId, planId);
return testPlanUiScenarioCaseService.getFailureCases(planId);
}
@GetMapping("/test/plan/uiScenario/case/list/all/{shareId}/{planId}")
public List<TestPlanFailureUiScenarioDTO> getUiScenarioAllList(@PathVariable String shareId, @PathVariable String planId) {
shareInfoService.validate(shareId, planId);
return testPlanUiScenarioCaseService.getAllCases(planId);
}
@GetMapping("/test/plan/uiScenario/case/list/errorReport/{shareId}/{planId}")
public List<TestPlanFailureUiScenarioDTO> getUiScenarioErrorReportList(@PathVariable String shareId, @PathVariable String planId) {
shareInfoService.validate(shareId, planId);
return testPlanUiScenarioCaseService.getErrorReportCases(planId);
}
@GetMapping("/test/plan/uiScenario/case/list/unExecute/{shareId}/{planId}")
public List<TestPlanFailureUiScenarioDTO> geUitUnExecuteScenarioCases(@PathVariable String shareId, @PathVariable String planId) {
shareInfoService.validate(shareId, planId);
return testPlanUiScenarioCaseService.getUnExecuteCases(planId);
return testPlanUiScenarioCaseService.getAllCasesByStatusList(planId, statusList);
}
@GetMapping("/api/definition/report/getReport/{shareId}/{testId}")

View File

@ -8,6 +8,6 @@ import lombok.Setter;
@Getter
@Setter
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TestPlanFailureUiScenarioDTO extends UiScenarioDTO {
public class TestPlanUiScenarioDTO extends UiScenarioDTO {
private APIScenarioReportResult response;
}

View File

@ -38,24 +38,10 @@ public class TestPlanUiScenarioCaseController {
return PageUtils.setPageInfo(page, testPlanUiScenarioCaseService.list(request));
}
@GetMapping("/list/failure/{planId}")
public List<TestPlanFailureUiScenarioDTO> getFailureList(@PathVariable String planId) {
return testPlanUiScenarioCaseService.getFailureCases(planId);
}
@GetMapping("/list/errorReport/{planId}")
public List<TestPlanFailureUiScenarioDTO> getErrorReportList(@PathVariable String planId) {
return testPlanUiScenarioCaseService.getErrorReportCases(planId);
}
@GetMapping("/list/unExecute/{planId}")
public List<TestPlanFailureUiScenarioDTO> getUnExecuteCases(@PathVariable String planId) {
return testPlanUiScenarioCaseService.getUnExecuteCases(planId);
}
@GetMapping("/list/all/{planId}")
public List<TestPlanFailureUiScenarioDTO> getAllList(@PathVariable String planId) {
return testPlanUiScenarioCaseService.getAllCases(planId);
@PostMapping("/list/all/{planId}")
public List<TestPlanUiScenarioDTO> getAllList(@PathVariable String planId,
@RequestBody(required = false) List<String> statusList) {
return testPlanUiScenarioCaseService.getAllCasesByStatusList(planId, statusList);
}
@PostMapping("/selectAllTableRows")

View File

@ -4,6 +4,7 @@ import io.metersphere.api.dto.automation.TestPlanFailureApiDTO;
import io.metersphere.api.dto.automation.TestPlanFailureScenarioDTO;
import io.metersphere.base.domain.IssuesDao;
import io.metersphere.base.domain.TestPlanReportContent;
import io.metersphere.dto.TestPlanUiScenarioDTO;
import lombok.Getter;
import lombok.Setter;
@ -43,14 +44,19 @@ public class TestPlanSimpleReportDTO extends TestPlanReportContent {
List<TestPlanCaseDTO> functionAllCases;
List<IssuesDao> issueList;
List<TestPlanFailureApiDTO> apiFailureCases;
List<TestPlanFailureApiDTO> apiAllCases;
List<TestPlanFailureScenarioDTO> scenarioFailureCases;
List<TestPlanFailureScenarioDTO> scenarioAllCases;
List<TestPlanLoadCaseDTO> loadAllCases;
List<TestPlanLoadCaseDTO> loadFailureCases;
List<TestPlanFailureApiDTO> apiAllCases;
List<TestPlanFailureApiDTO> errorReportCases;
List<TestPlanFailureScenarioDTO> errorReportScenarios;
List<TestPlanFailureApiDTO> apiFailureCases;
List<TestPlanFailureApiDTO> unExecuteCases;
List<TestPlanFailureScenarioDTO> scenarioAllCases;
List<TestPlanFailureScenarioDTO> errorReportScenarios;
List<TestPlanFailureScenarioDTO> scenarioFailureCases;
List<TestPlanFailureScenarioDTO> unExecuteScenarios;
List<TestPlanUiScenarioDTO> uiAllCases;
}

View File

@ -16,7 +16,7 @@ import io.metersphere.commons.utils.*;
import io.metersphere.constants.RunModeConstants;
import io.metersphere.dto.RunModeConfigDTO;
import io.metersphere.dto.TestPlanExecuteReportDTO;
import io.metersphere.dto.TestPlanFailureUiScenarioDTO;
import io.metersphere.dto.TestPlanUiScenarioDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.log.vo.OperatingLogDetails;
import io.metersphere.service.EnvironmentGroupProjectService;
@ -1104,9 +1104,9 @@ public class TestPlanReportService {
content.setPlanLoadCaseReportStruct(JSONObject.toJSONString(loadCaseReportIdMap));
}
if (MapUtils.isNotEmpty(uiScenarioReportMap)) {
List<TestPlanFailureUiScenarioDTO> uiScenarios =
List<TestPlanUiScenarioDTO> uiScenarios =
extTestPlanUiScenarioCaseMapper.getFailureListByIds(uiScenarioReportMap.keySet(), null);
for (TestPlanFailureUiScenarioDTO dto : uiScenarios) {
for (TestPlanUiScenarioDTO dto : uiScenarios) {
dto.setReportId(uiScenarioReportMap.get(dto.getId()));
}
content.setPlanUiScenarioReportStruct(JSONObject.toJSONString(uiScenarios));

View File

@ -504,19 +504,6 @@ public class TestPlanScenarioCaseService {
calculatePlanReport(report, planReportCaseDTOS);
}
public void calculatePlanReportByScenarioList(List<TestPlanFailureScenarioDTO> scenarioList, TestPlanSimpleReportDTO report) {
List<PlanReportCaseDTO> planReportCaseDTOS = new ArrayList<>();
for (TestPlanFailureScenarioDTO scenario : scenarioList) {
PlanReportCaseDTO dto = new PlanReportCaseDTO();
dto.setCaseId(scenario.getCaseId());
dto.setId(scenario.getId());
dto.setStatus(scenario.getStatus());
dto.setReportId(scenario.getReportId());
planReportCaseDTOS.add(dto);
}
calculatePlanReport(report, planReportCaseDTOS);
}
private void calculatePlanReport(TestPlanSimpleReportDTO report, List<PlanReportCaseDTO> planReportCaseDTOS) {
TestPlanApiResultReportDTO apiResult = report.getApiResult();

View File

@ -1364,15 +1364,11 @@ public class TestPlanService {
List<TestPlanCaseDTO> allCases = null;
List<String> statusList = getFunctionalReportStatusList(config);
if (statusList != null) {
// 不等于null说明配置了用例根据配置的状态查询用例
allCases = testPlanTestCaseService.getAllCasesByStatusList(planId, statusList);
report.setFunctionAllCases(allCases);
}
if (checkReportConfig(config, "functional", "all")) {
allCases = testPlanTestCaseService.getAllCases(planId);
report.setFunctionAllCases(allCases);
}
if (checkReportConfig(config, "functional", "issue")) {
List<IssuesDao> issueList = issuesService.getIssuesByPlanId(planId);
report.setIssueList(issueList);
@ -1380,6 +1376,28 @@ public class TestPlanService {
}
}
public void buildUiReport(TestPlanSimpleReportDTO report, JSONObject config, String planId, boolean saveResponse) {
if (checkReportConfig(config, "ui")) {
List<TestPlanUiScenarioDTO> allCases;
List<String> statusList = getUiReportStatusList(config);
if (statusList != null) {
// 不等于null说明配置了用例根据配置的状态查询用例
allCases = testPlanUiScenarioCaseService.getAllCasesByStatusList(planId, statusList);
report.setUiAllCases(allCases);
if (saveResponse) {
buildUiScenarioResponse(allCases);
}
}
}
}
/**
* 如果配置了全部用例返回空的数组
* 如果没有则添加对应的状态
* 都没配置就返回 null
* @param config
* @return
*/
public List<String> getFunctionalReportStatusList(JSONObject config) {
List<String> statusList = new ArrayList<>();
if (checkReportConfig(config, "functional", "all")) {
@ -1397,6 +1415,20 @@ public class TestPlanService {
return statusList.size() > 0 ? statusList : null;
}
public List<String> getUiReportStatusList(JSONObject config) {
List<String> statusList = new ArrayList<>();
if (checkReportConfig(config, "ui", "all")) {
return statusList;
}
if (checkReportConfig(config, "ui", "failure")) {
statusList.add(TestPlanUiResultStatus.Error.name());
}
if (checkReportConfig(config, "ui", "unExecute")) {
statusList.add(TestPlanUiResultStatus.UnExecute.name());
}
return statusList.size() > 0 ? statusList : null;
}
public void buildApiReport(TestPlanSimpleReportDTO report, JSONObject config, String planId, boolean saveResponse) {
if (checkReportConfig(config, "api")) {
List<TestPlanFailureApiDTO> apiAllCases = null;
@ -1474,6 +1506,14 @@ public class TestPlanService {
}
}
public void buildUiScenarioResponse(List<TestPlanUiScenarioDTO> cases) {
if (!CollectionUtils.isEmpty(cases)) {
cases.forEach((item) -> {
item.setResponse(apiScenarioReportService.get(item.getReportId(), true));
});
}
}
public void buildLoadResponse(List<TestPlanLoadCaseDTO> cases) {
if (!CollectionUtils.isEmpty(cases)) {
cases.forEach(item -> {
@ -1792,6 +1832,7 @@ public class TestPlanService {
buildFunctionalReport(report, config, planId);
buildApiReport(report, config, planId, saveResponse);
buildLoadReport(report, config, planId, saveResponse);
buildUiReport(report, config, planId, saveResponse);
return report;
}
@ -1817,21 +1858,27 @@ public class TestPlanService {
return true;
} else {
JSONObject configItem = config.getJSONObject(key);
if (configItem == null) {
return true;
}
return configItem.getBoolean("enable");
}
}
public Boolean checkReportConfig(JSONObject config, String key, String subKey) {
if (config == null) {
if (config == null || config.getJSONObject(key) == null) {
return true;
} else {
JSONObject configItem = config.getJSONObject(key);
Boolean enable = configItem.getBoolean("enable");
if (!enable) {
return false;
} else {
if (enable) {
JSONObject subConfig = configItem.getJSONObject("children").getJSONObject(subKey);
return subConfig == null ? true : subConfig.getBoolean("enable");
if (subConfig == null) {
return true;
}
return subConfig.getBoolean("enable");
} else {
return false;
}
}
}

View File

@ -451,19 +451,6 @@ public class TestPlanUiScenarioCaseService {
calculatePlanReport(report, planReportCaseDTOS);
}
public void calculatePlanReportByScenarioList(List<TestPlanFailureUiScenarioDTO> scenarioList,TestPlanSimpleReportDTO report){
List<PlanReportCaseDTO> planReportCaseDTOS = new ArrayList<>();
for (TestPlanFailureUiScenarioDTO scenario : scenarioList) {
PlanReportCaseDTO dto = new PlanReportCaseDTO();
dto.setCaseId(scenario.getCaseId());
dto.setId(scenario.getId());
dto.setStatus(scenario.getStatus());
dto.setReportId(scenario.getReportId());
planReportCaseDTOS.add(dto);
}
calculatePlanReport(report, planReportCaseDTOS);
}
private void calculatePlanReport(TestPlanSimpleReportDTO report, List<PlanReportCaseDTO> planReportCaseDTOS) {
TestPlanUiResultReportDTO uiResult = report.getUiResult();
@ -524,18 +511,18 @@ public class TestPlanUiScenarioCaseService {
}
}
public List<TestPlanFailureUiScenarioDTO> getAllCases(String planId) {
List<TestPlanFailureUiScenarioDTO> apiTestCases =
extTestPlanUiScenarioCaseMapper.getFailureList(planId, null);
return buildCases(apiTestCases);
public List<TestPlanUiScenarioDTO> getAllCasesByStatusList(String planId, List<String> statusList) {
List<TestPlanUiScenarioDTO> uiTestCases =
extTestPlanUiScenarioCaseMapper.getPlanUiScenarioByStatusList(planId, statusList);
return buildCases(uiTestCases);
}
public List<TestPlanFailureUiScenarioDTO> getAllCases(Map<String, String> idMap, Map<String, TestPlanFailureUiScenarioDTO> scenarioInfoDTOMap) {
public List<TestPlanUiScenarioDTO> getAllCases(Map<String, String> idMap, Map<String, TestPlanUiScenarioDTO> scenarioInfoDTOMap) {
String defaultStatus = "Fail";
Map<String, String> reportStatus = apiScenarioReportService.getReportStatusByReportIds(idMap.values());
Map<String, String> savedReportMap = new HashMap<>(idMap);
List<TestPlanFailureUiScenarioDTO> apiTestCases = new ArrayList<>();
for (TestPlanFailureUiScenarioDTO dto : scenarioInfoDTOMap.values()) {
List<TestPlanUiScenarioDTO> apiTestCases = new ArrayList<>();
for (TestPlanUiScenarioDTO dto : scenarioInfoDTOMap.values()) {
String reportId = savedReportMap.get(dto.getId());
savedReportMap.remove(dto.getId());
dto.setReportId(reportId);
@ -556,13 +543,7 @@ public class TestPlanUiScenarioCaseService {
return buildCases(apiTestCases);
}
public List<TestPlanFailureUiScenarioDTO> getFailureCases(String planId) {
List<TestPlanFailureUiScenarioDTO> apiTestCases =
extTestPlanUiScenarioCaseMapper.getFailureList(planId, "Fail");
return buildCases(apiTestCases);
}
public List<TestPlanFailureUiScenarioDTO> buildCases(List<TestPlanFailureUiScenarioDTO> apiTestCases) {
public List<TestPlanUiScenarioDTO> buildCases(List<TestPlanUiScenarioDTO> apiTestCases) {
if (CollectionUtils.isEmpty(apiTestCases)) {
return apiTestCases;
}
@ -603,16 +584,4 @@ public class TestPlanUiScenarioCaseService {
extTestPlanUiScenarioCaseMapper::getLastOrder,
testPlanUiScenarioMapper::updateByPrimaryKeySelective);
}
public List<TestPlanFailureUiScenarioDTO> getErrorReportCases(String planId) {
List<TestPlanFailureUiScenarioDTO> apiTestCases =
extTestPlanUiScenarioCaseMapper.getFailureList(planId, ExecuteResult.ERROR_REPORT_RESULT.toString());
return buildCases(apiTestCases);
}
public List<TestPlanFailureUiScenarioDTO> getUnExecuteCases(String planId) {
List<TestPlanFailureUiScenarioDTO> apiTestCases =
extTestPlanUiScenarioCaseMapper.getFailureList(planId, "unExecute");
return buildCases(apiTestCases);
}
}

View File

@ -8,34 +8,31 @@
<template v-slot:label>
<tab-pane-count :title="$t('test_track.report.fail_case')" :count="failureSize"/>
</template>
<api-cases :is-db="isDb" :share-id="shareId" :is-share="isShare" :report="report" :is-template="isTemplate"
:plan-id="planId" @setSize="setFailureSize" :is-ui="true"/>
<el-button class="rerun-button" plain size="mini" v-if="showRerunBtn && (failureSize > 0 || unExecuteSize > 0) && isRerun" @click="rerun">
{{ $t('api_test.automation.rerun') }}
</el-button>
<ui-scenario-result :is-db="isDb" :share-id="shareId" :is-share="isShare"
:report="report" :is-template="isTemplate" :plan-id="planId"
:ui-all-cases="uiAllCases"
:filter-status="['Error']"
@setSize="setFailureSize"/>
</el-tab-pane>
<el-tab-pane style="min-height: 500px" name="fourth" v-if="unExecuteEnable">
<el-tab-pane style="min-height: 500px" name="third" v-if="unExecuteEnable">
<template v-slot:label>
<tab-pane-count :title="$t('api_test.home_page.detail_card.unexecute')" :count="unExecuteSize"/>
</template>
<api-cases :is-db="isDb" :is-un-execute="true" :share-id="shareId" :is-share="isShare" :report="report"
:is-template="isTemplate" :plan-id="planId" @setSize="setUnExecuteSize" :is-ui="true"/>
<el-button class="rerun-button" plain size="mini" v-if="showRerunBtn && (failureSize > 0 || unExecuteSize > 0) && isRerun" @click="rerun">
{{ $t('api_test.automation.rerun') }}
</el-button>
<ui-scenario-result :is-db="isDb" :share-id="shareId" :is-share="isShare"
:report="report" :is-template="isTemplate" :plan-id="planId"
:ui-all-cases="uiAllCases"
:filter-status="['UnExecute']"
@setSize="setUnExecuteSize"/>
</el-tab-pane>
<el-tab-pane style="min-height: 500px" name="fifth" v-if="allEnable">
<template v-slot:label>
<tab-pane-count :title="$t('test_track.report.all_case')" :count="allSize"/>
</template>
<api-cases :is-db="isDb" :is-all="true" :share-id="shareId" :is-share="isShare" :report="report"
:is-template="isTemplate" :plan-id="planId" @setSize="setAllSize" :is-ui="true"/>
<el-button class="rerun-button" plain size="mini" v-if="showRerunBtn && (failureSize > 0 || unExecuteSize > 0) && isRerun" @click="rerun">
{{ $t('api_test.automation.rerun') }}
</el-button>
<ui-scenario-result :is-db="isDb" :share-id="shareId" :is-share="isShare"
:report="report" :is-template="isTemplate" :plan-id="planId"
:ui-all-cases="uiAllCases"
@setSize="setAllSize"/>
</el-tab-pane>
</el-tabs>
</test-plan-report-container>
@ -46,26 +43,26 @@ import MsFormDivider from "@/business/components/common/components/MsFormDivider
import UiResult from "@/business/components/track/plan/view/comonents/report/detail/component/UiResult";
import TestPlanReportContainer
from "@/business/components/track/plan/view/comonents/report/detail/TestPlanReportContainer";
import ApiCases from "@/business/components/track/plan/view/comonents/report/detail/component/ApiCases";
import TabPaneCount from "@/business/components/track/plan/view/comonents/report/detail/component/TabPaneCount";
import {hasLicense} from "@/common/js/utils";
import {
getPlanUiScenarioAllCase,
getSharePlanUiScenarioAllCase,
} from "@/network/test-plan";
import UiScenarioResult from "@/business/components/track/plan/view/comonents/report/detail/component/UiScenarioResult";
export default {
name: "TestPlanUiReport",
components: {TabPaneCount, ApiCases, TestPlanReportContainer, UiResult, MsFormDivider},
components: {UiScenarioResult, TabPaneCount, TestPlanReportContainer, UiResult, MsFormDivider},
data() {
return {
activeName: 'first',
failureSize: 0,
errorReportSize: 0,
unExecuteSize: 0,
allSize: 0,
showRerunBtn: false,
uiAllCases: []
};
},
created() {
// this.showRerunBtn = !this.isShare && hasLicense();
},
props: [
'report', 'planId', 'isTemplate', 'isShare', 'shareId', 'isDb'
],
@ -78,10 +75,6 @@ export default {
let disable = this.report.config && this.report.config.ui.children.failure.enable === false;
return !disable;
},
errorReportEnable() {
let disable = this.report.config && this.report.config.ui.children.errorReport && this.report.config.ui.children.errorReport.enable === false;
return !disable;
},
unExecuteEnable() {
let disable = this.report.config && this.report.config.ui.children.unExecute && this.report.config.ui.children.unExecute.enable === false;
return !disable;
@ -89,13 +82,6 @@ export default {
allEnable() {
let disable = this.report.config && this.report.config.ui.children.all.enable === false;
return !disable;
},
isRerun() {
return ((this.report && this.report.apiFailureCases)
|| (this.report && this.report.unExecuteCases)
|| (this.report && this.report.scenarioFailureCases)
|| (this.report && this.report.unExecuteScenarios)
|| (this.report && this.report.loadFailureCases));
}
},
watch: {
@ -105,15 +91,16 @@ export default {
failureEnable() {
this.initActiveName();
},
errorReportEnable() {
this.initActiveName();
},
allEnable() {
this.initActiveName();
},
'report.config'() {
this.getAllUiCase();
}
},
mounted() {
this.initActiveName();
this.getAllUiCase();
},
methods: {
initActiveName() {
@ -121,18 +108,13 @@ export default {
this.activeName = 'first';
} else if (this.failureEnable) {
this.activeName = 'second';
} else if (this.errorReportEnable) {
this.activeName = 'third';
} else if (this.allEnable) {
this.activeName = 'fourth';
this.activeName = 'third';
}
},
setFailureSize(size) {
this.failureSize = size;
},
setErrorReportSize(size) {
this.errorReportSize = size;
},
setUnExecuteSize(size) {
this.unExecuteSize = size;
},
@ -141,66 +123,41 @@ export default {
},
handleClick(tab, event) {
},
rerun() {
let type = "TEST_PLAN";
let scenarios = [];
let cases = [];
let performanceCases = [];
let rerunObj = {
type: type,
reportId: this.report.id,
scenarios: scenarios,
cases: cases,
performanceCases: performanceCases
}
//
if (this.report && this.report.apiFailureCases) {
this.format(cases, this.report.apiFailureCases);
}
if (this.report && this.report.unExecuteCases) {
this.format(cases, this.report.unExecuteCases);
}
//
if (this.report && this.report.scenarioFailureCases) {
this.format(scenarios, this.report.scenarioFailureCases);
}
if (this.report && this.report.unExecuteScenarios) {
this.format(scenarios, this.report.unExecuteScenarios);
}
//
if (this.report && this.report.loadFailureCases) {
this.format(performanceCases, this.report.loadFailureCases);
}
this.$post('/ui/test/exec/rerun', rerunObj, res => {
if (res.data !== 'SUCCESS') {
this.$error(res.data);
} else {
this.$success(this.$t('api_test.automation.rerun_success'));
getAllUiCase() {
if (this.isTemplate || this.isDb) {
this.uiAllCases = this.report.uiAllCases ? this.report.uiAllCases : [];
} else if (this.isShare) {
let param = this.getStatusList();
if (param) {
getSharePlanUiScenarioAllCase(this.shareId, this.planId, param, (data) => {
this.uiAllCases = data;
});
}
} else {
let param = this.getStatusList();
if (param) {
this.result = getPlanUiScenarioAllCase(this.planId, param, (data) => {
this.uiAllCases = data;
});
}
});
},
format(cases, datas) {
if (this.report && datas) {
datas.forEach(item => {
if (item) {
let obj = {id: item.id, reportId: item.reportId, userId: item.createUser};
cases.push(obj);
}
});
}
},
getStatusList() {
let statusList = [];
if (this.allEnable) {
return statusList;
}
if (this.failureEnable) {
statusList.push('Error');
}
if (this.unExecuteEnable) {
statusList.push('UnExecute');
}
return statusList.length > 0 ? statusList : null;
}
}
}
</script>
<style scoped>
.rerun-button {
position: absolute;
top: 10px;
right: 10px;
margin-right: 10px;
z-index: 1100;
background-color: #F2F9EF;
color: #87C45D;
}
</style>

View File

@ -1,7 +1,7 @@
<template>
<div>
<el-tabs type="card">
<el-tab-pane v-if="!isUi">
<el-tab-pane>
<template v-slot:label>
<tab-pane-count :title="$t('commons.api_case')" :count="apiSize"/>
</template>
@ -12,7 +12,7 @@
<template v-slot:label>
<tab-pane-count :title="$t('commons.scenario_case')" :count="scenarioSize"/>
</template>
<api-scenario-failure-result :is-ui="isUi" :is-db="isDb" :is-all="isAll" :is-error-report="isErrorReport" :is-un-execute="isUnExecute" :share-id="shareId" :is-share="isShare"
<api-scenario-failure-result :is-db="isDb" :is-all="isAll" :is-error-report="isErrorReport" :is-un-execute="isUnExecute" :share-id="shareId" :is-share="isShare"
:report="report" :is-template="isTemplate" :plan-id="planId"
@setSize="setScenarioSize"/>
</el-tab-pane>
@ -48,7 +48,6 @@ export default {
isErrorReport: Boolean,
isUnExecute:Boolean,
isDb: Boolean,
isUi: Boolean,
},
data() {
return {

View File

@ -85,15 +85,7 @@ import {
getPlanScenarioErrorReportCase,
getSharePlanScenarioErrorReportCase,
getPlanScenarioUnExecuteCase,
getSharePlanScenarioUnExecuteCase,
getPlanUiScenarioErrorReportCase,
getPlanUiScenarioFailureCase,
getPlanUiScenarioUnExecuteCase,
getPlanUiScenarioAllCase,
getSharePlanUiScenarioAllCase,
getSharePlanUiScenarioUnExecuteCase,
getSharePlanUiScenarioErrorReportCase,
getSharePlanUiScenarioFailureCase,
getSharePlanScenarioUnExecuteCase
} from "@/network/test-plan";
import MsTable from "@/business/components/common/components/table/MsTable";
import MsTableColumn from "@/business/components/common/components/table/MsTableColumn";
@ -119,7 +111,6 @@ export default {
isErrorReport: Boolean,
isUnExecute: Boolean,
isDb: Boolean,
isUi: Boolean,
},
data() {
return {
@ -152,7 +143,7 @@ export default {
} else {
this.scenarioCases = this.report.scenarioFailureCases ? this.report.scenarioFailureCases : [];
}
} else if (this.isShare && !this.isUi) {
} else if (this.isShare) {
if (this.isErrorReport) {
this.result = getSharePlanScenarioErrorReportCase(this.shareId, this.planId, (data) => {
this.scenarioCases = data;
@ -170,42 +161,6 @@ export default {
this.scenarioCases = data;
});
}
} else if (this.isShare && this.isUi) {
if (this.isErrorReport) {
this.result = getSharePlanUiScenarioErrorReportCase(this.shareId, this.planId, (data) => {
this.scenarioCases = data;
});
} else if (this.isUnExecute) {
this.result = getSharePlanUiScenarioUnExecuteCase(this.shareId, this.planId, (data) => {
this.scenarioCases = data;
});
} else if (this.isAll) {
this.result = getSharePlanUiScenarioAllCase(this.shareId, this.planId, (data) => {
this.scenarioCases = data;
});
} else {
this.result = getSharePlanUiScenarioFailureCase(this.shareId, this.planId, (data) => {
this.scenarioCases = data;
});
}
} else if (this.isUi) {
if (this.isErrorReport) {
this.result = getPlanUiScenarioErrorReportCase(this.planId, (data) => {
this.scenarioCases = data;
});
} else if (this.isUnExecute) {
this.result = getPlanUiScenarioUnExecuteCase(this.planId, (data) => {
this.scenarioCases = data;
});
} else if (this.isAll) {
this.result = getPlanUiScenarioAllCase(this.planId, (data) => {
this.scenarioCases = data;
});
} else {
this.result = getPlanUiScenarioFailureCase(this.planId, (data) => {
this.scenarioCases = data;
});
}
} else {
if (this.isErrorReport) {
this.result = getPlanScenarioErrorReportCase(this.planId, (data) => {

View File

@ -5,7 +5,6 @@
<ms-doughnut-pie-chart style="margin-right: 200px" :name="$t('api_test.home_page.ui_details_card.scenario_cases')" :data="caseCharData" ref="functionChar"/>
</el-col>
<el-col :span="12" v-if="scenarioCharData && scenarioCharData.length > 0">
<!-- <api-scenario-char-result :name="$t('test_track.plan.test_plan_api_scenario_count')" :data="scenarioCharData"/>-->
<api-scenario-char-result style="margin-top: -50px;" :name="$t('api_test.home_page.ui_details_card.step_count')" :data="stepCharData"/>
</el-col>
</el-row>

View File

@ -0,0 +1,177 @@
<template>
<el-container class="scenario-info">
<ms-aside-container width="500px" :default-hidden-bottom-top="200" :enable-auto-height="true">
<el-card>
<el-scrollbar>
<ms-table v-loading="result.loading"
:show-select-all="false"
:screen-height="null"
:enable-selection="false"
:highlight-current-row="true"
@refresh="getScenarioApiCase"
@handleRowClick="rowClick"
:data="scenarioCases">
<ms-table-column
:width="80"
:label="$t('commons.id')"
prop="customNum">
</ms-table-column>
<ms-table-column
:label="$t('commons.name')"
prop="name">
</ms-table-column>
<ms-table-column
:label="$t('test_track.report.list.creator')"
prop="creatorName"/>
<ms-table-column
:label="$t('test_track.case.priority')"
:width="80">
<template v-slot:default="scope">
<priority-table-item :value="scope.row.level" ref="priority"/>
</template>
</ms-table-column>
<ms-table-column
:width="70"
:label="$t('api_test.automation.step')"
prop="stepTotal">
</ms-table-column>
<ms-table-column
:width="80"
:label="$t('test_track.plan_view.execute_result')"
prop="lastResult">
<template v-slot:default="{row}">
<status-table-item :value="resultMap[row.lastResult]"/>
</template>
</ms-table-column>
</ms-table>
</el-scrollbar>
</el-card>
</ms-aside-container>
<el-main>
<ms-api-report
v-if="showResponse"
:is-plan="true"
:share-id="shareId"
:is-share="isShare"
:template-report="response"
:is-template="isTemplate"
:infoDb="true"
:report-id="reportId"
@reportNotExist="showResponse = false"/>
<div class="empty" v-else>{{ $t('test_track.plan.load_case.content_empty') }}</div>
</el-main>
</el-container>
</template>
<script>
import PriorityTableItem from "../../../../../../common/tableItems/planview/PriorityTableItem";
import TypeTableItem from "../../../../../../common/tableItems/planview/TypeTableItem";
import MethodTableItem from "../../../../../../common/tableItems/planview/MethodTableItem";
import StatusTableItem from "../../../../../../common/tableItems/planview/StatusTableItem";
import MsTable from "@/business/components/common/components/table/MsTable";
import MsTableColumn from "@/business/components/common/components/table/MsTableColumn";
import MsApiReport from "@/business/components/api/automation/report/ApiReportDetail";
import MsAsideContainer from "@/business/components/common/components/MsAsideContainer";
import MsMainContainer from "@/business/components/common/components/MsMainContainer";
export default {
name: "UiScenarioResult",
components: {
MsMainContainer,
MsAsideContainer,
MsApiReport,
MsTableColumn, MsTable, StatusTableItem, MethodTableItem, TypeTableItem, PriorityTableItem
},
props: {
planId: String,
isTemplate: Boolean,
report: Object,
isShare: Boolean,
shareId: String,
isAll: Boolean,
isErrorReport: Boolean,
isUnExecute: Boolean,
isDb: Boolean,
uiAllCases: Array,
filterStatus: Array,
},
data() {
return {
scenarioCases: [],
result: {},
reportId: null,
response: {},
showResponse: false,
resultMap: {
'Success' : 'Pass',
'Error' : 'Failure',
'STOP' : 'STOP',
'Running' : 'Running',
'UnExecute' : 'Prepare'
}
}
},
mounted() {
this.getScenarioApiCase();
},
watch: {
scenarioCases() {
if (this.scenarioCases) {
this.$emit('setSize', this.scenarioCases.length);
}
},
uiAllCases() {
this.getScenarioApiCase();
}
},
methods: {
getScenarioApiCase() {
this.scenarioCases = [];
if (this.filterStatus && this.filterStatus.length > 0) {
this.uiAllCases.forEach(item => {
if (this.filterStatus.indexOf(item.lastResult) > -1) {
this.scenarioCases.push(item);
}
});
} else {
this.scenarioCases = this.uiAllCases;
}
},
rowClick(row) {
this.showResponse = false;
if (this.isTemplate) {
if (row.response) {
this.showResponse = true;
this.response = row.response;
}
} else {
if (row.reportId && row.lastResult !== "Running" && row.lastResult !== "Waiting") {
this.showResponse = true;
this.reportId = row.reportId;
}
}
}
}
}
</script>
<style scoped>
.padding-col {
padding-right: 0px;
}
.el-card >>> .el-card__body {
height: 588px;
}
/deep/ .api-report-content {
height: auto;
}
.ms-aside-container {
border: 0px;
padding: 10px 0px 0px 10px;
}
</style>

View File

@ -94,19 +94,8 @@ export function getSharePlanScenarioUnExecuteCase(shareId, planId, callback) {
return planId ? baseGet('/share/test/plan/scenario/case/list/unExecute/' + shareId + '/' + planId, callback) : {};
}
export function getSharePlanUiScenarioFailureCase(shareId, planId, callback) {
return planId ? baseGet('/share/test/plan/uiScenario/case/list/failure/' + shareId + '/' + planId, callback) : {};
}
export function getSharePlanUiScenarioAllCase(shareId, planId, callback) {
return planId ? baseGet('/share/test/plan/uiScenario/case/list/all/' + shareId + '/' + planId, callback) : {};
}
export function getSharePlanUiScenarioErrorReportCase(shareId, planId, callback) {
return planId ? baseGet('/share/test/plan/uiScenario/case/list/errorReport/' + shareId + '/' + planId, callback) : {};
}
export function getSharePlanUiScenarioUnExecuteCase(shareId, planId, callback) {
return planId ? baseGet('/share/test/plan/uiScenario/case/list/unExecute/' + shareId + '/' + planId, callback) : {};
export function getSharePlanUiScenarioAllCase(shareId, planId, param, callback) {
return planId ? basePost('/share/test/plan/uiScenario/case/list/all/' + shareId + '/' + planId, param, callback) : {};
}
export function getPlanApiFailureCase(planId, callback) {
@ -187,19 +176,6 @@ export function saveTestPlanReport(planId, callback) {
return planId ? baseGet('/test/plan/report/saveTestPlanReport/' + planId + '/MANUAL', callback) : {};
}
export function getPlanUiScenarioFailureCase(planId, callback) {
return planId ? baseGet('/test/plan/uiScenario/case/list/failure/' + planId, callback) : {};
}
export function getPlanUiScenarioErrorReportCase(planId, callback) {
return planId ? baseGet('/test/plan/uiScenario/case/list/errorReport/' + planId, callback) : {};
}
export function getPlanUiScenarioUnExecuteCase(planId, callback) {
return planId ? baseGet('/test/plan/uiScenario/case/list/unExecute/' + planId, callback) : {};
}
export function getPlanUiScenarioAllCase(planId, callback) {
return planId ? baseGet('/test/plan/uiScenario/case/list/all/' + planId, callback) : {};
export function getPlanUiScenarioAllCase(planId, param, callback) {
return planId ? basePost('/test/plan/uiScenario/case/list/all/' + planId, param, callback) : {};
}