Skip to content

Commit

Permalink
ADM-963 [frontend]: fix bug of multiple pipeline (#1480)
Browse files Browse the repository at this point in the history
* ADM-963 [frontend]: fix bug of multiple pipeline

* ADM-963 [frontend]: fix coverage

* ADM-963 [frontend]: fix test

* ADM-963 add % for change failure rate

* ADM-963 fix type

---------

Co-authored-by: guzhongren <[email protected]>
  • Loading branch information
zhou-yinyuan and guzhongren authored Jun 6, 2024
1 parent c1129f4 commit bb86081
Show file tree
Hide file tree
Showing 12 changed files with 302 additions and 17 deletions.
25 changes: 25 additions & 0 deletions frontend/__tests__/containers/ReportStep/ReportStep.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
LEAD_TIME_FOR_CHANGES,
MOCK_JIRA_VERIFY_RESPONSE,
MOCK_REPORT_RESPONSE,
MOCK_REPORT_RESPONSE_WITH_AVERAGE_EXCEPTION,
PREVIOUS,
REQUIRED_DATA_LIST,
RETRY,
Expand Down Expand Up @@ -826,5 +827,29 @@ describe('Report Step', () => {
await userEvent.click(exportBoardButton);
expect(exportBoardButton).toBeInTheDocument();
});

it('should export error when click DORA Chart and lead time for change dont have average', async () => {
setup(REQUIRED_DATA_LIST, [fullValueDateRange, emptyValueDateRange]);

reportHook.current.reportInfos[0].reportData = { ...MOCK_REPORT_RESPONSE_WITH_AVERAGE_EXCEPTION };
reportHook.current.reportInfos[1].reportData = { ...MOCK_REPORT_RESPONSE };

const switchChartButton = screen.getByText(DISPLAY_TYPE.CHART);
await userEvent.click(switchChartButton);

const switchDORATab = screen.getByText(CHART_TYPE.DORA);
await userEvent.click(switchDORATab);

const exportDORAButton = screen.getByText(EXPORT_PIPELINE_DATA);
await userEvent.click(exportDORAButton);
expect(exportDORAButton).toBeInTheDocument();

const switchBoardTab = screen.getByText(CHART_TYPE.BOARD);
await userEvent.click(switchBoardTab);

const exportBoardButton = screen.getByText(EXPORT_BOARD_DATA);
await userEvent.click(exportBoardButton);
expect(exportBoardButton).toBeInTheDocument();
});
});
});
134 changes: 134 additions & 0 deletions frontend/__tests__/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,140 @@ const reportMetricsError = {
sourceControlMetricsError: null,
};

export const MOCK_REPORT_RESPONSE_WITH_AVERAGE_EXCEPTION: ReportResponseDTO = {
velocity: {
velocityForSP: 20,
velocityForCards: 14,
},
cycleTime: {
averageCycleTimePerCard: 30.26,
averageCycleTimePerSP: 21.18,
totalTimeForCards: 423.59,
swimlaneList: [
{
optionalItemName: 'Analysis',
averageTimeForSP: 8.36,
averageTimeForCards: 11.95,
totalTime: 167.27,
},
{
optionalItemName: 'In Dev',
averageTimeForSP: 12.13,
averageTimeForCards: 17.32,
totalTime: 242.51,
},
],
},
deploymentFrequency: {
avgDeploymentFrequency: {
name: 'Average',
deploymentFrequency: NaN,
},
deploymentFrequencyOfPipelines: [
{
name: 'fs-platform-onboarding',
step: ' :shipit: deploy to PROD',
deploymentFrequency: 0.3,
dailyDeploymentCounts: [
{
date: '9/9/2022',
count: 1,
},
],
},
],
},
devMeanTimeToRecovery: {
avgDevMeanTimeToRecovery: {
name: 'Average',
timeToRecovery: NaN,
},
devMeanTimeToRecoveryOfPipelines: [
{
name: 'Heartbeat',
step: ':react: Build Frontend',
timeToRecovery: 15560177,
},
{
name: 'Heartbeat',
step: ':cloudformation: Deploy infra',
timeToRecovery: 0,
},
{
name: 'Heartbeat',
step: ':rocket: Run e2e',
timeToRecovery: 27628149.333333332,
},
],
},
rework: {
totalReworkTimes: 111,
reworkState: 'In Dev',
fromAnalysis: null,
fromInDev: null,
fromBlock: 111,
fromReview: 111,
fromWaitingForTesting: 111,
fromTesting: null,
fromDone: 111,
totalReworkCards: 111,
reworkCardsRatio: 0.8888,
throughput: 1110,
},
leadTimeForChanges: {
leadTimeForChangesOfPipelines: [
{
name: 'fs-platform-payment-selector',
step: 'RECORD RELEASE TO PROD',
prLeadTime: 2702.53,
pipelineLeadTime: 2587.42,
totalDelayTime: 5289.95,
},
],
avgLeadTimeForChanges: {
name: 'other',
prLeadTime: 3647.51,
pipelineLeadTime: 2341.72,
totalDelayTime: 5989.22,
},
},
devChangeFailureRate: {
avgDevChangeFailureRate: {
name: 'Average',
totalTimes: 6,
totalFailedTimes: 0,
failureRate: 0.0,
},
devChangeFailureRateOfPipelines: [
{
name: 'fs-platform-onboarding',
step: ' :shipit: deploy to PROD',
failedTimesOfPipeline: 0,
totalTimesOfPipeline: 2,
failureRate: 0.0,
},
],
},
classificationList: [
{
fieldName: 'FS Work Type',
pairList: [
{
name: 'Feature Work - Planned',
value: 0.5714,
},
],
},
],
exportValidityTime: 1800000,
boardMetricsCompleted: true,
doraMetricsCompleted: true,
overallMetricsCompleted: true,
allMetricsCompleted: true,
isSuccessfulCreateCsvFile: true,
reportMetricsError,
};

