function ContextualLinksTest::testContextualLinksOutsideLayout

Same name and namespace in other branches
  1. 11.x core/modules/layout_builder/tests/src/FunctionalJavascript/ContextualLinksTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\ContextualLinksTest::testContextualLinksOutsideLayout()

Tests that contextual links outside the layout are removed.

File

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

Class

ContextualLinksTest
Test contextual links compatibility with the Layout Builder.

Namespace

Drupal\Tests\layout_builder\FunctionalJavascript

Code

public function testContextualLinksOutsideLayout() : void {
  $assert_session = $this->assertSession();
  $this->drupalPlaceBlock('system_powered_by_block', [
    'id' => 'global_block',
  ]);
  $this->drupalGet('node/1');
  // Ensure global blocks contextual link is present when not on
  // Layout Builder.
  $assert_session->elementsCount('css', '[data-contextual-id*=\'block:block=global_block:\']', 1);
  $this->drupalGet('node/1/layout');
  $this->addBlock('Test Block View: Teaser block');
  // Ensure that only the layout specific contextual links are present.
  $this->assertCorrectContextualLinks();
  $page = $this->getSession()
    ->getPage();
  $page->hasButton('Save layout');
  $page->pressButton('Save layout');
  $this->drupalGet('node/1/layout');
  // Ensure the contextual links are correct when the Layout Builder is loaded
  // after being saved.
  $this->assertCorrectContextualLinks();
}

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