Add browser tests for mail preview

pull/6781/merge
Aleksander Machniak 4 years ago
parent 7d2b4f8d15
commit c4f114fa84

@ -4,19 +4,17 @@ namespace Tests\Browser\Mail;
class Getunread extends \Tests\Browser\TestCase
{
protected $msgcount = 0;
protected static $msgcount = 0;
protected function setUp()
public static function setUpBeforeClass()
{
parent::setUp();
\bootstrap::init_imap();
\bootstrap::purge_mailbox('INBOX');
// import email messages
foreach (glob(TESTS_DIR . 'data/mail/list_*.eml') as $f) {
foreach (glob(TESTS_DIR . 'data/mail/list_??.eml') as $f) {
\bootstrap::import_message($f, 'INBOX');
$this->msgcount++;
self::$msgcount++;
}
}
@ -28,7 +26,7 @@ class Getunread extends \Tests\Browser\TestCase
$browser->waitFor('#messagelist tbody tr');
// Messages list state
$this->assertCount($this->msgcount, $browser->elements('#messagelist tbody tr.unread'));
$this->assertCount(self::$msgcount, $browser->elements('#messagelist tbody tr.unread'));
if (!$browser->isDesktop()) {
$browser->click('.back-sidebar-button');
@ -37,7 +35,7 @@ class Getunread extends \Tests\Browser\TestCase
// Folders list state
$browser->assertVisible('.folderlist li.inbox.unread');
$this->assertEquals(strval($this->msgcount), $browser->text('.folderlist li.inbox span.unreadcount'));
$this->assertEquals(strval(self::$msgcount), $browser->text('.folderlist li.inbox span.unreadcount'));
});
}
}

@ -6,16 +6,17 @@ use Tests\Browser\Components\Toolbarmenu;
class MailList extends \Tests\Browser\TestCase
{
protected function setUp()
{
parent::setUp();
protected static $msgcount = 0;
public static function setUpBeforeClass()
{
\bootstrap::init_imap();
\bootstrap::purge_mailbox('INBOX');
// import email messages
foreach (glob(TESTS_DIR . 'data/mail/list_00.eml') as $f) {
foreach (glob(TESTS_DIR . 'data/mail/list_??.eml') as $f) {
\bootstrap::import_message($f, 'INBOX');
self::$msgcount++;
}
}
@ -24,12 +25,13 @@ class MailList extends \Tests\Browser\TestCase
$this->browse(function ($browser) {
$browser->go('mail');
$this->assertCount(1, $browser->elements('#messagelist tbody tr'));
$this->assertCount(self::$msgcount, $browser->elements('#messagelist tbody tr'));
// check message list
$browser->assertVisible('#messagelist tbody tr:first-child.unread');
$this->assertEquals('Lines', $browser->text('#messagelist tbody tr:first-child span.subject'));
$this->assertEquals('Test HTML with local and remote image',
$browser->text('#messagelist tbody tr:first-child span.subject'));
// Note: This element icon has width=0, use assertPresent() not assertVisible()
$browser->assertPresent('#messagelist tbody tr:first-child span.msgicon.unread');
@ -52,7 +54,8 @@ class MailList extends \Tests\Browser\TestCase
});
}
else if ($browser->isTablet()) {
$browser->click('.toolbar-list-button');
$browser->click('.toolbar-list-button')
->waitFor('#toolbar-list-menu');
$browser->with('#toolbar-list-menu', function ($browser) {
$browser->assertVisible('a.select:not(.disabled)');

@ -7,10 +7,8 @@ use Tests\Browser\Components\Popupmenu;
class Open extends \Tests\Browser\TestCase
{
protected function setUp()
public static function setUpBeforeClass()
{
parent::setUp();
\bootstrap::init_imap();
\bootstrap::purge_mailbox('INBOX');

@ -0,0 +1,98 @@
<?php
namespace Tests\Browser\Mail;
use Tests\Browser\Components\App;
use Tests\Browser\Components\Popupmenu;
class Preview extends \Tests\Browser\TestCase
{
public static function setUpBeforeClass()
{
\bootstrap::init_imap();
\bootstrap::purge_mailbox('INBOX');
// import email messages
foreach (glob(TESTS_DIR . 'data/mail/list_??.eml') as $f) {
\bootstrap::import_message($f, 'INBOX');
}
}
/**
* Test opening an email in preview frame
*/
public function testPreview()
{
$this->browse(function ($browser) {
$browser->go('mail');
$browser->waitFor('#messagelist tbody tr:first-child')
->click('#messagelist tbody tr:first-child')
->waitForMessage('loading', 'Loading...')
->waitFor('#messagecontframe')
->waitUntilMissing('#messagestack');
// On phone check frame controls
if ($browser->isPhone()) {
$browser->with('#layout-content .footer', function ($browser) {
$browser->assertVisible('a.button.prev.disabled')
->assertVisible('a.button.next:not(.disabled)')
->assertVisible('a.button.reply:not(.disabled)')
->assertSeeIn('a.button.prev', 'Previous')
->assertSeeIn('a.button.reply', 'Reply')
->assertSeeIn('a.button.next', 'Next');
});
}
$browser->withinFrame('#messagecontframe', function ($browser) {
$browser->waitFor('img.contactphoto');
// Privacy warning
$browser->assertVisible('#remote-objects-message.alert-warning')
->assertSeeIn('#remote-objects-message', 'To protect your privacy remote resources have been blocked.');
// Images
$this->assertRegExp('/action=get/', $browser->attribute('p#v1attached > img', 'src'));
$this->assertRegExp('/blocked/', $browser->attribute('p#v1remote > img', 'src'));
// Attachments list
$browser->with('#attachment-list', function ($browser) {
$browser->assertVisible('li.image.ico')
->assertSeeIn('li .attachment-name', 'favicon.ico')
->assertSeeIn('li .attachment-size', '(~2 KB)')
->click('a.dropdown');
});
if (!$browser->isPhone()) {
$browser->waitFor('#attachmentmenu')
->with('#attachmentmenu', function ($browser) {
$browser->assertVisible('a.extwin.disabled')
->assertVisible('a.download:not(.disabled)')
->click('a.download');
});
}
});
if ($browser->isPhone()) {
$browser->waitFor('#attachmentmenu-clone')
->with('#attachmentmenu-clone', function ($browser) {
$browser->assertVisible('a.extwin.disabled')
->assertVisible('a.download:not(.disabled)')
->click('a.download');
});
}
$ico = $browser->readDownloadedFile('favicon.ico');
$this->assertTrue(strlen($ico) == 2294);
$this->assertSame("\0\0\1\0", substr($ico, 0, 4));
$browser->removeDownloadedFile('favicon.ico');
// On phone check Back button
if ($browser->isPhone()) {
$browser->click('#layout-content .header a.back-list-button')
->assertVisible('#messagelist');
}
});
}
}

@ -27,6 +27,7 @@
<file>Mail/Getunread.php</file>
<file>Mail/List.php</file>
<file>Mail/Open.php</file>
<file>Mail/Preview.php</file>
</testsuite>
</testsuites>
</phpunit>

Loading…
Cancel
Save