diff --git a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php index b48b8b767a..eb86487aa3 100644 --- a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php +++ b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php @@ -526,4 +526,59 @@ public function testValidationMessages() { } } + /** + * Clicks a contextual link. + * + * @todo Remove this function when related trait added in + * https://www.drupal.org/node/2821724. + * + * @param string $selector + * The selector for the element that contains the contextual link. + * @param string $link_locator + * The link id, title, or text. + * @param bool $force_visible + * If true then the button will be forced to visible so it can be clicked. + */ + protected function clickContextualLink($selector, $link_locator, $force_visible = TRUE) { + if ($force_visible) { + $this->toggleContextualTriggerVisibility($selector); + } + + $element = $this->getSession()->getPage()->find('css', $selector); + $element->find('css', '.contextual button')->press(); + $element->findLink($link_locator)->click(); + + if ($force_visible) { + $this->toggleContextualTriggerVisibility($selector); + } + } + + /** + * Toggles the visibility of a contextual trigger. + * + * @todo Remove this function when related trait added in + * https://www.drupal.org/node/2821724. + * + * @param string $selector + * The selector for the element that contains the contextual link. + */ + protected function toggleContextualTriggerVisibility($selector) { + // Hovering over the element itself with should be enough, but does not + // work. Manually remove the visually-hidden class. + $this->getSession()->executeScript("jQuery('{$selector} .contextual .trigger').toggleClass('visually-hidden');"); + } + + /** + * {@inheritdoc} + */ + protected function getTestThemes() { + $themes = parent::getTestThemes(); + // Remove 'seven' theme. Setting Tray "Edit Mode" will not work with 'seven' + // because it removes all contextual links the off-canvas dialog should. + if (($key = array_search('seven', $themes)) !== FALSE) { + unset($themes[$key]); + } + return $themes; + } + } diff --git a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php index a307841317..240362ba21 100644 --- a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php +++ b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php @@ -107,13 +107,4 @@ public function testNarrowWidth() { } } - /** - * {@inheritdoc} - */ - protected function getTestThemes() { - // Add 'seven' theme. Setting Tray "Edit Mode" will not work with 'seven' - // because it removes all contextual links the off-canvas dialog should. - return array_merge(parent::getTestThemes(), ['seven']); - } - } diff --git a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php index 6aa810568d..6ee6190d7b 100644 --- a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php +++ b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php @@ -73,6 +73,8 @@ protected function getTray() { * CSS selector. * @param int $timeout * (optional) Timeout in milliseconds, defaults to 10000. + * + * @todo Remove in https://www.drupal.org/node/2892440. */ protected function waitForNoElement($selector, $timeout = 10000) { $condition = "(jQuery('$selector').length == 0)"; @@ -80,55 +82,13 @@ protected function waitForNoElement($selector, $timeout = 10000) { } /** - * Clicks a contextual link. - * - * @todo Remove this function when related trait added in - * https://www.drupal.org/node/2821724. - * - * @param string $selector - * The selector for the element that contains the contextual link. - * @param string $link_locator - * The link id, title, or text. - * @param bool $force_visible - * If true then the button will be forced to visible so it can be clicked. - */ - protected function clickContextualLink($selector, $link_locator, $force_visible = TRUE) { - if ($force_visible) { - $this->toggleContextualTriggerVisibility($selector); - } - - $element = $this->getSession()->getPage()->find('css', $selector); - $element->find('css', '.contextual button')->press(); - $element->findLink($link_locator)->click(); - - if ($force_visible) { - $this->toggleContextualTriggerVisibility($selector); - } - } - - /** - * Toggles the visibility of a contextual trigger. - * - * @todo Remove this function when related trait added in - * https://www.drupal.org/node/2821724. - * - * @param string $selector - * The selector for the element that contains the contextual link. - */ - protected function toggleContextualTriggerVisibility($selector) { - // Hovering over the element itself with should be enough, but does not - // work. Manually remove the visually-hidden class. - $this->getSession()->executeScript("jQuery('{$selector} .contextual .trigger').toggleClass('visually-hidden');"); - } - - /** * Get themes to test. * * @return string[] * Theme names to test. */ protected function getTestThemes() { - return ['bartik', 'stark', 'classy', 'stable']; + return ['bartik', 'stark', 'classy', 'stable', 'seven']; } /**