diff --git a/frontend/__tests__/containers/MetricsStep/DeploymentFrequencySettings/BranchSelection.test.tsx b/frontend/__tests__/containers/MetricsStep/DeploymentFrequencySettings/BranchSelection.test.tsx index e25192ada6..4d8fc95e1e 100644 --- a/frontend/__tests__/containers/MetricsStep/DeploymentFrequencySettings/BranchSelection.test.tsx +++ b/frontend/__tests__/containers/MetricsStep/DeploymentFrequencySettings/BranchSelection.test.tsx @@ -1,6 +1,6 @@ +import { MOCK_SOURCE_CONTROL_VERIFY_BRANCH_URL, MOCK_SOURCE_CONTROL_VERIFY_REQUEST_PARAMS } from '@test/fixtures'; import { BranchSelection } from '@src/containers/MetricsStep/DeploymentFrequencySettings/BranchSelection'; -import { updatePipelineToolVerifyResponse } from '@src/context/config/configSlice'; -import { MOCK_SOURCE_CONTROL_VERIFY_BRANCH_URL } from '@test/fixtures'; +import { updatePipelineToolVerifyResponse, updateSourceControl } from '@src/context/config/configSlice'; import { render, screen, waitFor } from '@testing-library/react'; import { setupStore } from '@test/utils/setupStoreUtil'; import userEvent from '@testing-library/user-event'; @@ -44,6 +44,7 @@ describe('BranchSelection', () => { const setup = () => { store = setupStore(); store.dispatch(updatePipelineToolVerifyResponse(MOCK_PIPElINE_TOOL_VERIFY_RESPONSE)); + store.dispatch(updateSourceControl(MOCK_SOURCE_CONTROL_VERIFY_REQUEST_PARAMS)); return render( diff --git a/frontend/src/containers/MetricsStep/DeploymentFrequencySettings/BranchSelection/index.tsx b/frontend/src/containers/MetricsStep/DeploymentFrequencySettings/BranchSelection/index.tsx index df0791b2ed..b8f6492eb4 100644 --- a/frontend/src/containers/MetricsStep/DeploymentFrequencySettings/BranchSelection/index.tsx +++ b/frontend/src/containers/MetricsStep/DeploymentFrequencySettings/BranchSelection/index.tsx @@ -7,8 +7,8 @@ import { } from '@src/context/meta/metaSlice'; import { BranchSelectionWrapper } from '@src/containers/MetricsStep/DeploymentFrequencySettings/PipelineMetricSelection/style'; import BranchChip from '@src/containers/MetricsStep/DeploymentFrequencySettings/BranchSelection/BranchChip'; +import { selectPipelineList, selectSourceControl } from '@src/context/config/configSlice'; import { SOURCE_CONTROL_BRANCH_INVALID_TEXT } from '@src/constants/resources'; -import { selectPipelineList } from '@src/context/config/configSlice'; import { Autocomplete, Checkbox, TextField } from '@mui/material'; import React, { useCallback, useEffect, useMemo } from 'react'; import { useAppDispatch } from '@src/hooks/useAppDispatch'; @@ -27,6 +27,7 @@ export const BranchSelection = (props: BranchSelectionProps) => { const { id, organization, pipelineName, branches, onUpdatePipeline } = props; const formMeta = useAppSelector(getFormMeta); const pipelineList = useAppSelector(selectPipelineList); + const sourceControlFields = useAppSelector(selectSourceControl); const currentPipeline = useMemo( () => pipelineList.find((pipeline) => pipeline.name === pipelineName && pipeline.orgName === organization), @@ -51,7 +52,7 @@ export const BranchSelection = (props: BranchSelectionProps) => { ? metaInfo : { value: item, - needVerify: true, + needVerify: sourceControlFields.token !== '', }; }); }, [branches, branchesFormData]); @@ -72,7 +73,7 @@ export const BranchSelection = (props: BranchSelectionProps) => { const branchesWithMeta = values.map((branch) => { const formData = branchesFormData.find((item) => item.value === branch); - return formData ? formData : { value: branch, needVerify: true }; + return formData ? formData : { value: branch, needVerify: sourceControlFields.token !== '' }; }); dispatch(