From: Stas Vilchik Date: Thu, 19 Feb 2015 12:49:52 +0000 (+0100) Subject: enable parallel execution of web tests X-Git-Tag: 5.1-RC1~171^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4fe16a489ae02343bb3cc87e64ea927f95b1765f;p=sonarqube.git enable parallel execution of web tests --- diff --git a/server/sonar-web/Gruntfile.coffee b/server/sonar-web/Gruntfile.coffee index dd52e681784..fbb1f883bc3 100644 --- a/server/sonar-web/Gruntfile.coffee +++ b/server/sonar-web/Gruntfile.coffee @@ -331,6 +331,7 @@ module.exports = (grunt) -> 'no-colors': true 'fail-fast': true concise: true + parallel: true port: expressPort src: ['<%= pkg.sources %>js/tests/e2e/tests/**/*.js'] single: diff --git a/server/sonar-web/src/main/js/tests/e2e/lib.js b/server/sonar-web/src/main/js/tests/e2e/lib.js index b72cdf432c8..a896501eb9a 100644 --- a/server/sonar-web/src/main/js/tests/e2e/lib.js +++ b/server/sonar-web/src/main/js/tests/e2e/lib.js @@ -42,6 +42,11 @@ exports.changeWorkingDirectory = function (dir) { }; +exports.configureCasper = function () { + casper.options.waitTimeout = 30000; +}; + + exports.testName = function () { var head = Array.prototype.slice.call(arguments, 0); return function () { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-active-severity-facet.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-active-severity-facet.js index 53e57acd632..30a7f2bab9d 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-active-severity-facet.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-active-severity-facet.js @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules-page-active-severity-facet'); +lib.configureCasper(); casper.test.begin('coding-rules-page-active-severity-facet', 7, function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-available-since.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-available-since.js index 5faadae7b1d..a8eebcc16c9 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-available-since.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-available-since.js @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules-page-available-since'); +lib.configureCasper(); casper.test.begin('coding-rules-page-available-since', 2, function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-inheritance-facet.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-inheritance-facet.js index 01f720618b6..13a5f8020ce 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-inheritance-facet.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-inheritance-facet.js @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules-page-inheritance-facet'); +lib.configureCasper(); casper.test.begin('coding-rules-page-inheritance-facet', 11, function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-no-available-profiles-for-activation.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-no-available-profiles-for-activation.js index abaed5e82a1..e0b87598c15 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-no-available-profiles-for-activation.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-no-available-profiles-for-activation.js @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules-page-no-available-profiles-for-activation'); +lib.configureCasper(); casper.test.begin('coding-rules-page-no-available-profiles-for-activation', 2, function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-quality-profile-facet.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-quality-profile-facet.js index 4bcead8d45c..e0d84b86eef 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-quality-profile-facet.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-quality-profile-facet.js @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules-page-quality-profile-facet'); +lib.configureCasper(); casper.test.begin('coding-rules-page-quality-profile-facet', 6, function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-query-facet.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-query-facet.js index a412d423382..e953bbb091f 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-query-facet.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-query-facet.js @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules-page-query-facet'); +lib.configureCasper(); casper.test.begin('coding-rules-page-query-facet', 3, function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-rule-should-have-permalink.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-rule-should-have-permalink.js index 9d1e0171ef5..46c8b178f56 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-rule-should-have-permalink.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-rule-should-have-permalink.js @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules-page-rule-permalink'); +lib.configureCasper(); casper.test.begin('coding-rules-page-rule-permalink', 1, function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-activate-profile.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-activate-profile.js index 8c5e05d8cb4..dc5c3e36d61 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-activate-profile.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-activate-profile.js @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules-page-should-activate-profile'); +lib.configureCasper(); casper.test.begin('coding-rules-page-should-activate-profile', 5, function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-create-custom-rules.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-create-custom-rules.js index b0de4b2965f..d5cdd75e0a6 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-create-custom-rules.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-create-custom-rules.js @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules-page-should-create-custom-rules'); +lib.configureCasper(); casper.test.begin('coding-rules-page-should-delete-create-rules', 2, function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-create-manual-rules.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-create-manual-rules.js index 86af5a83c42..60b144d1713 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-create-manual-rules.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-create-manual-rules.js @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules-page-should-create-manual-rules'); +lib.configureCasper(); casper.test.begin('coding-rules-page-should-delete-manual-rules', 3, function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-delete-custom-rules.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-delete-custom-rules.js index 969919d7f9b..da134078c3a 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-delete-custom-rules.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-delete-custom-rules.js @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules-page-should-delete-custom-rules'); +lib.configureCasper(); casper.test.begin('coding-rules-page-should-delete-custom-rules', 2, function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-delete-manual-rules.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-delete-manual-rules.js index 718feaaa276..3ef58eff9db 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-delete-manual-rules.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-delete-manual-rules.js @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules-page-should-delete-manual-rules'); +lib.configureCasper(); casper.test.begin('coding-rules-page-should-delete-manual-rules', 1, function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-custom-rules.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-custom-rules.js index 3215bad5d5e..7698a660845 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-custom-rules.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-custom-rules.js @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules-page-should-show-custom-rules'); +lib.configureCasper(); casper.test.begin('coding-rules-page-should-show-custom-rules', 3, function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-deprecated-label.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-deprecated-label.js index 66edd6e27cc..9b647a25a02 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-deprecated-label.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-deprecated-label.js @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules-page-should-show-deprecated-label'); +lib.configureCasper(); casper.test.begin('coding-rules-page-should-show-deprecated-label', 1, function (test) { 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 index 11fe3b595f0..63a641c31df 100644 --- 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 @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules-page-should-show-details'); +lib.configureCasper(); casper.test.begin('coding-rules-page-should-show-details', 20, function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-empty-list.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-empty-list.js index 5fedf40cfc9..63ba6f44544 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-empty-list.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-empty-list.js @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules-page-should-show-empty-list'); +lib.configureCasper(); casper.test.begin('coding-rules-page-should-show-empty-list', 3, function (test) { 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 index 5fae7388ea5..e5ddaff2c24 100644 --- 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 @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules'); +lib.configureCasper(); casper.test.begin('coding-rules-page-should-show-facets', 1, function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-rule-issues.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-rule-issues.js index dd52ba03187..2673e002063 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-rule-issues.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-rule-issues.js @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules-page-should-show-rule-issues'); +lib.configureCasper(); casper.test.begin('coding-rules-page-should-show-rule-issues', 5, function (test) { 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 index f4e71de5e8d..85bdb1a285a 100644 --- 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 @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules'); +lib.configureCasper(); casper.test.begin('coding-rules-page-should-show-rule', 7, function (test) { 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 index 8b2fa3bceed..7ad9cf1a982 100644 --- 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 @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('coding-rules'); +lib.configureCasper(); casper.test.begin('coding-rules-page-should-show-rules', 4, function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/design-spec.js b/server/sonar-web/src/main/js/tests/e2e/tests/design-spec.js index 9f8919d0494..fd0ba14832c 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/design-spec.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/design-spec.js @@ -3,6 +3,7 @@ var lib = require('../lib'), lib.initMessages(); lib.changeWorkingDirectory('design-spec'); +lib.configureCasper(); casper.test.begin(testName('Base'), function suite(test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-open-issue-permalink.js b/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-open-issue-permalink.js index ca9d7a51984..f5580a998ca 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-open-issue-permalink.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-open-issue-permalink.js @@ -5,6 +5,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('issues-page-should-open-issue-permalink'); +lib.configureCasper(); var issueKey = 'some-issue-key'; diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-spec.js b/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-spec.js index 7451e020a32..d8a92d8dbcb 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-spec.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-spec.js @@ -6,6 +6,7 @@ var lib = require('../lib'), lib.initMessages(); lib.changeWorkingDirectory('issues-spec'); +lib.configureCasper(); casper.test.begin(testName('Base'), function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/quality-gates-spec.js b/server/sonar-web/src/main/js/tests/e2e/tests/quality-gates-spec.js index 6655b4eb9ac..41944ca27a7 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/quality-gates-spec.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/quality-gates-spec.js @@ -4,6 +4,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('quality-gates-spec'); +lib.configureCasper(); casper.test.begin('Quality Gates', function suite (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-create-manual-issue.js b/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-create-manual-issue.js index 050469da6b3..631c95cd18a 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-create-manual-issue.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-create-manual-issue.js @@ -5,6 +5,7 @@ var lib = require('../lib'), lib.initMessages(); lib.changeWorkingDirectory('source-viewer-create-manual-issue'); +lib.configureCasper(); casper.test.begin(testName('source-viewer-create-manual-issue'), function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-favorite-spec.js b/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-favorite-spec.js index 3f268dfd64a..afca90859a6 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-favorite-spec.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-favorite-spec.js @@ -5,6 +5,7 @@ var lib = require('../lib'), lib.initMessages(); lib.changeWorkingDirectory('source-viewer-spec'); +lib.configureCasper(); casper.test.begin(testName('Mark as Favorite'), function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-link-to-raw-spec.js b/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-link-to-raw-spec.js index d4ae21dff4f..1c696698b42 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-link-to-raw-spec.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-link-to-raw-spec.js @@ -5,6 +5,7 @@ var lib = require('../lib'), lib.initMessages(); lib.changeWorkingDirectory('source-viewer-spec'); +lib.configureCasper(); casper.test.begin(testName('Link to Raw'), function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-should-not-show-source-if-no-permission.js b/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-should-not-show-source-if-no-permission.js index 49406ab01ee..363a63f5ebc 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-should-not-show-source-if-no-permission.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-should-not-show-source-if-no-permission.js @@ -5,6 +5,7 @@ var lib = require('../lib'), lib.initMessages(); lib.changeWorkingDirectory('source-viewer-should-not-show-source-if-no-permission'); +lib.configureCasper(); casper.test.begin(testName('source-viewer-should-not-show-source-if-no-permission'), function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-should-open-in-new-window-with-line.js b/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-should-open-in-new-window-with-line.js index 1b39fdbbabe..ceaa0f3420e 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-should-open-in-new-window-with-line.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-should-open-in-new-window-with-line.js @@ -5,6 +5,7 @@ var lib = require('../lib'), lib.initMessages(); lib.changeWorkingDirectory('source-viewer-should-open-in-new-window'); +lib.configureCasper(); casper.test.begin(testName('source-viewer-should-open-in-new-window-with-line'), function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-should-open-in-new-window.js b/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-should-open-in-new-window.js index 56cb84f2855..0f910958616 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-should-open-in-new-window.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-should-open-in-new-window.js @@ -5,6 +5,7 @@ var lib = require('../lib'), lib.initMessages(); lib.changeWorkingDirectory('source-viewer-should-open-in-new-window'); +lib.configureCasper(); casper.test.begin(testName('source-viewer-should-open-in-new-window'), function (test) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-spec.js b/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-spec.js new file mode 100644 index 00000000000..4346ecfe1ea --- /dev/null +++ b/server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-spec.js @@ -0,0 +1,168 @@ +/* global casper:false */ + + +var lib = require('../lib'), + testName = lib.testName('Source Viewer'); + +lib.initMessages(); +lib.changeWorkingDirectory('source-viewer-spec'); +lib.configureCasper(); + + +casper.test.begin(testName('Base'), function (test) { + casper + .start(lib.buildUrl('source-viewer'), function () { + lib.setDefaultViewport(); + + lib.mockRequest('/api/l10n/index', '{}'); + lib.mockRequestFromFile('/api/components/app', 'app.json'); + lib.mockRequestFromFile('/api/sources/lines', 'lines.json'); + lib.mockRequestFromFile('/api/issues/search', 'issues.json'); + }) + + .then(function () { + casper.waitForSelector('.source-line', function () { + // Check header elements + test.assertExists('.source-viewer-header'); + test.assertSelectorContains('.source-viewer-header', 'SonarQube'); + test.assertSelectorContains('.source-viewer-header', 'SonarQube :: Batch'); + test.assertSelectorContains('.source-viewer-header', 'src/main/java/org/sonar/batch/index/Cache.java'); + test.assertExists('.source-viewer-header .js-favorite'); + test.assertExists('.source-viewer-header-actions'); + + // Check main measures + // FIXME enable lines check + //test.assertSelectorContains('.source-viewer-header-measure', '379'); + test.assertSelectorContains('.source-viewer-header-measure', 'A'); + test.assertSelectorContains('.source-viewer-header-measure', '2h 10min'); + test.assertSelectorContains('.source-viewer-header-measure', '6'); + test.assertSelectorContains('.source-viewer-header-measure', '74.3%'); + test.assertSelectorContains('.source-viewer-header-measure', '5.8%'); + + // Check source + // FIXME enable source lines count check + //test.assertElementCount('.source-line', 518); + test.assertSelectorContains('.source-viewer', 'public class Cache'); + }); + }) + + .run(function () { + test.done(); + }); +}); + + +casper.test.begin(testName('Decoration'), function (test) { + casper + .start(lib.buildUrl('source-viewer'), function () { + lib.setDefaultViewport(); + + lib.mockRequest('/api/l10n/index', '{}'); + lib.mockRequestFromFile('/api/components/app', 'app.json'); + lib.mockRequestFromFile('/api/sources/lines', 'lines.json'); + lib.mockRequestFromFile('/api/issues/search', 'issues.json'); + }) + + .then(function () { + casper.waitForSelector('.source-line'); + }) + + .then(function () { + // Check issues decoration + test.assertElementCount('.has-issues', 6); + }) + + .then(function () { + // Check coverage decoration + test.assertElementCount('.source-line-covered', 142); + test.assertElementCount('.source-line-uncovered', 50); + test.assertElementCount('.source-line-partially-covered', 2); + }) + + .then(function () { + // Check duplications decoration + test.assertElementCount('.source-line-duplicated', 30); + }) + + .then(function () { + // Check scm decoration + test.assertElementCount('.source-line-scm-inner', 186); + test.assertExists('.source-line-scm-inner[data-author="simon.brandhof@gmail.com"]'); + test.assertExists('.source-line-scm-inner[data-author="julien.henry@sonarsource.com"]'); + }) + + .run(function () { + test.done(); + }); +}); + + +casper.test.begin(testName('Test File'), function (test) { + casper + .start(lib.buildUrl('source-viewer'), function () { + lib.setDefaultViewport(); + + lib.mockRequest('/api/l10n/index', '{}'); + lib.mockRequestFromFile('/api/components/app', 'tests/app.json'); + lib.mockRequestFromFile('/api/sources/lines', 'tests/lines.json'); + lib.mockRequestFromFile('/api/issues/search', 'issues.json'); + }) + + .then(function () { + casper.waitForSelector('.source-line'); + }) + + .then(function () { + test.assertSelectorContains('.source-viewer-header-measure', '6'); + }) + + .run(function () { + test.done(); + }); +}); + + +// FIXME enable test +//casper.test.begin(testName('Go From Coverage to Test File'), function (test) { +// casper +// .start(lib.buildUrl('source-viewer'), function () { +// lib.setDefaultViewport(); +// lib.mockRequest('/api/l10n/index', '{}'); +// lib.mockRequestFromFile('/api/components/app', 'app.json'); +// lib.mockRequestFromFile('/api/sources/lines', 'lines.json'); +// lib.mockRequestFromFile('/api/issues/search', 'issues.json'); +// lib.mockRequestFromFile('/api/tests/test_cases', 'test-cases.json'); +// }) +// +// .then(function () { +// casper.waitForSelector('.component-viewer-source .source-line'); +// }) +// +// .then(function () { +// casper.click('.js-toggle-coverage'); +// casper.waitForSelector('.source-line-covered', function () { +// casper.click('.source-line-covered'); +// casper.waitForSelector('.bubble-popup', function () { +// test.assertSelectorContains('.bubble-popup', 'src/test/java/org/sonar/batch/issue/IssueCacheTest.java'); +// test.assertSelectorContains('.bubble-popup', 'should_update_existing_issue'); +// test.assertSelectorContains('.bubble-popup li[title="should_update_existing_issue"]', '293'); +// +// lib.clearRequestMocks(); +// lib.mockRequestFromFile('/api/components/app', 'tests/app.json'); +// lib.mockRequestFromFile('/api/sources/show', 'tests/source.json'); +// lib.mockRequestFromFile('/api/resources', 'tests/resources.json'); +// lib.mockRequest('/api/coverage/show', '{}'); +// lib.mockRequestFromFile('/api/tests/show', 'tests/tests.json'); +// casper.click('.component-viewer-popup-test-file[data-key]'); +// +// casper.waitForSelector('.js-unit-test', function () { +// test.assertElementCount('.js-unit-test', 2); +// }); +// }); +// }); +// }) +// +// .run(function () { +// test.done(); +// }); +//}); diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/treemap-spec.js b/server/sonar-web/src/main/js/tests/e2e/tests/treemap-spec.js index 36b41eb7003..2da6d88f776 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/treemap-spec.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/treemap-spec.js @@ -2,6 +2,7 @@ var lib = require('../lib'); lib.initMessages(); lib.changeWorkingDirectory('treemap-spec'); +lib.configureCasper(); casper.test.begin('Treemap', function (test) {