Chris@17: drupalCreateUser([ Chris@17: 'administer views', Chris@17: ]); Chris@17: $this->drupalLogin($admin_user); Chris@17: } Chris@17: Chris@17: /** Chris@17: * Tests theming throbber element. Chris@17: */ Chris@17: public function testThemingThrobberElement() { Chris@17: $session = $this->getSession(); Chris@17: $web_assert = $this->assertSession(); Chris@17: $page = $session->getPage(); Chris@17: Chris@17: $custom_ajax_progress_indicator_fullscreen = <<'; Chris@17: }; Chris@17: JS; Chris@17: $custom_ajax_progress_throbber = <<'; Chris@17: }; Chris@17: JS; Chris@17: $custom_ajax_progress_message = <<Hold door!'; Chris@17: }; Chris@17: JS; Chris@17: Chris@17: $this->drupalGet('admin/structure/views/view/content'); Chris@17: $this->waitForNoElement('.ajax-progress-fullscreen'); Chris@17: Chris@17: // Test theming fullscreen throbber. Chris@17: $session->executeScript($custom_ajax_progress_indicator_fullscreen); Chris@17: hold_test_response(TRUE); Chris@17: $page->clickLink('Content: Published (grouped)'); Chris@17: $this->assertNotNull($web_assert->waitForElement('css', '.custom-ajax-progress-fullscreen'), 'Custom ajaxProgressIndicatorFullscreen.'); Chris@17: hold_test_response(FALSE); Chris@17: $this->waitForNoElement('.custom-ajax-progress-fullscreen'); Chris@17: Chris@17: // Test theming throbber message. Chris@17: $web_assert->waitForElementVisible('css', '[data-drupal-selector="edit-options-group-info-add-group"]'); Chris@17: $session->executeScript($custom_ajax_progress_message); Chris@17: hold_test_response(TRUE); Chris@17: $page->pressButton('Add another item'); Chris@17: $this->assertNotNull($web_assert->waitForElement('css', '.ajax-progress-throbber .custom-ajax-progress-message'), 'Custom ajaxProgressMessage.'); Chris@17: hold_test_response(FALSE); Chris@17: $this->waitForNoElement('.ajax-progress-throbber'); Chris@17: Chris@17: // Test theming throbber. Chris@17: $web_assert->waitForElementVisible('css', '[data-drupal-selector="edit-options-group-info-group-items-3-title"]'); Chris@17: $session->executeScript($custom_ajax_progress_throbber); Chris@17: hold_test_response(TRUE); Chris@17: $page->pressButton('Add another item'); Chris@17: $this->assertNotNull($web_assert->waitForElement('css', '.custom-ajax-progress-throbber'), 'Custom ajaxProgressThrobber.'); Chris@17: hold_test_response(FALSE); Chris@17: $this->waitForNoElement('.custom-ajax-progress-throbber'); Chris@17: } Chris@17: Chris@17: /** Chris@17: * Waits for an element to be removed from the page. Chris@17: * Chris@17: * @param string $selector Chris@17: * CSS selector. Chris@17: * @param int $timeout Chris@17: * (optional) Timeout in milliseconds, defaults to 10000. Chris@17: * Chris@17: * @todo Remove in https://www.drupal.org/node/2892440. Chris@17: */ Chris@17: protected function waitForNoElement($selector, $timeout = 10000) { Chris@17: $condition = "(typeof jQuery !== 'undefined' && jQuery('$selector').length === 0)"; Chris@17: $this->assertJsCondition($condition, $timeout); Chris@17: } Chris@17: Chris@17: }