Page MenuHomePhorge

No OneTemporary

Size
9 KB
Referenced Files
None
Subscribers
None
diff --git a/tests/Browser/Components/Toolbarmenu.php b/tests/Browser/Components/Toolbarmenu.php
index 39b0e3c80..376e162be 100644
--- a/tests/Browser/Components/Toolbarmenu.php
+++ b/tests/Browser/Components/Toolbarmenu.php
@@ -1,126 +1,130 @@
<?php
namespace Tests\Browser\Components;
use Tests\Browser\Browser;
use Laravel\Dusk\Component as BaseComponent;
class Toolbarmenu extends BaseComponent
{
/**
* Get the root selector for the component.
*
* @return string
*/
public function selector()
{
return '#toolbar-menu';
}
/**
* Assert that the browser page contains the component.
*
* @param Browser $browser
*
* @return void
*/
public function assert($browser)
{
if ($browser->isPhone()) {
$browser->assertPresent($this->selector());
}
else {
$browser->assertVisible($this->selector());
}
}
/**
* Get the element shortcuts for the component.
*
* @return array
*/
public function elements()
{
return [
];
}
/**
* Assert toolbar menu state
*/
- public function assertMenuState($browser, $active, $disabled)
+ public function assertMenuState($browser, $active, $disabled = [], $missing = [])
{
// On phone the menu is invisible, open it
if ($browser->isPhone()) {
$browser->withinBody(function ($browser) {
$browser->click('.toolbar-menu-button');
$browser->waitFor($this->selector());
});
}
foreach ($active as $option) {
// Print action is disabled on phones
if ($option == 'print' && $browser->isPhone()) {
$browser->assertMissing("a.print");
}
else {
$browser->assertVisible("a.{$option}:not(.disabled)");
}
}
foreach ($disabled as $option) {
if ($option == 'print' && $browser->isPhone()) {
$browser->assertMissing("a.print");
}
else {
$browser->assertVisible("a.{$option}.disabled");
}
}
+ foreach ($missing as $option) {
+ $browser->assertMissing("a.{$option}");
+ }
+
$this->closeMenu($browser);
}
/**
* Close toolbar menu (on phones)
*/
public function closeMenu($browser)
{
// hide the menu back
if ($browser->isPhone()) {
$browser->withinBody(function ($browser) {
$browser->script("window.UI.menu_hide('toolbar-menu')");
$browser->waitUntilMissing($this->selector());
// FIXME: For some reason sometimes .popover-overlay does not close,
// we have to remove it manually
$browser->script(
"Array.from(document.getElementsByClassName('popover-overlay')).forEach(function(elem) { elem.parentNode.removeChild(elem); })"
);
});
}
}
/**
* Select toolbar menu item
*/
public function clickMenuItem($browser, $name, $dropdown_action = null)
{
if ($browser->isPhone()) {
$browser->withinBody(function ($browser) {
$browser->click('.toolbar-menu-button');
});
}
$selector = "a.{$name}" . ($dropdown_action ? " + a.dropdown" : '');
$browser->click($selector);
if ($dropdown_action) {
$popup_id = $browser->attribute($selector, 'data-popup');
$browser->withinBody(function ($browser) use ($popup_id, $dropdown_action) {
$browser->click("#{$popup_id} li a.{$dropdown_action}");
});
}
$this->closeMenu($browser);
}
}
diff --git a/tests/Browser/Mail/List.php b/tests/Browser/Mail/List.php
index f56985d97..4d27b9806 100644
--- a/tests/Browser/Mail/List.php
+++ b/tests/Browser/Mail/List.php
@@ -1,129 +1,130 @@
<?php
namespace Tests\Browser\Mail;
+use Tests\Browser\Components\Toolbarmenu;
+
class MailList extends \Tests\Browser\TestCase
{
protected function setUp()
{
parent::setUp();
\bootstrap::init_imap();
\bootstrap::purge_mailbox('INBOX');
// import email messages
foreach (glob(TESTS_DIR . 'data/mail/list_00.eml') as $f) {
\bootstrap::import_message($f, 'INBOX');
}
}
public function testList()
{
$this->browse(function ($browser) {
$browser->go('mail');
$this->assertCount(1, $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'));
// 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', 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');
}
});
}
else if ($browser->isTablet()) {
$browser->click('.toolbar-list-button');
$browser->with('#toolbar-list-menu', 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->click('.toolbar-menu-button');
-
- $browser->with('#toolbar-menu', function ($browser) {
- $browser->assertVisible('a.select:not(.disabled)');
- $browser->assertVisible('a.options:not(.disabled)');
-
+ $browser->with(new Toolbarmenu(), function ($browser) {
+ $active = ['select', 'options'];
+ $missing = [];
$imap = \bootstrap::get_storage();
+
if ($imap->get_threading()) {
- $browser->assertVisible('a.threads:not(.disabled)');
+ $active[] = 'threads';
}
else {
- $browser->assertMissing('a.threads');
+ $missing[] = 'threads';
}
- });
- $browser->closeToolbarMenu();
+ $browser->assertMenuState($active, [], $missing);
+ });
}
});
}
/**
* @depends testList
*/
public function testListSelection()
{
$this->browse(function ($browser) {
if ($browser->isPhone()) {
- $browser->click('.toolbar-menu-button');
- $browser->click('#toolbar-menu a.select');
+ $browser->with(new Toolbarmenu(), function ($browser) {
+ $browser->clickMenuItem('select');
+ });
}
else if ($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->with('#listselect-menu', 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
});
}
}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Mar 19, 8:56 AM (1 d, 1 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
456977
Default Alt Text
(9 KB)

Event Timeline