aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-07-26 15:11:41 +0200
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-07-26 16:05:54 +0200
commit104fffdee215450819881fa7ce8a92272c292c84 (patch)
treeb290aa3f2f218d59f8a1847130c9a34fd51db99d
parent3a988bb88a5c66f651682083496159a7495e1acb (diff)
downloadsonarqube-104fffdee215450819881fa7ce8a92272c292c84.tar.gz
sonarqube-104fffdee215450819881fa7ce8a92272c292c84.zip
Display graph on project activity page if there is 2 or more analyses
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.js43
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/utils.js2
2 files changed, 44 insertions, 1 deletions
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<Serie>) =>
- 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;