function QuickEditLoadingTest::testTitleBaseField

Same name in other branches
  1. 9 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 217

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();
    $assert->assertWaitOnAjaxRequest();
    // 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->assertWaitOnAjaxRequest();
    // 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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.