From 0f36cfce620a3af9910a45984e2f8be2924e1edc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Mo=C3=9Fhammer?= Date: Wed, 28 Aug 2013 10:12:27 +0200 Subject: [PATCH] Fix frontend tests, give forms names refs #4491 --- .../forms/Authentication/LoginForm.php | 2 +- .../Config/Authentication/DbBackendForm.php | 1 + .../Config/Authentication/LdapBackendForm.php | 1 + .../forms/Config/ConfirmRemovalForm.php | 1 + test/frontend/cases/loginpageTest.js | 18 ++++++------ test/frontend/icingawebtest.js | 4 +-- test/frontend/regression/regression-4606.js | 28 ++++++++++++++----- 7 files changed, 36 insertions(+), 19 deletions(-) diff --git a/application/forms/Authentication/LoginForm.php b/application/forms/Authentication/LoginForm.php index a7d8a31e3..2d96b4f87 100644 --- a/application/forms/Authentication/LoginForm.php +++ b/application/forms/Authentication/LoginForm.php @@ -43,7 +43,7 @@ class LoginForm extends Form */ protected function create() { - $this->setName('login'); + $this->setName('form_login'); $this->addElement( 'text', 'username', diff --git a/application/forms/Config/Authentication/DbBackendForm.php b/application/forms/Config/Authentication/DbBackendForm.php index 9bdebfcde..daeb38079 100644 --- a/application/forms/Config/Authentication/DbBackendForm.php +++ b/application/forms/Config/Authentication/DbBackendForm.php @@ -67,6 +67,7 @@ class DbBackendForm extends BaseBackendForm */ public function create() { + $this->setName('form_modify_backend'); $name = $this->filterName($this->getBackendName()); $this->addElement( diff --git a/application/forms/Config/Authentication/LdapBackendForm.php b/application/forms/Config/Authentication/LdapBackendForm.php index e2ab898e4..ffe34f593 100644 --- a/application/forms/Config/Authentication/LdapBackendForm.php +++ b/application/forms/Config/Authentication/LdapBackendForm.php @@ -49,6 +49,7 @@ class LdapBackendForm extends BaseBackendForm */ public function create() { + $this->setName('form_modify_backend'); $name = $this->filterName($this->getBackendName()); $backend = $this->getBackend(); diff --git a/application/forms/Config/ConfirmRemovalForm.php b/application/forms/Config/ConfirmRemovalForm.php index aad77e750..3fe3a568d 100644 --- a/application/forms/Config/ConfirmRemovalForm.php +++ b/application/forms/Config/ConfirmRemovalForm.php @@ -69,6 +69,7 @@ class ConfirmRemovalForm extends Form */ public function create() { + $this->setName('form_confirm_removal'); $this->addElement( 'hidden', $this->targetName, diff --git a/test/frontend/cases/loginpageTest.js b/test/frontend/cases/loginpageTest.js index f56c50d73..21b800fd7 100644 --- a/test/frontend/cases/loginpageTest.js +++ b/test/frontend/cases/loginpageTest.js @@ -32,19 +32,19 @@ var casper = icinga.getTestEnv(); var assertLoginFormExists = function(test) { test.assertExists( - 'form#login', + 'form#form_login', 'Test whether the login form exists' ); test.assertExists( - 'form#login input#username', + 'form#form_login input#username', 'Test whether a username input field exists' ); test.assertExists( - 'form#login input#password', + 'form#form_login input#password', 'Test whether a password input field exists' ); test.assertExists( - 'form#login input#submit', + 'form#form_login input#submit', 'Test whether a submit input field exists' ); }; @@ -71,11 +71,11 @@ casper.start('/', function() { * Login with invalid credentials */ casper.then(function() { - this.fill('form#login', { + this.fill('form#form_login', { 'username' : 'no', '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 */ casper.then(function() { - this.fill('form#login', icinga.getCredentials()); - this.click('form#login input#submit'); + this.fill('form#form_login', icinga.getCredentials()); + this.click('form#form_login input#submit'); }); /** @@ -151,7 +151,7 @@ casper.then(function() { this.click('#icinga_app_nav_useraction'); this.waitUntilVisible('#icinga_app_nav_logout', function() { this.click('#icinga_app_nav_logout a'); - this.waitForSelector('form#login', function() { + this.waitForSelector('form#form_login', function() { this.test.assertDoesntExist( '#icinga_app_username', 'Test if no username is set in the frontend after logout' diff --git a/test/frontend/icingawebtest.js b/test/frontend/icingawebtest.js index 26660e6ec..b4de406d6 100644 --- a/test/frontend/icingawebtest.js +++ b/test/frontend/icingawebtest.js @@ -110,8 +110,8 @@ if (path === null) { exports.performLogin = function() { casper.start("/authentication/login", function() { - this.fill('form#login', icinga.getCredentials()); - this.click('form#login input#submit'); + this.fill('form#form_login', icinga.getCredentials()); + this.click('form#form_login input#submit'); }); }; })(); diff --git a/test/frontend/regression/regression-4606.js b/test/frontend/regression/regression-4606.js index 1766aa3ce..a7ff0c07d 100644 --- a/test/frontend/regression/regression-4606.js +++ b/test/frontend/regression/regression-4606.js @@ -55,6 +55,7 @@ casper.then(function() { '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' }); @@ -65,6 +66,7 @@ casper.then(function() { * 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', @@ -72,7 +74,7 @@ casper.then(function() { 'Assert a success text to appear in the general form' ); }, 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