function LayoutBuilderTest::clickContextualLink
Same name in other branches
- 9 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderTest::clickContextualLink()
- 8.9.x core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderTest::clickContextualLink()
- 10 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderTest::clickContextualLink()
@todo Remove this in https://www.drupal.org/project/drupal/issues/2918718.
Overrides ContextualLinkClickTrait::clickContextualLink
1 call to LayoutBuilderTest::clickContextualLink()
- LayoutBuilderTest::testLayoutBuilderUi in core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ LayoutBuilderTest.php - Tests the Layout Builder UI.
File
-
core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ LayoutBuilderTest.php, line 410
Class
- LayoutBuilderTest
- Tests the Layout Builder UI.
Namespace
Drupal\Tests\layout_builder\FunctionalJavascriptCode
protected function clickContextualLink($selector, $link_locator, $force_visible = TRUE) {
/** @var \Drupal\FunctionalJavascriptTests\JSWebAssert $assert_session */
$assert_session = $this->assertSession();
/** @var \Behat\Mink\Element\DocumentElement $page */
$page = $this->getSession()
->getPage();
$page->waitFor(10, function () use ($page, $selector) {
return $page->find('css', "{$selector} .contextual-links");
});
if (count($page->findAll('css', "{$selector} .contextual-links")) > 1) {
throw new \Exception('More than one contextual links found by selector');
}
if ($force_visible && $page->find('css', "{$selector} .contextual .trigger.visually-hidden")) {
$this->toggleContextualTriggerVisibility($selector);
}
$link = $assert_session->elementExists('css', $selector)
->findLink($link_locator);
$this->assertNotEmpty($link);
if (!$link->isVisible()) {
$button = $assert_session->waitForElementVisible('css', "{$selector} .contextual button");
$this->assertNotEmpty($button);
$button->press();
$link = $page->waitFor(10, function () use ($link) {
return $link->isVisible() ? $link : FALSE;
});
}
$link->click();
if ($force_visible) {
$this->toggleContextualTriggerVisibility($selector);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.