You are here

protected function QuickEditJavascriptTestBase::assertQuickEditEntityToolbar in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditJavascriptTestBase.php \Drupal\Tests\quickedit\FunctionalJavascript\QuickEditJavascriptTestBase::assertQuickEditEntityToolbar()
  2. 10 core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditJavascriptTestBase.php \Drupal\Tests\quickedit\FunctionalJavascript\QuickEditJavascriptTestBase::assertQuickEditEntityToolbar()

Asserts the state of the Quick Edit entity toolbar.

Parameters

string $expected_entity_label: The expected label in the Quick Edit Entity Toolbar.

3 calls to QuickEditJavascriptTestBase::assertQuickEditEntityToolbar()
QuickEditImageTest::testImageInPlaceEditor in core/modules/image/tests/src/FunctionalJavascript/QuickEditImageTest.php
Test that quick editor works correctly with images.
QuickEditIntegrationTest::testArticleNode in core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php
Tests if an article node can be in-place edited with Quick Edit.
QuickEditIntegrationTest::testCustomBlock in core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php
Tests if a custom can be in-place edited with Quick Edit.

File

core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditJavascriptTestBase.php, line 161

Class

QuickEditJavascriptTestBase
Base class for testing the QuickEdit.

Namespace

Drupal\Tests\quickedit\FunctionalJavascript

Code

protected function assertQuickEditEntityToolbar($expected_entity_label, $expected_field_label) {
  $quickedit_entity_toolbar = $this
    ->getSession()
    ->getPage()
    ->findById('quickedit-entity-toolbar');

  // We cannot use ->getText() because it also returns the text of all child
  // nodes. We also cannot use XPath to select text node in Selenium. So we
  // use JS expression to select only the text node.
  $this
    ->assertSame($expected_entity_label, $this
    ->getSession()
    ->evaluateScript("return window.jQuery('#quickedit-entity-toolbar .quickedit-toolbar-label').clone().children().remove().end().text();"));
  if ($expected_field_label !== NULL) {
    $field_label = $quickedit_entity_toolbar
      ->find('css', '.quickedit-toolbar-label > .field');

    // Only try to find the text content of the element if it was actually
    // found; otherwise use the returned value for assertion. This helps
    // us find a more useful stack/error message from testbot instead of the
    // trimmed partial exception stack.
    if ($field_label) {
      $field_label = $field_label
        ->getText();
    }
    $this
      ->assertSame($expected_field_label, $field_label);
  }
  else {
    $this
      ->assertEmpty($quickedit_entity_toolbar
      ->find('css', '.quickedit-toolbar-label > .field'));
  }
}