Skip to content
Snippets Groups Projects
Commit 725d60a2 authored by Chris Hallberg's avatar Chris Hallberg
Browse files

Record Email Lightbox fix

Fixes an error with creating an account while emailing a record by adding an action. Also adds tests for this particular case.
parent aad6ec26
Branches
Tags
No related merge requests found
......@@ -79,6 +79,21 @@ class RecordActionsTest extends \VuFindTest\Unit\MinkTestCase
return $page;
}
/**
* Make new account
*
* @return void
*/
protected function makeAccount($page, $username) {
$this->findCss($page, '.modal-body .createAccountLink')->click();
$this->snooze();
$this->fillInAccountForm(
$page, ['username' => $username, 'email' => $username . '@vufind.org']
);
$this->findCss($page, '.modal-body .btn.btn-primary')->click();
$this->snooze();
}
/**
* Test adding comments on records.
*
......@@ -106,11 +121,7 @@ class RecordActionsTest extends \VuFindTest\Unit\MinkTestCase
$this->findCss($page, '.modal.in'); // Lightbox open
$this->findCss($page, '.modal [name="username"]');
// Create new account
$this->findCss($page, '.modal-body .createAccountLink')->click();
$this->snooze();
$this->fillInAccountForm($page);
$this->findCss($page, '.modal-body .btn.btn-primary')->click();
$this->snooze();
$this->makeAccount($page, 'username1');
// Make sure page updated for login
$page = $this->gotoRecord();
$this->findCss($page, '.record-tabs .usercomments')->click();
......@@ -154,12 +165,8 @@ class RecordActionsTest extends \VuFindTest\Unit\MinkTestCase
// Lightbox login open?
$this->findCss($page, '.modal.in [name="username"]');
// Make account
$this->findCss($page, '.modal-body .createAccountLink')->click();
$this->fillInAccountForm(
$page, ['username' => 'username2', 'email' => 'test2@com.com']
);
$this->findCss($page, '.modal-body .btn.btn-primary')->click();
$this->snooze();
$this->makeAccount($page, 'username2');
// Add tag exists?
$this->findCss($page, '.modal #addtag_tag');
$this->findCss($page, '.modal .close')->click();
$this->snooze(); // wait for display to update
......@@ -251,6 +258,31 @@ class RecordActionsTest extends \VuFindTest\Unit\MinkTestCase
]
);
// Go to a record view
$page = $this->gotoRecord();
// Click email record without logging in
$this->findCss($page, '.mail-record')->click();
$this->snooze();
$this->findCss($page, '.modal.in [name="username"]');
// Make account
$this->makeAccount($page, 'emailmaniac');
// Make sure Lightbox redirects to email view
$this->findCss($page, '.modal #email_to');
// Type invalid email
$this->findCss($page, '.modal #email_to')->setValue('blargarsaurus');
$this->findCss($page, '.modal #email_from')->setValue('asdf@asdf.com');
$this->findCss($page, '.modal #email_message')->setValue('message');
// Send text to false email
$this->snooze();
$this->findCss($page, '.modal #email_to')->setValue('asdf@vufind.org');
$this->findCss($page, '.modal-body .btn.btn-primary')->click();
$this->snooze();
// Check for confirmation message
$this->findCss($page, '.modal .alert-success');
$this->findCss($page, '.modal .close')->click();
// Logout
$this->findCss($page, '.logoutOptions a.logout')->click();
// Go to a record view
$page = $this->gotoRecord();
// Click email record without logging in
......@@ -258,7 +290,7 @@ class RecordActionsTest extends \VuFindTest\Unit\MinkTestCase
$this->snooze();
$this->findCss($page, '.modal.in [name="username"]');
// Login in Lightbox
$this->fillInLoginForm($page, 'username1', 'test');
$this->fillInLoginForm($page, 'emailmaniac', 'test');
$this->submitLoginForm($page);
// Make sure Lightbox redirects to email view
$this->findCss($page, '.modal #email_to');
......@@ -269,13 +301,9 @@ class RecordActionsTest extends \VuFindTest\Unit\MinkTestCase
$this->findCss($page, '.mail-record')->click();
$this->snooze();
$this->findCss($page, '.modal #email_to');
// Type invalid email
$this->findCss($page, '.modal #email_to')->setValue('blargarsaurus');
$this->findCss($page, '.modal #email_from')->setValue('asdf@asdf.com');
$this->findCss($page, '.modal #email_message')->setValue('message');
// Send text to false email
$this->snooze();
$this->findCss($page, '.modal #email_to')->setValue('asdf@vufind.org');
$this->findCss($page, '.modal #email_from')->setValue('asdf@vufind.org');
$this->findCss($page, '.modal-body .btn.btn-primary')->click();
$this->snooze();
// Check for confirmation message
......@@ -349,6 +377,6 @@ class RecordActionsTest extends \VuFindTest\Unit\MinkTestCase
*/
public static function tearDownAfterClass()
{
static::removeUsers(['username1', 'username2']);
static::removeUsers(['username1', 'username2', 'emailmaniac']);
}
}
......@@ -8,7 +8,7 @@
. '<li class="active">' . $this->transEsc('Email Record') . '</li>';
?>
<h2><?=$this->transEsc('Email Record') ?>: <span class="title-in-heading"><?=$this->escapeHtml($this->driver->getBreadcrumb())?></span></h2>
<form class="form-horizontal" method="post" name="emailRecord">
<form class="form-horizontal" method="post" action="<?=$this->recordLink()->getActionUrl($this->driver, 'Email')?>" name="emailRecord">
<?=$this->flashmessages()?>
<input type="hidden" name="id" value="<?=$this->escapeHtmlAttr($this->driver->getUniqueId())?>" />
<input type="hidden" name="source" value="<?=$this->escapeHtmlAttr($this->driver->getSourceIdentifier())?>" />
......
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