]> source.dussan.org Git - sonarqube.git/commitdiff
add some tests
authorStas Vilchik <vilchiks@gmail.com>
Mon, 13 Apr 2015 13:28:31 +0000 (15:28 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Mon, 13 Apr 2015 13:28:44 +0000 (15:28 +0200)
server/sonar-web/src/test/js/coding-rules-page-spec.js [new file with mode: 0644]
server/sonar-web/src/test/json/coding-rules/show.json [new file with mode: 0644]
server/sonar-web/src/test/json/coding-rules/show2.json [new file with mode: 0644]

diff --git a/server/sonar-web/src/test/js/coding-rules-page-spec.js b/server/sonar-web/src/test/js/coding-rules-page-spec.js
new file mode 100644 (file)
index 0000000..807218d
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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.
+ */
+/* global casper:false */
+
+var lib = require('../lib'),
+    testName = lib.testName('Coding Rules');
+
+lib.initMessages();
+lib.changeWorkingDirectory('coding-rules');
+lib.configureCasper();
+
+
+casper.test.begin(testName('Move Between Rules From Detailed View'), 3, function (test) {
+  casper
+      .start(lib.buildUrl('coding-rules'), function () {
+        lib.setDefaultViewport();
+
+
+        lib.mockRequestFromFile('/api/rules/app', 'app.json');
+        lib.mockRequestFromFile('/api/rules/search', 'search.json');
+        this.showMock = lib.mockRequestFromFile('/api/rules/show', 'show.json');
+      })
+
+      .then(function () {
+        casper.evaluate(function () {
+          require(['/js/coding-rules/app.js']);
+        });
+      })
+
+      .then(function () {
+        casper.waitForSelector('.coding-rule.selected', function () {
+          casper.click('.coding-rule.selected .js-rule');
+        });
+      })
+
+      .then(function () {
+        casper.waitForSelector('.coding-rules-detail-header');
+      })
+
+      .then(function () {
+        test.assertSelectorContains('.coding-rules-detail-header', '".equals()" should not be used to test the values');
+
+        lib.clearRequestMock(this.showMock);
+        this.showMock = lib.mockRequestFromFile('/api/rules/show', 'show2.json');
+
+        casper.click('.js-next');
+        casper.waitForSelectorTextChange('.coding-rules-detail-header');
+      })
+
+      .then(function () {
+        test.assertSelectorContains('.coding-rules-detail-header', '"@Override" annotation should be used on any');
+
+        lib.clearRequestMock(this.showMock);
+        this.showMock = lib.mockRequestFromFile('/api/rules/show', 'show.json');
+
+        casper.click('.js-prev');
+        casper.waitForSelectorTextChange('.coding-rules-detail-header');
+      })
+
+      .then(function () {
+        test.assertSelectorContains('.coding-rules-detail-header', '".equals()" should not be used to test the values');
+      })
+
+      .then(function () {
+        lib.sendCoverage();
+      })
+
+      .run(function () {
+        test.done();
+      });
+});
diff --git a/server/sonar-web/src/test/json/coding-rules/show.json b/server/sonar-web/src/test/json/coding-rules/show.json
new file mode 100644 (file)
index 0000000..f43ca43
--- /dev/null
@@ -0,0 +1,39 @@
+{
+  "rule": {
+    "key": "squid:S2204",
+    "repo": "squid",
+    "name": "\".equals()\" should not be used to test the values of \"Atomic\" classes",
+    "createdAt": "2015-04-13T13:44:13+0200",
+    "severity": "BLOCKER",
+    "status": "READY",
+    "internalKey": "S2204",
+    "isTemplate": false,
+    "tags": [],
+    "sysTags": [
+      "bug"
+    ],
+    "lang": "java",
+    "langName": "Java",
+    "htmlDesc": "",
+    "defaultDebtChar": "RELIABILITY",
+    "defaultDebtSubChar": "DATA_RELIABILITY",
+    "debtChar": "RELIABILITY",
+    "debtSubChar": "DATA_RELIABILITY",
+    "debtCharName": "Reliability",
+    "debtSubCharName": "Data",
+    "defaultDebtRemFnType": "CONSTANT_ISSUE",
+    "defaultDebtRemFnOffset": "5min",
+    "debtOverloaded": false,
+    "debtRemFnType": "CONSTANT_ISSUE",
+    "debtRemFnOffset": "5min",
+    "params": []
+  },
+  "actives": [
+    {
+      "qProfile": "java-sonar-way-68866",
+      "inherit": "NONE",
+      "severity": "BLOCKER",
+      "params": []
+    }
+  ]
+}
diff --git a/server/sonar-web/src/test/json/coding-rules/show2.json b/server/sonar-web/src/test/json/coding-rules/show2.json
new file mode 100644 (file)
index 0000000..26642d4
--- /dev/null
@@ -0,0 +1,37 @@
+{
+  "rule": {
+    "key": "squid:S1161",
+    "repo": "squid",
+    "name": "\"@Override\" annotation should be used on any method overriding (since Java 5) or implementing (since Java 6) another one",
+    "createdAt": "2015-04-13T13:44:13+0200",
+    "severity": "MAJOR",
+    "status": "READY",
+    "internalKey": "S1161",
+    "isTemplate": false,
+    "tags": [],
+    "sysTags": [],
+    "lang": "java",
+    "langName": "Java",
+    "htmlDesc": "",
+    "defaultDebtChar": "MAINTAINABILITY",
+    "defaultDebtSubChar": "UNDERSTANDABILITY",
+    "debtChar": "MAINTAINABILITY",
+    "debtSubChar": "UNDERSTANDABILITY",
+    "debtCharName": "Maintainability",
+    "debtSubCharName": "Understandability",
+    "defaultDebtRemFnType": "LINEAR",
+    "defaultDebtRemFnCoeff": "5min",
+    "debtOverloaded": false,
+    "debtRemFnType": "LINEAR",
+    "debtRemFnCoeff": "5min",
+    "params": []
+  },
+  "actives": [
+    {
+      "qProfile": "java-sonar-way-68866",
+      "inherit": "NONE",
+      "severity": "MAJOR",
+      "params": []
+    }
+  ]
+}