diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-06-18 11:16:00 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-06-18 11:16:07 +0200 |
commit | d370049974502061b852e73f25700c0d3bf218e6 (patch) | |
tree | a0f6ab394d11804f4a91e09add17ab5b68cec2e0 /server/sonar-web | |
parent | ff0de9e003be737aae3f76c0172f65665ce9b5a1 (diff) | |
download | sonarqube-d370049974502061b852e73f25700c0d3bf218e6.tar.gz sonarqube-d370049974502061b852e73f25700c0d3bf218e6.zip |
add web tests for maintenance app
Diffstat (limited to 'server/sonar-web')
6 files changed, 83 insertions, 24 deletions
diff --git a/server/sonar-web/Gruntfile.coffee b/server/sonar-web/Gruntfile.coffee index 831558a585b..548d37260c1 100644 --- a/server/sonar-web/Gruntfile.coffee +++ b/server/sonar-web/Gruntfile.coffee @@ -164,6 +164,7 @@ module.exports = (grunt) -> 'casper:provisioning' 'casper:computation' 'casper:metrics' + 'casper:maintenance' ] @@ -338,6 +339,8 @@ module.exports = (grunt) -> src: ['src/test/js/groups-spec.js'] metrics: src: ['src/test/js/metrics-spec.js'] + maintenance: + src: ['src/test/js/maintenance-spec.js'] uglify: build: diff --git a/server/sonar-web/src/main/js/apps/maintenance/main-view.js b/server/sonar-web/src/main/js/apps/maintenance/main-view.js index ff445f919d7..65bcc701939 100644 --- a/server/sonar-web/src/main/js/apps/maintenance/main-view.js +++ b/server/sonar-web/src/main/js/apps/maintenance/main-view.js @@ -5,37 +5,20 @@ define([ return Marionette.ItemView.extend({ template: Templates['maintenance-main'], - events: { - 'click #start-migration': 'onStartMigrationClick' - }, - initialize: function () { + var that = this; this.requestOptions = { type: 'GET', url: baseUrl + '/api/system/status' }; setInterval(function () { - this.refresh(); - }.bind(this), 5000); + that.refresh(); + }, 5000); }, refresh: function () { + var that = this; return Backbone.ajax(this.requestOptions).done(function (r) { - if (r.status === 'DB_MIGRATION_RUNNING' && this.options.setup) { - // we are at setup page and migration is running - // so, let's switch to the migration status WS - return this.startMigration(); - } - this.model.set(r); - this.render(); - }.bind(this)); - }, - - onStartMigrationClick: function (e) { - e.preventDefault(); - this.startMigration(); - }, - - startMigration: function () { - this.requestOptions = { type: 'POST', url: baseUrl + '/api/system/migrate_db' }; - return this.refresh(); + that.model.set(r); + that.render(); + }); }, serializeData: function () { diff --git a/server/sonar-web/src/test/js/maintenance-spec.js b/server/sonar-web/src/test/js/maintenance-spec.js new file mode 100644 index 00000000000..2f0891a4a96 --- /dev/null +++ b/server/sonar-web/src/test/js/maintenance-spec.js @@ -0,0 +1,58 @@ +/* global describe:false, it:false */ +var lib = require('../lib'); + +describe('Maintenance App', function () { + + it('should exist', 2, function (casper, test) { + return casper + .start(lib.buildUrl('maintenance'), function () { + lib.setDefaultViewport(); + lib.fmock('/api/system/status', 'status-up.json'); + }) + + .then(function () { + casper.evaluate(function () { + require(['apps/maintenance/app'], function (App) { + App.start({ el: '#maintenance', setup: false }); + }); + }); + }) + + .then(function () { + casper.waitForSelector('.maintenance-title'); + }) + + .then(function () { + test.assertExists('.maintenance-title'); + test.assertExists('.maintenance-text'); + }); + }); + + it('should change status', 1, function (casper, test) { + return casper + .start(lib.buildUrl('maintenance'), function () { + lib.setDefaultViewport(); + lib.fmock('/api/system/status', 'status-up.json'); + }) + + .then(function () { + casper.evaluate(function () { + require(['apps/maintenance/app'], function (App) { + App.start({ el: '#maintenance', setup: false }); + }); + }); + }) + + .then(function () { + casper.waitForSelector('.maintenance-title'); + }) + + .then(function () { + test.assertDoesntExist('.maintenance-title.text-danger'); + lib.clearRequestMocks(); + lib.fmock('/api/system/status', 'status-down.json'); + casper.waitForSelector('.maintenance-title.text-danger'); + }); + }); + +}); diff --git a/server/sonar-web/src/test/json/maintenance-spec/status-down.json b/server/sonar-web/src/test/json/maintenance-spec/status-down.json new file mode 100644 index 00000000000..1a1bd37fefc --- /dev/null +++ b/server/sonar-web/src/test/json/maintenance-spec/status-down.json @@ -0,0 +1,5 @@ +{ + "id": "1", + "version": "1.0", + "status": "DOWN" +} diff --git a/server/sonar-web/src/test/json/maintenance-spec/status-up.json b/server/sonar-web/src/test/json/maintenance-spec/status-up.json new file mode 100644 index 00000000000..b582c6d30c0 --- /dev/null +++ b/server/sonar-web/src/test/json/maintenance-spec/status-up.json @@ -0,0 +1,5 @@ +{ + "id": "1", + "version": "1.0", + "status": "UP" +} diff --git a/server/sonar-web/src/test/views/maintenance.jade b/server/sonar-web/src/test/views/maintenance.jade new file mode 100644 index 00000000000..a3fadf98edb --- /dev/null +++ b/server/sonar-web/src/test/views/maintenance.jade @@ -0,0 +1,5 @@ +extends layouts/main + +block body + #content + #maintenance |