Fix frontend tests, give forms names

refs #4491
This commit is contained in:
Jannis Moßhammer 2013-08-28 10:12:27 +02:00
parent ec359c76d8
commit 0f36cfce62
7 changed files with 36 additions and 19 deletions

View File

@ -43,7 +43,7 @@ class LoginForm extends Form
*/ */
protected function create() protected function create()
{ {
$this->setName('login'); $this->setName('form_login');
$this->addElement( $this->addElement(
'text', 'text',
'username', 'username',

View File

@ -67,6 +67,7 @@ class DbBackendForm extends BaseBackendForm
*/ */
public function create() public function create()
{ {
$this->setName('form_modify_backend');
$name = $this->filterName($this->getBackendName()); $name = $this->filterName($this->getBackendName());
$this->addElement( $this->addElement(

View File

@ -49,6 +49,7 @@ class LdapBackendForm extends BaseBackendForm
*/ */
public function create() public function create()
{ {
$this->setName('form_modify_backend');
$name = $this->filterName($this->getBackendName()); $name = $this->filterName($this->getBackendName());
$backend = $this->getBackend(); $backend = $this->getBackend();

View File

@ -69,6 +69,7 @@ class ConfirmRemovalForm extends Form
*/ */
public function create() public function create()
{ {
$this->setName('form_confirm_removal');
$this->addElement( $this->addElement(
'hidden', 'hidden',
$this->targetName, $this->targetName,

View File

@ -32,19 +32,19 @@ var casper = icinga.getTestEnv();
var assertLoginFormExists = function(test) { var assertLoginFormExists = function(test) {
test.assertExists( test.assertExists(
'form#login', 'form#form_login',
'Test whether the login form exists' 'Test whether the login form exists'
); );
test.assertExists( test.assertExists(
'form#login input#username', 'form#form_login input#username',
'Test whether a username input field exists' 'Test whether a username input field exists'
); );
test.assertExists( test.assertExists(
'form#login input#password', 'form#form_login input#password',
'Test whether a password input field exists' 'Test whether a password input field exists'
); );
test.assertExists( test.assertExists(
'form#login input#submit', 'form#form_login input#submit',
'Test whether a submit input field exists' 'Test whether a submit input field exists'
); );
}; };
@ -71,11 +71,11 @@ casper.start('/', function() {
* Login with invalid credentials * Login with invalid credentials
*/ */
casper.then(function() { casper.then(function() {
this.fill('form#login', { this.fill('form#form_login', {
'username' : 'no', 'username' : 'no',
'password' : 'existing_user' 'password' : 'existing_user'
}); });
this.click('form#login input#submit'); this.click('form#form_login input#submit');
}); });
/** /**
@ -98,8 +98,8 @@ casper.then(function() {
* Login with valid credentials * Login with valid credentials
*/ */
casper.then(function() { casper.then(function() {
this.fill('form#login', icinga.getCredentials()); this.fill('form#form_login', icinga.getCredentials());
this.click('form#login input#submit'); this.click('form#form_login input#submit');
}); });
/** /**
@ -151,7 +151,7 @@ casper.then(function() {
this.click('#icinga_app_nav_useraction'); this.click('#icinga_app_nav_useraction');
this.waitUntilVisible('#icinga_app_nav_logout', function() { this.waitUntilVisible('#icinga_app_nav_logout', function() {
this.click('#icinga_app_nav_logout a'); this.click('#icinga_app_nav_logout a');
this.waitForSelector('form#login', function() { this.waitForSelector('form#form_login', function() {
this.test.assertDoesntExist( this.test.assertDoesntExist(
'#icinga_app_username', '#icinga_app_username',
'Test if no username is set in the frontend after logout' 'Test if no username is set in the frontend after logout'

View File

@ -110,8 +110,8 @@ if (path === null) {
exports.performLogin = function() { exports.performLogin = function() {
casper.start("/authentication/login", function() { casper.start("/authentication/login", function() {
this.fill('form#login', icinga.getCredentials()); this.fill('form#form_login', icinga.getCredentials());
this.click('form#login input#submit'); this.click('form#form_login input#submit');
}); });
}; };
})(); })();

View File

@ -55,6 +55,7 @@ casper.then(function() {
'div.alert.alert-success', 'div.alert.alert-success',
'Assert no success notice existing when no changes have been done in the general form' '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', { this.fill('#form_config_general', {
'timezone': 'Europe/Minsk' 'timezone': 'Europe/Minsk'
}); });
@ -65,6 +66,7 @@ casper.then(function() {
* Check for the 'Successfully Update' information bubble * Check for the 'Successfully Update' information bubble
*/ */
casper.then(function() { casper.then(function() {
this.echo("Clicked on save button of the general form, waiting for success");
this.waitForSelector('div.alert.alert-success', function() { this.waitForSelector('div.alert.alert-success', function() {
this.test.assertSelectorHasText( this.test.assertSelectorHasText(
'div.alert.alert-success', 'div.alert.alert-success',
@ -72,7 +74,7 @@ casper.then(function() {
'Assert a success text to appear in the general form' 'Assert a success text to appear in the general form'
); );
}, function() { }, function() {
this.die("No success text appeared in the general form"); this.fail("No success text appeared in the general form");
}); });
}); });
@ -85,9 +87,12 @@ casper.thenOpen('/config/authentication', function() {
for (var i=0; i<links.length; i++) { for (var i=0; i<links.length; i++) {
if (/.* Edit This Authentication/.test(links[i].text)) { if (/.* Edit This Authentication/.test(links[i].text)) {
document.location.href = links[i].getAttribute('href'); document.location.href = links[i].getAttribute('href');
return;
} }
} }
}); });
this.echo("Clicked on first authentication backend link");
}); });
/** /**
@ -96,8 +101,21 @@ casper.thenOpen('/config/authentication', function() {
casper.then(function() { casper.then(function() {
this.waitForSelector('input#btn_submit', function() { this.waitForSelector('input#btn_submit', function() {
this.click('input#btn_submit'); this.click('input#btn_submit');
this.waitForSelector('div.alert.alert-success', function() { this.echo("Submitted authentication form");
this.test.assertExists('div.alert.alert-success', 'Assert a success message to exist');
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() { }, function() {
this.test.fail("Success message for authentication provider tests didn't pop up"); this.test.fail("Success message for authentication provider tests didn't pop up");
}); });
@ -113,15 +131,11 @@ casper.then(function() {
casper.thenOpen('/config/logging', function() { casper.thenOpen('/config/logging', function() {
this.test.assertExists('form#form_config_logging', 'Asserting the logging form to exist'); this.test.assertExists('form#form_config_logging', 'Asserting the logging form to exist');
this.click('form#form_config_logging input#btn_submit'); this.click('form#form_config_logging input#btn_submit');
this.echo("Submitting authentication form1");
this.waitForSelector('div.alert.alert-success', function() { this.waitForSelector('div.alert.alert-success', function() {
this.test.assertExists('div.alert.alert-success', 'Assert a success message to exist'); this.test.assertExists('div.alert.alert-success', 'Assert a success message to exist');
}, function() { }, function() {
this.test.fail('No success message popped up when saving logging configuration'); this.test.fail('No success message popped up when saving logging configuration');
}); });
this.echo("Submitting authentication form2");
}); });
/** /**