Sort assets in search indexing app (#18791)

This commit is contained in:
Kenil Shah 2024-11-26 18:11:37 +05:30 committed by GitHub
parent 998cbd1558
commit b3679f0cea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 7 deletions

View File

@ -22,11 +22,12 @@ describe('ApplicationUtils tests', () => {
it('getEntityStatsData should return stats data in array', () => {
const resultData = getEntityStatsData(MOCK_APPLICATION_ENTITY_STATS);
expect(resultData).toEqual(
MOCK_APPLICATION_ENTITY_STATS_DATA.map((data) => ({
...data,
name: upperFirst(data.name),
}))
);
const sortedMockData = MOCK_APPLICATION_ENTITY_STATS_DATA.map((data) => ({
...data,
name: upperFirst(data.name),
})).sort((a, b) => a.name.localeCompare(b.name));
// Verify the result matches the sorted mock data
expect(resultData).toEqual(sortedMockData);
});
});

View File

@ -60,7 +60,7 @@ export const getStatusFromPipelineState = (status: PipelineState) => {
export const getEntityStatsData = (data: EntityStats): EntityStatsData[] => {
const filteredRow = ['failedRecords', 'totalRecords', 'successRecords'];
return Object.keys(data).reduce((acc, key) => {
const result = Object.keys(data).reduce((acc, key) => {
if (filteredRow.includes(key)) {
return acc;
}
@ -73,4 +73,6 @@ export const getEntityStatsData = (data: EntityStats): EntityStatsData[] => {
},
];
}, [] as EntityStatsData[]);
return result.sort((a, b) => a.name.localeCompare(b.name));
};