Tests: Added browser tests for Archive plugin
parent
c6392f2168
commit
84aa5d93f1
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Browser\Plugins\Archive;
|
||||
|
||||
use Tests\Browser\Components\Popupmenu;
|
||||
|
||||
class MailTest extends \Tests\Browser\TestCase
|
||||
{
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
\bootstrap::init_db();
|
||||
\bootstrap::init_imap();
|
||||
\bootstrap::purge_mailbox('INBOX');
|
||||
\bootstrap::purge_mailbox('Archive');
|
||||
|
||||
// import single email messages
|
||||
foreach (glob(TESTS_DIR . 'data/mail/list_00.eml') as $f) {
|
||||
\bootstrap::import_message($f, 'INBOX');
|
||||
}
|
||||
}
|
||||
|
||||
public function testMailUI()
|
||||
{
|
||||
$this->browse(function ($browser) {
|
||||
$browser->go('mail');
|
||||
|
||||
if (!$browser->isDesktop()) {
|
||||
$browser->click('.back-sidebar-button');
|
||||
}
|
||||
|
||||
// Folders list
|
||||
$browser->whenAvailable('#mailboxlist', function ($browser) {
|
||||
$browser->assertVisible('li.mailbox.archive')
|
||||
->assertMissing('li.mailbox.archive .unreadcount');
|
||||
});
|
||||
|
||||
if (!$browser->isDesktop()) {
|
||||
$browser->click('.back-list-button');
|
||||
}
|
||||
|
||||
// Toolbar menu (Archive button inactive)
|
||||
$browser->assertToolbarMenu([], ['archive']);
|
||||
|
||||
$browser->whenAvailable('#messagelist tbody', function ($browser) {
|
||||
$browser->ctrlClick('tr:last-child');
|
||||
});
|
||||
|
||||
$browser->clickToolbarMenuItem('archive')
|
||||
->waitForMessage('confirmation', 'Successfully archived')
|
||||
->closeMessage('confirmation');
|
||||
|
||||
if (!$browser->isDesktop()) {
|
||||
$browser->click('.back-sidebar-button');
|
||||
}
|
||||
|
||||
// Folders list
|
||||
$browser->whenAvailable('#mailboxlist', function ($browser) {
|
||||
$browser->assertSeeIn('li.mailbox.archive .unreadcount', '1')
|
||||
->click('li.mailbox.archive')
|
||||
->waitUntilNotBusy();
|
||||
});
|
||||
|
||||
// Messages list contains the moved message
|
||||
$browser->assertElementsCount('#messagelist tbody tr', 1);
|
||||
|
||||
// Toolbar menu (Archive button inactive again)
|
||||
$browser->assertToolbarMenu([], ['archive']);
|
||||
|
||||
// Test archive class on folder in folder selector
|
||||
$browser->ctrlClick('#messagelist tbody tr')
|
||||
->clickToolbarMenuItem('more')
|
||||
->with(new Popupmenu('message-menu'), function ($browser) {
|
||||
$browser->clickMenuItem('move');
|
||||
})
|
||||
->with(new Popupmenu('folder-selector'), function ($browser) {
|
||||
$browser->assertVisible('li.archive')
|
||||
->assertSeeIn('li.archive', 'Archive');
|
||||
})
|
||||
->click(); // close menus
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Browser\Plugins\Archive;
|
||||
|
||||
class SettingsTest extends \Tests\Browser\TestCase
|
||||
{
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
\bootstrap::init_db();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Folders UI
|
||||
*/
|
||||
public function testFolders()
|
||||
{
|
||||
$this->browse(function ($browser) {
|
||||
$browser->go('settings', 'folders');
|
||||
|
||||
// Folders list
|
||||
$browser->with('#subscription-table', function ($browser) {
|
||||
$browser->assertHasClass('li:nth-child(7)', 'archive')
|
||||
->assertSeeIn('li:nth-child(7)', 'Archive')
|
||||
->assertPresent('li:nth-child(7) [type=checkbox][disabled]');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Preferences UI
|
||||
*/
|
||||
public function testPreferences()
|
||||
{
|
||||
$this->browse(function ($browser) {
|
||||
$browser->go('settings');
|
||||
|
||||
if (!$browser->isDesktop()) {
|
||||
$browser->click('#settings-menu li.preferences')
|
||||
->waitFor('#sections-table');
|
||||
}
|
||||
|
||||
$browser->click('#sections-table tr.folders');
|
||||
|
||||
if ($browser->isPhone()) {
|
||||
$browser->waitFor('#layout-content .footer a.button.submit:not(.disabled)');
|
||||
}
|
||||
|
||||
$browser->withinFrame('#preferences-frame', function ($browser) {
|
||||
if (!$browser->isPhone()) {
|
||||
$browser->waitFor('.formbuttons button.submit');
|
||||
}
|
||||
|
||||
// Main Options fieldset
|
||||
$browser->with('form.propform fieldset.main', function ($browser) {
|
||||
$browser->assertSeeIn('legend', 'Main Options');
|
||||
|
||||
$browser->assertSeeIn('label[for=_archive_mbox]', 'Archive')
|
||||
->assertVisible('select[name=_archive_mbox]')
|
||||
->assertSelected('select[name=_archive_mbox]', 'Archive');
|
||||
|
||||
$browser->select('_archive_mbox', 'Drafts');
|
||||
});
|
||||
|
||||
// Archive fieldset
|
||||
$browser->with('form.propform fieldset.archive', function ($browser) {
|
||||
$browser->assertSeeIn('legend', 'Archive');
|
||||
|
||||
$browser->assertSeeIn('label[for=ff_archive_type]', 'Divide archive by')
|
||||
->assertVisible('select[name=_archive_type]')
|
||||
->assertSelected('select[name=_archive_type]', '')
|
||||
->with('select[name=_archive_type]', function ($browser) {
|
||||
$browser->assertValue('option:nth-child(1)', '')
|
||||
->assertSeeIn('option:nth-child(1)', 'None')
|
||||
->assertValue('option:nth-child(2)', 'year')
|
||||
->assertSeeIn('option:nth-child(2)', 'Year (e.g. Archive/2012)')
|
||||
->assertValue('option:nth-child(3)', 'month')
|
||||
->assertSeeIn('option:nth-child(3)', 'Month (e.g. Archive/2012/06)')
|
||||
->assertValue('option:nth-child(4)', 'tbmonth')
|
||||
->assertSeeIn('option:nth-child(4)', 'Month - Thunderbird compatible (e.g. Archive/2012/2012-06)')
|
||||
->assertValue('option:nth-child(5)', 'sender')
|
||||
->assertSeeIn('option:nth-child(5)', 'Sender email')
|
||||
->assertValue('option:nth-child(6)', 'folder')
|
||||
->assertSeeIn('option:nth-child(6)', 'Original folder');
|
||||
});
|
||||
|
||||
$browser->select('_archive_type', 'year');
|
||||
});
|
||||
|
||||
// Submit form
|
||||
if (!$browser->isPhone()) {
|
||||
$browser->click('.formbuttons button.submit');
|
||||
}
|
||||
});
|
||||
|
||||
if ($browser->isPhone()) {
|
||||
$browser->click('#layout-content .footer a.submit');
|
||||
}
|
||||
|
||||
$browser->waitForMessage('confirmation', 'Successfully saved');
|
||||
|
||||
// Verify if every option has been updated
|
||||
$browser->withinFrame('#preferences-frame', function ($browser) {
|
||||
$browser->assertSelected('_archive_mbox', 'Drafts');
|
||||
$browser->assertSelected('_archive_type', 'year');
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue