]> source.dussan.org Git - sonarqube.git/commitdiff
Display graph on project activity page if there is 2 or more analyses
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Wed, 26 Jul 2017 13:11:41 +0000 (15:11 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Wed, 26 Jul 2017 14:05:54 +0000 (16:05 +0200)
server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.js
server/sonar-web/src/main/js/apps/projectActivity/utils.js

index 77fde4653861972cc6f15cca2c297883edb4102f..6790f43f4da37cca280ae24e356a7bac11cfdeb4 100644 (file)
@@ -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();
+  });
+});
index 49cec35fd5a778468fad53e2d47959981e870c85..63558f363cf519a2f07b1971f08d319cc2fa1436 100644 (file)
@@ -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;