Commit 39402f6e authored by Jaypan's avatar Jaypan

cleanup of tests, and adding tests for inclusion and exlcusion classes

parent 4c5fa9c6
......@@ -3,7 +3,6 @@
namespace Drupal\Tests\fancy_login\FunctionalJavascript;
use Drupal\user\Entity\Role;
use Drupal\Tests\fancy_login\Base\FancyLoginJavascriptTestBase;
/**
* @group fancy_login
......@@ -324,6 +323,7 @@ class FancyLoginJavascriptTest extends FancyLoginJavascriptTestBase
// Click the create account link and confirm redirect goes to correct page
$this->clickLink('Create new account');
$this->getSession()->wait(5000);
$this->assertStatusCodeEquals(200);
$this->assertSession()->addressMatches('/\/user\/register$/');
......@@ -347,10 +347,89 @@ class FancyLoginJavascriptTest extends FancyLoginJavascriptTestBase
// Click the create new account link and confirm correct page loads
$this->clickLink('Create new account');
$this->getSession()->wait(5000);
$this->assertStatusCodeEquals(200);
$this->assertSession()->addressMatches('/\/user\/register$/');
}
public function testInclusionLink()
{
// Ensure screen is ready
$this->assertJsCondition('jQuery("#fancy_login_dim_screen").not(":animated")');
$this->assertJsCondition('jQuery("#fancy-login-user-login-form").not(":animated")');
// Click the login link
$this->click('#fancy_login_close_button');
// Ensure screen is ready
$this->assertJsCondition('jQuery("#fancy_login_dim_screen").not(":animated")');
$this->assertJsCondition('jQuery("#fancy-login-user-login-form").not(":animated")');
// Create the inclusion link
$this->getSession()->executeScript('jQuery("<a/>", {class:"fancy_login_show_popup", href:"/node/1"}).text("open popup").appendTo("body")');
$link = $this->getSession()->getPage()->find('css', 'a.fancy_login_show_popup');
if(!$link)
{
throw new \Exception('Could not create inclusion link');
}
$this->getSession()->executeScript('Drupal.attachBehaviors()');
// Confirm that the dimmer and form are hidden
$this->assertJsCondition('jQuery("#fancy_login_dim_screen").not(":visible")');
$this->assertJsCondition('jQuery("#fancy-login-user-login-form").not(":visible")');
$this->getSession()->executeScript('jQuery("#fancy_login_dim_screen").hide()');
// Trigger the popup
$this->getSession()->executeScript('jQuery("a.fancy_login_show_popup:first").click()');
// Confirm that the dimmer and form are visible
$this->assertJsCondition('jQuery("#fancy_login_dim_screen").is(":visible")');
$this->assertJsCondition('jQuery("#fancy-login-user-login-form").is(":visible")');
}
public function testExclusionLink()
{
// Ensure screen is ready
$this->assertJsCondition('jQuery("#fancy_login_dim_screen").not(":animated")');
$this->assertJsCondition('jQuery("#fancy-login-user-login-form").not(":animated")');
// Click the login link
$this->click('#fancy_login_close_button');
// Ensure screen is ready
$this->assertJsCondition('jQuery("#fancy_login_dim_screen").not(":animated")');
$this->assertJsCondition('jQuery("#fancy-login-user-login-form").not(":animated")');
// Confirm that the dimmer and form are hidden
$this->assertJsCondition('jQuery("#fancy_login_dim_screen").not(":visible")');
$this->assertJsCondition('jQuery("#fancy-login-user-login-form").not(":visible")');
// Create the inclusion link
$this->getSession()->executeScript('jQuery("<a/>", {class:"fancy_login_disable", href:"/user/login"}).text("do not open popup").prependTo("body")');
$link = $this->getSession()->getPage()->find('css', 'a.fancy_login_disable');
if(!$link)
{
throw new \Exception('Could not create exclusion link');
}
$this->getSession()->executeScript('Drupal.attachBehaviors()');
// Confirm that the dimmer and form are hidden
$this->assertJsCondition('jQuery("#fancy_login_dim_screen").not(":visible")');
$this->assertJsCondition('jQuery("#fancy-login-user-login-form").not(":visible")');
$this->getSession()->executeScript('jQuery("#fancy_login_dim_screen").remove()');
// Click the exclusion link
$this->click("a.fancy_login_disable");
$this->getSession()->wait(5000);
$this->assertStatusCodeEquals(200);
$this->assertSession()->addressMatches('/\/user\/login$/');
}
private function goToConfigPage()
{
$user = $this->createUser(['Administer fancy login', 'access administration pages']);
......@@ -359,6 +438,7 @@ class FancyLoginJavascriptTest extends FancyLoginJavascriptTestBase
$this->fillTextValue('#edit-pass', $user->passRaw);
$this->click('#fancy-login-user-login-form .form-submit');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->getSession()->wait(5000);
$this->assertStatusCodeEquals(200);
$this->assertSession()->addressMatches('/\/user\/2$/');
......
<?php
namespace Drupal\Tests\fancy_login\Base;
namespace Drupal\Tests\fancy_login\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
/**
* @group fancy_login
*/
class FancyLoginJavascriptTestBase extends JavascriptTestBase
{
public function assertStatusCodeEquals($statusCode)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment