Remove obsolete frontend tests
This commit is contained in:
parent
8ca9437a9c
commit
f67b83fb75
|
@ -1,203 +0,0 @@
|
|||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
/**
|
||||
* This file is part of Icinga Web 2.
|
||||
*
|
||||
* Icinga Web 2 - Head for multiple monitoring backends.
|
||||
* Copyright (C) 2013 Icinga Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||
* @author Icinga Development Team <info@icinga.org>
|
||||
*
|
||||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
/**
|
||||
* Test case for the login page
|
||||
*
|
||||
* Steps:
|
||||
* - Request application root path
|
||||
* - Assert login page to appear
|
||||
* - Enter invalid credentials
|
||||
* - Enter valid credentials
|
||||
* - Reload page without credentials
|
||||
* - Logout
|
||||
**/
|
||||
|
||||
/**
|
||||
* The icinga util object
|
||||
*
|
||||
* @type object
|
||||
*/
|
||||
var icinga = require('./icingawebtest');
|
||||
|
||||
/**
|
||||
* The casperjs object
|
||||
*
|
||||
* @type Casper
|
||||
*/
|
||||
var casper = icinga.getTestEnv();
|
||||
|
||||
/**
|
||||
* Test whether the login form exists and has valid input elements
|
||||
*
|
||||
* @param {testing} The casperjs testing module to perform assertions
|
||||
*/
|
||||
var assertLoginFormExists = function(test) {
|
||||
|
||||
test.assertExists(
|
||||
'form#form_login',
|
||||
'Test whether the login form exists'
|
||||
);
|
||||
test.assertExists(
|
||||
'form#form_login input#username',
|
||||
'Test whether a username input field exists'
|
||||
);
|
||||
test.assertExists(
|
||||
'form#form_login input#password',
|
||||
'Test whether a password input field exists'
|
||||
);
|
||||
test.assertExists(
|
||||
'form#form_login input#submit',
|
||||
'Test whether a submit input field exists'
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Request the initial application path
|
||||
*/
|
||||
casper.start('/', function() {
|
||||
if (this.getCurrentUrl() === 'about:blank') {
|
||||
this.die('Url can\'t be accessed');
|
||||
}
|
||||
this.test.assertTitle(
|
||||
"Icinga Web Login",
|
||||
"Test whether the login page (" + this.getCurrentUrl() + ") has a correct title"
|
||||
);
|
||||
assertLoginFormExists(this.test);
|
||||
this.test.assertDoesntExist(
|
||||
'#icinga_app_username',
|
||||
'Test if no username is set in the frontend after initial page load'
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Login with invalid credentials
|
||||
*/
|
||||
casper.then(function() {
|
||||
this.fill('form#form_login', {
|
||||
'username' : 'no',
|
||||
'password' : 'existing_user'
|
||||
});
|
||||
this.click('form#form_login input#submit');
|
||||
});
|
||||
|
||||
/**
|
||||
* Test if login failed and feedback is given
|
||||
*/
|
||||
casper.then(function() {
|
||||
this.test.assertTextExists(
|
||||
'Please provide a valid username and password',
|
||||
'Test if the user gets a note that authorization failed if providing wrong credentials'
|
||||
);
|
||||
assertLoginFormExists(this.test);
|
||||
this.test.assertDoesntExist(
|
||||
'#icinga_app_username',
|
||||
'Test if no username is set in the frontend after entering wrong credentials'
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Login with valid credentials
|
||||
*/
|
||||
casper.then(function() {
|
||||
this.fill('form#form_login', icinga.getCredentials());
|
||||
this.click('form#form_login input#submit');
|
||||
});
|
||||
|
||||
/**
|
||||
* Test if the login suceeded and the username is shown in the navigation bar
|
||||
*/
|
||||
casper.then(function() {
|
||||
this.test.assertTextDoesntExist(
|
||||
'Please provide a valid username and password',
|
||||
'Test if valid credentials don\'t end cause a note that credentials are wrong to appear'
|
||||
);
|
||||
this.test.assertSelectorHasText(
|
||||
'#icinga_app_nav_username',
|
||||
icinga.getCredentials().username,
|
||||
'Test if the username is set in the frontend after successful login'
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Test if session is persisted after reloading the page
|
||||
*/
|
||||
casper.thenOpen('/', function() {
|
||||
this.test.assertSelectorHasText(
|
||||
'#icinga_app_nav_username',
|
||||
icinga.getCredentials().username,
|
||||
'Test if the username is still set if reloading the page via GET'
|
||||
);
|
||||
|
||||
this.test.assertExists(
|
||||
'#icinga_app_nav_logout',
|
||||
'Test if the logout button exists'
|
||||
);
|
||||
|
||||
this.test.assertExists(
|
||||
'#icinga_app_nav_useraction',
|
||||
'Test whether the dropdown for user specific actions exists'
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Test if logout button is displayed when username is clicked and test for correct logout
|
||||
*/
|
||||
casper.then(function() {
|
||||
this.test.assertNotVisible(
|
||||
'#icinga_app_nav_logout',
|
||||
'Test if the logout button is hidden when not clicked'
|
||||
);
|
||||
|
||||
this.wait(500, function() { // wait until everything is initialized, sometimes this takes a while
|
||||
this.click('#icinga_app_nav_useraction');
|
||||
this.waitUntilVisible('#icinga_app_nav_logout', function() {
|
||||
this.click('#icinga_app_nav_logout a');
|
||||
this.waitForSelector('form#form_login', function() {
|
||||
this.test.assertDoesntExist(
|
||||
'#icinga_app_username',
|
||||
'Test if no username is set in the frontend after logout'
|
||||
);
|
||||
assertLoginFormExists(this.test);
|
||||
});
|
||||
}, function() {
|
||||
this.test.assertVisible(
|
||||
'#icinga_app_nav_logout',
|
||||
'Test if the logout button is visible when click on username occurs'
|
||||
);
|
||||
}, 500);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Run the tests
|
||||
*/
|
||||
casper.run(function() {
|
||||
this.test.done();
|
||||
});
|
|
@ -1,96 +0,0 @@
|
|||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
/**
|
||||
* This file is part of Icinga Web 2.
|
||||
*
|
||||
* Icinga Web 2 - Head for multiple monitoring backends.
|
||||
* Copyright (C) 2013 Icinga Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||
* @author Icinga Development Team <info@icinga.org>
|
||||
*
|
||||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
/**
|
||||
* loadIndicator test
|
||||
*
|
||||
* Test for feature #4400
|
||||
* https://dev.icinga.org/issues/4400
|
||||
*
|
||||
* Steps:
|
||||
* - Request host list
|
||||
* - Click on a row
|
||||
* - Test for load indicator
|
||||
* - Test new url loaded
|
||||
* - Test for non existing load indicator
|
||||
**/
|
||||
|
||||
/**
|
||||
* The icinga util object
|
||||
*
|
||||
* @type object
|
||||
*/
|
||||
var icinga = require('./icingawebtest');
|
||||
|
||||
/**
|
||||
* The casperjs object
|
||||
*
|
||||
* @type Casper
|
||||
*/
|
||||
var casper = icinga.getTestEnv();
|
||||
|
||||
icinga.performLogin();
|
||||
|
||||
/**
|
||||
* Login with valid credentials
|
||||
*/
|
||||
casper.thenOpen('/monitoring/list/hosts', function() {
|
||||
this.test.assertExists('div#icingadetail');
|
||||
this.test.assertExists('div#icingamain');
|
||||
});
|
||||
|
||||
casper.then(function() {
|
||||
this.waitForSelector('div[data-icinga-component="app/mainDetailGrid"]', function() {
|
||||
this.wait(1000, function() {
|
||||
this.test.assertExists('div[data-icinga-component="app/mainDetailGrid"] table.table-condensed tr:nth-child(2) td:nth-child(3) a');
|
||||
this.click('div[data-icinga-component="app/mainDetailGrid"] table.table-condensed tr:nth-child(2) td:nth-child(3) a')
|
||||
});
|
||||
}, function() {
|
||||
this.test.fail('mainDetailGrid not found');
|
||||
});
|
||||
});
|
||||
|
||||
casper.then(function() {
|
||||
this.waitForSelector('div#icingadetail div.load-indicator', function() {
|
||||
this.test.assertExists('div#icingadetail div.load-indicator div.label');
|
||||
this.waitFor(function check() {
|
||||
return this.getCurrentUrl().search(/\?detail=/) > -1;
|
||||
}, function then() {
|
||||
this.test.assertDoesntExist('div.load-indicator');
|
||||
}, function timeout() {
|
||||
this.test.fail('Url did not changed detail pane');
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* Run the tests
|
||||
*/
|
||||
casper.run(function() {
|
||||
this.test.done();
|
||||
});
|
|
@ -1,146 +0,0 @@
|
|||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
/**
|
||||
* This file is part of Icinga Web 2.
|
||||
*
|
||||
* Icinga Web 2 - Head for multiple monitoring backends.
|
||||
* Copyright (C) 2013 Icinga Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||
* @author Icinga Development Team <info@icinga.org>
|
||||
*
|
||||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
/**
|
||||
* Tools for setting up the casperjs tests
|
||||
* mainly setting host, port and path path
|
||||
**/
|
||||
|
||||
// load config files
|
||||
var fs = require('fs');
|
||||
var env = require('system').env;
|
||||
var args = require('system').args;
|
||||
var utils = require('utils');
|
||||
|
||||
|
||||
var host = 'localhost';
|
||||
var port = 80;
|
||||
var path = 'icingaweb';
|
||||
var verbose = false;
|
||||
var user = 'jdoe';
|
||||
var pass = 'password';
|
||||
|
||||
if (typeof(env.CASPERJS_HOST) === 'string')
|
||||
host = env.CASPERJS_HOST;
|
||||
if (typeof(env.CASPERJS_PORT) === 'string')
|
||||
port = parseInt(env.CASPERJS_PORT, 10);
|
||||
if (typeof(env.CASPERJS_PATH) === 'string')
|
||||
path = env.CASPERJS_PATH;
|
||||
if (typeof(env.CASPERJS_USER) === 'string')
|
||||
user = env.CASPERJS_USER;
|
||||
if (typeof(env.CASPERJS_PASS) === 'string')
|
||||
pass = env.CASPERJS_PASS;
|
||||
|
||||
for (var i=0;i<args.length;i++) {
|
||||
switch(args[i]) {
|
||||
case '--verbose':
|
||||
verbose = true;
|
||||
break;
|
||||
case '--host':
|
||||
host = args[++i];
|
||||
break;
|
||||
case '--port':
|
||||
port = parseInt(args[++i], 10);
|
||||
break;
|
||||
case '--path':
|
||||
path = args[++i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (host === null) {
|
||||
console.error('Can\'t initialize tests: No host given in casperjs.config or via CASPERJS_HOST environment');
|
||||
return false;
|
||||
}
|
||||
if (port === null) {
|
||||
console.error('Can\'t initialize tests: No port given in casperjs.config or via CASPERJS_PORT environment');
|
||||
return false;
|
||||
}
|
||||
if (path === null) {
|
||||
console.error('Can\'t initialize tests: No path given in casperjs.config or via CASPERJS_PATH environment');
|
||||
return false;
|
||||
}
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var getBaseURL = function(url) {
|
||||
url = url || '';
|
||||
if (url.substr(0,4) == 'http') {
|
||||
return url;
|
||||
}
|
||||
return 'http://'+host+':'+port+'/'+path+'/'+url;
|
||||
};
|
||||
var cstart = casper.start;
|
||||
var cthenOpen = casper.thenOpen;
|
||||
var copen = casper.open;
|
||||
|
||||
|
||||
var startFromBase = function(url, then) {
|
||||
return cstart.call(casper, getBaseURL(url), then);
|
||||
};
|
||||
|
||||
var thenOpenFromBase = function(url, options) {
|
||||
return cthenOpen.apply(casper, [getBaseURL(url), options]);
|
||||
};
|
||||
|
||||
var openFromBase = function(url, options) {
|
||||
return copen.apply(casper, [getBaseURL(url), options]);
|
||||
};
|
||||
|
||||
casper.on('remote.message', function(message) {
|
||||
console.log(message);
|
||||
});
|
||||
|
||||
casper.on('page.error', function(message, trace) {
|
||||
console.error(message, JSON.stringify(trace));
|
||||
});
|
||||
|
||||
|
||||
exports.getTestEnv = function() {
|
||||
casper.getBaseURL = getBaseURL;
|
||||
casper.start = startFromBase;
|
||||
casper.thenOpen = thenOpenFromBase;
|
||||
casper.open = openFromBase;
|
||||
return casper;
|
||||
};
|
||||
|
||||
exports.getCredentials = function() {
|
||||
return {
|
||||
'username' : user,
|
||||
'password' : pass
|
||||
};
|
||||
};
|
||||
|
||||
exports.performLogin = function() {
|
||||
casper.start("/authentication/logout");
|
||||
casper.thenOpen("/authentication/login", function() {
|
||||
this.fill('form#form_login', icinga.getCredentials());
|
||||
this.click('form#form_login input#submit');
|
||||
});
|
||||
};
|
||||
})();
|
|
@ -1,168 +0,0 @@
|
|||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
/**
|
||||
* This file is part of Icinga Web 2.
|
||||
*
|
||||
* Icinga Web 2 - Head for multiple monitoring backends.
|
||||
* Copyright (C) 2013 Icinga Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||
* @author Icinga Development Team <info@icinga.org>
|
||||
*
|
||||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
/**
|
||||
* SubmitPassiveCheckResult is always type service
|
||||
*
|
||||
* As a user I want to be able to choose between host
|
||||
* check results when no services are passed in.
|
||||
*
|
||||
* This test performs the following steps
|
||||
*
|
||||
* - Login using the provided credentials
|
||||
* - Open the form to submit passive check results
|
||||
* - Check whether it is possible to choose between result types for hosts,
|
||||
* if no services are given
|
||||
* - Check whether it is possible to choose between result types for services
|
||||
**/
|
||||
|
||||
/**
|
||||
* The icinga util object
|
||||
*
|
||||
* @type object
|
||||
*/
|
||||
var icinga = require('./icingawebtest');
|
||||
|
||||
/**
|
||||
* The casperjs object
|
||||
*
|
||||
* @type Casper
|
||||
*/
|
||||
var casper = icinga.getTestEnv();
|
||||
|
||||
/**
|
||||
* Login to the instance
|
||||
*/
|
||||
icinga.performLogin();
|
||||
|
||||
/**
|
||||
* Open the command dialog with only a host pattern and ensure that the form exists
|
||||
*/
|
||||
casper.thenOpen('/monitoring/command/submitpassivecheckresult?host=*', function() {
|
||||
if (this.exists('.alert')) {
|
||||
this.test.info('Skipping test; See issue #4666 for more details');
|
||||
return;
|
||||
}
|
||||
|
||||
this.test.assertExists(
|
||||
'#form_submit_passive_checkresult',
|
||||
'Test whether the form to submit passive checkresults is available'
|
||||
);
|
||||
this.test.assertExists(
|
||||
'#form_submit_passive_checkresult select#pluginstate',
|
||||
'Ensure that the result type input exists'
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Check whether the input contains the checkresult types for hosts
|
||||
*/
|
||||
casper.then(function() {
|
||||
if (this.exists('.alert')) {
|
||||
this.test.info('Skipping test; See issue #4666 for more details');
|
||||
return;
|
||||
}
|
||||
|
||||
var options = this.evaluate(function() {
|
||||
var elements = document.querySelector(
|
||||
'#form_submit_passive_checkresult select#pluginstate'
|
||||
).options;
|
||||
|
||||
var options = [];
|
||||
for (var i = 0; i < elements.length; i++)
|
||||
options.push(elements[i].text);
|
||||
return options;
|
||||
});
|
||||
|
||||
if (options.indexOf('UP') == -1)
|
||||
{
|
||||
this.test.fail('UP not available as checkresult type for hosts');
|
||||
}
|
||||
else if (options.indexOf('DOWN') == -1)
|
||||
{
|
||||
this.test.fail('DOWN not available as checkresult type for hosts');
|
||||
}
|
||||
else if (options.indexOf('UNREACHABLE') == -1)
|
||||
{
|
||||
this.test.fail('UNREACHABLE not available as checkresult type for hosts');
|
||||
}
|
||||
else
|
||||
{
|
||||
this.test.pass('Found all checkresult types for hosts');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Open the command dialog with a host and a service pattern as well and
|
||||
* check whether the input contains the checkresult types for services
|
||||
*/
|
||||
casper.thenOpen('/monitoring/command/submitpassivecheckresult?host=*&service=*', function() {
|
||||
if (this.exists('.alert')) {
|
||||
this.test.info('Skipping test; See issue #4666 for more details');
|
||||
return;
|
||||
}
|
||||
|
||||
var options = this.evaluate(function() {
|
||||
var elements = document.querySelector(
|
||||
'#form_submit_passive_checkresult select#pluginstate'
|
||||
).options;
|
||||
|
||||
var options = [];
|
||||
for (var i = 0; i < elements.length; i++)
|
||||
options.push(elements[i].text);
|
||||
return options;
|
||||
});
|
||||
|
||||
if (options.indexOf('OK') == -1)
|
||||
{
|
||||
this.test.fail('OK not available as checkresult type for services');
|
||||
}
|
||||
else if (options.indexOf('WARNING') == -1)
|
||||
{
|
||||
this.test.fail('WARNING not available as checkresult type for services');
|
||||
}
|
||||
else if (options.indexOf('CRITICAL') == -1)
|
||||
{
|
||||
this.test.fail('CRITICAL not available as checkresult type for services');
|
||||
}
|
||||
else if (options.indexOf('UNKNOWN') == -1)
|
||||
{
|
||||
this.test.fail('UNKNOWN not available as checkresult type for services');
|
||||
}
|
||||
else
|
||||
{
|
||||
this.test.pass('Found all checkresult types for services');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Run the tests
|
||||
*/
|
||||
casper.run(function() {
|
||||
this.test.done();
|
||||
});
|
|
@ -1,176 +0,0 @@
|
|||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
/**
|
||||
* This file is part of Icinga Web 2.
|
||||
*
|
||||
* Icinga Web 2 - Head for multiple monitoring backends.
|
||||
* Copyright (C) 2013 Icinga Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||
* @author Icinga Development Team <info@icinga.org>
|
||||
*
|
||||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
/**
|
||||
* Configuration: Show message that changes were saved successfully
|
||||
*
|
||||
* As a user I want to see that configuration changes were successful.
|
||||
*
|
||||
* This test performs the following steps
|
||||
*
|
||||
* - Login using the provided credentials
|
||||
* - Open the configuration dialog and change the timezone
|
||||
* - Save and test for a success bubble to appear
|
||||
* - Open the authentication dialog
|
||||
* - Open the edit link of the first backend
|
||||
* - Hit save and test for a success bubble to apper
|
||||
* - Open the logging dialog, hit save and test for a success bubble to appear
|
||||
**/
|
||||
|
||||
/**
|
||||
* The icinga util object
|
||||
*
|
||||
* @type object
|
||||
*/
|
||||
var icinga = require('./icingawebtest');
|
||||
|
||||
/**
|
||||
* The casperjs object
|
||||
*
|
||||
* @type Casper
|
||||
*/
|
||||
var casper = icinga.getTestEnv();
|
||||
|
||||
/**
|
||||
* Login to the instance
|
||||
*/
|
||||
icinga.performLogin();
|
||||
|
||||
/**
|
||||
* Open the config dialog and test if the form exists
|
||||
*/
|
||||
casper.thenOpen('/config', function() {
|
||||
this.test.assertExists(
|
||||
'#form_config_general',
|
||||
'Test whether the general settings dialog exists in the general form'
|
||||
);
|
||||
this.test.assertExists(
|
||||
'#form_config_general select#timezone',
|
||||
'Assert the timezone input to exist'
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Change the timezone and submit
|
||||
*/
|
||||
casper.then(function() {
|
||||
this.test.assertDoesntExist(
|
||||
'div.alert.alert-success',
|
||||
'Assert no success notice existing when no changes have been done in the general form'
|
||||
);
|
||||
this.echo("Changing the default timezone");
|
||||
this.fill('#form_config_general', {
|
||||
'timezone': 'Europe/Minsk'
|
||||
});
|
||||
this.click('#form_config_general input#btn_submit');
|
||||
});
|
||||
|
||||
/**
|
||||
* Check for the 'Successfully Update' information bubble
|
||||
*/
|
||||
casper.then(function() {
|
||||
this.echo("Clicked on save button of the general form, waiting for success");
|
||||
this.waitForSelector('div.alert.alert-success', function() {
|
||||
this.test.assertSelectorHasText(
|
||||
'div.alert.alert-success',
|
||||
'Config Sucessfully Updated',
|
||||
'Assert a success text to appear in the general form'
|
||||
);
|
||||
}, function() {
|
||||
this.test.fail("No success text appeared in the general form");
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Open the config dialog and click on the first 'Edit This Authentication Backend' Link
|
||||
*/
|
||||
casper.thenOpen('/config/authentication', function() {
|
||||
var link = this.evaluate(function() {
|
||||
var links = document.querySelectorAll('#icingamain a');
|
||||
for (var i=0; i<links.length; i++) {
|
||||
if (/.* Edit This Authentication/.test(links[i].text)) {
|
||||
document.location.href = links[i].getAttribute('href');
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.echo("Clicked on first authentication backend link");
|
||||
});
|
||||
|
||||
/**
|
||||
* Submit the authenticaton backend without any changes and test for the success bubble
|
||||
*/
|
||||
casper.then(function() {
|
||||
this.waitForSelector('input#btn_submit', function() {
|
||||
this.click('input#btn_submit');
|
||||
this.echo("Submitted authentication form");
|
||||
|
||||
this.waitForSelector('div.alert', function() {
|
||||
// Force creation when message bubbled
|
||||
if (this.exists('form#form_modify_backend input#backend_force_creation')) {
|
||||
this.echo("Backend persistence requires an additional confirmation in this case");
|
||||
this.fill('#form_modify_backend', {
|
||||
'backend_force_creation' : '1'
|
||||
});
|
||||
this.click('input#btn_submit');
|
||||
}
|
||||
this.echo("Waiting for success feedback");
|
||||
this.waitForSelector('div.alert.alert-success', function() {
|
||||
this.test.assertExists('div.alert.alert-success', 'Assert a success message to exist');
|
||||
});
|
||||
}, function() {
|
||||
this.test.fail("Success message for authentication provider tests didn't pop up");
|
||||
});
|
||||
}, function() {
|
||||
this.test.fail('No submit button found when expected the "Edit this authentication provider" form');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Submit the logging dialog without any changes and test for the success bubble
|
||||
*/
|
||||
casper.thenOpen('/config/logging', function() {
|
||||
this.test.assertExists('form#form_config_logging', 'Asserting the logging form to exist');
|
||||
this.click('form#form_config_logging input#btn_submit');
|
||||
this.waitForSelector('div.alert.alert-success', function() {
|
||||
this.test.assertExists('div.alert.alert-success', 'Assert a success message to exist');
|
||||
}, function() {
|
||||
this.test.fail('No success message popped up when saving logging configuration');
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Run the tests
|
||||
*/
|
||||
casper.run(function() {
|
||||
this.test.done();
|
||||
});
|
||||
|
||||
|
|
@ -1,116 +0,0 @@
|
|||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
/**
|
||||
* This file is part of Icinga Web 2.
|
||||
*
|
||||
* Icinga Web 2 - Head for multiple monitoring backends.
|
||||
* Copyright (C) 2013 Icinga Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
|
||||
* @author Icinga Development Team <info@icinga.org>
|
||||
*
|
||||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
/**
|
||||
* Config: Warn about unsaved changes before leaving current dialog (Bug #4622)
|
||||
*
|
||||
* It's not possible to test if the confirmation dialog really appears, but as this is a rather simple
|
||||
* event listener (that is also tested with mocha), the state preservation is tested here
|
||||
*
|
||||
* This test performs the following steps
|
||||
* - Log in and open the logging dialog form
|
||||
* - Wait for component initialisation
|
||||
* - Modify the first input field and test for the data-icinga-form-modified flag to be set
|
||||
* - Modify the an autosubmit field (debug log), wait for the textfield to appear or disappear and test if
|
||||
* the modified attribute is set on the server side.
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
* The icinga util object
|
||||
*
|
||||
* @type object
|
||||
*/
|
||||
var icinga = require('./icingawebtest');
|
||||
|
||||
/**
|
||||
* The casperjs object
|
||||
*
|
||||
* @type Casper
|
||||
*/
|
||||
var casper = icinga.getTestEnv();
|
||||
|
||||
/**
|
||||
* Login to the instance
|
||||
*/
|
||||
icinga.performLogin();
|
||||
|
||||
/**
|
||||
* Test if the modified attribute is correctly set when altering input
|
||||
*/
|
||||
casper.thenOpen('./config/logging', function() {
|
||||
"use strict";
|
||||
|
||||
this.test.assertExists('form[name=form_config_logging]', 'Assert the logging configuration form being displayed');
|
||||
this.test.assertEquals(
|
||||
this.getElementAttribute('form[name=form_config_logging]', 'data-icinga-form-modified'),
|
||||
"",
|
||||
'Assert a form to initially have no modified flag'
|
||||
);
|
||||
// Wait for the component to initialize
|
||||
this.wait(1000, function() {
|
||||
this.sendKeys('form[name=form_config_logging] input#logging_app_target', 'somewhere');
|
||||
this.test.assertEquals(
|
||||
this.getElementAttribute('form[name=form_config_logging]', 'data-icinga-form-modified'),
|
||||
"true",
|
||||
'Assert a form to initially be marked as modified when changed'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Test if the modified flag will be set on the server side
|
||||
*/
|
||||
casper.then(function() {
|
||||
"use strict";
|
||||
|
||||
var checkbox = this.getElementAttribute('form[name=form_config_logging] input#logging_debug_enable', 'value');
|
||||
this.click('form[name=form_config_logging] input#logging_debug_enable');
|
||||
// determine whether the text input field appears after the click or not
|
||||
var waitFn = (checkbox === '0' ? this.waitForSelector : this.waitWhileSelector).bind(this);
|
||||
waitFn('form[name=form_config_logging] input#logging_debug_target', function() {
|
||||
this.test.assertEquals(
|
||||
this.getElementAttribute('form[name=form_config_logging]', 'data-icinga-form-modified'),
|
||||
"true",
|
||||
'Assert modify flag to be set on the server side if using an autosubmit field'
|
||||
);
|
||||
}, function() {
|
||||
this.test.fail('Debug textfield appearcance didn\'t occur after click');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Run the tests
|
||||
*/
|
||||
casper.run(function() {
|
||||
"use strict";
|
||||
|
||||
this.test.done();
|
||||
});
|
|
@ -1,178 +0,0 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
set -o nounset
|
||||
cd `dirname $0`
|
||||
|
||||
DIR=`pwd`
|
||||
CASPER=$(which casperjs)
|
||||
INCLUDE=""
|
||||
EXCLUDE=""
|
||||
VERBOSE=0
|
||||
VAGRANT=0
|
||||
BUILD=0
|
||||
|
||||
CASPERJS_HOST="localhost"
|
||||
CASPERJS_PORT=80
|
||||
CASPERJS_USER="jdoe"
|
||||
CASPERJS_PASS="password"
|
||||
CASPERJS_PATH="icingaweb"
|
||||
|
||||
if [ ! -x $CASPER ]; then
|
||||
echo "CasperJS is not installed but required to run frontend tests\n"\
|
||||
"Take a look at http://casperjs.org/installation.html to see how the installation works for your system"
|
||||
exit 1
|
||||
fi;
|
||||
|
||||
|
||||
PARAM="0"
|
||||
for arg in $@;do
|
||||
if [ ! "$PARAM" = "0" ]; then
|
||||
export $PARAM=$arg
|
||||
PARAM="0"
|
||||
continue
|
||||
fi;
|
||||
case $arg in
|
||||
-v|--verbose)
|
||||
VERBOSE=1
|
||||
;;
|
||||
-V|--vagrant)
|
||||
VAGRANT=1
|
||||
;;
|
||||
-i|--include)
|
||||
PARAM="INCLUDE"
|
||||
continue
|
||||
;;
|
||||
-e|--exclude)
|
||||
PARAM="EXCLUDE"
|
||||
continue
|
||||
;;
|
||||
-b|--build)
|
||||
BUILD=1
|
||||
continue
|
||||
;;
|
||||
-h|--host)
|
||||
PARAM="CASPERJS_HOST"
|
||||
continue
|
||||
;;
|
||||
-p|--port)
|
||||
PARAM="CASPERJS_PORT"
|
||||
continue
|
||||
;;
|
||||
--path)
|
||||
PARAM="CASPERJS_PATH"
|
||||
continue
|
||||
;;
|
||||
-U|--user)
|
||||
PARAM="CASPERJS_USER"
|
||||
continue
|
||||
;;
|
||||
-P|--pass)
|
||||
PARAM="CASPERJS_PASS"
|
||||
continue
|
||||
;;
|
||||
**)
|
||||
if [ "$arg" != "--help" ]; then
|
||||
echo "Unknown option $arg"
|
||||
fi;
|
||||
printf "%b" "Testrunner for interface tests\n\n"
|
||||
printf "%b" "Usage: $0 [--verbose] [--include %include%] [--exclude %exclude%] [--build]\n\n"
|
||||
printf "%b" " --verbose \t\t\t Print verbose output when testing\n"
|
||||
printf "%b" " --include %filelist%\t\t Include only files matching this patterns\n"
|
||||
printf "%b" " --exclude %filelist%\t\t Exclude files matching this patterns\n"
|
||||
printf "%b" " --build \t\t\t Write test results to ../../build/log/casper_results.xml\n"
|
||||
printf "%b" " --host \t\t\t Host to run frontend tests on, default is localhost\n"
|
||||
printf "%b" " --port \t\t\t Port to use for the host, default is 80 \n"
|
||||
printf "%b" " --path \t\t\t Base path where icinga can be found (default is icingaweb)\n"
|
||||
printf "%b" " --user \t\t\t User to use for authentication (default jdoe)\n"
|
||||
printf "%b" " --pass \t\t\t Password to use for authentication (default password)\n"
|
||||
printf "%b" " --help \t\t\t Print this message\n\n"
|
||||
exit 1
|
||||
esac;
|
||||
done;
|
||||
|
||||
#
|
||||
# If vagrant is set the tests are ran in the vagrant VM
|
||||
#
|
||||
if [ $VAGRANT -eq 1 ] && [ $USER != "vagrant" ]; then
|
||||
# Check if vagrant is installed
|
||||
if [ ! -n `which vagrant` ]; then
|
||||
echo "Vagrant is not installed on your system!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Call the script in the Vagrant VM with the same parameters
|
||||
vagrant ssh -c "/vagrant/test/frontend/runtests $@"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
if [ "$CASPER" = "" -o ! -x $CASPER ]; then
|
||||
echo "CasperJS is not installed but required to run frontend tests\n"\
|
||||
"Take a look at http://casperjs.org/installation.html to see how the installation works for your system"
|
||||
exit 1
|
||||
fi;
|
||||
|
||||
EXEC="$CASPER test --ignore-ssl-errors=true "
|
||||
|
||||
#
|
||||
# If build is set, the results are written for our jenkins server
|
||||
#
|
||||
if [ $BUILD -eq 1 ];then
|
||||
mkdir -p $DIR/../../build/log
|
||||
EXEC="$EXEC --xunit=$DIR/../../build/log/casper_results.xml"
|
||||
fi;
|
||||
if [ "$PARAM" != "0" ]; then
|
||||
echo "Missing parameter for $PARAM"
|
||||
exit 1
|
||||
fi;
|
||||
|
||||
FILELIST=""
|
||||
#
|
||||
# Default : Run regression and cases directory
|
||||
#
|
||||
if [ "$INCLUDE" = "" -a "$EXCLUDE" = "" ];then
|
||||
FILELIST="./cases ./regression"
|
||||
fi;
|
||||
|
||||
#
|
||||
# Include patterns set with the --include directive
|
||||
#
|
||||
if [ "$INCLUDE" != "" ];then
|
||||
NAME="\("
|
||||
GLUE=""
|
||||
for INC in $INCLUDE;do
|
||||
NAME="$NAME${GLUE}${INC}.*js"
|
||||
GLUE="\|"
|
||||
done;
|
||||
NAME=$NAME"\)$"
|
||||
FILELIST=`find . | grep "$NAME"`
|
||||
fi;
|
||||
|
||||
#
|
||||
# Exclude patterns that match the include directive
|
||||
#
|
||||
if [ "$EXCLUDE" != "" ];then
|
||||
NAME="\("
|
||||
GLUE=""
|
||||
for EXC in $EXCLUDE;do
|
||||
NAME="$NAME${GLUE}${EXC}.*js"
|
||||
GLUE="\|"
|
||||
done;
|
||||
NAME=$NAME"\)$"
|
||||
if [ "$FILELIST" = "" ]; then
|
||||
FILELIST=`find .|grep ".*js$"`
|
||||
fi
|
||||
FILELIST=`echo $FILELIST | grep -v "$NAME"`
|
||||
fi;
|
||||
|
||||
|
||||
export CASPERJS_HOST=$CASPERJS_HOST
|
||||
export CASPERJS_PORT=$CASPERJS_PORT
|
||||
export CASPERJS_USER=$CASPERJS_USER
|
||||
export CASPERJS_PASS=$CASPERJS_PASS
|
||||
export CASPERJS_PATH=$CASPERJS_PATH
|
||||
|
||||
echo Executing $EXEC $FILELIST
|
||||
for JSFILE in $FILELIST;do
|
||||
$EXEC $JSFILE;
|
||||
done;
|
||||
exit 0
|
Loading…
Reference in New Issue