Skip to content

Commit

Permalink
ADM-960 [frontend]: make cursor to pointer when hover tooltips (#1475)
Browse files Browse the repository at this point in the history
* ADM-960 [frontend]: make cursor to pointer when hover tooltips

* ADM-960 [frontend]: fix the rework chart tooltip issue

* ADM-960 [frontend]: fix the coverage

* ADM-960 [frontend]: modify the cycle time name
  • Loading branch information
zhou-yinyuan authored Jun 3, 2024
1 parent 6a0e387 commit aeb2821
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 21 deletions.
17 changes: 17 additions & 0 deletions frontend/__tests__/utils/Util.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
sortDisabledOptions,
transformToCleanedBuildKiteEmoji,
updateResponseCrews,
valueFormatter,
xAxisLabelDateFormatter,
} from '@src/utils/util';
import {
Expand Down Expand Up @@ -722,3 +723,19 @@ describe('percentageFormatter function', () => {
expect(result).toEqual('66.66');
});
});

describe('valueFormatter function', () => {
it('should return the percent data format with number', () => {
const inputData: number = 66.66;

const result: string = valueFormatter(inputData);

expect(result).toEqual('66.66%');
});

it('should return symbol when data is NaN', () => {
const result: string = valueFormatter(NaN);

expect(result).toEqual('-');
});
});
25 changes: 11 additions & 14 deletions frontend/e2e/pages/metrics/report-step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class ReportStep {
readonly displayBoardChartTab: Locator;
readonly displayDoraChartTab: Locator;
readonly velocityChart: Locator;
readonly averageCycleTimeChart: Locator;
readonly cycleTimeChart: Locator;
readonly cycleTimeAllocationChart: Locator;
readonly reworkChart: Locator;
readonly leadTimeForChangeChart: Locator;
Expand All @@ -80,11 +80,11 @@ export class ReportStep {
readonly velocityTrendContainer: Locator;
readonly reworkTrendContainer: Locator;
readonly cycleTimeAllocationTrendContainer: Locator;
readonly averageCycleTimeTrendContainer: Locator;
readonly cycleTimeTrendContainer: Locator;
readonly velocityTrendIcon: Locator;
readonly reworkTrendIcon: Locator;
readonly cycleTimeAllocationTrendIcon: Locator;
readonly averageCycleTimeTrendIcon: Locator;
readonly cycleTimeTrendIcon: Locator;
readonly devMeanTimeToRecoveryTrendContainer: Locator;
readonly devChangeFailureRateTrendContainer: Locator;
readonly deploymentFrequencyTrendContainer: Locator;
Expand Down Expand Up @@ -145,19 +145,19 @@ export class ReportStep {
this.displayBoardChartTab = this.chartTabsContainer.getByLabel('board chart');
this.displayDoraChartTab = this.chartTabsContainer.getByLabel('dora chart');
this.velocityChart = this.page.getByLabel('velocity chart');
this.averageCycleTimeChart = this.page.getByLabel('average cycle time chart');
this.cycleTimeChart = this.page.getByLabel('cycle time chart');
this.cycleTimeAllocationChart = this.page.getByLabel('cycle time allocation chart');
this.reworkChart = this.page.getByLabel('rework chart');
this.leadTimeForChangeChart = this.page.getByLabel('lead time for changes chart');
this.deploymentFrequencyChart = this.page.getByLabel('deployment frequency chart');
this.changeFailureRateChart = this.page.getByLabel('change failure rate chart');
this.meanTimeToRecoveryChart = this.page.getByLabel('mean time to recovery chart');
this.velocityTrendContainer = this.page.getByLabel('velocity trend container');
this.averageCycleTimeTrendContainer = this.page.getByLabel('average cycle time trend container');
this.cycleTimeTrendContainer = this.page.getByLabel('cycle time trend container');
this.cycleTimeAllocationTrendContainer = this.page.getByLabel('cycle time allocation trend container');
this.reworkTrendContainer = this.page.getByLabel('rework trend container');
this.velocityTrendIcon = this.velocityTrendContainer.getByLabel('trend up');
this.averageCycleTimeTrendIcon = this.averageCycleTimeTrendContainer.getByLabel('trend up');
this.cycleTimeTrendIcon = this.cycleTimeTrendContainer.getByLabel('trend up');
this.cycleTimeAllocationTrendIcon = this.cycleTimeAllocationTrendContainer.getByLabel('trend up');
this.reworkTrendIcon = this.reworkTrendContainer.getByLabel('trend up');

Expand Down Expand Up @@ -655,7 +655,7 @@ export class ReportStep {
expect(await this.displayBoardChartTab.getAttribute('aria-selected')).toEqual('true');
expect(await this.displayDoraChartTab.getAttribute('aria-selected')).toEqual('false');
await expect(this.velocityChart).toBeVisible();
await expect(this.averageCycleTimeChart).toBeVisible();
await expect(this.cycleTimeChart).toBeVisible();
await expect(this.cycleTimeAllocationChart).toBeVisible();
await expect(this.reworkChart).toBeVisible();

Expand All @@ -664,13 +664,10 @@ export class ReportStep {
await expect(this.velocityTrendIcon).toBeVisible();
await expect(this.velocityTrendContainer).toContainText(BOARD_CHART_VALUE.Velocity.value);

await expect(this.averageCycleTimeTrendContainer).toBeVisible();
await expect(this.averageCycleTimeTrendContainer).toHaveAttribute(
'color',
BOARD_CHART_VALUE['Average Cycle Time'].color,
);
await expect(this.averageCycleTimeTrendIcon).toBeVisible();
await expect(this.averageCycleTimeTrendContainer).toContainText(BOARD_CHART_VALUE['Average Cycle Time'].value);
await expect(this.cycleTimeTrendContainer).toBeVisible();
await expect(this.cycleTimeTrendContainer).toHaveAttribute('color', BOARD_CHART_VALUE['Average Cycle Time'].color);
await expect(this.cycleTimeTrendIcon).toBeVisible();
await expect(this.cycleTimeTrendContainer).toContainText(BOARD_CHART_VALUE['Average Cycle Time'].value);

await expect(this.cycleTimeAllocationTrendContainer).toBeVisible();
await expect(this.cycleTimeAllocationTrendContainer).toHaveAttribute(
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/constants/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export enum MetricsTitle {

export enum ChartType {
Velocity = 'Velocity',
AverageCycleTime = 'Average Cycle Time',
CycleTime = 'Cycle Time',
CycleTimeAllocation = 'Cycle Time Allocation',
Rework = 'Rework',
LeadTimeForChanges = 'Lead Time For Changes',
Expand All @@ -108,7 +108,7 @@ export enum TrendType {

export const CHART_TREND_TIP = {
[ChartType.Velocity]: 'Velocity(Story point)',
[ChartType.AverageCycleTime]: 'Days/Story point',
[ChartType.CycleTime]: 'Days/Story point',
[ChartType.CycleTimeAllocation]: 'Total development time/Total cycle time',
[ChartType.Rework]: 'Total rework times',
[ChartType.LeadTimeForChanges]: 'PR Lead Time',
Expand All @@ -124,7 +124,7 @@ export const UP_TREND_IS_BETTER: ChartType[] = [
];
export const DOWN_TREND_IS_BETTER: ChartType[] = [
ChartType.Rework,
ChartType.AverageCycleTime,
ChartType.CycleTime,
ChartType.LeadTimeForChanges,
ChartType.DevMeanTimeToRecovery,
ChartType.DevChangeFailureRate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface Series {
smooth?: boolean;
areaStyle?: unknown;
yAxisIndex?: number;
tooltip?: object;
}

export interface XAxis {
Expand Down Expand Up @@ -125,7 +126,7 @@ export const stackedAreaOptionMapper = (props: AreaOptionProps) => {
yAxisIndex: item.yAxisIndex,
smooth: item.smooth,
areaStyle: item.areaStyle,
...commonConfig.seriesConfig,
tooltip: item.tooltip,
};
}),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
stackedBarOptionMapper,
} from '@src/containers/ReportStep/BoardMetricsChart/ChartOption';
import { ChartType, CYCLE_TIME_CHARTS_MAPPING, METRICS_CONSTANTS } from '@src/constants/resources';
import { calculateTrendInfo, valueFormatter, xAxisLabelDateFormatter } from '@src/utils/util';
import ChartAndTitleWrapper from '@src/containers/ReportStep/ChartAndTitleWrapper';
import { calculateTrendInfo, xAxisLabelDateFormatter } from '@src/utils/util';
import { ReportResponse, Swimlane } from '@src/clients/report/dto/response';
import { ChartContainer } from '@src/containers/MetricsStep/style';
import { IReportInfo } from '@src/hooks/useGenerateReportEffect';
Expand Down Expand Up @@ -109,7 +109,7 @@ function extractAverageCycleTimeData(dateRanges: string[], mappedData?: ReportRe
const data = mappedData?.map((item) => item.cycleTimeList);
const storyPoints = data?.map((item) => item?.[0]?.valueList?.[0]?.value as number);
const cardCount = data?.map((item) => item?.[0]?.valueList?.[1]?.value as number);
const trendInfo = calculateTrendInfo(storyPoints, dateRanges, ChartType.AverageCycleTime);
const trendInfo = calculateTrendInfo(storyPoints, dateRanges, ChartType.CycleTime);
return {
xAxis: {
data: dateRanges,
Expand Down Expand Up @@ -211,8 +211,9 @@ function extractReworkData(dateRanges: string[], mappedData?: ReportResponse[])
],
series: [
{
name: 'Rework cards ratrio',
name: 'Rework cards ratio',
type: 'line',
tooltip: { valueFormatter },
data: reworkCardsRatio!,
yAxisIndex: 1,
setAreaStyle: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export const TrendContainer = styled('div')(({ color }: { color: string }) => ({
color: color,
marginLeft: '0.5rem',
fontSize: '1.125rem',
'&:hover': {
cursor: 'pointer',
},
}));

export const StyledTooltipContent = styled('div')({
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,9 @@ export const convertNumberToPercent = (num: number): string => {
export const percentageFormatter = (showPercentage = true) => {
return (value: number) => value + (showPercentage ? '%' : '');
};
export const valueFormatter = (value: number) => {
if (isNaN(value)) {
return '-';
}
return value.toFixed(2) + '%';
};

0 comments on commit aeb2821

Please sign in to comment.