Files
roundcubemail/tests/Browser/Components/Taskmenu.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

95 lines
2.2 KiB
PHP

<?php
namespace Tests\Browser\Components;
use Laravel\Dusk\Component;
use Tests\Browser\Browser;
class Taskmenu extends Component
{
protected $options = ['compose', 'mail', 'contacts', 'settings', 'about', 'logout'];
/**
* Get the root selector for the component.
*
* @return string
*/
public function selector()
{
return '#taskmenu';
}
/**
* 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 Taskmenu state
*/
public function assertMenuState(Browser $browser, $selected)
{
// On phone the menu is invisible, open it
if ($browser->isPhone()) {
$browser->withinBody(function ($browser) {
$browser->click('.task-menu-button');
$browser->waitFor($this->selector());
});
}
foreach ($this->options as $option) {
$browser->assertVisible("a.{$option}:not(.disabled)" . ($selected == $option ? '.selected' : ':not(.selected)'));
}
// hide the menu back
if ($browser->isPhone()) {
$browser->withinBody(function ($browser) {
$browser->click('.popover a.button.cancel');
$browser->waitUntilMissingOrStale($this->selector());
});
}
}
/**
* Select Taskmenu item
*/
public function clickMenuItem(Browser $browser, $name)
{
if ($browser->isPhone()) {
$browser->withinBody(static function ($browser) {
$browser->click('.task-menu-button');
});
}
$browser->click("a.{$name}");
if ($browser->isPhone()) {
$browser->withinBody(function ($browser) {
$browser->waitUntilMissingOrStale($this->selector());
});
}
}
}