fix(测试跟踪): 修复执行不含有环境的接口和场景用例时无法选择新环境的问题

This commit is contained in:
song-tianyang 2023-08-14 12:57:59 +08:00 committed by fit2-zhao
parent 2f94824031
commit 2ccd543d06
6 changed files with 62 additions and 39 deletions

View File

@ -265,6 +265,12 @@ public class TestPlanController {
return testPlanService.getRelevanceProjectIds(plan.getId());
}
@GetMapping("/case/relevance/project/id/{testPlanId}/{caseType}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ)
public List<String> getRelevanceProjectIds(@PathVariable String testPlanId, @PathVariable String caseType) {
return testPlanService.getRelevanceProjectIdsByCaseType(testPlanId, caseType);
}
@PostMapping("/edit/run/config")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RUN)

View File

@ -2318,6 +2318,18 @@ public class TestPlanService {
return projectIds.stream().distinct().collect(Collectors.toList());
}
public List<String> getRelevanceProjectIdsByCaseType(String planId, String caseType) {
if (StringUtils.equalsIgnoreCase(caseType, "apiCase")) {
return planTestPlanApiCaseService.getApiCaseProjectIds(planId);
} else if (StringUtils.equalsIgnoreCase(caseType, "apiScenario")) {
return planTestPlanScenarioCaseService.getApiScenarioProjectIds(planId);
} else if (StringUtils.equalsIgnoreCase(caseType, "uiScenario") && DiscoveryUtil.hasService(MicroServiceName.UI_TEST)) {
return planTestPlanUiScenarioCaseService.getUiScenarioProjectIds(planId);
} else {
return new ArrayList<>();
}
}
public TestPlanReportDataStruct buildOldVersionTestPlanReport(TestPlanReport
testPlanReport, TestPlanReportContentWithBLOBs testPlanReportContent) {
TestPlanWithBLOBs testPlanWithBLOBs = this.testPlanMapper.selectByPrimaryKey(testPlanReport.getTestPlanId());

View File

@ -1,6 +1,6 @@
import { get, post, socket } from "metersphere-frontend/src/plugins/request";
import { getCurrentProjectID } from "metersphere-frontend/src/utils/token";
import { buildListPagePath } from "@/api/base-network";
import {get, post, socket} from "metersphere-frontend/src/plugins/request";
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
import {buildListPagePath} from "@/api/base-network";
const BASE_URL = "/test/plan/";
@ -383,6 +383,11 @@ export function getPlanCaseProjectIds(param) {
return post(BASE_URL + "case/relevance/project/ids", param);
}
export function getProjectIdsByPlanIdAndCaseType(planId, caseType) {
return get(BASE_URL + `case/relevance/project/id/${planId}/${caseType}`);
}
export function run(testId, reportId) {
return get(`${BASE_URL}api/case/run/${testId}/${reportId}`);
}

View File

@ -66,7 +66,7 @@
class="mode-row"
v-if="
testType === 'API' &&
(haveOtherExecCase && !haveUICase)
(haveOtherExecCase)
"
>
<span>{{ $t("run_mode.run_with_resource_pool") }}: </span>
@ -171,7 +171,12 @@ import {getCurrentProjectID, getOwnerProjects,} from "@/business/utils/sdk-utils
import {getQuotaValidResourcePools} from "@/api/remote/resource-pool";
import EnvGroupPopover from "@/business/plan/env/EnvGroupPopover";
import {getApiCaseEnv} from "@/api/remote/plan/test-plan-api-case";
import {getApiScenarioEnv, getPlanCaseEnv, getPlanCaseProjectIds,} from "@/api/remote/plan/test-plan";
import {
getApiScenarioEnv,
getPlanCaseEnv,
getPlanCaseProjectIds,
getProjectIdsByPlanIdAndCaseType,
} from "@/api/remote/plan/test-plan";
import EnvGroupWithOption from "../env/EnvGroupWithOption";
import EnvironmentGroup from "@/business/plan/env/EnvironmentGroupList";
import EnvSelectPopover from "@/business/plan/env/EnvSelectPopover";
@ -379,11 +384,16 @@ export default {
let data = res.data;
if (data) {
this.projectEnvListMap = data;
for (let d in data) {
this.projectIds.add(d);
}
}
getProjectIdsByPlanIdAndCaseType(this.planId, 'apiCase').then((res) => {
let data = res.data;
if (data) {
for (let i = 0; i < data.length; i++) {
this.projectIds.add(data[i]);
}
}
this.$refs.envSelectPopover.open();
});
});
} else if (this.type === "apiScenario") {
param = this.planCaseIds;
@ -391,11 +401,16 @@ export default {
let data = res.data;
if (data) {
this.projectEnvListMap = data;
for (let d in data) {
this.projectIds.add(d);
}
}
this.$refs.envSelectPopover.open();
getProjectIdsByPlanIdAndCaseType(this.planId, 'apiScenario').then((res) => {
let data = res.data;
if (data) {
for (let i = 0; i < data.length; i++) {
this.projectIds.add(data[i]);
}
}
this.$refs.envSelectPopover.open();
});
});
} else if (this.type === "plan") {
param = {id: this.planId};

View File

@ -222,6 +222,7 @@
@handleRunBatch="handleRunBatch"
ref="runMode"
:plan-case-ids="testPlanCaseIds"
:plan-id="planId"
:type="'apiCase'"
@close="search"
/>
@ -236,24 +237,14 @@ import MsTag from "metersphere-frontend/src/components/MsTag";
import MsContainer from "metersphere-frontend/src/components/MsContainer";
import MsBottomContainer from "metersphere-frontend/src/components/MsBottomContainer";
import BatchEdit from "@/business/case/components/BatchEdit";
import {
API_METHOD_COLOUR,
CASE_PRIORITY,
RESULT_MAP,
} from "metersphere-frontend/src/model/JsonData";
import {
getCurrentProjectID,
getCurrentWorkspaceId,
} from "metersphere-frontend/src/utils/token";
import {
hasLicense,
hasPermission,
} from "metersphere-frontend/src/utils/permission";
import { getUUID, strMapToObj } from "metersphere-frontend/src/utils";
import {API_METHOD_COLOUR, CASE_PRIORITY, RESULT_MAP,} from "metersphere-frontend/src/model/JsonData";
import {getCurrentProjectID, getCurrentWorkspaceId,} from "metersphere-frontend/src/utils/token";
import {hasLicense, hasPermission,} from "metersphere-frontend/src/utils/permission";
import {getUUID, strMapToObj} from "metersphere-frontend/src/utils";
import PriorityTableItem from "../../../../common/tableItems/planview/PriorityTableItem";
import TestPlanCaseListHeader from "./TestPlanCaseListHeader";
import TestPlanApiCaseResult from "./TestPlanApiCaseResult";
import { TEST_PLAN_API_CASE } from "metersphere-frontend/src/utils/constants";
import {TEST_PLAN_API_CASE} from "metersphere-frontend/src/utils/constants";
import {
buildBatchParam,
deepClone,
@ -267,16 +258,9 @@ import MsTable from "metersphere-frontend/src/components/table/MsTable";
import MsTableColumn from "metersphere-frontend/src/components/table/MsTableColumn";
import MsUpdateTimeColumn from "metersphere-frontend/src/components/table/MsUpdateTimeColumn";
import MsCreateTimeColumn from "metersphere-frontend/src/components/table/MsCreateTimeColumn";
import {
editTestPlanApiCaseOrder,
run,
testPlanAutoCheck,
} from "@/api/remote/plan/test-plan";
import { getProjectMemberUserFilter } from "@/api/user";
import {
apiTestCaseGet,
apiTestCaseReduction,
} from "@/api/remote/api/api-case";
import {editTestPlanApiCaseOrder, run, testPlanAutoCheck,} from "@/api/remote/plan/test-plan";
import {getProjectMemberUserFilter} from "@/api/user";
import {apiTestCaseReduction,} from "@/api/remote/api/api-case";
import {
testPlanApiCaseBatchDelete,
testPlanApiCaseBatchUpdateEnv,
@ -286,8 +270,8 @@ import {
testPlanApiCaseSelectAllTableRows,
} from "@/api/remote/plan/test-plan-api-case";
import MsTestPlanApiStatus from "@/business/plan/view/comonents/api/TestPlanApiStatus";
import { getProjectVersions } from "@/business/utils/sdk-utils";
import { TEST_PLAN_API_CASE_CONFIGS } from "metersphere-frontend/src/components/search/search-components";
import {getProjectVersions} from "@/business/utils/sdk-utils";
import {TEST_PLAN_API_CASE_CONFIGS} from "metersphere-frontend/src/components/search/search-components";
import MsTestPlanRunModeWithEnv from "@/business/plan/common/TestPlanRunModeWithEnv";
export default {

View File

@ -269,6 +269,7 @@
<ms-test-plan-run-mode-with-env
@handleRunBatch="handleRunBatch"
ref="runMode"
:plan-id="planId"
:plan-case-ids="planCaseIds"
:type="'apiScenario'"
@close="search"