You are here

public function ContextualLinksTest::testContextualLinks in Drupal 8

Same name and namespace in other branches
  1. 9 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();
}