diff --git a/.ci/config-test.inc.php b/.ci/config-test.inc.php
index d9b8195dd..c64f6ac96 100644
--- a/.ci/config-test.inc.php
+++ b/.ci/config-test.inc.php
@@ -18,3 +18,8 @@ $config['create_default_folders'] = true;
$config['skin'] = 'elastic';
$config['support_url'] = 'http://support.url';
+// Plugins with tests
+
+$config['plugins'] = ['archive'];
+
+$config['archive_mbox'] = 'Archive';
diff --git a/plugins/archive/tests/Browser/MailTest.php b/plugins/archive/tests/Browser/MailTest.php
new file mode 100644
index 000000000..7cfcbc435
--- /dev/null
+++ b/plugins/archive/tests/Browser/MailTest.php
@@ -0,0 +1,82 @@
+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
+ });
+ }
+}
diff --git a/plugins/archive/tests/Browser/SettingsTest.php b/plugins/archive/tests/Browser/SettingsTest.php
new file mode 100644
index 000000000..5b137b33b
--- /dev/null
+++ b/plugins/archive/tests/Browser/SettingsTest.php
@@ -0,0 +1,108 @@
+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');
+ });
+ });
+ }
+}
diff --git a/tests/Browser/Browser.php b/tests/Browser/Browser.php
index e9af776e3..f6733f058 100644
--- a/tests/Browser/Browser.php
+++ b/tests/Browser/Browser.php
@@ -139,6 +139,8 @@ class Browser extends \Laravel\Dusk\Browser
$this->driver->getKeyboard()->pressKey(WebDriverKeys::LEFT_CONTROL);
$this->element($selector)->click();
$this->driver->getKeyboard()->releaseKey(WebDriverKeys::LEFT_CONTROL);
+
+ return $this;
}
/**
@@ -259,6 +261,16 @@ class Browser extends \Laravel\Dusk\Browser
return $this;
}
+ /**
+ * Wait until the UI is unlocked
+ */
+ public function waitUntilNotBusy()
+ {
+ $this->waitUntil("!rcmail.busy");
+
+ return $this;
+ }
+
/**
* Wait for UI (notice/confirmation/loading/error/warning) message
* and assert it's text
diff --git a/tests/Browser/Mail/ListTest.php b/tests/Browser/Mail/ListTest.php
index 3efe16816..8b1861887 100644
--- a/tests/Browser/Mail/ListTest.php
+++ b/tests/Browser/Mail/ListTest.php
@@ -25,7 +25,8 @@ class ListTest extends \Tests\Browser\TestCase
$this->browse(function ($browser) {
$browser->go('mail');
- $browser->assertElementsCount('#messagelist tbody tr', self::$msgcount);
+ $browser->waitUntilNotBusy()
+ ->assertElementsCount('#messagelist tbody tr', self::$msgcount);
// check message list
$browser->assertVisible('#messagelist tbody tr:first-child.unread');
diff --git a/tests/Browser/Settings/FoldersTest.php b/tests/Browser/Settings/FoldersTest.php
index 4a9a8a7cf..08bbd78f0 100644
--- a/tests/Browser/Settings/FoldersTest.php
+++ b/tests/Browser/Settings/FoldersTest.php
@@ -45,9 +45,8 @@ class FoldersTest extends \Tests\Browser\TestCase
// Folders list
$browser->with('#subscription-table', function ($browser) {
- $browser->assertElementsCount('li', 5)
- // Note: first li element is root which is hidden in Elastic
- ->assertHasClass('li:nth-child(2)', 'inbox')
+ // Note: first li element is root which is hidden in Elastic
+ $browser->assertHasClass('li:nth-child(2)', 'inbox')
->assertSeeIn('li:nth-child(2)', 'Inbox')
->assertPresent('li:nth-child(2) [type=checkbox][disabled]')
->assertHasClass('li:nth-child(3)', 'drafts')
@@ -74,6 +73,8 @@ class FoldersTest extends \Tests\Browser\TestCase
$this->browse(function ($browser) {
$browser->go('settings', 'folders');
+ $num = count($browser->elements('#subscription-table li'));
+
if ($browser->isPhone()) {
$browser->assertVisible('.floating-action-buttons a.create:not(.disabled)')
->click('.floating-action-buttons a.create')
@@ -117,13 +118,15 @@ class FoldersTest extends \Tests\Browser\TestCase
$browser->closeMessage('confirmation');
+ $num++;
+
// Folders list
- $browser->with('#subscription-table', function ($browser) {
+ $browser->with('#subscription-table', function ($browser) use ($num) {
// Note: li.root is hidden in Elastic
- $browser->waitFor('li.mailbox:nth-child(7)')
- ->assertElementsCount('li', 6)
- ->assertPresent('li.mailbox:nth-child(7) [type=checkbox]:not([disabled])')
- ->click('li.mailbox:nth-child(7)');
+ $browser->waitFor("li.mailbox:nth-child({$num})")
+ ->assertElementsCount('li', $num - 1)
+ ->assertPresent("li.mailbox:nth-child({$num}) [type=checkbox]:not([disabled])")
+ ->click("li.mailbox:nth-child({$num})");
});
if ($browser->isPhone()) {
@@ -141,7 +144,7 @@ class FoldersTest extends \Tests\Browser\TestCase
->waitFor('#subscription-table');
}
- $browser->setCheckboxState('#subscription-table li:nth-child(7) input', false)
+ $browser->setCheckboxState("#subscription-table li:nth-child({$num}) input", false)
->waitForMessage('confirmation', 'Folder successfully unsubscribed.');
});
}
diff --git a/tests/Browser/Settings/Preferences/GeneralTest.php b/tests/Browser/Settings/Preferences/GeneralTest.php
index 2c580c5f5..de124aefe 100644
--- a/tests/Browser/Settings/Preferences/GeneralTest.php
+++ b/tests/Browser/Settings/Preferences/GeneralTest.php
@@ -6,13 +6,9 @@ use Tests\Browser\Components\App;
class GeneralTest extends \Tests\Browser\TestCase
{
- protected function tearDown()
+ public static function setUpBeforeClass()
{
- parent::tearDown();
-
- // Reset user preferences back to defaults
- $db = $this->app->get_dbh();
- $db->query("UPDATE users SET preferences = '' WHERE username = ?", TESTS_USER);
+ \bootstrap::init_db();
}
public function testGeneral()
diff --git a/tests/Browser/Settings/PreferencesTest.php b/tests/Browser/Settings/PreferencesTest.php
index 81e3a15e9..e8998358d 100644
--- a/tests/Browser/Settings/PreferencesTest.php
+++ b/tests/Browser/Settings/PreferencesTest.php
@@ -19,20 +19,19 @@ class PreferencesTest extends \Tests\Browser\TestCase
// On phone/tablet #sections-table is initially hidden
if (!$browser->isDesktop()) {
- $browser->assertMissing('#sections-table');
- $browser->click('#settings-menu li.preferences');
- $browser->waitFor('#sections-table');
+ $browser->assertMissing('#sections-table')
+ ->click('#settings-menu li.preferences')
+ ->waitFor('#sections-table');
}
-
// Preferences actions
$browser->with('#sections-table', function($browser) {
- $browser->assertSeeIn('tr.general', 'User Interface');
- $browser->assertSeeIn('tr.mailbox', 'Mailbox View');
- $browser->assertSeeIn('tr.mailview', 'Displaying Messages');
- $browser->assertSeeIn('tr.compose', 'Composing Messages');
- $browser->assertSeeIn('tr.addressbook', 'Contacts');
- $browser->assertSeeIn('tr.folders', 'Special Folders');
- $browser->assertSeeIn('tr.server', 'Server Settings');
+ $browser->assertSeeIn('tr.general', 'User Interface')
+ ->assertSeeIn('tr.mailbox', 'Mailbox View')
+ ->assertSeeIn('tr.mailview', 'Displaying Messages')
+ ->assertSeeIn('tr.compose', 'Composing Messages')
+ ->assertSeeIn('tr.addressbook', 'Contacts')
+ ->assertSeeIn('tr.folders', 'Special Folders')
+ ->assertSeeIn('tr.server', 'Server Settings');
});
});
}
diff --git a/tests/Browser/bootstrap.php b/tests/Browser/bootstrap.php
index 80e89452a..cef2ad7e5 100644
--- a/tests/Browser/bootstrap.php
+++ b/tests/Browser/bootstrap.php
@@ -110,8 +110,6 @@ class bootstrap
}
self::connect_imap(TESTS_USER, TESTS_PASS);
- self::purge_mailbox('INBOX');
- // self::ensure_mailbox('Archive', true);
return self::$imap_ready;
}
@@ -145,6 +143,12 @@ class bootstrap
rcube::raise_error("IMAP error: unable to authenticate with user " . TESTS_USER, false, true);
}
+ if (in_array('archive', (array) $rcmail->config->get('plugins'))) {
+ // Register special folder type for the Archive plugin.
+ // As we're in cli mode the plugin can't do it by its own
+ rcube_storage::$folder_types[] = 'archive';
+ }
+
self::$imap_ready = true;
}
diff --git a/tests/Browser/phpunit.xml b/tests/Browser/phpunit.xml
index 453492bfa..3df29f4e0 100644
--- a/tests/Browser/phpunit.xml
+++ b/tests/Browser/phpunit.xml
@@ -14,5 +14,8 @@
Mail
+
+ ../../plugins/*/tests/Browser
+