From: Stas Vilchik Date: Mon, 13 Apr 2015 13:28:31 +0000 (+0200) Subject: add some tests X-Git-Tag: 5.2-RC1~2299 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fd9f6dd6b14b00355d4ac3fc20fa6ee541b147c4;p=sonarqube.git add some tests --- 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 index 00000000000..807218ddf22 --- /dev/null +++ b/server/sonar-web/src/test/js/coding-rules-page-spec.js @@ -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 index 00000000000..f43ca43797e --- /dev/null +++ b/server/sonar-web/src/test/json/coding-rules/show.json @@ -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 index 00000000000..26642d4c5b2 --- /dev/null +++ b/server/sonar-web/src/test/json/coding-rules/show2.json @@ -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": [] + } + ] +}