X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Foutside_in%2Ftests%2Fsrc%2FFunctionalJavascript%2FOutsideInJavascriptTestBase.php;fp=web%2Fcore%2Fmodules%2Foutside_in%2Ftests%2Fsrc%2FFunctionalJavascript%2FOutsideInJavascriptTestBase.php;h=0000000000000000000000000000000000000000;hp=129aaec7ec2d8c1f42ea1f048698d728d647d87f;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php b/web/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php deleted file mode 100644 index 129aaec7e..000000000 --- a/web/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php +++ /dev/null @@ -1,158 +0,0 @@ -assertSession()->assertWaitOnAjaxRequest(); - - return $return; - } - - /** - * Enables a theme. - * - * @param string $theme - * The theme. - */ - public function enableTheme($theme) { - // Enable the theme. - \Drupal::service('theme_installer')->install([$theme]); - $theme_config = \Drupal::configFactory()->getEditable('system.theme'); - $theme_config->set('default', $theme); - $theme_config->save(); - } - - /** - * Waits for off-canvas dialog to open. - */ - protected function waitForOffCanvasToOpen() { - $web_assert = $this->assertSession(); - $web_assert->assertWaitOnAjaxRequest(); - $this->assertElementVisibleAfterWait('css', '#drupal-off-canvas'); - } - - /** - * Waits for off-canvas dialog to close. - */ - protected function waitForOffCanvasToClose() { - $this->waitForNoElement('#drupal-off-canvas'); - } - - /** - * Gets the off-canvas dialog element. - * - * @return \Behat\Mink\Element\NodeElement|null - */ - protected function getTray() { - $tray = $this->getSession()->getPage()->find('css', '.ui-dialog[aria-describedby="drupal-off-canvas"]'); - $this->assertEquals(FALSE, empty($tray), 'The tray was found.'); - return $tray; - } - - /** - * Waits for an element to be removed from the page. - * - * @param string $selector - * CSS selector. - * @param int $timeout - * (optional) Timeout in milliseconds, defaults to 10000. - */ - protected function waitForNoElement($selector, $timeout = 10000) { - $condition = "(jQuery('$selector').length == 0)"; - $this->assertJsCondition($condition, $timeout); - } - - /** - * 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');"); - } - - /** - * Waits for Toolbar to load. - */ - protected function waitForToolbarToLoad() { - $web_assert = $this->assertSession(); - // Waiting for Toolbar module. - // @todo Remove the hack after https://www.drupal.org/node/2542050. - $this->assertElementVisibleAfterWait('css', '.toolbar-fixed'); - // Waiting for Toolbar animation. - $web_assert->assertWaitOnAjaxRequest(); - } - - /** - * Get themes to test. - * - * @return string[] - * Theme names to test. - */ - protected function getTestThemes() { - return ['bartik', 'stark', 'classy', 'stable']; - } - - /** - * Asserts the specified selector is visible after a wait. - * - * @param string $selector - * The selector engine name. See ElementInterface::findAll() for the - * supported selectors. - * @param string|array $locator - * The selector locator. - * @param int $timeout - * (Optional) Timeout in milliseconds, defaults to 10000. - */ - protected function assertElementVisibleAfterWait($selector, $locator, $timeout = 10000) { - $this->assertNotEmpty($this->assertSession()->waitForElementVisible($selector, $locator, $timeout)); - } - -}