From 104fffdee215450819881fa7ce8a92272c292c84 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Wed, 26 Jul 2017 15:11:41 +0200 Subject: [PATCH] Display graph on project activity page if there is 2 or more analyses --- .../projectActivity/__tests__/utils-test.js | 43 +++++++++++++++++++ .../src/main/js/apps/projectActivity/utils.js | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.js b/server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.js index 77fde465386..6790f43f4da 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.js @@ -225,3 +225,46 @@ describe('serializeUrlQuery', () => { }); }); }); + +describe('hasHistoryData', () => { + it('should correctly detect if there is history data', () => { + expect( + utils.hasHistoryData([ + { + name: 'foo', + type: 'INT', + data: [ + { x: new Date('2017-04-27T08:21:32+0200'), y: 2 }, + { x: new Date('2017-04-30T23:06:24+0200'), y: 2 } + ] + } + ]) + ).toBeTruthy(); + expect( + utils.hasHistoryData([ + { + name: 'foo', + type: 'INT', + data: [] + }, + { + name: 'bar', + type: 'INT', + data: [ + { x: new Date('2017-04-27T08:21:32+0200'), y: 2 }, + { x: new Date('2017-04-30T23:06:24+0200'), y: 2 } + ] + } + ]) + ).toBeTruthy(); + expect( + utils.hasHistoryData([ + { + name: 'bar', + type: 'INT', + data: [{ x: new Date('2017-04-27T08:21:32+0200'), y: 2 }] + } + ]) + ).toBeFalsy(); + }); +}); diff --git a/server/sonar-web/src/main/js/apps/projectActivity/utils.js b/server/sonar-web/src/main/js/apps/projectActivity/utils.js index 49cec35fd5a..63558f363cf 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/utils.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/utils.js @@ -64,7 +64,7 @@ export const datesQueryChanged = (prevQuery: Query, nextQuery: Query): boolean = export const hasDataValues = (serie: Serie) => serie.data.some(point => point.y || point.y === 0); export const hasHistoryData = (series: Array) => - series.some(serie => serie.data && serie.data.length > 2); + series.some(serie => serie.data && serie.data.length > 1); export const historyQueryChanged = (prevQuery: Query, nextQuery: Query): boolean => prevQuery.graph !== nextQuery.graph; -- 2.39.5