aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-06-20 17:07:51 +0200
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-07-04 14:15:34 +0200
commit33e68fd792458053de7492ba6cba4edf0f517ac7 (patch)
tree1bca71db176a449e3d023a38951569fc6566c208 /server/sonar-web/src/main/js/apps
parent81e84eee8fc89dffa83b8a9a0a8437b94be19f9f (diff)
downloadsonarqube-33e68fd792458053de7492ba6cba4edf0f517ac7.tar.gz
sonarqube-33e68fd792458053de7492ba6cba4edf0f517ac7.zip
SONAR-9440 Fix usage of measures/search_history api
Diffstat (limited to 'server/sonar-web/src/main/js/apps')
-rw-r--r--server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistory.js2
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityGraphs-test.js81
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityGraphs-test.js.snap84
3 files changed, 166 insertions, 1 deletions
diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistory.js b/server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistory.js
index c653d64e7b8..7cbf786922d 100644
--- a/server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistory.js
+++ b/server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistory.js
@@ -76,7 +76,7 @@ export default class MeasureHistory extends React.PureComponent {
if (r.measures.length === 0) {
return [];
}
- return r.measures[0].history.map(analysis => ({
+ return r.measures[0].history.filter(analysis => analysis.value != null).map(analysis => ({
date: moment(analysis.date).toDate(),
value: analysis.value
}));
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityGraphs-test.js b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityGraphs-test.js
new file mode 100644
index 00000000000..57f093bd56d
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityGraphs-test.js
@@ -0,0 +1,81 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import React from 'react';
+import { shallow } from 'enzyme';
+import ProjectActivityGraphs from '../ProjectActivityGraphs';
+
+const ANALYSES = [
+ {
+ key: 'A1',
+ date: '2016-10-27T16:33:50+0200',
+ events: [
+ {
+ key: 'E1',
+ category: 'VERSION',
+ name: '6.5-SNAPSHOT'
+ }
+ ]
+ },
+ {
+ key: 'A2',
+ date: '2016-10-27T12:21:15+0200',
+ events: []
+ },
+ {
+ key: 'A3',
+ date: '2016-10-26T12:17:29+0200',
+ events: [
+ {
+ key: 'E2',
+ category: 'VERSION',
+ name: '6.4'
+ },
+ {
+ key: 'E3',
+ category: 'OTHER',
+ name: 'foo'
+ }
+ ]
+ }
+];
+
+const DEFAULT_PROPS = {
+ analyses: ANALYSES,
+ leakPeriodDate: '2017-05-16T13:50:02+0200',
+ loading: false,
+ measuresHistory: [
+ {
+ metric: 'code_smells',
+ history: [
+ { date: new Date('2016-10-26T12:17:29+0200'), value: '2286' },
+ { date: new Date('2016-10-27T12:21:15+0200'), value: '1749' },
+ { date: new Date('2016-10-27T16:33:50+0200'), value: '500' }
+ ]
+ }
+ ],
+ metricsType: 'INT',
+ project: 'org.sonarsource.sonarqube:sonarqube',
+ query: { category: '', graph: 'overview', project: 'org.sonarsource.sonarqube:sonarqube' },
+ updateQuery: () => {}
+};
+
+it('should render correctly the graph and legends', () => {
+ expect(shallow(<ProjectActivityGraphs {...DEFAULT_PROPS} />)).toMatchSnapshot();
+});
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityGraphs-test.js.snap b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityGraphs-test.js.snap
new file mode 100644
index 00000000000..27471bc95a8
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityGraphs-test.js.snap
@@ -0,0 +1,84 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render correctly the graph and legends 1`] = `
+<div
+ className="project-activity-layout-page-main-inner boxed-group boxed-group-inner"
+>
+ <ProjectActivityGraphsHeader
+ graph="overview"
+ updateQuery={[Function]}
+ />
+ <StaticGraphs
+ analyses={
+ Array [
+ Object {
+ "date": "2016-10-27T16:33:50+0200",
+ "events": Array [
+ Object {
+ "category": "VERSION",
+ "key": "E1",
+ "name": "6.5-SNAPSHOT",
+ },
+ ],
+ "key": "A1",
+ },
+ Object {
+ "date": "2016-10-27T12:21:15+0200",
+ "events": Array [],
+ "key": "A2",
+ },
+ Object {
+ "date": "2016-10-26T12:17:29+0200",
+ "events": Array [
+ Object {
+ "category": "VERSION",
+ "key": "E2",
+ "name": "6.4",
+ },
+ Object {
+ "category": "OTHER",
+ "key": "E3",
+ "name": "foo",
+ },
+ ],
+ "key": "A3",
+ },
+ ]
+ }
+ eventFilter=""
+ leakPeriodDate="2017-05-16T13:50:02+0200"
+ loading={false}
+ measuresHistory={
+ Array [
+ Object {
+ "history": Array [
+ Object {
+ "date": 2016-10-26T10:17:29.000Z,
+ "value": "2286",
+ },
+ Object {
+ "date": 2016-10-27T10:21:15.000Z,
+ "value": "1749",
+ },
+ Object {
+ "date": 2016-10-27T14:33:50.000Z,
+ "value": "500",
+ },
+ ],
+ "metric": "code_smells",
+ },
+ ]
+ }
+ metricsType="INT"
+ project="org.sonarsource.sonarqube:sonarqube"
+ seriesOrder={
+ Array [
+ "bugs",
+ "code_smells",
+ "vulnerabilities",
+ ]
+ }
+ showAreas={false}
+ />
+</div>
+`;