Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/Components/Menu.php
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | class Menu extends BaseComponent | ||||
* @param array $items List of menu items | * @param array $items List of menu items | ||||
* @param string $active Expected active item | * @param string $active Expected active item | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function assertMenuItems($browser, array $items, string $active = null) | public function assertMenuItems($browser, array $items, string $active = null) | ||||
{ | { | ||||
// On mobile the links are not visible, show them first (wait for transition) | // On mobile the links are not visible, show them first (wait for transition) | ||||
if ($browser->isPhone()) { | if (!$browser->isDesktop()) { | ||||
$browser->click('@toggler')->waitFor('.navbar-collapse.show'); | $browser->click('@toggler')->waitFor('.navbar-collapse.show'); | ||||
} | } | ||||
foreach ($items as $item) { | foreach ($items as $item) { | ||||
$browser->assertVisible('.link-' . $item); | $browser->assertVisible('.link-' . $item); | ||||
} | } | ||||
// Check number of items, to make sure there's no extra items | // Check number of items, to make sure there's no extra items | ||||
PHPUnit::assertCount(count($items), $browser->elements('li')); | PHPUnit::assertCount(count($items), $browser->elements('li')); | ||||
if ($active) { | if ($active) { | ||||
$browser->assertPresent(".link-{$active}.active"); | $browser->assertPresent(".link-{$active}.active"); | ||||
} | } | ||||
if ($browser->isPhone()) { | if (!$browser->isDesktop()) { | ||||
$browser->click('@toggler')->waitUntilMissing('.navbar-collapse.show'); | $browser->click('@toggler')->waitUntilMissing('.navbar-collapse.show'); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Click menu link. | * Click menu link. | ||||
* | * | ||||
* @param \Tests\Browser $browser The browser object | * @param \Tests\Browser $browser The browser object | ||||
Show All 34 Lines |