From: Grégoire Aubert Date: Wed, 26 Jul 2017 13:11:41 +0000 (+0200) Subject: Display graph on project activity page if there is 2 or more analyses X-Git-Tag: 6.6-RC1~817 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=104fffdee215450819881fa7ce8a92272c292c84;p=sonarqube.git Display graph on project activity page if there is 2 or more analyses --- 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;