refactor(测试计划): 重写测试计划加载场景报告的方式

This commit is contained in:
song-tianyang 2023-06-27 19:30:16 +08:00 committed by 刘瑞斌
parent e69c669ae1
commit f180fbf884
6 changed files with 57 additions and 59 deletions

View File

@ -37,7 +37,17 @@ export default {
methods: { methods: {
getRouteParam(name) { getRouteParam(name) {
if (this.$route) { if (this.$route) {
if (name === 'reportId') {
// 使qiankunreportIdUUID'[TEST-PLAN-REDIRECT]'
let reportId = this.$route.params[name];
if (reportId && reportId.indexOf('[TEST-PLAN-REDIRECT]') > -1) {
return reportId.split('[TEST-PLAN-REDIRECT]')[1];
} else {
return reportId;
}
} else {
return this.$route.params[name]; return this.$route.params[name];
}
} else { } else {
return null; return null;
} }

View File

@ -111,12 +111,13 @@
<script> <script>
import MsDrawer from "../MsDrawer"; import MsDrawer from "../MsDrawer";
import {getCurrentProjectID, getCurrentUser} from "../../utils/token"; import {getCurrentProjectID, getCurrentUser} from "../../utils/token";
import {hasPermissions, hasLicense} from "../../utils/permission"; import {hasLicense, hasPermissions} from "../../utils/permission";
import {getProjectUsers} from "../../api/user"; import {getProjectUsers} from "../../api/user";
import {getCaseData, getScenarioData, getTaskList, getTaskSocket, stopBatchTask, stopTask} from "../../api/task"; import {getCaseData, getScenarioData, getTaskList, getTaskSocket, stopBatchTask, stopTask} from "../../api/task";
import MicroApp from "../../components/MicroApp"; import MicroApp from "../../components/MicroApp";
import {prefetchApps} from "qiankun"; import {prefetchApps} from "qiankun";
import TaskCenterItem from "./TaskCenterItem"; import TaskCenterItem from "./TaskCenterItem";
import {getUUID} from "../../utils";
export default { export default {
name: "MsTaskCenter", name: "MsTaskCenter",
@ -350,9 +351,13 @@ export default {
this.executionModule = null; this.executionModule = null;
this.$nextTick(() => { this.$nextTick(() => {
this.size = window.innerWidth; this.size = window.innerWidth;
this.reportId = row.id;
this.executionModule = row.executionModule; this.executionModule = row.executionModule;
this.reportType = row.reportType; this.reportType = row.reportType;
if (row.executionModule === 'SCENARIO' || row.reportType === 'API_INTEGRATED') {
this.reportId = getUUID() + "[TEST-PLAN-REDIRECT]" + row.id;
} else {
this.reportId = row.id;
}
}) })
} else { } else {
this.$warning(this.$t('commons.run_warning')) this.$warning(this.$t('commons.run_warning'))

View File

@ -282,15 +282,9 @@
import MsTableHeader from "metersphere-frontend/src/components/MsTableHeader"; import MsTableHeader from "metersphere-frontend/src/components/MsTableHeader";
import MsTablePagination from "metersphere-frontend/src/components/pagination/TablePagination"; import MsTablePagination from "metersphere-frontend/src/components/pagination/TablePagination";
import MsTag from "metersphere-frontend/src/components/MsTag"; import MsTag from "metersphere-frontend/src/components/MsTag";
import { import {getCurrentProjectID, getCurrentWorkspaceId,} from "metersphere-frontend/src/utils/token";
getCurrentProjectID, import {getUUID, strMapToObj} from "metersphere-frontend/src/utils";
getCurrentWorkspaceId, import {hasLicense, hasPermission,} from "metersphere-frontend/src/utils/permission";
} from "metersphere-frontend/src/utils/token";
import { getUUID, strMapToObj } from "metersphere-frontend/src/utils";
import {
hasLicense,
hasPermission,
} from "metersphere-frontend/src/utils/permission";
import MsTableMoreBtn from "metersphere-frontend/src/components/table/TableMoreBtn"; import MsTableMoreBtn from "metersphere-frontend/src/components/table/TableMoreBtn";
import TestPlanScenarioListHeader from "./TestPlanScenarioListHeader"; import TestPlanScenarioListHeader from "./TestPlanScenarioListHeader";
import { import {
@ -299,18 +293,18 @@ import {
getCustomTableWidth, getCustomTableWidth,
initCondition, initCondition,
} from "metersphere-frontend/src/utils/tableUtils"; } from "metersphere-frontend/src/utils/tableUtils";
import { TEST_PLAN_SCENARIO_CASE } from "metersphere-frontend/src/utils/constants"; import {TEST_PLAN_SCENARIO_CASE} from "metersphere-frontend/src/utils/constants";
import HeaderLabelOperate from "metersphere-frontend/src/components/head/HeaderLabelOperate"; import HeaderLabelOperate from "metersphere-frontend/src/components/head/HeaderLabelOperate";
import BatchEdit from "@/business/case/components/BatchEdit"; import BatchEdit from "@/business/case/components/BatchEdit";
import MsPlanRunMode from "@/business/plan/common/PlanRunModeWithEnv"; import MsPlanRunMode from "@/business/plan/common/PlanRunModeWithEnv";
import PriorityTableItem from "@/business/common/tableItems/planview/PriorityTableItem"; import PriorityTableItem from "@/business/common/tableItems/planview/PriorityTableItem";
import { API_SCENARIO_FILTERS } from "metersphere-frontend/src/utils/table-constants"; import {API_SCENARIO_FILTERS} from "metersphere-frontend/src/utils/table-constants";
import MsTaskCenter from "metersphere-frontend/src/components/task/TaskCenter"; import MsTaskCenter from "metersphere-frontend/src/components/task/TaskCenter";
import MsTable from "metersphere-frontend/src/components/table/MsTable"; import MsTable from "metersphere-frontend/src/components/table/MsTable";
import MsTableColumn from "metersphere-frontend/src/components/table/MsTableColumn"; import MsTableColumn from "metersphere-frontend/src/components/table/MsTableColumn";
import MsUpdateTimeColumn from "metersphere-frontend/src/components/table/MsUpdateTimeColumn"; import MsUpdateTimeColumn from "metersphere-frontend/src/components/table/MsUpdateTimeColumn";
import MsCreateTimeColumn from "metersphere-frontend/src/components/table/MsCreateTimeColumn"; import MsCreateTimeColumn from "metersphere-frontend/src/components/table/MsCreateTimeColumn";
import { editTestPlanScenarioCaseOrder } from "@/api/remote/plan/test-plan"; import {editTestPlanScenarioCaseOrder} from "@/api/remote/plan/test-plan";
import { import {
testPlanScenarioCaseBatchDelete, testPlanScenarioCaseBatchDelete,
testPlanScenarioCaseBatchUpdateEnv, testPlanScenarioCaseBatchUpdateEnv,
@ -319,11 +313,11 @@ import {
testPlanScenarioCaseSelectAllTableRows, testPlanScenarioCaseSelectAllTableRows,
testPlanScenarioList, testPlanScenarioList,
} from "@/api/remote/plan/test-plan-scenario"; } from "@/api/remote/plan/test-plan-scenario";
import { apiAutomationReduction } from "@/api/remote/api/api-automation"; import {apiAutomationReduction} from "@/api/remote/api/api-automation";
import MicroApp from "metersphere-frontend/src/components/MicroApp"; import MicroApp from "metersphere-frontend/src/components/MicroApp";
import MsTestPlanApiStatus from "@/business/plan/view/comonents/api/TestPlanApiStatus"; import MsTestPlanApiStatus from "@/business/plan/view/comonents/api/TestPlanApiStatus";
import { getVersionFilters } from "@/business/utils/sdk-utils"; import {getVersionFilters} from "@/business/utils/sdk-utils";
import { TEST_PLAN_API_SCENARIO_CONFIGS } from "metersphere-frontend/src/components/search/search-components"; import {TEST_PLAN_API_SCENARIO_CONFIGS} from "metersphere-frontend/src/components/search/search-components";
import MsTestPlanRunModeWithEnv from "@/business/plan/common/TestPlanRunModeWithEnv"; import MsTestPlanRunModeWithEnv from "@/business/plan/common/TestPlanRunModeWithEnv";
export default { export default {
@ -600,7 +594,7 @@ export default {
showReport(row) { showReport(row) {
this.runVisible = true; this.runVisible = true;
this.infoDb = true; this.infoDb = true;
this.reportId = row.reportId; this.reportId = getUUID() + "[TEST-PLAN-REDIRECT]" + row.reportId;
}, },
remove(row) { remove(row) {
if (this.planId) { if (this.planId) {

View File

@ -56,9 +56,10 @@
<div v-if="showResponse"> <div v-if="showResponse">
<micro-app <micro-app
v-show="!isTemplate" v-show="!isTemplate"
v-if="reportId!==null"
service="ui" service="ui"
route-name="ApiReportView" route-name="ApiReportView"
:route-params="routeParams" :route-params="getRouteParams()"
/> />
<UiShareReportDetail <UiShareReportDetail
v-show="isTemplate" v-show="isTemplate"
@ -133,16 +134,7 @@ export default {
Running: "Running", Running: "Running",
UnExecute: "Prepare", UnExecute: "Prepare",
}, },
routeParams: {
reportId: this.reportId,
isShare: this.isShare,
shareId: this.shareId,
isPlanReport: true,
isTemplate: this.isTemplate,
response: this.response,
showCancelButton: false,
showReportNameButton: false,
},
}; };
}, },
mounted() { mounted() {
@ -159,6 +151,18 @@ export default {
}, },
}, },
methods: { methods: {
getRouteParams() {
return {
reportId: this.reportId,
isShare: this.isShare,
shareId: this.shareId,
isPlanReport: true,
isTemplate: this.isTemplate,
response: this.response,
showCancelButton: false,
showReportNameButton: false,
};
},
getScenarioApiCase() { getScenarioApiCase() {
this.scenarioCases = []; this.scenarioCases = [];
if (this.filterStatus && this.filterStatus.length > 0) { if (this.filterStatus && this.filterStatus.length > 0) {

View File

@ -130,19 +130,10 @@ import MsScenarioResults from "./ScenarioResults";
import MsContainer from "metersphere-frontend/src/components/MsContainer"; import MsContainer from "metersphere-frontend/src/components/MsContainer";
import MsMainContainer from "metersphere-frontend/src/components/MsMainContainer"; import MsMainContainer from "metersphere-frontend/src/components/MsMainContainer";
import MsApiReportViewHeader from "./ApiReportViewHeader"; import MsApiReportViewHeader from "./ApiReportViewHeader";
import { STEP } from "./Setting"; import {STEP} from "./Setting";
import MsCodeEdit from "metersphere-frontend/src/components/MsCodeEdit"; import MsCodeEdit from "metersphere-frontend/src/components/MsCodeEdit";
import { import {getCurrentProjectID, getUUID, hasLicense, windowPrint,} from "@/business/utils/sdk-utils";
getCurrentProjectID, import {getScenarioReport, getScenarioReportAll, getShareScenarioReport,} from "@/api/ui-report";
getUUID,
hasLicense,
windowPrint,
} from "@/business/utils/sdk-utils";
import {
getScenarioReport,
getScenarioReportAll,
getShareScenarioReport,
} from "@/api/ui-report";
export default { export default {
name: "UiShareReportDetail", name: "UiShareReportDetail",
@ -623,10 +614,10 @@ export default {
}, },
buildReport() { buildReport() {
if (this.report) { if (this.report) {
if (this.isNotRunning) { if (this.isNotRunning && this.report.content) {
this.content = JSON.parse(this.report.content); this.content = JSON.parse(this.report.content);
if (!this.content) { if (!this.content) {
this.content = { scenarios: [] }; this.content = {scenarios: []};
} }
this.formatResult(this.content); this.formatResult(this.content);
this.getFails(); this.getFails();

View File

@ -275,12 +275,9 @@
import MsTableHeader from "metersphere-frontend/src/components/MsTableHeader"; import MsTableHeader from "metersphere-frontend/src/components/MsTableHeader";
import MsTablePagination from "metersphere-frontend/src/components/pagination/TablePagination"; import MsTablePagination from "metersphere-frontend/src/components/pagination/TablePagination";
import MsTag from "metersphere-frontend/src/components/MsTag"; import MsTag from "metersphere-frontend/src/components/MsTag";
import { import {getCurrentProjectID, getCurrentWorkspaceId,} from "metersphere-frontend/src/utils/token";
getCurrentProjectID, import {hasLicense} from "metersphere-frontend/src/utils/permission";
getCurrentWorkspaceId, import {getUUID, strMapToObj} from "metersphere-frontend/src/utils";
} from "metersphere-frontend/src/utils/token";
import { hasLicense } from "metersphere-frontend/src/utils/permission";
import { getUUID, strMapToObj } from "metersphere-frontend/src/utils";
import TestPlanScenarioListHeader from "../ui/TestPlanUiScenarioListHeader"; import TestPlanScenarioListHeader from "../ui/TestPlanUiScenarioListHeader";
import MsPlanRunMode from "@/business/plan/common/PlanRunModeWithEnv"; import MsPlanRunMode from "@/business/plan/common/PlanRunModeWithEnv";
import { import {
@ -289,7 +286,7 @@ import {
getCustomTableWidth, getCustomTableWidth,
initCondition, initCondition,
} from "metersphere-frontend/src/utils/tableUtils"; } from "metersphere-frontend/src/utils/tableUtils";
import { TEST_PLAN_UI_SCENARIO_CASE } from "metersphere-frontend/src/utils/constants"; import {TEST_PLAN_UI_SCENARIO_CASE} from "metersphere-frontend/src/utils/constants";
import HeaderLabelOperate from "metersphere-frontend/src/components/head/HeaderLabelOperate"; import HeaderLabelOperate from "metersphere-frontend/src/components/head/HeaderLabelOperate";
import BatchEdit from "@/business/case/components/BatchEdit"; import BatchEdit from "@/business/case/components/BatchEdit";
import PriorityTableItem from "@/business/common/tableItems/planview/PriorityTableItem"; import PriorityTableItem from "@/business/common/tableItems/planview/PriorityTableItem";
@ -298,7 +295,7 @@ import MsTable from "metersphere-frontend/src/components/table/MsTable";
import MsTableColumn from "metersphere-frontend/src/components/table/MsTableColumn"; import MsTableColumn from "metersphere-frontend/src/components/table/MsTableColumn";
import MsUpdateTimeColumn from "metersphere-frontend/src/components/table/MsUpdateTimeColumn"; import MsUpdateTimeColumn from "metersphere-frontend/src/components/table/MsUpdateTimeColumn";
import MsCreateTimeColumn from "metersphere-frontend/src/components/table/MsCreateTimeColumn"; import MsCreateTimeColumn from "metersphere-frontend/src/components/table/MsCreateTimeColumn";
import { editTestPlanUiScenarioCaseOrder } from "@/api/remote/plan/test-plan"; import {editTestPlanUiScenarioCaseOrder} from "@/api/remote/plan/test-plan";
import { import {
testPlanUiScenarioCaseBatchDelete, testPlanUiScenarioCaseBatchDelete,
testPlanUiScenarioCaseBatchUpdateEnv, testPlanUiScenarioCaseBatchUpdateEnv,
@ -307,16 +304,13 @@ import {
testPlanUiScenarioCaseSelectAllTableRows, testPlanUiScenarioCaseSelectAllTableRows,
testPlanUiScenarioList, testPlanUiScenarioList,
} from "@/api/remote/ui/test-plan-ui-scenario-case"; } from "@/api/remote/ui/test-plan-ui-scenario-case";
import { getVersionFilters } from "@/business/utils/sdk-utils"; import {getVersionFilters} from "@/business/utils/sdk-utils";
import { import {uiAutomationReduction, uiAutomationVerifySeleniumServer,} from "@/api/remote/ui/api-scenario";
uiAutomationReduction,
uiAutomationVerifySeleniumServer,
} from "@/api/remote/ui/api-scenario";
import i18n from "@/i18n"; import i18n from "@/i18n";
import MicroApp from "metersphere-frontend/src/components/MicroApp"; import MicroApp from "metersphere-frontend/src/components/MicroApp";
import MsTestPlanApiStatus from "@/business/plan/view/comonents/api/TestPlanApiStatus"; import MsTestPlanApiStatus from "@/business/plan/view/comonents/api/TestPlanApiStatus";
import UiRunMode from "@/business/plan/view/comonents/ui/UiRunMode"; import UiRunMode from "@/business/plan/view/comonents/ui/UiRunMode";
import { baseSocket } from "@/api/base-network"; import {baseSocket} from "@/api/base-network";
export default { export default {
name: "MsTestPlanUiScenarioList", name: "MsTestPlanUiScenarioList",
@ -722,7 +716,7 @@ export default {
showReport(row) { showReport(row) {
this.runVisible = true; this.runVisible = true;
this.infoDb = true; this.infoDb = true;
this.reportId = row.reportId; this.reportId = getUUID() + "[TEST-PLAN-REDIRECT]" + row.reportId;
}, },
remove(row) { remove(row) {
if (this.planId) { if (this.planId) {