feat(API): Return null deviation on insights summary if previous period has no data (#14193)

This commit is contained in:
Guillaume Jacquart
2025-03-26 17:56:56 +01:00
committed by GitHub
parent 41b1797a25
commit ffc0a596e0
9 changed files with 79 additions and 24 deletions

View File

@@ -34,15 +34,15 @@ describe('InsightsController', () => {
// ASSERT
expect(response).toEqual({
total: { deviation: 0, unit: 'count', value: 0 },
failed: { deviation: 0, unit: 'count', value: 0 },
failureRate: { deviation: 0, unit: 'ratio', value: 0 },
averageRunTime: { deviation: 0, unit: 'time', value: 0 },
timeSaved: { deviation: 0, unit: 'time', value: 0 },
total: { deviation: null, unit: 'count', value: 0 },
failed: { deviation: null, unit: 'count', value: 0 },
failureRate: { deviation: null, unit: 'ratio', value: 0 },
averageRunTime: { deviation: null, unit: 'time', value: 0 },
timeSaved: { deviation: null, unit: 'time', value: 0 },
});
});
it('should return the insights summary with deviation = current if insights exist only for current period', async () => {
it('should return the insights summary with null deviation if insights exist only for current period', async () => {
// ARRANGE
insightsByPeriodRepository.getPreviousAndCurrentPeriodTypeAggregates.mockResolvedValue([
{ period: 'current', type: TypeToNumber.success, total_value: 20 },
@@ -56,11 +56,11 @@ describe('InsightsController', () => {
// ASSERT
expect(response).toEqual({
total: { deviation: 30, unit: 'count', value: 30 },
failed: { deviation: 10, unit: 'count', value: 10 },
failureRate: { deviation: 0.33, unit: 'ratio', value: 0.33 },
averageRunTime: { deviation: 10, unit: 'time', value: 10 },
timeSaved: { deviation: 10, unit: 'time', value: 10 },
total: { deviation: null, unit: 'count', value: 30 },
failed: { deviation: null, unit: 'count', value: 10 },
failureRate: { deviation: null, unit: 'ratio', value: 0.33 },
averageRunTime: { deviation: null, unit: 'time', value: 10 },
timeSaved: { deviation: null, unit: 'time', value: 10 },
});
});