mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-21 03:42:16 +00:00
feat(API): Return null deviation on insights summary if previous period has no data (#14193)
This commit is contained in:
committed by
GitHub
parent
41b1797a25
commit
ffc0a596e0
@@ -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 },
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user