Files
roundcubemail/tests/Browser/Mail/ListTest.php
Michael Voříšek 6a53a1d853 Fix CS (whitespace, visibility) (#9297)
* Fix "method_argument_space"

* Fix "control_structure_continuation_position"

* Fix "new_with_parentheses"

* Fix "blank_line_before_statement"

* Fix "visibility_required"

* Fix some "array_indentation"

* Fix some "array_indentation" - unify all "rcube::raise_error" calls

* rm useless eslint ignores and add rules counts

* sort eslint ignores

* fix eslint ignores grammar

* Revert "Fix "blank_line_before_statement""

* fix CS 3.46.0
2024-01-04 14:26:35 +01:00

129 lines
4.8 KiB
PHP

<?php
namespace Tests\Browser\Mail;
use Tests\Browser\Components\Toolbarmenu;
class ListTest extends \Tests\Browser\TestCase
{
protected static $msgcount = 0;
public static function setUpBeforeClass(): void
{
\bootstrap::init_imap(true);
\bootstrap::purge_mailbox('INBOX');
// import email messages
foreach (glob(TESTS_DIR . 'data/mail/list_??.eml') as $f) {
\bootstrap::import_message($f, 'INBOX');
self::$msgcount++;
}
}
public function testList()
{
$this->browse(function ($browser) {
$browser->go('mail');
$browser->waitUntilNotBusy()
->assertElementsCount('#messagelist tbody tr', self::$msgcount);
// check message list
$browser->assertVisible('#messagelist tbody tr:first-child.unread');
$this->assertSame('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');
// List toolbar menu
$browser->assertVisible('#layout-list .header a.toolbar-button.refresh:not(.disabled)');
if ($browser->isDesktop()) {
$browser->with('#toolbar-list-menu', static function ($browser) {
$browser->assertVisible('a.select:not(.disabled)');
$browser->assertVisible('a.options:not(.disabled)');
$imap = \bootstrap::get_storage();
if ($imap->get_threading()) {
$browser->assertVisible('a.threads:not(.disabled)');
} else {
$browser->assertMissing('a.threads');
}
});
} elseif ($browser->isTablet()) {
$browser->click('.toolbar-list-button')
->waitFor('#toolbar-list-menu');
$browser->with('#toolbar-list-menu', static function ($browser) {
$browser->assertVisible('a.select:not(.disabled)');
$browser->assertVisible('a.options:not(.disabled)');
$imap = \bootstrap::get_storage();
if ($imap->get_threading()) {
$browser->assertVisible('a.threads:not(.disabled)');
} else {
$browser->assertMissing('a.threads');
}
});
$browser->click(); // hide the popup menu
} else { // phone
// On phones list options are in the toolbar menu
$browser->with(new Toolbarmenu(), static function ($browser) {
$active = ['select', 'options'];
$missing = [];
$imap = \bootstrap::get_storage();
if ($imap->get_threading()) {
$active[] = 'threads';
} else {
$missing[] = 'threads';
}
$browser->assertMenuState($active, [], $missing);
});
}
});
}
/**
* @depends testList
*/
public function testListSelection()
{
$this->browse(static function ($browser) {
if ($browser->isPhone()) {
$browser->with(new Toolbarmenu(), static function ($browser) {
$browser->clickMenuItem('select', null, false);
});
} elseif ($browser->isTablet()) {
$browser->click('.toolbar-list-button');
$browser->click('#toolbar-list-menu a.select');
} else {
$browser->click('#toolbar-list-menu a.select');
$browser->assertFocused('#toolbar-list-menu a.select');
}
// Popup menu content
$browser->waitFor('#listselect-menu');
$browser->with('#listselect-menu', static function ($browser) {
$browser->assertVisible('a.selection:not(.disabled)');
$browser->assertVisible('a.select.all:not(.disabled)');
$browser->assertVisible('a.select.page:not(.disabled)');
$browser->assertVisible('a.select.unread:not(.disabled)');
$browser->assertVisible('a.select.flagged:not(.disabled)');
$browser->assertVisible('a.select.invert:not(.disabled)');
$browser->assertVisible('a.select.none:not(.disabled)');
});
// Close the menu(s) by clicking the page body
$browser->click();
$browser->waitUntilMissing('#listselect-menu');
// TODO: Test selection actions
});
}
}