aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-06-18 11:16:00 +0200
committerStas Vilchik <vilchiks@gmail.com>2015-06-18 11:16:07 +0200
commitd370049974502061b852e73f25700c0d3bf218e6 (patch)
treea0f6ab394d11804f4a91e09add17ab5b68cec2e0 /server/sonar-web
parentff0de9e003be737aae3f76c0172f65665ce9b5a1 (diff)
downloadsonarqube-d370049974502061b852e73f25700c0d3bf218e6.tar.gz
sonarqube-d370049974502061b852e73f25700c0d3bf218e6.zip
add web tests for maintenance app
Diffstat (limited to 'server/sonar-web')
-rw-r--r--server/sonar-web/Gruntfile.coffee3
-rw-r--r--server/sonar-web/src/main/js/apps/maintenance/main-view.js31
-rw-r--r--server/sonar-web/src/test/js/maintenance-spec.js58
-rw-r--r--server/sonar-web/src/test/json/maintenance-spec/status-down.json5
-rw-r--r--server/sonar-web/src/test/json/maintenance-spec/status-up.json5
-rw-r--r--server/sonar-web/src/test/views/maintenance.jade5
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