function ContextualLinksTest::testContextualLinks

Same name in other branches
  1. 9 core/modules/layout_builder/tests/src/FunctionalJavascript/ContextualLinksTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\ContextualLinksTest::testContextualLinks()
  2. 10 core/modules/layout_builder/tests/src/FunctionalJavascript/ContextualLinksTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\ContextualLinksTest::testContextualLinks()
  3. 11.x core/modules/layout_builder/tests/src/FunctionalJavascript/ContextualLinksTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\ContextualLinksTest::testContextualLinks()

Tests that the contextual links inside Layout Builder are removed.

File

core/modules/layout_builder/tests/src/FunctionalJavascript/ContextualLinksTest.php, line 68

Class

ContextualLinksTest
Test contextual links compatibility with the Layout Builder.

Namespace

Drupal\Tests\layout_builder\FunctionalJavascript

Code

public function testContextualLinks() {
    $page = $this->getSession()
        ->getPage();
    $field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
    // Enable Layout Builder and overrides.
    $this->drupalPostForm("{$field_ui_prefix}/display/default", [
        'layout[enabled]' => TRUE,
        'layout[allow_custom]' => TRUE,
    ], 'Save');
    $this->drupalGet('node/1/layout');
    // Add a block that includes an entity contextual link.
    $this->addBlock('Test Block View: Teaser block');
    // Add a block that includes a views contextual link.
    $this->addBlock('Recent content');
    // Ensure the contextual links are correct before the layout is saved.
    $this->assertCorrectContextualLinksInUi();
    // Ensure the contextual links are correct when the Layout Builder is loaded
    // after being saved.
    $page->hasButton('Save layout');
    $page->pressButton('Save layout');
    $this->drupalGet('node/1/layout');
    $this->assertCorrectContextualLinksInUi();
    $this->drupalGet('node/1');
    $this->assertCorrectContextualLinksInNode();
}

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