From: Stas Vilchik Date: Tue, 23 Dec 2014 12:32:10 +0000 (+0100) Subject: SONAR-5820 Update MTs X-Git-Tag: latest-silver-master-#65~428 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ee22b2b77e1aac15130ec87b59e8f795418784bf;p=sonarqube.git SONAR-5820 Update MTs --- diff --git a/server/sonar-web/src/main/hbs/coding-rules/coding-rules-workspace-list-item.hbs b/server/sonar-web/src/main/hbs/coding-rules/coding-rules-workspace-list-item.hbs index fffa5b5e9cc..3d7a6e67f2d 100644 --- a/server/sonar-web/src/main/hbs/coding-rules/coding-rules-workspace-list-item.hbs +++ b/server/sonar-web/src/main/hbs/coding-rules/coding-rules-workspace-list-item.hbs @@ -4,10 +4,10 @@
{{langName}} - {{#notEmpty sysTags}} + {{#notEmpty tags}}     - {{#each sysTags}} + {{#each tags}} {{this}} {{/each}} {{/notEmpty}} diff --git a/server/sonar-web/src/main/js/coding-rules/workspace-list-item-view.js b/server/sonar-web/src/main/js/coding-rules/workspace-list-item-view.js index 890f05d2af9..c2827277d4b 100644 --- a/server/sonar-web/src/main/js/coding-rules/workspace-list-item-view.js +++ b/server/sonar-web/src/main/js/coding-rules/workspace-list-item-view.js @@ -22,6 +22,12 @@ define([ openRule: function () { this.options.app.controller.showDetails(this.model); + }, + + serializeData: function () { + return _.extend(WorkspaceListItemView.prototype.serializeData.apply(this, arguments), { + tags: _.union(this.model.get('sysTags'), this.model.get('tags')) + }); } }); diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-details.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-details.js new file mode 100644 index 00000000000..0598f9019fd --- /dev/null +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-details.js @@ -0,0 +1,58 @@ +/* global casper:false */ + +var lib = require('../lib'); + +lib.initMessages(); +lib.changeWorkingDirectory('coding-rules-page-should-show-details'); + + +casper.test.begin('coding-rules-page-should-show-details', 17, function (test) { + casper + .start(lib.buildUrl('coding-rules'), function () { + lib.setDefaultViewport(); + + lib.mockRequest('/api/l10n/index', '{}'); + lib.mockRequestFromFile('/api/rules/app', 'app.json'); + lib.mockRequestFromFile('/api/rules/search', 'search.json'); + lib.mockRequestFromFile('/api/rules/show', 'show.json'); + }) + + .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('.search-navigator-workspace-details', + 'Throwable and Error classes should not be caught'); + + test.assertSelectorContains('.search-navigator-workspace-details', 'squid:S1181'); + test.assertExists('.coding-rules-detail-properties .icon-severity-blocker'); + test.assertSelectorContains('.coding-rules-detail-properties', 'error-handling'); + test.assertSelectorContains('.coding-rules-detail-properties', '2013'); + test.assertSelectorContains('.coding-rules-detail-properties', 'SonarQube (Java)'); + + test.assertSelectorContains('.coding-rules-detail-description', 'is the superclass of all errors and'); + test.assertSelectorContains('.coding-rules-detail-description', 'its subclasses should be caught.'); + test.assertSelectorContains('.coding-rules-detail-description', 'Noncompliant Code Example'); + test.assertSelectorContains('.coding-rules-detail-description', 'Compliant Solution'); + + test.assertSelectorContains('.coding-rules-detail-parameters', 'max'); + test.assertSelectorContains('.coding-rules-detail-parameters', 'Maximum authorized number of parameters'); + test.assertSelectorContains('.coding-rules-detail-parameters', '7'); + + test.assertElementCount('.coding-rules-detail-quality-profile-name', 6); + test.assertSelectorContains('.coding-rules-detail-quality-profile-name', 'Default - Top'); + test.assertElementCount('.coding-rules-detail-quality-profile-inheritance', 4); + test.assertSelectorContains('.coding-rules-detail-quality-profile-inheritance', 'Default - Top'); + }) + + .run(function () { + test.done(); + }); +}); diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-details/app.json b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-details/app.json new file mode 100644 index 00000000000..4f3319c8707 --- /dev/null +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-details/app.json @@ -0,0 +1,168 @@ +{ + "canWrite": false, + "qualityprofiles": [ + { + "key": "java-default-with-mojo-conventions-49307", + "name": "Default - Maven Conventions", + "lang": "java", + "parentKey": "java-top-profile-without-formatting-conventions-50037" + }, + { + "key": "java-default-with-sonarsource-conventions-27339", + "name": "Default - SonarSource conventions", + "lang": "java", + "parentKey": "java-top-profile-without-formatting-conventions-50037" + }, + { + "key": "java-top-profile-without-formatting-conventions-50037", + "name": "Default - Top", + "lang": "java" + }, + { + "key": "java-findbugs-14954", + "name": "FindBugs", + "lang": "java" + }, + { + "key": "java-for-sq-java-plugin-only-92289", + "name": "For SQ Java Plugin Only", + "lang": "java", + "parentKey": "java-default-with-sonarsource-conventions-27339" + }, + { + "key": "java-for-sq-only-95381", + "name": "For SQ Only", + "lang": "java", + "parentKey": "java-default-with-sonarsource-conventions-27339" + }, + { + "key": "php-psr-2-06315", + "name": "PSR-2", + "lang": "php" + }, + { + "key": "java-sonar-way-80423", + "name": "Sonar way", + "lang": "java" + }, + { + "key": "js-sonar-way", + "name": "Sonar way", + "lang": "js" + }, + { + "key": "php-sonar-way-05548", + "name": "Sonar way", + "lang": "php" + }, + { + "key": "py-sonar-way-80265", + "name": "Sonar way", + "lang": "py" + }, + { + "key": "java-without-findbugs", + "name": "Without Findbugs", + "lang": "java" + } + ], + "languages": { + "py": "Python", + "js": "JavaScript", + "php": "PHP", + "java": "Java" + }, + "repositories": [ + { + "key": "common-java", + "name": "Common SonarQube", + "language": "java" + }, + { + "key": "common-js", + "name": "Common SonarQube", + "language": "js" + }, + { + "key": "common-php", + "name": "Common SonarQube", + "language": "php" + }, + { + "key": "common-py", + "name": "Common SonarQube", + "language": "py" + }, + { + "key": "Pylint", + "name": "Pylint", + "language": "py" + }, + { + "key": "javascript", + "name": "SonarQube", + "language": "js" + }, + { + "key": "php", + "name": "SonarQube", + "language": "php" + }, + { + "key": "python", + "name": "SonarQube", + "language": "py" + }, + { + "key": "squid", + "name": "SonarQube", + "language": "java" + } + ], + "statuses": { + "BETA": "Beta", + "DEPRECATED": "Deprecated", + "READY": "Ready" + }, + "characteristics": { + "UNDERSTANDABILITY": "Maintainability: Understandability", + "MAINTAINABILITY": "Maintainability", + "TIME_ZONE_RELATED_PORTABILITY": "Portability: Time zone related portability", + "READABILITY": "Maintainability: Readability", + "SECURITY_FEATURES": "Security: Security features", + "ARCHITECTURE_RELIABILITY": "Reliability: Architecture related reliability", + "OS_RELATED_PORTABILITY": "Portability: OS related portability", + "EXCEPTION_HANDLING": "Reliability: Exception handling", + "LOGIC_CHANGEABILITY": "Changeability: Logic related changeability", + "SOFTWARE_RELATED_PORTABILITY": "Portability: Software related portability", + "INPUT_VALIDATION_AND_REPRESENTATION": "Security: Input validation and representation", + "LANGUAGE_RELATED_PORTABILITY": "Portability: Language related portability", + "ERRORS": "Security: Errors", + "SECURITY": "Security", + "RELIABILITY": "Reliability", + "PORTABILITY": "Portability", + "HARDWARE_RELATED_PORTABILITY": "Portability: Hardware related portability", + "SYNCHRONIZATION_RELIABILITY": "Reliability: Synchronization related reliability", + "TRANSPORTABILITY": "Reusability: Transportability", + "COMPILER_RELATED_PORTABILITY": "Portability: Compiler related portability", + "RESOURCE_RELIABILITY": "Reliability: Resource", + "CPU_EFFICIENCY": "Efficiency: Processor use", + "EFFICIENCY": "Efficiency", + "CHANGEABILITY": "Changeability", + "DATA_CHANGEABILITY": "Changeability: Data related changeability", + "API_ABUSE": "Security: API abuse", + "ARCHITECTURE_CHANGEABILITY": "Changeability: Architecture related changeability", + "UNIT_TESTS": "Reliability: Unit tests", + "INSTRUCTION_RELIABILITY": "Reliability: Instruction related reliability", + "REUSABILITY": "Reusability", + "MODULARITY": "Reusability: Modularity", + "UNIT_TESTABILITY": "Testability: Unit level testability", + "TESTABILITY": "Testability", + "INTEGRATION_TESTABILITY": "Testability: Integration level testability", + "NETWORK_USE": "Efficiency: Network use", + "MEMORY_EFFICIENCY": "Efficiency: Memory use", + "DATA_RELIABILITY": "Reliability: Data related reliability", + "FAULT_TOLERANCE": "Reliability: Fault tolerance", + "LOGIC_RELIABILITY": "Reliability: Logic related reliability" + } +} diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-details/search.json b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-details/search.json new file mode 100644 index 00000000000..b5a6bc269b9 --- /dev/null +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-details/search.json @@ -0,0 +1,171 @@ +{ + "total": 10, + "p": 1, + "ps": 200, + "rules": [ + { + "key": "squid:S1181", + "name": "Throwable and Error classes should not be caught", + "lang": "java", + "langName": "Java", + "sysTags": [ + "error-handling" + ], + "tags": [] + }, + { + "key": "squid:S1849", + "name": "\"Iterator.hasNext()\" should not call \"Iterator.next()\"", + "lang": "java", + "langName": "Java", + "sysTags": [ + "bug" + ], + "tags": [] + }, + { + "key": "squid:S1844", + "name": "\"Object.wait(...)\" should never be called on objects that implement \"java.util.concurrent.locks.Condition\"", + "lang": "java", + "langName": "Java", + "sysTags": [ + "bug", + "pitfall" + ], + "tags": [] + }, + { + "key": "squid:S2258", + "name": "\"javax.crypto.NullCipher\" should not be used for anything other than testing", + "lang": "java", + "langName": "Java", + "sysTags": [ + "cwe", + "owasp-top10", + "security" + ], + "tags": [] + }, + { + "key": "squid:S2251", + "name": "A \"for\" loop update clause should move the counter in the right direction", + "lang": "java", + "langName": "Java", + "sysTags": [ + "bug" + ], + "tags": [] + }, + { + "key": "squid:ObjectFinalizeOverridenCallsSuperFinalizeCheck", + "name": "super.finalize() should be called at the end of Object.finalize() implementations", + "lang": "java", + "langName": "Java", + "sysTags": [ + "bug" + ], + "tags": [] + }, + { + "key": "squid:S1143", + "name": "Return statements should not occur in finally blocks", + "lang": "java", + "langName": "Java", + "sysTags": [ + "bug" + ], + "tags": [] + }, + { + "key": "squid:S1206", + "name": "\"equals(Object obj)\" and \"hashCode()\" should be overridden in pairs", + "lang": "java", + "langName": "Java", + "sysTags": [ + "bug" + ], + "tags": [] + }, + { + "key": "squid:S1451", + "name": "Copyright and license headers should be defined in all source files", + "lang": "java", + "langName": "Java", + "sysTags": [ + "convention" + ], + "tags": [] + }, + { + "key": "squid:S1697", + "name": "Short-circuit logic should be used to prevent null pointer dereferences in conditionals", + "lang": "java", + "langName": "Java", + "sysTags": [ + "bug" + ], + "tags": [] + } + ], + "facets": [ + { + "property": "tags", + "values": [ + { + "val": "bug", + "count": 7 + }, + { + "val": "convention", + "count": 1 + }, + { + "val": "cwe", + "count": 1 + }, + { + "val": "error-handling", + "count": 1 + }, + { + "val": "owasp-top10", + "count": 1 + }, + { + "val": "pitfall", + "count": 1 + }, + { + "val": "security", + "count": 1 + } + ] + }, + { + "property": "languages", + "values": [ + { + "val": "java", + "count": 10 + }, + { + "val": "js", + "count": 6 + }, + { + "val": "php", + "count": 2 + } + ] + }, + { + "property": "repositories", + "values": [ + { + "val": "squid", + "count": 10 + } + ] + } + ] +} diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-details/show.json b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-details/show.json new file mode 100644 index 00000000000..274b587bfb2 --- /dev/null +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-details/show.json @@ -0,0 +1,76 @@ +{ + "rule": { + "key": "squid:S1181", + "repo": "squid", + "name": "Throwable and Error classes should not be caught", + "createdAt": "2013-08-09T14:40:54+0200", + "severity": "BLOCKER", + "status": "READY", + "internalKey": "S1181", + "isTemplate": false, + "tags": [], + "sysTags": [ + "error-handling" + ], + "lang": "java", + "langName": "Java", + "htmlDesc": "

\nThrowable is the superclass of all errors and exceptions in Java.\nError is the superclass of all errors which are not meant to be caught by applications.\n

\n\n

\nCatching either Throwable or Error will also catch OutOfMemoryError or InternalError from which an application should not attempt to recover.\n

\n\n

Only Exception and its subclasses should be caught.

\n\n

Noncompliant Code Example

\n\n
\ntry { /* ... */ } catch (Throwable t) { /* ... */ }\ntry { /* ... */ } catch (Error e) { /* ... */ } \n
\n\n

Compliant Solution

\n\n
\ntry { /* ... */ } catch (Exception e) { /* ... */ }  \ntry { /* ... */ } catch (RuntimeException e) { /* ... */ }  \ntry { /* ... */ } catch (MyException e) { /* ... */ }  \n
", + "defaultDebtChar": "RELIABILITY", + "defaultDebtSubChar": "EXCEPTION_HANDLING", + "debtChar": "RELIABILITY", + "debtSubChar": "EXCEPTION_HANDLING", + "debtCharName": "Reliability", + "debtSubCharName": "Exception handling", + "defaultDebtRemFnType": "CONSTANT_ISSUE", + "defaultDebtRemFnOffset": "20min", + "debtOverloaded": true, + "debtRemFnType": "LINEAR", + "debtRemFnCoeff": "20min", + "params": [ + { + "key": "max", + "htmlDesc": "Maximum authorized number of parameters", + "type": "INTEGER", + "defaultValue": "7" + } + ] + }, + "actives": [ + { + "qProfile": "java-top-profile-without-formatting-conventions-50037", + "inherit": "NONE", + "severity": "BLOCKER", + "params": [] + }, + { + "qProfile": "java-default-with-sonarsource-conventions-27339", + "inherit": "INHERITED", + "severity": "BLOCKER", + "params": [] + }, + { + "qProfile": "java-for-sq-java-plugin-only-92289", + "inherit": "INHERITED", + "severity": "BLOCKER", + "params": [] + }, + { + "qProfile": "java-for-sq-only-95381", + "inherit": "INHERITED", + "severity": "BLOCKER", + "params": [] + }, + { + "qProfile": "java-default-with-mojo-conventions-49307", + "inherit": "INHERITED", + "severity": "BLOCKER", + "params": [] + }, + { + "qProfile": "java-sonar-way-80423", + "inherit": "NONE", + "severity": "BLOCKER", + "params": [] + } + ] +} diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-facets.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-facets.js new file mode 100644 index 00000000000..2ad4cf7b076 --- /dev/null +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-facets.js @@ -0,0 +1,30 @@ +/* global casper:false */ + +var lib = require('../lib'); + +lib.initMessages(); +lib.changeWorkingDirectory('coding-rules'); + + +casper.test.begin('coding-rules-page-should-show-facets', 1, function (test) { + casper + .start(lib.buildUrl('coding-rules'), function () { + lib.setDefaultViewport(); + + lib.mockRequest('/api/l10n/index', '{}'); + lib.mockRequestFromFile('/api/rules/app', 'app.json'); + lib.mockRequestFromFile('/api/rules/search', 'search.json'); + }) + + .then(function () { + casper.waitForSelector('.search-navigator-facet-box'); + }) + + .then(function () { + test.assertElementCount('.search-navigator-facet-box', 7); + }) + + .run(function () { + test.done(); + }); +}); diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-rule.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-rule.js new file mode 100644 index 00000000000..f4e71de5e8d --- /dev/null +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-rule.js @@ -0,0 +1,36 @@ +/* global casper:false */ + +var lib = require('../lib'); + +lib.initMessages(); +lib.changeWorkingDirectory('coding-rules'); + + +casper.test.begin('coding-rules-page-should-show-rule', 7, function (test) { + casper + .start(lib.buildUrl('coding-rules'), function () { + lib.setDefaultViewport(); + + lib.mockRequest('/api/l10n/index', '{}'); + lib.mockRequestFromFile('/api/rules/app', 'app.json'); + lib.mockRequestFromFile('/api/rules/search', 'search.json'); + }) + + .then(function () { + casper.waitForSelector('.coding-rule.selected'); + }) + + .then(function () { + test.assertSelectorContains('.coding-rule.selected', 'Values passed to SQL commands should be sanitized'); + test.assertSelectorContains('.coding-rule.selected', 'Java'); + test.assertSelectorContains('.coding-rule.selected', 'cwe'); + test.assertSelectorContains('.coding-rule.selected', 'owasp-top10'); + test.assertSelectorContains('.coding-rule.selected', 'security'); + test.assertSelectorContains('.coding-rule.selected', 'sql'); + test.assertSelectorContains('.coding-rule.selected', 'custom-tag'); + }) + + .run(function () { + test.done(); + }); +}); diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-rules.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-rules.js new file mode 100644 index 00000000000..8b2fa3bceed --- /dev/null +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-rules.js @@ -0,0 +1,33 @@ +/* global casper:false */ + +var lib = require('../lib'); + +lib.initMessages(); +lib.changeWorkingDirectory('coding-rules'); + + +casper.test.begin('coding-rules-page-should-show-rules', 4, function (test) { + casper + .start(lib.buildUrl('coding-rules'), function () { + lib.setDefaultViewport(); + + lib.mockRequest('/api/l10n/index', '{}'); + lib.mockRequestFromFile('/api/rules/app', 'app.json'); + lib.mockRequestFromFile('/api/rules/search', 'search.json'); + }) + + .then(function () { + casper.waitForSelector('.coding-rule'); + }) + + .then(function () { + test.assertElementCount('.coding-rule', 25); + test.assertSelectorContains('.coding-rule', 'Values passed to SQL commands should be sanitized'); + test.assertSelectorContains('.coding-rule', 'An open curly brace should be located at the beginning of a line'); + test.assertSelectorContains('#coding-rules-total', '609'); + }) + + .run(function () { + test.done(); + }); +}); diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec.js index afbc1bb8510..4c6f2f75adf 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-spec.js @@ -6,137 +6,12 @@ lib.initMessages(); lib.changeWorkingDirectory('coding-rules-spec'); -casper.test.begin(testName('Readonly Tests'), function suite(test) { - - var appId = null; - var showId = null; - - casper.start(lib.buildUrl('coding-rules'), function() { - lib.mockRequest('/api/l10n/index', '{}'); - lib.mockRequestFromFile('/api/rules/app', 'app.json'); - lib.mockRequestFromFile('/api/rules/tags', 'tags.json'); - lib.mockRequestFromFile('/api/rules/search', 'search_initial.json'); - showId = lib.mockRequestFromFile('/api/rules/show', 'show_x1.json'); - }); - - - casper.waitWhileSelector("div#coding-rules-page-loader", function checkInitialPageLoad() { - - casper.waitForSelector('.navigator-header', function checkHeader() { - test.assertExists('.navigator-header h1'); - test.assertExists('button#coding-rules-new-search'); - test.assertDoesntExist('button#coding-rules-create-rule'); - }); - - - casper.waitForSelector('.navigator-filters', function checkDefaultFilters() { - test.assertVisible('input[type="text"].query-filter-input'); - test.assertElementCount('.navigator-filter', 15); - test.assertElementCount('.navigator-filter-optional', 12 /* Only query, qProfile and 'More' are visible by default */); - test.assertVisible('button.navigator-filter-submit'); - - - casper.click('.navigator-filter-more-criteria'); - casper.waitForSelector('.navigator-filter-details.active', function checkTagsAreOrdered() { - casper.click('.navigator-filter-details.active label[data-property="tags"]'); - test.assertSelectorHasText('.navigator-filter[data-property="tags"] option:nth-child(1)', 'brain-overload'); - test.assertSelectorHasText('.navigator-filter[data-property="tags"] option:nth-child(11)', 'unused'); - casper.click('.navigator-filter.active>.navigator-filter-disable'); - }); - - // Check repositories are sorted by name, then language - test.assertSelectorHasText('#filter-repositories li:nth-child(1) span:nth-child(1)', 'Common SonarQube'); - test.assertSelectorHasText('#filter-repositories li:nth-child(1) span:nth-child(2)', 'CoffeeScript'); - test.assertSelectorHasText('#filter-repositories li:nth-child(2) span:nth-child(1)', 'Common SonarQube'); - test.assertSelectorHasText('#filter-repositories li:nth-child(2) span:nth-child(2)', 'Java'); - test.assertSelectorHasText('#filter-repositories li:nth-child(3) span:nth-child(1)', 'Manual Rules'); - test.assertSelectorHasText('#filter-repositories li:nth-child(3) span:nth-child(2)', 'None'); - test.assertSelectorHasText('#filter-repositories li:nth-child(4) span:nth-child(1)', 'SonarQube'); - test.assertSelectorHasText('#filter-repositories li:nth-child(4) span:nth-child(2)', 'CoffeeScript'); - test.assertSelectorHasText('#filter-repositories li:nth-child(5) span:nth-child(1)', 'SonarQube'); - test.assertSelectorHasText('#filter-repositories li:nth-child(5) span:nth-child(2)', 'Java'); - test.assertSelectorHasText('#filter-repositories li:nth-child(6) span:nth-child(1)', 'SonarQube'); - test.assertSelectorHasText('#filter-repositories li:nth-child(6) span:nth-child(2)', 'Xoo'); - }); - - - casper.waitForSelector('div.navigator-facets-list-item:nth-child(2)', function checkFacets() { - test.assertSelectorHasText('div.navigator-facets-list-item:nth-child(2) a:nth-child(1)', 'Java SonarQube'); - test.assertSelectorHasText('div.navigator-facets-list-item:nth-child(2) a:nth-child(2)', 'Java Common SonarQube'); - test.assertSelectorHasText('div.navigator-facets-list-item:nth-child(2) a:nth-child(3)', 'CoffeeScript SonarQube'); - test.assertSelectorHasText('div.navigator-facets-list-item:nth-child(2) a:nth-child(4)', 'CoffeeScript Common SonarQube'); - test.assertSelectorHasText('div.navigator-facets-list-item:nth-child(2) a:nth-child(5)', 'Xoo SonarQube'); - }); - - - casper.waitForSelector('li.active', function checkResultsList() { - test.assertElementCount('ol.navigator-results-list li', 10); - test.assertElementCount('li.active', 1); - test.assertSelectorHasText('ol.navigator-results-list li.active', 'Xoo'); - test.assertSelectorHasText('ol.navigator-results-list li.active', 'No empty line'); - test.assertSelectorHasText('ol.navigator-results-list li.active', 'BETA'); - }); - - - casper.waitForSelector('h3.coding-rules-detail-header', function showFirstRule() { - test.assertSelectorHasText('h3.coding-rules-detail-header', 'No empty line'); - test.assertSelectorHasText('.navigator-details .subtitle', 'squid-xoo:x1'); - test.assertSelectorHasText('.coding-rules-detail-property:nth-child(1)', 'severity.MINOR'); - test.assertSelectorHasText('.coding-rules-detail-property:nth-child(2)', 'BETA'); - test.assertSelectorHasText('.coding-rules-detail-property:nth-child(3)', 'convention, pitfall'); - test.assertSelectorHasText('.coding-rules-detail-property:nth-child(4)', 'Testability > Integration level testability'); - test.assertSelectorHasText('.coding-rules-detail-property:nth-child(6)', 'SonarQube (Xoo)'); - - - casper.click('.coding-rules-subcharacteristic'); - casper.waitForSelector('.coding-rules-debt-popup', function checkDebtPopup() { - test.assertElementCount('ul.bubble-popup-list li', 3); - test.assertSelectorHasText('.bubble-popup-list li:nth-child(1)', 'LINEAR_OFFSET'); - test.assertSelectorHasText('.bubble-popup-list li:nth-child(2)', '1h'); - test.assertSelectorHasText('.bubble-popup-list li:nth-child(3)', '30min'); - }); - - - test.assertDoesntExist('button#coding-rules-detail-extend-description'); - - - casper.then(function checkParameters() { - test.assertElementCount('.coding-rules-detail-parameter', 3); - test.assertVisible('.coding-rules-detail-parameter-description[data-key=acceptWhitespace]'); - test.assertSelectorHasText('.coding-rules-detail-parameter-description[data-key=acceptWhitespace]', 'Accept whitespace'); - casper.click('.coding-rules-detail-parameter:nth-child(1) .coding-rules-detail-parameter-name'); - test.assertNotVisible('.coding-rules-detail-parameter-description[data-key=acceptWhitespace]'); - casper.click('.coding-rules-detail-parameter:nth-child(1) .coding-rules-detail-parameter-name'); - test.assertVisible('.coding-rules-detail-parameter-description[data-key=acceptWhitespace]'); - }); - }); - }); - - casper.then(function showDeprecated() { - lib.clearRequestMock(showId); - showId = lib.mockRequestFromFile('/api/rules/show', 'show_deprecated.json'); - - casper.click('div[name="squid:S0001"]'); - - casper.waitWhileSelector('.navigator-details i.spinner'); - casper.waitForSelector('h3.coding-rules-detail-header', function() { - test.assertSelectorHasText('h3.coding-rules-detail-header', 'Deprecated rule'); - }); - - }); - - casper.run(function() { - test.done(); - }); -}); - - casper.test.begin(testName('Admin Tests'), function suite(test) { var showId = null; var updateId = null; - casper.start(lib.buildUrl('coding-rules'), function() { + casper.start(lib.buildUrl('coding-rules-old'), function() { lib.mockRequest('/api/l10n/index', '{}'); lib.mockRequestFromFile('/api/rules/app', 'app_admin.json'); lib.mockRequestFromFile('/api/rules/tags', 'tags.json'); @@ -186,7 +61,7 @@ casper.test.begin(testName('Activation Tests'), function suite(test) { var showId = null; var activateId = null; - casper.start(lib.buildUrl('coding-rules#rule_key=squid-xoo:x1'), function() { + casper.start(lib.buildUrl('coding-rules-old#rule_key=squid-xoo:x1'), function() { lib.clearRequestMocks(); lib.mockRequest('/api/l10n/index', '{}'); lib.mockRequestFromFile('/api/rules/app', 'app_admin.json'); @@ -296,7 +171,7 @@ casper.test.begin(testName('Activation Tests'), function suite(test) { casper.test.begin(testName('Tag Navigation Test'), function suite(test) { - casper.start(lib.buildUrl('coding-rules#tags=polop,bug,pilip,unused,palap'), function() { + casper.start(lib.buildUrl('coding-rules-old#tags=polop,bug,pilip,unused,palap'), function() { lib.clearRequestMocks(); lib.mockRequest('/api/l10n/index', '{}'); lib.mockRequestFromFile('/api/rules/app', 'app_admin.json'); diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules/app.json b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules/app.json new file mode 100644 index 00000000000..4f3319c8707 --- /dev/null +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules/app.json @@ -0,0 +1,168 @@ +{ + "canWrite": false, + "qualityprofiles": [ + { + "key": "java-default-with-mojo-conventions-49307", + "name": "Default - Maven Conventions", + "lang": "java", + "parentKey": "java-top-profile-without-formatting-conventions-50037" + }, + { + "key": "java-default-with-sonarsource-conventions-27339", + "name": "Default - SonarSource conventions", + "lang": "java", + "parentKey": "java-top-profile-without-formatting-conventions-50037" + }, + { + "key": "java-top-profile-without-formatting-conventions-50037", + "name": "Default - Top", + "lang": "java" + }, + { + "key": "java-findbugs-14954", + "name": "FindBugs", + "lang": "java" + }, + { + "key": "java-for-sq-java-plugin-only-92289", + "name": "For SQ Java Plugin Only", + "lang": "java", + "parentKey": "java-default-with-sonarsource-conventions-27339" + }, + { + "key": "java-for-sq-only-95381", + "name": "For SQ Only", + "lang": "java", + "parentKey": "java-default-with-sonarsource-conventions-27339" + }, + { + "key": "php-psr-2-06315", + "name": "PSR-2", + "lang": "php" + }, + { + "key": "java-sonar-way-80423", + "name": "Sonar way", + "lang": "java" + }, + { + "key": "js-sonar-way", + "name": "Sonar way", + "lang": "js" + }, + { + "key": "php-sonar-way-05548", + "name": "Sonar way", + "lang": "php" + }, + { + "key": "py-sonar-way-80265", + "name": "Sonar way", + "lang": "py" + }, + { + "key": "java-without-findbugs", + "name": "Without Findbugs", + "lang": "java" + } + ], + "languages": { + "py": "Python", + "js": "JavaScript", + "php": "PHP", + "java": "Java" + }, + "repositories": [ + { + "key": "common-java", + "name": "Common SonarQube", + "language": "java" + }, + { + "key": "common-js", + "name": "Common SonarQube", + "language": "js" + }, + { + "key": "common-php", + "name": "Common SonarQube", + "language": "php" + }, + { + "key": "common-py", + "name": "Common SonarQube", + "language": "py" + }, + { + "key": "Pylint", + "name": "Pylint", + "language": "py" + }, + { + "key": "javascript", + "name": "SonarQube", + "language": "js" + }, + { + "key": "php", + "name": "SonarQube", + "language": "php" + }, + { + "key": "python", + "name": "SonarQube", + "language": "py" + }, + { + "key": "squid", + "name": "SonarQube", + "language": "java" + } + ], + "statuses": { + "BETA": "Beta", + "DEPRECATED": "Deprecated", + "READY": "Ready" + }, + "characteristics": { + "UNDERSTANDABILITY": "Maintainability: Understandability", + "MAINTAINABILITY": "Maintainability", + "TIME_ZONE_RELATED_PORTABILITY": "Portability: Time zone related portability", + "READABILITY": "Maintainability: Readability", + "SECURITY_FEATURES": "Security: Security features", + "ARCHITECTURE_RELIABILITY": "Reliability: Architecture related reliability", + "OS_RELATED_PORTABILITY": "Portability: OS related portability", + "EXCEPTION_HANDLING": "Reliability: Exception handling", + "LOGIC_CHANGEABILITY": "Changeability: Logic related changeability", + "SOFTWARE_RELATED_PORTABILITY": "Portability: Software related portability", + "INPUT_VALIDATION_AND_REPRESENTATION": "Security: Input validation and representation", + "LANGUAGE_RELATED_PORTABILITY": "Portability: Language related portability", + "ERRORS": "Security: Errors", + "SECURITY": "Security", + "RELIABILITY": "Reliability", + "PORTABILITY": "Portability", + "HARDWARE_RELATED_PORTABILITY": "Portability: Hardware related portability", + "SYNCHRONIZATION_RELIABILITY": "Reliability: Synchronization related reliability", + "TRANSPORTABILITY": "Reusability: Transportability", + "COMPILER_RELATED_PORTABILITY": "Portability: Compiler related portability", + "RESOURCE_RELIABILITY": "Reliability: Resource", + "CPU_EFFICIENCY": "Efficiency: Processor use", + "EFFICIENCY": "Efficiency", + "CHANGEABILITY": "Changeability", + "DATA_CHANGEABILITY": "Changeability: Data related changeability", + "API_ABUSE": "Security: API abuse", + "ARCHITECTURE_CHANGEABILITY": "Changeability: Architecture related changeability", + "UNIT_TESTS": "Reliability: Unit tests", + "INSTRUCTION_RELIABILITY": "Reliability: Instruction related reliability", + "REUSABILITY": "Reusability", + "MODULARITY": "Reusability: Modularity", + "UNIT_TESTABILITY": "Testability: Unit level testability", + "TESTABILITY": "Testability", + "INTEGRATION_TESTABILITY": "Testability: Integration level testability", + "NETWORK_USE": "Efficiency: Network use", + "MEMORY_EFFICIENCY": "Efficiency: Memory use", + "DATA_RELIABILITY": "Reliability: Data related reliability", + "FAULT_TOLERANCE": "Reliability: Fault tolerance", + "LOGIC_RELIABILITY": "Reliability: Logic related reliability" + } +} diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules/search.json b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules/search.json new file mode 100644 index 00000000000..c17c58d2b42 --- /dev/null +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules/search.json @@ -0,0 +1,371 @@ +{ + "total": 609, + "p": 1, + "ps": 25, + "rules": [ + { + "key": "squid:S2077", + "name": "Values passed to SQL commands should be sanitized", + "lang": "java", + "langName": "Java", + "sysTags": [ + "cwe", + "owasp-top10", + "security", + "sql" + ], + "tags": [ + "custom-tag" + ] + }, + { + "key": "php:S107", + "name": "Functions should not have too many parameters", + "lang": "php", + "langName": "PHP", + "sysTags": [ + "brain-overload" + ], + "tags": [] + }, + { + "key": "php:S1192", + "name": "String literals should not be duplicated", + "lang": "php", + "langName": "PHP", + "sysTags": [], + "tags": [] + }, + { + "key": "php:S1145", + "name": "\"if\" statement conditions should not always evaluate to \"true\" or to \"false\"", + "lang": "php", + "langName": "PHP", + "sysTags": [ + "bug", + "cwe", + "security" + ], + "tags": [] + }, + { + "key": "php:S108", + "name": "Nested blocks of code should not be left empty", + "lang": "php", + "langName": "PHP", + "sysTags": [], + "tags": [] + }, + { + "key": "php:S1301", + "name": "\"switch\" statements should have at least 3 \"case\" clauses", + "lang": "php", + "langName": "PHP", + "sysTags": [], + "tags": [] + }, + { + "key": "php:S103", + "name": "Lines should not be too long", + "lang": "php", + "langName": "PHP", + "sysTags": [ + "convention" + ], + "tags": [] + }, + { + "key": "php:S1144", + "name": "Unused private method should be removed", + "lang": "php", + "langName": "PHP", + "sysTags": [ + "unused" + ], + "tags": [] + }, + { + "key": "php:S105", + "name": "Tabulation characters should not be used", + "lang": "php", + "langName": "PHP", + "sysTags": [ + "convention", + "psr2" + ], + "tags": [] + }, + { + "key": "php:S1481", + "name": "Unused local variables should be removed", + "lang": "php", + "langName": "PHP", + "sysTags": [ + "unused" + ], + "tags": [] + }, + { + "key": "php:S1142", + "name": "Functions should not contain too many return statements", + "lang": "php", + "langName": "PHP", + "sysTags": [ + "brain-overload" + ], + "tags": [] + }, + { + "key": "php:S104", + "name": "Files should not have too many lines", + "lang": "php", + "langName": "PHP", + "sysTags": [ + "brain-overload" + ], + "tags": [] + }, + { + "key": "php:S1605", + "name": "PHP 4 style calls to parent constructors should not be used in PHP5 \"__construct\" functions", + "lang": "php", + "langName": "PHP", + "sysTags": [ + "convention" + ], + "tags": [] + }, + { + "key": "php:S1448", + "name": "Classes should not have too many methods", + "lang": "php", + "langName": "PHP", + "sysTags": [ + "brain-overload" + ], + "tags": [] + }, + { + "key": "php:S1603", + "name": "PHP 4 constructor declarations should not be used", + "lang": "php", + "langName": "PHP", + "sysTags": [ + "pitfail" + ], + "tags": [] + }, + { + "key": "php:S1779", + "name": "Only LF character (Unix-like) should be used to end lines", + "lang": "php", + "langName": "PHP", + "sysTags": [ + "convention", + "psr2" + ], + "tags": [] + }, + { + "key": "php:S1185", + "name": "Overriding methods should do more than simply call the same method in the super class", + "lang": "php", + "langName": "PHP", + "sysTags": [], + "tags": [] + }, + { + "key": "php:S1600", + "name": "Deprecated predefined variables should not be used", + "lang": "php", + "langName": "PHP", + "sysTags": [ + "pitfail" + ], + "tags": [] + }, + { + "key": "php:S1109", + "name": "A close curly brace should be located at the beginning of a line", + "lang": "php", + "langName": "PHP", + "sysTags": [ + "convention" + ], + "tags": [] + }, + { + "key": "php:S2001", + "name": "Functions deprecated in PHP 5 should not be used", + "lang": "php", + "langName": "PHP", + "sysTags": [ + "obsolete" + ], + "tags": [] + }, + { + "key": "php:S2002", + "name": "Errors should not be silenced", + "lang": "php", + "langName": "PHP", + "sysTags": [ + "pitfail" + ], + "tags": [] + }, + { + "key": "php:S2000", + "name": "Files should not contain characters before \"