From 3b2aa1fb4a8bad6412bed82cdf736eba580de510 Mon Sep 17 00:00:00 2001 From: Leiqiuhong Date: Fri, 22 Mar 2024 11:09:17 +0800 Subject: [PATCH 01/11] ADM-694-latest: [frontend] fix: fix dc issues --- frontend/src/constants/resources.ts | 32 ++++++------- .../ReportStep/BoardMetrics/index.tsx | 2 +- .../ReportStep/ReportDetail/style.tsx | 5 +++ .../reportMapper/reportUIDataStructure.ts | 4 +- .../src/hooks/reportMapper/reworkMapper.ts | 31 ------------- .../src/hooks/reportMapper/reworkMapper.tsx | 45 +++++++++++++++++++ 6 files changed, 70 insertions(+), 49 deletions(-) delete mode 100644 frontend/src/hooks/reportMapper/reworkMapper.ts create mode 100644 frontend/src/hooks/reportMapper/reworkMapper.tsx diff --git a/frontend/src/constants/resources.ts b/frontend/src/constants/resources.ts index 9a6d8d6090..ef0ffc4ee1 100644 --- a/frontend/src/constants/resources.ts +++ b/frontend/src/constants/resources.ts @@ -212,27 +212,27 @@ export enum CYCLE_TIME_METRICS_NAME { AVERAGE_TESTING_TIME = 'Average testing time', } -export const REWORK_TIME_METRICS_NAME = { +export const REWORK_TIME_MAPPING = { totalReworkTimes: 'Total rework', - fromAnalysis: 'From analysis to', - fromInDev: 'From in dev to', - fromBlock: 'From block to', - fromWaitingForTesting: 'From waiting for testing to', - fromTesting: 'From testing to', - fromReview: 'From review to', - fromDone: 'From done to', + fromAnalysis: 'analysis', + fromInDev: 'in dev', + fromBlock: 'block', + fromReview: 'review', + fromWaitingForTesting: 'waiting for testing', + fromTesting: 'testing', + fromDone: 'done', totalReworkCards: 'Total rework cards', reworkCardsRatio: 'Rework cards ratio', }; -export const BOARD_COLUMN_STATE: string[] = [ - REWORK_TIME_METRICS_NAME.fromAnalysis, - REWORK_TIME_METRICS_NAME.fromInDev, - REWORK_TIME_METRICS_NAME.fromBlock, - REWORK_TIME_METRICS_NAME.fromWaitingForTesting, - REWORK_TIME_METRICS_NAME.fromTesting, - REWORK_TIME_METRICS_NAME.fromReview, - REWORK_TIME_METRICS_NAME.fromDone, +export const REWORK_BOARD_STATUS: string[] = [ + REWORK_TIME_MAPPING.fromAnalysis, + REWORK_TIME_MAPPING.fromInDev, + REWORK_TIME_MAPPING.fromBlock, + REWORK_TIME_MAPPING.fromWaitingForTesting, + REWORK_TIME_MAPPING.fromTesting, + REWORK_TIME_MAPPING.fromReview, + REWORK_TIME_MAPPING.fromDone, ]; export const DEPLOYMENT_FREQUENCY_NAME = 'Deployment frequency'; diff --git a/frontend/src/containers/ReportStep/BoardMetrics/index.tsx b/frontend/src/containers/ReportStep/BoardMetrics/index.tsx index dd4b8e534d..53de8516b6 100644 --- a/frontend/src/containers/ReportStep/BoardMetrics/index.tsx +++ b/frontend/src/containers/ReportStep/BoardMetrics/index.tsx @@ -177,7 +177,7 @@ const BoardMetrics = ({ isToFixed: false, }, { - value: rework.reworkCardsRatio, + value: Number(rework.reworkCardsRatio) * 100, extraValue: `% (${rework.totalReworkCards}/${rework.throughput})`, subtitle: METRICS_SUBTITLE.REWORK_CARDS_RATIO, }, diff --git a/frontend/src/containers/ReportStep/ReportDetail/style.tsx b/frontend/src/containers/ReportStep/ReportDetail/style.tsx index e69de29bb2..1cd1273133 100644 --- a/frontend/src/containers/ReportStep/ReportDetail/style.tsx +++ b/frontend/src/containers/ReportStep/ReportDetail/style.tsx @@ -0,0 +1,5 @@ +import { styled } from '@mui/material/styles'; + +export const StyledSpan = styled('span')({ + fontWeight: 'bold', +}); diff --git a/frontend/src/hooks/reportMapper/reportUIDataStructure.ts b/frontend/src/hooks/reportMapper/reportUIDataStructure.ts index d9add8c71d..db5e35112c 100644 --- a/frontend/src/hooks/reportMapper/reportUIDataStructure.ts +++ b/frontend/src/hooks/reportMapper/reportUIDataStructure.ts @@ -1,6 +1,8 @@ +import { ReactNode } from 'react'; + export interface ReportDataWithTwoColumns { id: number; - name: string; + name: string | ReactNode; valueList: ValueWithUnits[]; } diff --git a/frontend/src/hooks/reportMapper/reworkMapper.ts b/frontend/src/hooks/reportMapper/reworkMapper.ts deleted file mode 100644 index e612dae6ef..0000000000 --- a/frontend/src/hooks/reportMapper/reworkMapper.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { ReportDataWithTwoColumns } from '@src/hooks/reportMapper/reportUIDataStructure'; -import { BOARD_COLUMN_STATE, REWORK_TIME_METRICS_NAME } from '@src/constants/resources'; -import { ReworkTimeResponse } from '@src/clients/report/dto/response'; - -const getUnit = (value: string) => { - const UNIT_TIME = [...BOARD_COLUMN_STATE, REWORK_TIME_METRICS_NAME.totalReworkTimes]; - if (UNIT_TIME.includes(value)) return ' (times)'; - if (value === REWORK_TIME_METRICS_NAME.reworkCardsRatio) return ' (rework cards/throughput)'; - if (value === REWORK_TIME_METRICS_NAME.totalReworkCards) return ' (cards)'; -}; - -const reworkMapper = (reworkTimeResponse: ReworkTimeResponse) => { - const result: ReportDataWithTwoColumns[] = []; - const reworkState = reworkTimeResponse.reworkState.toLowerCase(); - - Object.entries(REWORK_TIME_METRICS_NAME).map(([key, value], index) => { - reworkTimeResponse[key as keyof ReworkTimeResponse] !== null && - result.push({ - id: index, - name: `${BOARD_COLUMN_STATE.includes(value) ? `${value} ${reworkState}` : `${value}`} `, - valueList: [ - { - value: reworkTimeResponse[key as keyof ReworkTimeResponse]!, - unit: getUnit(value), - }, - ], - }); - }); - return result; -}; -export default reworkMapper; diff --git a/frontend/src/hooks/reportMapper/reworkMapper.tsx b/frontend/src/hooks/reportMapper/reworkMapper.tsx new file mode 100644 index 0000000000..96025ae08b --- /dev/null +++ b/frontend/src/hooks/reportMapper/reworkMapper.tsx @@ -0,0 +1,45 @@ +import { ReportDataWithTwoColumns } from '@src/hooks/reportMapper/reportUIDataStructure'; +import { REWORK_BOARD_STATUS, REWORK_TIME_MAPPING } from '@src/constants/resources'; +import { StyledSpan } from '@src/containers/ReportStep/ReportDetail/style'; +import { ReworkTimeResponse } from '@src/clients/report/dto/response'; +import { ReactNode } from 'react'; + +const getUnit = (value: string) => { + const UNIT_TIME = [...REWORK_BOARD_STATUS, REWORK_TIME_MAPPING.totalReworkTimes]; + if (UNIT_TIME.includes(value)) return ' (times)'; + if (value === REWORK_TIME_MAPPING.reworkCardsRatio) return '% (rework cards/throughput)'; + if (value === REWORK_TIME_MAPPING.totalReworkCards) return ' (cards)'; +}; +const getRowName = (value: string, reworkState: string): ReactNode => { + if (REWORK_BOARD_STATUS.includes(value)) { + return ( + <> + From {value} to {reworkState.toLowerCase()} + + ); + } else { + return <>{value}; + } +}; + +const reworkMapper = (reworkTimeResponse: ReworkTimeResponse) => { + const result: ReportDataWithTwoColumns[] = []; + Object.entries(REWORK_TIME_MAPPING).map(([key, value], index) => { + reworkTimeResponse[key as keyof ReworkTimeResponse] !== null && + result.push({ + id: index, + name: getRowName(value, reworkTimeResponse.reworkState), + valueList: [ + { + value: + key === 'reworkCardsRatio' + ? Number(reworkTimeResponse[key as keyof ReworkTimeResponse]) * 100 + : reworkTimeResponse[key as keyof ReworkTimeResponse]!, + unit: getUnit(value), + }, + ], + }); + }); + return result; +}; +export default reworkMapper; From 8567c1cd1157df3a2c90f6869e29b2f6b4a3e4d7 Mon Sep 17 00:00:00 2001 From: yulongcai Date: Fri, 22 Mar 2024 11:22:33 +0800 Subject: [PATCH 02/11] ADM-694:[backend] fix: keep four decimal --- .../src/main/java/heartbeat/service/board/jira/JiraService.java | 2 +- .../main/java/heartbeat/service/report/CSVFileGenerator.java | 2 +- .../java/heartbeat/service/report/CSVFileGeneratorTest.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/heartbeat/service/board/jira/JiraService.java b/backend/src/main/java/heartbeat/service/board/jira/JiraService.java index 72ecb67069..cbe44333c4 100644 --- a/backend/src/main/java/heartbeat/service/board/jira/JiraService.java +++ b/backend/src/main/java/heartbeat/service/board/jira/JiraService.java @@ -271,7 +271,7 @@ public CardCollection getStoryPointsAndCycleTimeAndReworkInfoForDoneCards(StoryP .size(); double reworkRatio = realDoneCards.isEmpty() ? 0 : BigDecimal.valueOf(reworkCardNumber) - .divide(BigDecimal.valueOf(realDoneCards.size()), 2, RoundingMode.HALF_UP) + .divide(BigDecimal.valueOf(realDoneCards.size()), 4, RoundingMode.HALF_UP) .doubleValue(); return CardCollection.builder() diff --git a/backend/src/main/java/heartbeat/service/report/CSVFileGenerator.java b/backend/src/main/java/heartbeat/service/report/CSVFileGenerator.java index 3f62856626..287854f74c 100644 --- a/backend/src/main/java/heartbeat/service/report/CSVFileGenerator.java +++ b/backend/src/main/java/heartbeat/service/report/CSVFileGenerator.java @@ -483,7 +483,7 @@ private List getRowFromRework(Rework rework) { rows.add(new String[] { REWORK_FIELD, "Total rework times", String.valueOf(rework.getTotalReworkTimes()) }); rows.add(new String[] { REWORK_FIELD, "Total rework cards", String.valueOf(rework.getTotalReworkCards()) }); rows.add(new String[] { REWORK_FIELD, "Rework cards ratio(Total rework cards/Throughput)", - String.valueOf(rework.getReworkCardsRatio()) }); + String.valueOf(rework.getReworkCardsRatio() * 100) }); return rows; } diff --git a/backend/src/test/java/heartbeat/service/report/CSVFileGeneratorTest.java b/backend/src/test/java/heartbeat/service/report/CSVFileGeneratorTest.java index 861cf23e31..80290bee7b 100644 --- a/backend/src/test/java/heartbeat/service/report/CSVFileGeneratorTest.java +++ b/backend/src/test/java/heartbeat/service/report/CSVFileGeneratorTest.java @@ -529,7 +529,7 @@ void shouldHasNoContentForAveragesWhenGetDataFromCsvGivenDataTypeIsMetricAndTheQ "Group","Metrics","Value" "Rework","Total rework times","3" "Rework","Total rework cards","3" - "Rework","Rework cards ratio(Total rework cards/Throughput)","0.99" + "Rework","Rework cards ratio(Total rework cards/Throughput)","99.0" "Deployment frequency","Heartbeat / Deploy prod / Deployment frequency(Deployments/Day)","0.78" "Lead time for changes","Heartbeat / Deploy prod / PR Lead Time","0" "Lead time for changes","Heartbeat / Deploy prod / Pipeline Lead Time","0.02" From 025e6723336ecbabc7b658482f43cd70b7864a14 Mon Sep 17 00:00:00 2001 From: yulongcai Date: Fri, 22 Mar 2024 11:35:48 +0800 Subject: [PATCH 03/11] ADM-694:[frontend] fix: fix e2e for export metric csv --- frontend/e2e/fixtures/createNew/metricData.csv | 2 +- frontend/e2e/fixtures/importFile/metricData.csv | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/e2e/fixtures/createNew/metricData.csv b/frontend/e2e/fixtures/createNew/metricData.csv index ad13c4eeef..2ca421831c 100644 --- a/frontend/e2e/fixtures/createNew/metricData.csv +++ b/frontend/e2e/fixtures/createNew/metricData.csv @@ -20,7 +20,7 @@ "Cycle time","Average testing time(days/card)","0.84" "Rework","Total rework times","11" "Rework","Total rework cards","6" -"Rework","Rework cards ratio(Total rework cards/Throughput)","0.67" +"Rework","Rework cards ratio(Total rework cards/Throughput)","67.00" "Classifications","Issue Type / Spike","11.11" "Classifications","Issue Type / Task","88.89" "Classifications","Parent / ADM-322","66.67" diff --git a/frontend/e2e/fixtures/importFile/metricData.csv b/frontend/e2e/fixtures/importFile/metricData.csv index ad13c4eeef..2ca421831c 100644 --- a/frontend/e2e/fixtures/importFile/metricData.csv +++ b/frontend/e2e/fixtures/importFile/metricData.csv @@ -20,7 +20,7 @@ "Cycle time","Average testing time(days/card)","0.84" "Rework","Total rework times","11" "Rework","Total rework cards","6" -"Rework","Rework cards ratio(Total rework cards/Throughput)","0.67" +"Rework","Rework cards ratio(Total rework cards/Throughput)","67.00" "Classifications","Issue Type / Spike","11.11" "Classifications","Issue Type / Task","88.89" "Classifications","Parent / ADM-322","66.67" From 5366ef4e1060efa0c35e894611eb74727cb524a0 Mon Sep 17 00:00:00 2001 From: Leiqiuhong Date: Fri, 22 Mar 2024 15:44:12 +0800 Subject: [PATCH 04/11] ADM-694-latest: [frontend] test: fix test --- frontend/__tests__/fixtures.ts | 114 +++--------------- .../hooks/reportMapper/report.test.tsx | 105 +++++++++++++++- .../e2e/fixtures/createNew/metricData.csv | 2 +- .../e2e/fixtures/createNew/reportResult.ts | 4 +- .../e2e/fixtures/importFile/metricData.csv | 2 +- frontend/e2e/pages/metrics/ReportStep.ts | 12 +- .../ReportStep/BoardMetrics/index.tsx | 16 ++- .../ReportStep/BoardMetrics/style.tsx | 7 ++ .../src/hooks/reportMapper/reworkMapper.tsx | 4 +- 9 files changed, 152 insertions(+), 114 deletions(-) create mode 100644 frontend/src/containers/ReportStep/BoardMetrics/style.tsx diff --git a/frontend/__tests__/fixtures.ts b/frontend/__tests__/fixtures.ts index 6a3b0588b2..daa0e8343d 100644 --- a/frontend/__tests__/fixtures.ts +++ b/frontend/__tests__/fixtures.ts @@ -1,5 +1,5 @@ +import { ReportResponseDTO, ReworkTimeResponse } from '@src/clients/report/dto/response'; import { CSVReportRequestDTO, ReportRequestDTO } from '@src/clients/report/dto/request'; -import { ReportResponseDTO } from '@src/clients/report/dto/response'; import { SOURCE_CONTROL_TYPES } from '@src/constants/resources'; export const PROJECT_NAME = 'Heartbeat'; @@ -412,20 +412,6 @@ export const MOCK_REPORT_RESPONSE: ReportResponseDTO = { }, ], }, - rework: { - totalReworkTimes: 111, - reworkState: 'In Dev', - fromAnalysis: null, - fromInDev: 111, - fromBlock: 111, - fromWaitingForTesting: 111, - fromTesting: null, - fromReview: 111, - fromDone: 111, - totalReworkCards: 111, - reworkCardsRatio: 111, - throughput: 1110, - }, deploymentFrequency: { avgDeploymentFrequency: { name: 'Average', @@ -468,6 +454,7 @@ export const MOCK_REPORT_RESPONSE: ReportResponseDTO = { }, ], }, + rework: null, leadTimeForChanges: { leadTimeForChangesOfPipelines: [ { @@ -520,6 +507,20 @@ export const MOCK_REPORT_RESPONSE: ReportResponseDTO = { reportMetricsError, }; +export const REWORK_REPORT_RESPONSE: ReworkTimeResponse = { + 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, +}; export const MOCK_RETRIEVE_REPORT_RESPONSE = { callbackUrl: 'reports/123', interval: 10, @@ -667,88 +668,7 @@ export const EXPECTED_REPORT_VALUES = { }, ], exportValidityTimeMin: 30, - reworkList: [ - { - id: 0, - name: 'Total rework ', - valueList: [ - { - value: 111, - unit: ' (times)', - }, - ], - }, - { - id: 2, - name: 'From in dev to in dev ', - valueList: [ - { - value: 111, - unit: ' (times)', - }, - ], - }, - { - id: 3, - name: 'From block to in dev ', - valueList: [ - { - value: 111, - unit: ' (times)', - }, - ], - }, - { - id: 4, - name: 'From waiting for testing to in dev ', - valueList: [ - { - value: 111, - unit: ' (times)', - }, - ], - }, - { - id: 6, - name: 'From review to in dev ', - valueList: [ - { - value: 111, - unit: ' (times)', - }, - ], - }, - { - id: 7, - name: 'From done to in dev ', - valueList: [ - { - value: 111, - unit: ' (times)', - }, - ], - }, - { - id: 8, - name: 'Total rework cards ', - valueList: [ - { - value: 111, - unit: ' (cards)', - }, - ], - }, - { - id: 9, - name: 'Rework cards ratio ', - valueList: [ - { - value: 111, - unit: ' (rework cards/throughput)', - }, - ], - }, - ], + reworkList: null, }; export const EMPTY_REPORT_VALUES: ReportResponseDTO = { diff --git a/frontend/__tests__/hooks/reportMapper/report.test.tsx b/frontend/__tests__/hooks/reportMapper/report.test.tsx index 4a1155d375..14d1edc11f 100644 --- a/frontend/__tests__/hooks/reportMapper/report.test.tsx +++ b/frontend/__tests__/hooks/reportMapper/report.test.tsx @@ -1,5 +1,93 @@ -import { EXPECTED_REPORT_VALUES, MOCK_REPORT_RESPONSE } from '../../fixtures'; +import { EXPECTED_REPORT_VALUES, MOCK_REPORT_RESPONSE, REWORK_REPORT_RESPONSE } from '../../fixtures'; +import ReportForTwoColumns from '@src/components/Common/ReportForTwoColumns'; +import { StyledSpan } from '@src/containers/ReportStep/ReportDetail/style'; +import reworkMapper from '@src/hooks/reportMapper/reworkMapper'; import { reportMapper } from '@src/hooks/reportMapper/report'; +import { render } from '@testing-library/react'; +import React from 'react'; + +[ + { + id: 0, + name: 'Total rework ', + valueList: [ + { + value: 111, + unit: ' (times)', + }, + ], + }, + { + id: 2, + name: 'From in dev to in dev ', + valueList: [ + { + value: 111, + unit: ' (times)', + }, + ], + }, + { + id: 3, + name: 'From block to in dev ', + valueList: [ + { + value: 111, + unit: ' (times)', + }, + ], + }, + { + id: 4, + name: 'From waiting for testing to in dev ', + valueList: [ + { + value: 111, + unit: ' (times)', + }, + ], + }, + { + id: 6, + name: 'From review to in dev ', + valueList: [ + { + value: 111, + unit: ' (times)', + }, + ], + }, + { + id: 7, + name: 'From done to in dev ', + valueList: [ + { + value: 111, + unit: ' (times)', + }, + ], + }, + { + id: 8, + name: 'Total rework cards ', + valueList: [ + { + value: 111, + unit: ' (cards)', + }, + ], + }, + { + id: 9, + name: 'Rework cards ratio ', + valueList: [ + { + value: '88.88', + unit: '% (rework cards/throughput)', + }, + ], + }, +]; describe('report response data mapper', () => { it('maps response velocity values to ui display value', () => { @@ -7,4 +95,19 @@ describe('report response data mapper', () => { expect(mappedReportResponseValues).toEqual(EXPECTED_REPORT_VALUES); }); + + it('aaa', () => { + const reworkMappedReportResponseValue = reworkMapper(REWORK_REPORT_RESPONSE); + const { getByText, container, debug } = render( + , + ); + debug(); + // container.expect(getByText('Total rework')).not.toBeEmptyDOMElement(); + // expect(getByText("From 'block' to 'in dev'")).not.toBeEmptyDOMElement(); + // expect(getByText("From 'waiting for testing' to 'in dev'")).not.toBeEmptyDOMElement(); + // expect(getByText("From 'review' to 'in dev'")).not.toBeEmptyDOMElement(); + // expect(getByText("From 'done' to 'in dev'")).not.toBeEmptyDOMElement(); + // expect(getByText('Total rework cards')).not.toBeEmptyDOMElement(); + // expect(getByText('Rework cards ratio')).not.toBeEmptyDOMElement(); + }); }); diff --git a/frontend/e2e/fixtures/createNew/metricData.csv b/frontend/e2e/fixtures/createNew/metricData.csv index 2ca421831c..6af9c9a79d 100644 --- a/frontend/e2e/fixtures/createNew/metricData.csv +++ b/frontend/e2e/fixtures/createNew/metricData.csv @@ -20,7 +20,7 @@ "Cycle time","Average testing time(days/card)","0.84" "Rework","Total rework times","11" "Rework","Total rework cards","6" -"Rework","Rework cards ratio(Total rework cards/Throughput)","67.00" +"Rework","Rework cards ratio(Total rework cards/Throughput)","66.67" "Classifications","Issue Type / Spike","11.11" "Classifications","Issue Type / Task","88.89" "Classifications","Parent / ADM-322","66.67" diff --git a/frontend/e2e/fixtures/createNew/reportResult.ts b/frontend/e2e/fixtures/createNew/reportResult.ts index 681de1fdff..a866d63dee 100644 --- a/frontend/e2e/fixtures/createNew/reportResult.ts +++ b/frontend/e2e/fixtures/createNew/reportResult.ts @@ -5,7 +5,7 @@ export const BOARD_METRICS_RESULT = { AverageCycleTime4Card: '9.18', totalReworkTimes: '11', totalReworkCards: '6', - reworkCardsRatio: '0.67', + reworkCardsRatio: '0.6667', throughput: '9', }; @@ -16,7 +16,7 @@ export const FLAG_AS_BLOCK_PROJECT_BOARD_METRICS_RESULT = { AverageCycleTime4Card: '0.28', totalReworkTimes: '3', totalReworkCards: '3', - reworkCardsRatio: '0.60', + reworkCardsRatio: '0.6000', throughput: '5', }; diff --git a/frontend/e2e/fixtures/importFile/metricData.csv b/frontend/e2e/fixtures/importFile/metricData.csv index 2ca421831c..6af9c9a79d 100644 --- a/frontend/e2e/fixtures/importFile/metricData.csv +++ b/frontend/e2e/fixtures/importFile/metricData.csv @@ -20,7 +20,7 @@ "Cycle time","Average testing time(days/card)","0.84" "Rework","Total rework times","11" "Rework","Total rework cards","6" -"Rework","Rework cards ratio(Total rework cards/Throughput)","67.00" +"Rework","Rework cards ratio(Total rework cards/Throughput)","66.67" "Classifications","Issue Type / Spike","11.11" "Classifications","Issue Type / Task","88.89" "Classifications","Parent / ADM-322","66.67" diff --git a/frontend/e2e/pages/metrics/ReportStep.ts b/frontend/e2e/pages/metrics/ReportStep.ts index eb5b2092ea..0728350513 100644 --- a/frontend/e2e/pages/metrics/ReportStep.ts +++ b/frontend/e2e/pages/metrics/ReportStep.ts @@ -133,7 +133,7 @@ export class ReportStep { totalReworkTimes: string, totalReworkCards: string, reworkCardsRatio: string, - throughput: string, + reworkThroughput: string, ) { await expect(this.velocityPart).toContainText(`${velocity}Velocity(Story Point)`); await expect(this.velocityPart).toContainText(`${throughPut}Throughput(Cards Count)`); @@ -142,7 +142,7 @@ export class ReportStep { await expect(this.boardMetricRework).toContainText(`${totalReworkTimes}Total rework times`); await expect(this.boardMetricRework).toContainText(`${totalReworkCards}Total rework cards`); await expect(this.boardMetricRework).toContainText( - `${reworkCardsRatio}% (${totalReworkCards}/${throughput})Rework cards ratio`, + `${(Number(reworkCardsRatio) * 100).toFixed(2)}% (${totalReworkCards}/${reworkThroughput})Rework cards ratio`, ); } @@ -232,14 +232,14 @@ export class ReportStep { await expect(this.reworkRows.filter({ hasText: 'Total rework' }).getByRole('cell').nth(1)).toContainText( '11 (times)', ); - await expect(this.reworkRows.filter({ hasText: 'From block to In Dev' }).getByRole('cell').nth(1)).toContainText( - '11 (times)', - ); + await expect( + this.reworkRows.filter({ hasText: "From 'block' to 'in Dev'" }).getByRole('cell').nth(1), + ).toContainText('11 (times)'); await expect(this.reworkRows.filter({ hasText: 'Total rework cards' }).getByRole('cell').nth(1)).toContainText( '6 (cards)', ); await expect(this.reworkRows.filter({ hasText: 'Rework cards ratio' }).getByRole('cell').nth(1)).toContainText( - '0.67 (rework cards/throughput)', + '66.67% (rework cards/throughput)', ); } diff --git a/frontend/src/containers/ReportStep/BoardMetrics/index.tsx b/frontend/src/containers/ReportStep/BoardMetrics/index.tsx index 53de8516b6..0b2140a85e 100644 --- a/frontend/src/containers/ReportStep/BoardMetrics/index.tsx +++ b/frontend/src/containers/ReportStep/BoardMetrics/index.tsx @@ -23,6 +23,7 @@ import { getRealDoneStatus, } from '@src/utils/util'; import { IBasicReportRequestDTO, ReportRequestDTO } from '@src/clients/report/dto/request'; +import { GridContainer } from '@src/containers/ReportStep/BoardMetrics/style'; import { ReportTitle } from '@src/components/Common/ReportGrid/ReportTitle'; import { selectMetricsContent } from '@src/context/Metrics/metricsSlice'; import { ReportResponseDTO } from '@src/clients/report/dto/response'; @@ -121,7 +122,6 @@ const BoardMetrics = ({ const getBoardItems = () => { const velocity = boardReport?.velocity; const cycleTime = boardReport?.cycleTime; - const rework = boardReport?.rework; const velocityItems = boardMetrics.includes(REQUIRED_DATA.VELOCITY) ? [ @@ -161,6 +161,12 @@ const BoardMetrics = ({ ] : []; + return [...velocityItems, ...cycleTimeItems]; + }; + + const getReworkBoardItem = () => { + const rework = boardReport?.rework; + const reworkItems = boardMetrics.includes(REQUIRED_DATA.REWORK_TIMES) ? [ { @@ -185,8 +191,7 @@ const BoardMetrics = ({ }, ] : []; - - return [...velocityItems, ...cycleTimeItems, ...reworkItems]; + return [...reworkItems]; }; const handleRetry = () => { @@ -219,7 +224,10 @@ const BoardMetrics = ({ )} {errorMessage && {RETRY}} - + + + + ); diff --git a/frontend/src/containers/ReportStep/BoardMetrics/style.tsx b/frontend/src/containers/ReportStep/BoardMetrics/style.tsx new file mode 100644 index 0000000000..a76fbca15c --- /dev/null +++ b/frontend/src/containers/ReportStep/BoardMetrics/style.tsx @@ -0,0 +1,7 @@ +import { styled } from '@mui/material/styles'; + +export const GridContainer = styled('div')({ + display: 'flex', + flexDirection: 'column', + gap: '1rem', +}); diff --git a/frontend/src/hooks/reportMapper/reworkMapper.tsx b/frontend/src/hooks/reportMapper/reworkMapper.tsx index 96025ae08b..a1ca57579b 100644 --- a/frontend/src/hooks/reportMapper/reworkMapper.tsx +++ b/frontend/src/hooks/reportMapper/reworkMapper.tsx @@ -14,7 +14,7 @@ const getRowName = (value: string, reworkState: string): ReactNode => { if (REWORK_BOARD_STATUS.includes(value)) { return ( <> - From {value} to {reworkState.toLowerCase()} + From {`'${value}'`} to {`'${reworkState.toLowerCase()}'`} ); } else { @@ -33,7 +33,7 @@ const reworkMapper = (reworkTimeResponse: ReworkTimeResponse) => { { value: key === 'reworkCardsRatio' - ? Number(reworkTimeResponse[key as keyof ReworkTimeResponse]) * 100 + ? (Number(reworkTimeResponse[key as keyof ReworkTimeResponse]) * 100).toFixed(2) : reworkTimeResponse[key as keyof ReworkTimeResponse]!, unit: getUnit(value), }, From c1aef0b3760be7860b9fe89c9effa1b7826c99ab Mon Sep 17 00:00:00 2001 From: Leiqiuhong Date: Fri, 22 Mar 2024 16:50:46 +0800 Subject: [PATCH 05/11] ADM-694-latest: [frontend] test: fix unit test --- .../__tests__/{fixtures.ts => fixtures.tsx} | 106 +++++++++++++++++- .../hooks/reportMapper/report.test.tsx | 105 +---------------- 2 files changed, 105 insertions(+), 106 deletions(-) rename frontend/__tests__/{fixtures.ts => fixtures.tsx} (91%) diff --git a/frontend/__tests__/fixtures.ts b/frontend/__tests__/fixtures.tsx similarity index 91% rename from frontend/__tests__/fixtures.ts rename to frontend/__tests__/fixtures.tsx index daa0e8343d..5eb4ff1b17 100644 --- a/frontend/__tests__/fixtures.ts +++ b/frontend/__tests__/fixtures.tsx @@ -1,6 +1,8 @@ import { ReportResponseDTO, ReworkTimeResponse } from '@src/clients/report/dto/response'; import { CSVReportRequestDTO, ReportRequestDTO } from '@src/clients/report/dto/request'; +import { StyledSpan } from '@src/containers/ReportStep/ReportDetail/style'; import { SOURCE_CONTROL_TYPES } from '@src/constants/resources'; +import React from 'react'; export const PROJECT_NAME = 'Heartbeat'; export const PROJECT_DESCRIPTION = @@ -454,7 +456,20 @@ export const MOCK_REPORT_RESPONSE: ReportResponseDTO = { }, ], }, - rework: null, + 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: [ { @@ -668,7 +683,94 @@ export const EXPECTED_REPORT_VALUES = { }, ], exportValidityTimeMin: 30, - reworkList: null, + reworkList: [ + { + id: 0, + name: Total rework, + valueList: [ + { + value: 111, + unit: ' (times)', + }, + ], + }, + { + id: 3, + name: ( + + From 'block' to 'in dev' + + ), + valueList: [ + { + value: 111, + unit: ' (times)', + }, + ], + }, + { + id: 4, + name: ( + + From 'review' to 'in dev' + + ), + valueList: [ + { + value: 111, + unit: ' (times)', + }, + ], + }, + { + id: 5, + name: ( + + From 'waiting for testing' to 'in dev' + + ), + valueList: [ + { + value: 111, + unit: ' (times)', + }, + ], + }, + { + id: 7, + name: ( + + From 'done' to 'in dev' + + ), + valueList: [ + { + value: 111, + unit: ' (times)', + }, + ], + }, + { + id: 8, + name: Total rework cards, + valueList: [ + { + value: 111, + unit: ' (cards)', + }, + ], + }, + { + id: 9, + name: Rework cards ratio, + valueList: [ + { + value: '88.88', + unit: '% (rework cards/throughput)', + }, + ], + }, + ], }; export const EMPTY_REPORT_VALUES: ReportResponseDTO = { diff --git a/frontend/__tests__/hooks/reportMapper/report.test.tsx b/frontend/__tests__/hooks/reportMapper/report.test.tsx index 14d1edc11f..4a1155d375 100644 --- a/frontend/__tests__/hooks/reportMapper/report.test.tsx +++ b/frontend/__tests__/hooks/reportMapper/report.test.tsx @@ -1,93 +1,5 @@ -import { EXPECTED_REPORT_VALUES, MOCK_REPORT_RESPONSE, REWORK_REPORT_RESPONSE } from '../../fixtures'; -import ReportForTwoColumns from '@src/components/Common/ReportForTwoColumns'; -import { StyledSpan } from '@src/containers/ReportStep/ReportDetail/style'; -import reworkMapper from '@src/hooks/reportMapper/reworkMapper'; +import { EXPECTED_REPORT_VALUES, MOCK_REPORT_RESPONSE } from '../../fixtures'; import { reportMapper } from '@src/hooks/reportMapper/report'; -import { render } from '@testing-library/react'; -import React from 'react'; - -[ - { - id: 0, - name: 'Total rework ', - valueList: [ - { - value: 111, - unit: ' (times)', - }, - ], - }, - { - id: 2, - name: 'From in dev to in dev ', - valueList: [ - { - value: 111, - unit: ' (times)', - }, - ], - }, - { - id: 3, - name: 'From block to in dev ', - valueList: [ - { - value: 111, - unit: ' (times)', - }, - ], - }, - { - id: 4, - name: 'From waiting for testing to in dev ', - valueList: [ - { - value: 111, - unit: ' (times)', - }, - ], - }, - { - id: 6, - name: 'From review to in dev ', - valueList: [ - { - value: 111, - unit: ' (times)', - }, - ], - }, - { - id: 7, - name: 'From done to in dev ', - valueList: [ - { - value: 111, - unit: ' (times)', - }, - ], - }, - { - id: 8, - name: 'Total rework cards ', - valueList: [ - { - value: 111, - unit: ' (cards)', - }, - ], - }, - { - id: 9, - name: 'Rework cards ratio ', - valueList: [ - { - value: '88.88', - unit: '% (rework cards/throughput)', - }, - ], - }, -]; describe('report response data mapper', () => { it('maps response velocity values to ui display value', () => { @@ -95,19 +7,4 @@ describe('report response data mapper', () => { expect(mappedReportResponseValues).toEqual(EXPECTED_REPORT_VALUES); }); - - it('aaa', () => { - const reworkMappedReportResponseValue = reworkMapper(REWORK_REPORT_RESPONSE); - const { getByText, container, debug } = render( - , - ); - debug(); - // container.expect(getByText('Total rework')).not.toBeEmptyDOMElement(); - // expect(getByText("From 'block' to 'in dev'")).not.toBeEmptyDOMElement(); - // expect(getByText("From 'waiting for testing' to 'in dev'")).not.toBeEmptyDOMElement(); - // expect(getByText("From 'review' to 'in dev'")).not.toBeEmptyDOMElement(); - // expect(getByText("From 'done' to 'in dev'")).not.toBeEmptyDOMElement(); - // expect(getByText('Total rework cards')).not.toBeEmptyDOMElement(); - // expect(getByText('Rework cards ratio')).not.toBeEmptyDOMElement(); - }); }); From c673fa6c210cb320364f40f1712261e0ed55a22c Mon Sep 17 00:00:00 2001 From: Leiqiuhong Date: Fri, 22 Mar 2024 17:21:23 +0800 Subject: [PATCH 06/11] ADM-694-latest: [frontend] feat: add flag column --- frontend/__tests__/fixtures.tsx | 25 +++++---------------- frontend/src/clients/report/ReportClient.ts | 1 + frontend/src/clients/report/dto/response.ts | 1 + frontend/src/constants/resources.ts | 2 ++ 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/frontend/__tests__/fixtures.tsx b/frontend/__tests__/fixtures.tsx index 5eb4ff1b17..c161efc709 100644 --- a/frontend/__tests__/fixtures.tsx +++ b/frontend/__tests__/fixtures.tsx @@ -462,6 +462,7 @@ export const MOCK_REPORT_RESPONSE: ReportResponseDTO = { fromAnalysis: null, fromInDev: null, fromBlock: 111, + fromFlag: null, fromReview: 111, fromWaitingForTesting: 111, fromTesting: null, @@ -522,20 +523,6 @@ export const MOCK_REPORT_RESPONSE: ReportResponseDTO = { reportMetricsError, }; -export const REWORK_REPORT_RESPONSE: ReworkTimeResponse = { - 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, -}; export const MOCK_RETRIEVE_REPORT_RESPONSE = { callbackUrl: 'reports/123', interval: 10, @@ -709,7 +696,7 @@ export const EXPECTED_REPORT_VALUES = { ], }, { - id: 4, + id: 5, name: ( From 'review' to 'in dev' @@ -723,7 +710,7 @@ export const EXPECTED_REPORT_VALUES = { ], }, { - id: 5, + id: 6, name: ( From 'waiting for testing' to 'in dev' @@ -737,7 +724,7 @@ export const EXPECTED_REPORT_VALUES = { ], }, { - id: 7, + id: 8, name: ( From 'done' to 'in dev' @@ -751,7 +738,7 @@ export const EXPECTED_REPORT_VALUES = { ], }, { - id: 8, + id: 9, name: Total rework cards, valueList: [ { @@ -761,7 +748,7 @@ export const EXPECTED_REPORT_VALUES = { ], }, { - id: 9, + id: 10, name: Rework cards ratio, valueList: [ { diff --git a/frontend/src/clients/report/ReportClient.ts b/frontend/src/clients/report/ReportClient.ts index 08174a8cc0..86f66957d2 100644 --- a/frontend/src/clients/report/ReportClient.ts +++ b/frontend/src/clients/report/ReportClient.ts @@ -31,6 +31,7 @@ export class ReportClient extends HttpClient { reworkState: 'Done', fromAnalysis: 0, fromInDev: 0, + fromFlag: 0, fromBlock: 0, fromWaitingForTesting: 0, fromTesting: 0, diff --git a/frontend/src/clients/report/dto/response.ts b/frontend/src/clients/report/dto/response.ts index 0dcb297428..1884c4fc62 100644 --- a/frontend/src/clients/report/dto/response.ts +++ b/frontend/src/clients/report/dto/response.ts @@ -47,6 +47,7 @@ export interface ReworkTimeResponse { fromAnalysis: number | null; fromInDev: number | null; fromBlock: number | null; + fromFlag: number | null; fromWaitingForTesting: number | null; fromTesting: number | null; fromReview: number | null; diff --git a/frontend/src/constants/resources.ts b/frontend/src/constants/resources.ts index ef0ffc4ee1..e229a84668 100644 --- a/frontend/src/constants/resources.ts +++ b/frontend/src/constants/resources.ts @@ -217,6 +217,7 @@ export const REWORK_TIME_MAPPING = { fromAnalysis: 'analysis', fromInDev: 'in dev', fromBlock: 'block', + fromFlag: 'flag', fromReview: 'review', fromWaitingForTesting: 'waiting for testing', fromTesting: 'testing', @@ -229,6 +230,7 @@ export const REWORK_BOARD_STATUS: string[] = [ REWORK_TIME_MAPPING.fromAnalysis, REWORK_TIME_MAPPING.fromInDev, REWORK_TIME_MAPPING.fromBlock, + REWORK_TIME_MAPPING.fromFlag, REWORK_TIME_MAPPING.fromWaitingForTesting, REWORK_TIME_MAPPING.fromTesting, REWORK_TIME_MAPPING.fromReview, From 44dc599a7ebe1efa8b1ad864cfef07b9d1eed9d0 Mon Sep 17 00:00:00 2001 From: Leiqiuhong Date: Fri, 22 Mar 2024 17:46:58 +0800 Subject: [PATCH 07/11] ADM-694-latest: [frontend] fix: fix eslint --- frontend/__tests__/fixtures.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/__tests__/fixtures.tsx b/frontend/__tests__/fixtures.tsx index c161efc709..da0eb2fbf1 100644 --- a/frontend/__tests__/fixtures.tsx +++ b/frontend/__tests__/fixtures.tsx @@ -685,7 +685,7 @@ export const EXPECTED_REPORT_VALUES = { id: 3, name: ( - From 'block' to 'in dev' + From 'block' to 'in dev' ), valueList: [ @@ -699,7 +699,7 @@ export const EXPECTED_REPORT_VALUES = { id: 5, name: ( - From 'review' to 'in dev' + From 'review' to 'in dev' ), valueList: [ @@ -713,7 +713,7 @@ export const EXPECTED_REPORT_VALUES = { id: 6, name: ( - From 'waiting for testing' to 'in dev' + From 'waiting for testing' to 'in dev' ), valueList: [ @@ -727,7 +727,7 @@ export const EXPECTED_REPORT_VALUES = { id: 8, name: ( - From 'done' to 'in dev' + From 'done' to 'in dev' ), valueList: [ From 0264446c3ebe89df68b09a35ba9efab7ae0ea0be Mon Sep 17 00:00:00 2001 From: Leiqiuhong Date: Fri, 22 Mar 2024 17:49:20 +0800 Subject: [PATCH 08/11] ADM-694-latest: [frontend] fix: fix useless import --- frontend/__tests__/fixtures.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/__tests__/fixtures.tsx b/frontend/__tests__/fixtures.tsx index da0eb2fbf1..9eda314c95 100644 --- a/frontend/__tests__/fixtures.tsx +++ b/frontend/__tests__/fixtures.tsx @@ -1,6 +1,6 @@ -import { ReportResponseDTO, ReworkTimeResponse } from '@src/clients/report/dto/response'; import { CSVReportRequestDTO, ReportRequestDTO } from '@src/clients/report/dto/request'; import { StyledSpan } from '@src/containers/ReportStep/ReportDetail/style'; +import { ReportResponseDTO } from '@src/clients/report/dto/response'; import { SOURCE_CONTROL_TYPES } from '@src/constants/resources'; import React from 'react'; From 8b14680f1e0b67e885553e974b4df34bff1961f4 Mon Sep 17 00:00:00 2001 From: Leiqiuhong Date: Fri, 22 Mar 2024 17:56:58 +0800 Subject: [PATCH 09/11] ADM-694-latest: [frontend] fix: use rgb instead of hex color --- frontend/__tests__/fixtures.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/__tests__/fixtures.tsx b/frontend/__tests__/fixtures.tsx index 9eda314c95..6a28cf5f4e 100644 --- a/frontend/__tests__/fixtures.tsx +++ b/frontend/__tests__/fixtures.tsx @@ -72,7 +72,7 @@ export const DEV_CHANGE_FAILURE_RATE = 'Dev change failure rate'; export const DEV_MEAN_TIME_TO_RECOVERY = 'Dev mean time to recovery'; export const REQUIRED_DATA = 'Required metrics'; export const TEST_PROJECT_NAME = 'test project Name'; -export const ERROR_MESSAGE_COLOR = 'color: #d32f2f'; +export const ERROR_MESSAGE_COLOR = 'color: rgb(211,47,47)'; export const ERROR_DATE = '02/03/'; export const CREATE_NEW_PROJECT = 'Create a new project'; export const IMPORT_PROJECT_FROM_FILE = 'Import project from file'; From 4a75ed5d037a60efe5c77abdfddf85df1ba2a401 Mon Sep 17 00:00:00 2001 From: "yp.wu" Date: Fri, 22 Mar 2024 18:06:01 +0800 Subject: [PATCH 10/11] AMD-694-fix [frontend] fix: fix css hex check --- .../__tests__/{fixtures.tsx => fixtures.ts} | 236 +----------------- .../hooks/reportMapper/report.test.tsx | 235 ++++++++++++++++- 2 files changed, 235 insertions(+), 236 deletions(-) rename frontend/__tests__/{fixtures.tsx => fixtures.ts} (79%) diff --git a/frontend/__tests__/fixtures.tsx b/frontend/__tests__/fixtures.ts similarity index 79% rename from frontend/__tests__/fixtures.tsx rename to frontend/__tests__/fixtures.ts index 6a28cf5f4e..7432b99613 100644 --- a/frontend/__tests__/fixtures.tsx +++ b/frontend/__tests__/fixtures.ts @@ -1,8 +1,6 @@ import { CSVReportRequestDTO, ReportRequestDTO } from '@src/clients/report/dto/request'; -import { StyledSpan } from '@src/containers/ReportStep/ReportDetail/style'; import { ReportResponseDTO } from '@src/clients/report/dto/response'; import { SOURCE_CONTROL_TYPES } from '@src/constants/resources'; -import React from 'react'; export const PROJECT_NAME = 'Heartbeat'; export const PROJECT_DESCRIPTION = @@ -72,7 +70,7 @@ export const DEV_CHANGE_FAILURE_RATE = 'Dev change failure rate'; export const DEV_MEAN_TIME_TO_RECOVERY = 'Dev mean time to recovery'; export const REQUIRED_DATA = 'Required metrics'; export const TEST_PROJECT_NAME = 'test project Name'; -export const ERROR_MESSAGE_COLOR = 'color: rgb(211,47,47)'; +export const ERROR_MESSAGE_COLOR = 'color: #d32f2f'; export const ERROR_DATE = '02/03/'; export const CREATE_NEW_PROJECT = 'Create a new project'; export const IMPORT_PROJECT_FROM_FILE = 'Import project from file'; @@ -528,238 +526,6 @@ export const MOCK_RETRIEVE_REPORT_RESPONSE = { interval: 10, }; -export const EXPECTED_REPORT_VALUES = { - velocityList: [ - { id: 0, name: 'Velocity(Story Point)', valueList: [{ value: 20 }] }, - { id: 1, name: 'Throughput(Cards Count)', valueList: [{ value: 14 }] }, - ], - cycleTimeList: [ - { - id: 0, - name: 'Average cycle time', - valueList: [ - { value: 21.18, unit: '(Days/SP)' }, - { value: '30.26', unit: '(Days/Card)' }, - ], - }, - { - id: 1, - name: 'Total development time / Total cycle time', - valueList: [{ value: '57.25%' }], - }, - { - id: 2, - name: 'Average development time', - valueList: [ - { value: '12.13', unit: '(Days/SP)' }, - { value: '17.32', unit: '(Days/Card)' }, - ], - }, - ], - classification: [ - { - id: 0, - name: 'FS Work Type', - valuesList: [{ name: 'Feature Work - Planned', value: '57.14%' }], - }, - ], - deploymentFrequencyList: [ - { - id: 0, - name: 'fs-platform-onboarding/ :shipit: deploy to PROD', - valuesList: [ - { - name: 'Deployment frequency', - value: '0.30', - }, - ], - }, - { - id: 1, - name: 'Average', - valuesList: [ - { - name: 'Deployment frequency', - value: '0.40', - }, - ], - }, - ], - devMeanTimeToRecoveryList: [ - { - id: 0, - name: 'Heartbeat/:react: Build Frontend', - valuesList: [ - { - name: 'Dev mean time to recovery', - value: '4.32', - }, - ], - }, - { - id: 1, - name: 'Heartbeat/:cloudformation: Deploy infra', - valuesList: [ - { - name: 'Dev mean time to recovery', - value: '0.00', - }, - ], - }, - { - id: 2, - name: 'Heartbeat/:rocket: Run e2e', - valuesList: [ - { - name: 'Dev mean time to recovery', - value: '7.67', - }, - ], - }, - { - id: 3, - name: 'Average', - valuesList: [ - { - name: 'Dev mean time to recovery', - value: '4.00', - }, - ], - }, - ], - leadTimeForChangesList: [ - { - id: 0, - name: 'fs-platform-payment-selector/RECORD RELEASE TO PROD', - valuesList: [ - { name: PR_LEAD_TIME, value: '45.04' }, - { name: PIPELINE_LEAD_TIME, value: '43.12' }, - { name: TOTAL_DELAY_TIME, value: '88.17' }, - ], - }, - { - id: 1, - name: 'Average', - valuesList: [ - { name: PR_LEAD_TIME, value: '60.79' }, - { name: PIPELINE_LEAD_TIME, value: '39.03' }, - { name: TOTAL_DELAY_TIME, value: '99.82' }, - ], - }, - ], - devChangeFailureRateList: [ - { - id: 0, - name: 'fs-platform-onboarding/ :shipit: deploy to PROD', - valuesList: [ - { - name: 'Dev change failure rate', - value: '0.00%(0/2)', - }, - ], - }, - { - id: 1, - name: 'Average', - valuesList: [ - { - name: 'Dev change failure rate', - value: '0.00%(0/6)', - }, - ], - }, - ], - exportValidityTimeMin: 30, - reworkList: [ - { - id: 0, - name: Total rework, - valueList: [ - { - value: 111, - unit: ' (times)', - }, - ], - }, - { - id: 3, - name: ( - - From 'block' to 'in dev' - - ), - valueList: [ - { - value: 111, - unit: ' (times)', - }, - ], - }, - { - id: 5, - name: ( - - From 'review' to 'in dev' - - ), - valueList: [ - { - value: 111, - unit: ' (times)', - }, - ], - }, - { - id: 6, - name: ( - - From 'waiting for testing' to 'in dev' - - ), - valueList: [ - { - value: 111, - unit: ' (times)', - }, - ], - }, - { - id: 8, - name: ( - - From 'done' to 'in dev' - - ), - valueList: [ - { - value: 111, - unit: ' (times)', - }, - ], - }, - { - id: 9, - name: Total rework cards, - valueList: [ - { - value: 111, - unit: ' (cards)', - }, - ], - }, - { - id: 10, - name: Rework cards ratio, - valueList: [ - { - value: '88.88', - unit: '% (rework cards/throughput)', - }, - ], - }, - ], -}; - export const EMPTY_REPORT_VALUES: ReportResponseDTO = { velocity: null, classificationList: null, diff --git a/frontend/__tests__/hooks/reportMapper/report.test.tsx b/frontend/__tests__/hooks/reportMapper/report.test.tsx index 4a1155d375..6cf7238510 100644 --- a/frontend/__tests__/hooks/reportMapper/report.test.tsx +++ b/frontend/__tests__/hooks/reportMapper/report.test.tsx @@ -1,6 +1,239 @@ -import { EXPECTED_REPORT_VALUES, MOCK_REPORT_RESPONSE } from '../../fixtures'; +import { MOCK_REPORT_RESPONSE, PIPELINE_LEAD_TIME, PR_LEAD_TIME, TOTAL_DELAY_TIME } from '../../fixtures'; +import { StyledSpan } from '@src/containers/ReportStep/ReportDetail/style'; import { reportMapper } from '@src/hooks/reportMapper/report'; +import React from 'react'; +export const EXPECTED_REPORT_VALUES = { + velocityList: [ + { id: 0, name: 'Velocity(Story Point)', valueList: [{ value: 20 }] }, + { id: 1, name: 'Throughput(Cards Count)', valueList: [{ value: 14 }] }, + ], + cycleTimeList: [ + { + id: 0, + name: 'Average cycle time', + valueList: [ + { value: 21.18, unit: '(Days/SP)' }, + { value: '30.26', unit: '(Days/Card)' }, + ], + }, + { + id: 1, + name: 'Total development time / Total cycle time', + valueList: [{ value: '57.25%' }], + }, + { + id: 2, + name: 'Average development time', + valueList: [ + { value: '12.13', unit: '(Days/SP)' }, + { value: '17.32', unit: '(Days/Card)' }, + ], + }, + ], + classification: [ + { + id: 0, + name: 'FS Work Type', + valuesList: [{ name: 'Feature Work - Planned', value: '57.14%' }], + }, + ], + deploymentFrequencyList: [ + { + id: 0, + name: 'fs-platform-onboarding/ :shipit: deploy to PROD', + valuesList: [ + { + name: 'Deployment frequency', + value: '0.30', + }, + ], + }, + { + id: 1, + name: 'Average', + valuesList: [ + { + name: 'Deployment frequency', + value: '0.40', + }, + ], + }, + ], + devMeanTimeToRecoveryList: [ + { + id: 0, + name: 'Heartbeat/:react: Build Frontend', + valuesList: [ + { + name: 'Dev mean time to recovery', + value: '4.32', + }, + ], + }, + { + id: 1, + name: 'Heartbeat/:cloudformation: Deploy infra', + valuesList: [ + { + name: 'Dev mean time to recovery', + value: '0.00', + }, + ], + }, + { + id: 2, + name: 'Heartbeat/:rocket: Run e2e', + valuesList: [ + { + name: 'Dev mean time to recovery', + value: '7.67', + }, + ], + }, + { + id: 3, + name: 'Average', + valuesList: [ + { + name: 'Dev mean time to recovery', + value: '4.00', + }, + ], + }, + ], + leadTimeForChangesList: [ + { + id: 0, + name: 'fs-platform-payment-selector/RECORD RELEASE TO PROD', + valuesList: [ + { name: PR_LEAD_TIME, value: '45.04' }, + { name: PIPELINE_LEAD_TIME, value: '43.12' }, + { name: TOTAL_DELAY_TIME, value: '88.17' }, + ], + }, + { + id: 1, + name: 'Average', + valuesList: [ + { name: PR_LEAD_TIME, value: '60.79' }, + { name: PIPELINE_LEAD_TIME, value: '39.03' }, + { name: TOTAL_DELAY_TIME, value: '99.82' }, + ], + }, + ], + devChangeFailureRateList: [ + { + id: 0, + name: 'fs-platform-onboarding/ :shipit: deploy to PROD', + valuesList: [ + { + name: 'Dev change failure rate', + value: '0.00%(0/2)', + }, + ], + }, + { + id: 1, + name: 'Average', + valuesList: [ + { + name: 'Dev change failure rate', + value: '0.00%(0/6)', + }, + ], + }, + ], + exportValidityTimeMin: 30, + reworkList: [ + { + id: 0, + name: Total rework, + valueList: [ + { + value: 111, + unit: ' (times)', + }, + ], + }, + { + id: 3, + name: ( + + From 'block' to 'in dev' + + ), + valueList: [ + { + value: 111, + unit: ' (times)', + }, + ], + }, + { + id: 5, + name: ( + + From 'review' to 'in dev' + + ), + valueList: [ + { + value: 111, + unit: ' (times)', + }, + ], + }, + { + id: 6, + name: ( + + From 'waiting for testing' to 'in dev' + + ), + valueList: [ + { + value: 111, + unit: ' (times)', + }, + ], + }, + { + id: 8, + name: ( + + From 'done' to 'in dev' + + ), + valueList: [ + { + value: 111, + unit: ' (times)', + }, + ], + }, + { + id: 9, + name: Total rework cards, + valueList: [ + { + value: 111, + unit: ' (cards)', + }, + ], + }, + { + id: 10, + name: Rework cards ratio, + valueList: [ + { + value: '88.88', + unit: '% (rework cards/throughput)', + }, + ], + }, + ], +}; describe('report response data mapper', () => { it('maps response velocity values to ui display value', () => { const mappedReportResponseValues = reportMapper(MOCK_REPORT_RESPONSE); From 735cd9405054cf9760527481e11a85252df7594c Mon Sep 17 00:00:00 2001 From: "yp.wu" Date: Fri, 22 Mar 2024 18:23:04 +0800 Subject: [PATCH 11/11] AMD-694-latest [frontend] fix: flag undefined --- frontend/src/hooks/reportMapper/reworkMapper.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/hooks/reportMapper/reworkMapper.tsx b/frontend/src/hooks/reportMapper/reworkMapper.tsx index a1ca57579b..27b2845c36 100644 --- a/frontend/src/hooks/reportMapper/reworkMapper.tsx +++ b/frontend/src/hooks/reportMapper/reworkMapper.tsx @@ -26,6 +26,7 @@ const reworkMapper = (reworkTimeResponse: ReworkTimeResponse) => { const result: ReportDataWithTwoColumns[] = []; Object.entries(REWORK_TIME_MAPPING).map(([key, value], index) => { reworkTimeResponse[key as keyof ReworkTimeResponse] !== null && + reworkTimeResponse[key as keyof ReworkTimeResponse] !== undefined && result.push({ id: index, name: getRowName(value, reworkTimeResponse.reworkState),