supported running status in contract execution chart (#23611)

This commit is contained in:
Ashish Gupta 2025-09-30 10:48:57 +05:30 committed by GitHub
parent 18677afd39
commit a852a06166
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 40 additions and 1 deletions

View File

@ -25,6 +25,7 @@ import {
XAxis,
} from 'recharts';
import {
BLUE_1,
GREEN_4,
GREY_100,
RED_3,
@ -177,6 +178,15 @@ const ContractExecutionChart = ({ contract }: { contract: DataContract }) => {
stackId="single"
{...DATA_CONTRACT_EXECUTION_CHART_COMMON_PROPS}
/>
<Bar
activeBar={<Rectangle fill={BLUE_1} stroke={BLUE_1} />}
dataKey="running"
fill={BLUE_1}
name={t('label.running')}
stackId="single"
{...DATA_CONTRACT_EXECUTION_CHART_COMMON_PROPS}
/>
</BarChart>
</ResponsiveContainer>
)}

View File

@ -183,6 +183,7 @@ jest.mock('react-i18next', () => ({
'label.success': 'Success',
'label.failed': 'Failed',
'label.aborted': 'Aborted',
'label.running': 'Running',
};
return translations[key] || key;
@ -391,6 +392,9 @@ describe('ContractExecutionChart', () => {
expect(await screen.findByTestId('bar-aborted')).toHaveTextContent(
'Aborted'
);
expect(await screen.findByTestId('bar-running')).toHaveTextContent(
'Running'
);
});
it('should use correct colors for bars', async () => {
@ -409,6 +413,10 @@ describe('ContractExecutionChart', () => {
'data-fill',
'#f79009'
);
expect(screen.getByTestId('bar-running')).toHaveAttribute(
'data-fill',
'#175cd3'
);
});
});
});

View File

@ -30,6 +30,7 @@ export const GRAY_1 = '#A1A1AA';
export const LIGHT_GRAY = '#F1F4F9';
export const INDIGO_1 = '#3538CD';
export const PRIMARY_COLOR = DEFAULT_THEME.primaryColor;
export const BLUE_1 = '#175cd3';
export const BLUE_2 = '#3ca2f4';
export const CHART_BLUE_1 = '#1890FF';
export const RIPTIDE = '#76E9C6';

View File

@ -85,11 +85,16 @@ describe('DataContractUtils', () => {
timestamp: 1234567891000,
contractExecutionStatus: ContractExecutionStatus.Aborted,
},
{
id: '4',
timestamp: 1234567891000,
contractExecutionStatus: ContractExecutionStatus.Running,
},
];
const result = processContractExecutionData(executionData as any);
expect(result).toHaveLength(3);
expect(result).toHaveLength(4);
expect(result[0]).toEqual({
name: '1234567890000_0',
displayTimestamp: 1234567890000,
@ -98,6 +103,7 @@ describe('DataContractUtils', () => {
failed: 0,
success: 1,
aborted: 0,
running: 0,
data: executionData[0],
});
expect(result[1]).toEqual({
@ -108,6 +114,7 @@ describe('DataContractUtils', () => {
failed: 1,
success: 0,
aborted: 0,
running: 0,
data: executionData[1],
});
expect(result[2]).toEqual({
@ -118,8 +125,20 @@ describe('DataContractUtils', () => {
failed: 0,
success: 0,
aborted: 1,
running: 0,
data: executionData[2],
});
expect(result[3]).toEqual({
name: '1234567891000_3',
displayTimestamp: 1234567891000,
value: 1,
status: ContractExecutionStatus.Running,
failed: 0,
success: 0,
aborted: 0,
running: 1,
data: executionData[3],
});
});
it('should handle empty execution data', () => {

View File

@ -236,6 +236,7 @@ export const processContractExecutionData = (
failed: status === ContractExecutionStatus.Failed ? 1 : 0,
success: status === ContractExecutionStatus.Success ? 1 : 0,
aborted: status === ContractExecutionStatus.Aborted ? 1 : 0,
running: status === ContractExecutionStatus.Running ? 1 : 0,
data: item,
};
});