You are here

public function QuickEditLoadingTest::testTitleBaseField in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php \Drupal\Tests\quickedit\FunctionalJavascript\QuickEditLoadingTest::testTitleBaseField()

Tests the loading of Quick Edit for the title base field.

File

core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php, line 218

Class

QuickEditLoadingTest
Tests loading of in-place editing functionality and lazy loading of its in-place editors.

Namespace

Drupal\Tests\quickedit\FunctionalJavascript

Code

public function testTitleBaseField() {
  $page = $this
    ->getSession()
    ->getPage();
  $assert = $this
    ->assertSession();
  $nid = $this->testNode
    ->id();
  $this
    ->drupalLogin($this->editorUser);
  $this
    ->drupalGet('node/' . $nid);

  // Wait "Quick edit" button for node.
  $assert
    ->waitForElement('css', '[data-quickedit-entity-id="node/' . $nid . '"] .contextual .quickedit');

  // Click by "Quick edit".
  $this
    ->clickContextualLink('[data-quickedit-entity-id="node/' . $nid . '"]', 'Quick edit');

  // Switch to title field.
  $page
    ->find('css', '[data-quickedit-field-id="node/' . $nid . '/title/en/full"]')
    ->click();

  // Wait and update title field.
  $field_locator = '.field--name-title';
  $text_new = 'Obligatory question';
  $assert
    ->waitForElementVisible('css', $field_locator)
    ->setValue($text_new);

  // Wait and click by "Save" button after title field was changed.
  $this
    ->assertSession()
    ->waitForElementVisible('css', '.quickedit-toolgroup.ops [type="submit"][aria-hidden="false"]')
    ->click();
  $assert
    ->waitForElementRemoved('css', '.quickedit-toolgroup.ops [type="submit"][aria-hidden="false"]');

  // Ensure that the changes take effect.
  $assert
    ->responseMatches("|\\s*{$text_new}\\s*|");

  // Reload the page and check for updated title.
  $this
    ->drupalGet('node/' . $nid);
  $assert
    ->pageTextContains($text_new);
}