export const MOCK_REPORT_RESPONSE: ReportResponseDTO = {
velocity: {
velocityForSP: 20,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ describe('dev change failure rate data mapper', () => {
},
],
},
{
id: 1,
name: 'Average',
valueList: [
{
value: '0.00',
},
],
},
];
const mappedDevChangeFailureRate = devChangeFailureRateMapper(mockDevChangeFailureRateRes);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ describe('deployment frequency data mapper', () => {
},
],
},
{
id: 1,
name: 'Average',
valueList: [
{
value: '0.40',
},
],
},
];
const mappedDeploymentFrequency = deploymentFrequencyMapper(mockDeploymentFrequencyRes);

Expand Down
27 changes: 27 additions & 0 deletions frontend/__tests__/hooks/reportMapper/meanTimeToRecovery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ describe('dev mean time to recovery data mapper', () => {
},
],
},
{
id: 1,
name: 'Average',
valueList: [
{
value: '45.03',
},
],
},
];
const mappedDevMeanTimeToRecovery = devMeanTimeToRecoveryMapper(mockDevMeanTimeToRecovery);

Expand Down Expand Up @@ -55,6 +64,15 @@ describe('dev mean time to recovery data mapper', () => {
},
],
},
{
id: 1,
name: 'Average',
valueList: [
{
value: '0.00',
},
],
},
];
const mappedDevMeanTimeToRecovery = devMeanTimeToRecoveryMapper(mockDevMeanTimeToRecovery);

Expand Down Expand Up @@ -85,6 +103,15 @@ describe('dev mean time to recovery data mapper', () => {
},
],
},
{
id: 1,
name: 'Average',
valueList: [
{
value: '0.00',
},
],
},
];
const mappedDevMeanTimeToRecovery = devMeanTimeToRecoveryMapper(mockDevMeanTimeToRecovery);

Expand Down
27 changes: 27 additions & 0 deletions frontend/__tests__/hooks/reportMapper/report.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ export const EXPECTED_REPORT_VALUES = {
},
],
},
{
id: 1,
name: 'Average',
valueList: [
{
value: '0.40',
},
],
},
],
devMeanTimeToRecoveryList: [
{
Expand Down Expand Up @@ -110,6 +119,15 @@ export const EXPECTED_REPORT_VALUES = {
},
],
},
{
id: 3,
name: 'Average',
valueList: [
{
value: '4.00',
},
],
},
],
leadTimeForChangesList: [
{
Expand Down Expand Up @@ -141,6 +159,15 @@ export const EXPECTED_REPORT_VALUES = {
},
],
},
{
id: 1,
name: 'Average',
valueList: [
{
value: '0.00',
},
],
},
],
exportValidityTimeMin: 30,
reworkList: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { percentageFormatter, xAxisLabelDateFormatter } from '@src/utils/util';
import { TooltipComponentOption } from 'echarts';
import { theme } from '@src/theme';

export interface BarOptionProps {
Expand All @@ -21,6 +22,7 @@ export interface Series {
name: string;
type: string;
data: number[];
tooltip?: TooltipComponentOption;
}
export interface yAxis {
name: string;
Expand Down Expand Up @@ -102,6 +104,7 @@ export const oneLineOptionMapper = (props: LineOptionProps) => {
areaStyle: {
opacity: 0.3,
},
tooltip: props.series.tooltip,
},
};
};
Expand Down
Loading

0 comments on commit bb86081

Please sign in to comment.