From: Stas Vilchik Date: Mon, 6 Jul 2015 15:14:22 +0000 (+0200) Subject: transition computation web tests X-Git-Tag: 5.2-RC1~1200 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5c0d4c2ada0e63910cf6ca9b11a7a799a41a82b5;p=sonarqube.git transition computation web tests --- diff --git a/server/sonar-web/src/main/js/apps/computation/app.js b/server/sonar-web/src/main/js/apps/computation/app.js index 47b483f3099..43e64d86b5d 100644 --- a/server/sonar-web/src/main/js/apps/computation/app.js +++ b/server/sonar-web/src/main/js/apps/computation/app.js @@ -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; }); diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/computation/index.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/computation/index.html.erb index f77eb797c80..1e7b45c9f6c 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/computation/index.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/computation/index.html.erb @@ -1,6 +1,7 @@ -
- +<% content_for :extra_script do %> + +<% end %> diff --git a/server/sonar-web/test/helpers/test-page.js b/server/sonar-web/test/helpers/test-page.js index e38ad102907..b07a0b91a0b 100644 --- a/server/sonar-web/test/helpers/test-page.js +++ b/server/sonar-web/test/helpers/test-page.js @@ -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'); }); }; diff --git a/server/sonar-web/test/intern.js b/server/sonar-web/test/intern.js index 3463d7b1ee8..1de94e101e3 100644 --- a/server/sonar-web/test/intern.js +++ b/server/sonar-web/test/intern.js @@ -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 index 00000000000..f6af86f4654 --- /dev/null +++ b/server/sonar-web/test/medium/computation.spec.js @@ -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); + }); + }); +});