]> source.dussan.org Git - sonarqube.git/commitdiff
transition computation web tests
authorStas Vilchik <vilchiks@gmail.com>
Mon, 6 Jul 2015 15:14:22 +0000 (17:14 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Tue, 7 Jul 2015 07:48:17 +0000 (09:48 +0200)
server/sonar-web/src/main/js/apps/computation/app.js
server/sonar-web/src/main/webapp/WEB-INF/app/views/computation/index.html.erb
server/sonar-web/test/helpers/test-page.js
server/sonar-web/test/intern.js
server/sonar-web/test/medium/computation.spec.js [new file with mode: 0644]

index 47b483f309901565a314b2d02a042ad771c0551a..43e64d86b5d2a404d1ca6d17dc5a847f92d2e606 100644 (file)
@@ -42,7 +42,7 @@ define([
         // Go!
         Backbone.history.start({
           pushState: true,
-          root: getRoot()
+          root: options.urlRoot
         });
       };
 
@@ -52,13 +52,6 @@ define([
     });
   });
 
-  function getRoot () {
-    var COMPUTATION = '/computation',
-        path = window.location.pathname,
-        pos = path.indexOf(COMPUTATION);
-    return path.substr(0, pos + COMPUTATION.length);
-  }
-
   return App;
 
 });
index f77eb797c805c12fbe5fc27895f7e03012e0feef..1e7b45c9f6c34f7183e1a7b72ebf7c35f847503a 100644 (file)
@@ -1,6 +1,7 @@
-<div id="computation"></div>
-<script>
-  require(['apps/computation/app'], function (App) {
-    App.start({ el: '#computation' });
-  });
-</script>
+<% content_for :extra_script do %>
+  <script>
+    require(['apps/computation/app'], function (App) {
+      App.start({ el: '#content', urlRoot: baseUrl + '/computation' });
+    });
+  </script>
+<% end %>
index e38ad1029078fdbf6733eaa820a0fbbb8d601089..b07a0b91a0ba10e13e2c3761828e9162204c960c 100644 (file)
@@ -157,6 +157,7 @@ define(function (require) {
     return new this.constructor(this, function () {
       return this.parent
           .get(require.toUrl(url))
+          .mockFromString('/api/l10n/index', '{}')
           .checkElementExist('#content');
     });
   };
index 3463d7b1ee8ba8b0549bafc9b77a21735cda2633..1de94e101e3f67bd7706cab4e4c49a16c266dac2 100644 (file)
@@ -22,7 +22,8 @@ define(['intern'], function (intern) {
     functionalSuites: [
       'test/medium/users.spec',
       'test/medium/issues.spec',
-      'test/medium/update-center.spec'
+      'test/medium/update-center.spec',
+      'test/medium/computation.spec'
     ],
 
     tunnel: tunnel,
diff --git a/server/sonar-web/test/medium/computation.spec.js b/server/sonar-web/test/medium/computation.spec.js
new file mode 100644 (file)
index 0000000..f6af86f
--- /dev/null
@@ -0,0 +1,38 @@
+define(function (require) {
+  var bdd = require('intern!bdd');
+  require('../helpers/test-page');
+
+  bdd.describe('Computation Page', function () {
+    bdd.it('should show list', function () {
+      return this.remote
+          .open()
+          .mockFromFile('/api/computation/queue', 'computation-spec/queue.json')
+          .mockFromFile('/api/computation/history', 'computation-spec/history.json')
+          .startApp('computation', { urlRoot: '/test/medium/base.html' })
+          .checkElementCount('#computation-list li[data-id]', 1)
+          .checkElementInclude('#computation-list', 'SonarQube')
+          .checkElementInclude('#computation-list-footer', '1')
+          .checkElementExist('.js-queue.selected')
+          .clickElement('.js-history')
+          .checkElementCount('#computation-list li[data-id]', 3)
+          .checkElementInclude('#computation-list', 'Duration')
+          .checkElementExist('.js-history.selected')
+          .checkElementExist('.panel-danger[data-id="3"]')
+          .clickElement('.js-queue')
+          .checkElementCount('#computation-list li[data-id]', 1);
+    });
+
+    bdd.it('should show more', function () {
+      return this.remote
+          .open('#past')
+          .mockFromFile('/api/computation/queue', 'computation-spec/queue.json')
+          .mockFromFile('/api/computation/history', 'computation-spec/history-big-1.json')
+          .startApp('computation', { urlRoot: '/test/medium/base.html' })
+          .checkElementCount('#computation-list li[data-id]', 2)
+          .clearMocks()
+          .mockFromFile('/api/computation/history', 'computation-spec/history-big-2.json', { data: { p: '2' } })
+          .clickElement('#computation-fetch-more')
+          .checkElementCount('#computation-list li[data-id]', 3);
+    });
+  });
+});