forked from thoughtworks/HeartBeat
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ADM-1000 [frontend][backend]: support lead time for changes for singl…
…e data source in the metrics page (#1610) * ADM-1000 [frontend]: show source control configuration when pipeline tool select buildkite * ADM-1000 [frontend]: add test for source control configuration when pipeline tool select buildkite * ADM-1000 [backend]: add repo name in the pipeline info api * ADM-1000 [backend]: finish test for repo name in the pipeline info api * ADM-1000 [backend]: format * ADM-1000 [backend]: update repoName data * ADM-1000 [frontend]: add repo name for pipeline configuration in the metrics page * ADM-1000 [frontend]: fix test * ADM-1000 [frontend]: fix test coverage * ADM-1000 [frontend]: disable repo name in the source control settings when pipeline configuration select repo name * ADM-1000 [frontend]: fix test * ADM-1000 [frontend]: adjust the logic for the next button in the metrics page * ADM-1000 [frontend]: fix test * ADM-1000 [backend]: fix sonar issues * ADM-1000 [frontend]: fix sonar issues * ADM-1000 [frontend]: adjust the logic for the next button in the metrics page * ADM-1000 [frontend]: fix e2e test * ADM-1000 [frontend]: refactor: rename the deployment settings in the state * ADM-1000 [frontend]: refactor: rename the deployment frequency settings component * ADM-1000 [frontend]: fix the bug of branch selection in the source control settings * ADM-1000 [frontend]: format and rename * ADM-1000 [frontend]: fix test coverage * ADM-1000 [frontend]: fix save config file * ADM-1000 [frontend]: fix e2e test * ADM-1000 [frontend][backend]: fix comments * ADM-1000 [frontend]: fix sonar issues
- Loading branch information
1 parent
03564e6
commit a8ece41
Showing
49 changed files
with
572 additions
and
373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,8 @@ public class Pipeline { | |
|
||
String repository; | ||
|
||
String repoName; | ||
|
||
List<String> steps; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...requencySettings/BranchSelection.test.tsx → ...ineConfiguration/BranchSelection.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,13 @@ | ||
import { | ||
addADeploymentFrequencySetting, | ||
deleteADeploymentFrequencySetting, | ||
updateDeploymentFrequencySettings, | ||
} from '@src/context/Metrics/metricsSlice'; | ||
import { addAPipelineSetting, deleteAPipelineSetting, updatePipelineSetting } from '@src/context/Metrics/metricsSlice'; | ||
import { DEPLOYMENT_FREQUENCY_SETTINGS, LIST_OPEN, LOADING, ORGANIZATION, REMOVE_BUTTON } from '@test/fixtures'; | ||
import { DeploymentFrequencySettings } from '@src/containers/MetricsStep/DeploymentFrequencySettings'; | ||
import { IUseVerifyPipeLineToolStateInterface } from '@src/hooks/useGetPipelineToolInfoEffect'; | ||
import { PipelineConfiguration } from '@src/containers/MetricsStep/PipelineConfiguration'; | ||
import { TokenAccessAlert } from '@src/containers/MetricsStep/TokenAccessAlert'; | ||
import { act, render, screen, waitFor, within } from '@testing-library/react'; | ||
import { setupStore } from '@test/utils/setupStoreUtil'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { Provider } from 'react-redux'; | ||
|
||
import { setupStore } from '@test/utils/setupStoreUtil'; | ||
|
||
let mockSelectShouldGetPipelineConfig = true; | ||
let mockSelectPipelineNames: string[] = []; | ||
const mockSelectStepsParams = { | ||
|
@@ -37,10 +32,10 @@ jest.mock('@src/hooks', () => ({ | |
|
||
jest.mock('@src/context/Metrics/metricsSlice', () => ({ | ||
...jest.requireActual('@src/context/Metrics/metricsSlice'), | ||
addADeploymentFrequencySetting: jest.fn(), | ||
deleteADeploymentFrequencySetting: jest.fn(), | ||
updateDeploymentFrequencySettings: jest.fn(), | ||
selectDeploymentFrequencySettings: jest.fn().mockReturnValue([ | ||
addAPipelineSetting: jest.fn(), | ||
deleteAPipelineSetting: jest.fn(), | ||
updatePipelineSetting: jest.fn(), | ||
selectPipelineSettings: jest.fn().mockReturnValue([ | ||
{ id: 0, organization: 'mockOrgName', pipelineName: '1', steps: '', branches: [] }, | ||
{ id: 1, organization: '', pipelineName: '', steps: '', branches: [] }, | ||
]), | ||
|
@@ -85,6 +80,7 @@ const mockGetPipelineToolInfoOkResponse = { | |
orgName: 'Thoughtworks-Heartbeat', | ||
repository: '[email protected]:au-heartbeat/Heartbeat.git', | ||
steps: [':pipeline: Upload pipeline.yml'], | ||
repoName: 'au-heartbeat/Heartbeat', | ||
branches: [], | ||
crews: [], | ||
}, | ||
|
@@ -99,13 +95,13 @@ let mockGetPipelineToolInfoSpy: IUseVerifyPipeLineToolStateInterface = mockGetPi | |
jest.mock('@src/hooks/useGetPipelineToolInfoEffect', () => ({ | ||
useGetPipelineToolInfoEffect: () => mockGetPipelineToolInfoSpy, | ||
})); | ||
describe('DeploymentFrequencySettings', () => { | ||
describe('PipelineConfiguration', () => { | ||
let store = null; | ||
const setup = () => { | ||
store = setupStore(); | ||
return render( | ||
<Provider store={store}> | ||
<DeploymentFrequencySettings /> | ||
<PipelineConfiguration /> | ||
</Provider>, | ||
); | ||
}; | ||
|
@@ -148,24 +144,79 @@ describe('DeploymentFrequencySettings', () => { | |
expect(getAllByText(ORGANIZATION).length).toBe(2); | ||
}); | ||
|
||
it('should call addADeploymentFrequencySetting function when click add another pipeline button', async () => { | ||
it('should call addAPipelineSetting function when click add another pipeline button', async () => { | ||
const { getByTestId } = await setup(); | ||
|
||
await userEvent.click(getByTestId('AddIcon')); | ||
|
||
expect(addADeploymentFrequencySetting).toHaveBeenCalledTimes(1); | ||
expect(addAPipelineSetting).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('should call deleteADeploymentFrequencySetting function when click remove pipeline button', async () => { | ||
it('should call deleteAPipelineSetting function when click remove pipeline button', async () => { | ||
const { getAllByRole } = await setup(); | ||
|
||
await act(async () => { | ||
await userEvent.click(getAllByRole('button', { name: REMOVE_BUTTON })[0]); | ||
}); | ||
expect(deleteADeploymentFrequencySetting).toHaveBeenCalledTimes(1); | ||
|
||
expect(deleteAPipelineSetting).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('should call updatePipelineSetting function and clearErrorMessages function when select organization and the value doesnt match pipeline info', async () => { | ||
const { getAllByRole, getByRole } = setup(); | ||
|
||
await act(async () => { | ||
await userEvent.click(getAllByRole('button', { name: LIST_OPEN })[0]); | ||
}); | ||
const listBox = within(getByRole('listbox')); | ||
await userEvent.click(listBox.getByText('mockOrgName2')); | ||
|
||
expect(updatePipelineSetting).toHaveBeenCalledTimes(2); | ||
}); | ||
|
||
it('should call updatePipelineSetting function and clearErrorMessages function when select organization and the value match pipeline info', async () => { | ||
mockGetPipelineToolInfoSpy = { | ||
...mockGetPipelineToolInfoOkResponse, | ||
result: { | ||
...mockGetPipelineToolInfoOkResponse.result, | ||
data: { | ||
pipelineList: [ | ||
{ | ||
id: 'heartbeat', | ||
name: 'Heartbeat', | ||
orgId: 'thoughtworks-Heartbeat', | ||
orgName: 'mockOrgName2', | ||
repository: '[email protected]:au-heartbeat/Heartbeat.git', | ||
steps: [':pipeline: Upload pipeline.yml'], | ||
repoName: 'au-heartbeat/Heartbeat', | ||
branches: [], | ||
crews: [], | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
const { getAllByRole, getByRole } = setup(); | ||
|
||
await act(async () => { | ||
await userEvent.click(getAllByRole('button', { name: LIST_OPEN })[0]); | ||
}); | ||
const listBox = within(getByRole('listbox')); | ||
await act(async () => { | ||
await userEvent.click(listBox.getByText('mockOrgName2')); | ||
}); | ||
|
||
expect(updatePipelineSetting).toHaveBeenCalledTimes(2); | ||
}); | ||
|
||
it('should call updateDeploymentFrequencySetting function and clearErrorMessages function when select organization', async () => { | ||
it('should call updatePipelineSetting function and clearErrorMessages function when select organization and pipeline info is undefined', async () => { | ||
mockGetPipelineToolInfoSpy = { | ||
...mockGetPipelineToolInfoOkResponse, | ||
result: { | ||
...mockGetPipelineToolInfoOkResponse.result, | ||
data: undefined, | ||
}, | ||
}; | ||
const { getAllByRole, getByRole } = setup(); | ||
|
||
await act(async () => { | ||
|
@@ -176,7 +227,7 @@ describe('DeploymentFrequencySettings', () => { | |
await userEvent.click(listBox.getByText('mockOrgName2')); | ||
}); | ||
|
||
expect(updateDeploymentFrequencySettings).toHaveBeenCalledTimes(1); | ||
expect(updatePipelineSetting).toHaveBeenCalledTimes(2); | ||
}); | ||
|
||
it('show render crews component when all pipelines load completed', () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...requencySettings/SingleSelection.test.tsx → ...ineConfiguration/SingleSelection.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.