]> source.dussan.org Git - sonarqube.git/commitdiff
enable parallel execution of web tests
authorStas Vilchik <vilchiks@gmail.com>
Thu, 19 Feb 2015 12:49:52 +0000 (13:49 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 19 Feb 2015 13:09:18 +0000 (14:09 +0100)
34 files changed:
server/sonar-web/Gruntfile.coffee
server/sonar-web/src/main/js/tests/e2e/lib.js
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-active-severity-facet.js
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-available-since.js
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-inheritance-facet.js
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-no-available-profiles-for-activation.js
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-quality-profile-facet.js
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-query-facet.js
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-rule-should-have-permalink.js
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-activate-profile.js
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-create-custom-rules.js
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-create-manual-rules.js
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-delete-custom-rules.js
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-delete-manual-rules.js
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-custom-rules.js
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-deprecated-label.js
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-details.js
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-empty-list.js
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-facets.js
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-rule-issues.js
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-rule.js
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-should-show-rules.js
server/sonar-web/src/main/js/tests/e2e/tests/design-spec.js
server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-open-issue-permalink.js
server/sonar-web/src/main/js/tests/e2e/tests/issues-page-spec.js
server/sonar-web/src/main/js/tests/e2e/tests/quality-gates-spec.js
server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-create-manual-issue.js
server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-favorite-spec.js
server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-link-to-raw-spec.js
server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-should-not-show-source-if-no-permission.js
server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-should-open-in-new-window-with-line.js
server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-should-open-in-new-window.js
server/sonar-web/src/main/js/tests/e2e/tests/source-viewer-spec.js [new file with mode: 0644]
server/sonar-web/src/main/js/tests/e2e/tests/treemap-spec.js

index dd52e681784643e942da900136deac97d0758cec..fbb1f883bc3efa55175aee96c9303cd620f53193 100644 (file)
@@ -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:
index b72cdf432c89ea4370391f4150d3cafed3586ac2..a896501eb9a3c520c7e0799b5895e0c0986062be 100644 (file)
@@ -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 () {
index 53e57acd63272d0028021482fe8c89cd443fb36f..30a7f2bab9d65b0469824f11ce38a09bef6c46aa 100644 (file)
@@ -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) {
index 5faadae7b1da413c72faa7c8ed3f10077dadc755..a8eebcc16c95dce368040a98fb65cf480070b504 100644 (file)
@@ -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) {
index 01f720618b64d8447b0b50a378cbad3eab11de2c..13a5f8020ce313f3deb4b0b416f5532d600f4733 100644 (file)
@@ -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) {
index abaed5e82a1eb283bd112178e0b507b7813e27a9..e0b87598c15f89524a9edae9446787f47ae67a15 100644 (file)
@@ -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) {
index 4bcead8d45c279bc79b3a36e4e74e3315b300629..e0d84b86eef091b11e02d1a09c267c43dce8bb5a 100644 (file)
@@ -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) {
index a412d423382a6dc13f0a45210fea51325a63303c..e953bbb091f32210e9521c55befaded993d22ca9 100644 (file)
@@ -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) {
index 9d1e0171ef587ca368ed026aafa7dbb66bd9b920..46c8b178f565c9b91f0cf1774b362d98d9a5ce77 100644 (file)
@@ -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) {
index 8c5e05d8cb46a44a5eb364f1d8cae7b792d711ed..dc5c3e36d610021355e1615b2f29756bb2e1e75f 100644 (file)
@@ -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) {
index b0de4b2965fb760d159b0c9f62eb1d1ce4cf0a53..d5cdd75e0a6b78f74549d3082c3741969df6f3e5 100644 (file)
@@ -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) {
index 86af5a83c428bce7a0f1eb75cad03ee07574e8bb..60b144d1713f8e4020a7787fbb6335d17aa845ad 100644 (file)
@@ -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) {
index 969919d7f9bba93d595a876b000d29798ff71e3e..da134078c3aa69ca9486f726cfd56d4f61229ebb 100644 (file)
@@ -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) {
index 718feaaa2769ce9887f759ebc48e8b20c241273e..3ef58eff9db8d55b387158b9868284fc9122ce22 100644 (file)
@@ -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) {
index 3215bad5d5e06a1a575c5dab0f26f2e6c94c9539..7698a6608455865dad5e7230738594067c6fe1c6 100644 (file)
@@ -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) {
index 66edd6e27ccd425b0bd6aa8da509c3a655223d05..9b647a25a0268604c5854bc297a2a09f4203e37b 100644 (file)
@@ -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) {
index 11fe3b595f013bfff0d022235a595585993e165d..63a641c31dfb4e46ebc73b0a818b1d4da4abe54e 100644 (file)
@@ -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) {
index 5fedf40cfc98fdd8254831c2a459fee60d5669e7..63ba6f445449feb22788bb42ec2294d846dec41a 100644 (file)
@@ -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) {
index 5fae7388ea5c2c001f6b7dcd70bf934e6fd8e9f8..e5ddaff2c24319d4d8df67f76ae37118e4bfd081 100644 (file)
@@ -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) {
index dd52ba03187aa8b50645471bc30a7544dc23c5fc..2673e00206389d18c62b142bbc4902b7555f84b2 100644 (file)
@@ -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) {
index f4e71de5e8d63625a8f923a5eabdda05d139bd2d..85bdb1a285a9b236dd890fe63526ddca240e9adf 100644 (file)
@@ -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) {
index 8b2fa3bceeda30a5bffd46eb20aa9ec4eb1cfd48..7ad9cf1a982dea7e8a91c0ea299d59c4ae17f8d3 100644 (file)
@@ -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) {
index 9f8919d0494b471b32698f29a3e0214c0ac1f1a2..fd0ba14832c59ab08383eb4d9f0950e9fc782455 100644 (file)
@@ -3,6 +3,7 @@ var lib = require('../lib'),
 
 lib.initMessages();
 lib.changeWorkingDirectory('design-spec');
+lib.configureCasper();
 
 
 casper.test.begin(testName('Base'), function suite(test) {
index ca9d7a51984779117e999b65aa7f28d43dca0a5d..f5580a998ca246f38378affc96bd13516b4eeda3 100644 (file)
@@ -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';
index 7451e020a329ec8d822ef5a8d927a0683d6fa848..d8a92d8dbcbb7069c1eedd4e28785739a6b67476 100644 (file)
@@ -6,6 +6,7 @@ var lib = require('../lib'),
 
 lib.initMessages();
 lib.changeWorkingDirectory('issues-spec');
+lib.configureCasper();
 
 
 casper.test.begin(testName('Base'), function (test) {
index 6655b4eb9ac4da1747a3b84af3ed9e3772b9f8b6..41944ca27a74ca370a23242fb7fd443f05e9e62e 100644 (file)
@@ -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) {
index 050469da6b39dd2b08489cf282374d33effa2f62..631c95cd18acc2b27b904b371cd9ea329d3be67f 100644 (file)
@@ -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) {
index 3f268dfd64ad902cf0f6f9a6a6ea851eede6d358..afca90859a603e1139490813cf68372de846ac8b 100644 (file)
@@ -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) {
index d4ae21dff4f9cb33aacaa2b9476143a514bb3c75..1c696698b42dc08e62c89c1f119104205c7353a1 100644 (file)
@@ -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) {
index 49406ab01ee03cc167f97b374830e3ad20c7dea7..363a63f5ebcbbe42b0e24cad4ef9014c644390ad 100644 (file)
@@ -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) {
index 1b39fdbbabe6409ac783c078ef35d223c315f5f7..ceaa0f3420e22ae7abf28da651eb70ce4ff7aff5 100644 (file)
@@ -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) {
index 56cb84f285511b40f4f051f8617023842173bf67..0f910958616da9a066a62900239aaf3f4b6d346f 100644 (file)
@@ -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 (file)
index 0000000..4346ecf
--- /dev/null
@@ -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();
+//      });
+//});
index 36b41eb7003acddd53bb55cb3483e955e69d8719..2da6d88f7766dbc76b1b04a01a5323f6711c33d7 100644 (file)
@@ -2,6 +2,7 @@ var lib = require('../lib');
 
 lib.initMessages();
 lib.changeWorkingDirectory('treemap-spec');
+lib.configureCasper();
 
 
 casper.test.begin('Treemap', function (test) {