function LayoutBuilderBlocksTest::testPluginsProvidingCustomAttributesAndContextualLinks

Same name and namespace in other branches
  1. 10 core/modules/layout_builder/tests/src/Functional/LayoutBuilderBlocksTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderBlocksTest::testPluginsProvidingCustomAttributesAndContextualLinks()

Tests that block plugins can define custom attributes and contextual links.

File

core/modules/layout_builder/tests/src/Functional/LayoutBuilderBlocksTest.php, line 22

Class

LayoutBuilderBlocksTest
Tests the Layout Builder UI with blocks.

Namespace

Drupal\Tests\layout_builder\Functional

Code

public function testPluginsProvidingCustomAttributesAndContextualLinks() : void {
  $assert_session = $this->assertSession();
  $page = $this->getSession()
    ->getPage();
  $this->drupalLogin($this->drupalCreateUser([
    'access contextual links',
    'configure any layout',
    'administer node display',
  ]));
  $this->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default');
  $this->submitForm([
    'layout[enabled]' => TRUE,
  ], 'Save');
  $page->clickLink('Manage layout');
  $page->clickLink('Add section');
  $page->clickLink('Layout Builder Test Plugin');
  $page->pressButton('Add section');
  $page->clickLink('Add block');
  $page->clickLink('Test Attributes');
  $page->pressButton('Add block');
  $page->pressButton('Save layout');
  $this->drupalGet('node/1');
  $assert_session->elementExists('css', '.attribute-test-class');
  $assert_session->elementExists('css', '[custom-attribute=test]');
  $assert_session->elementExists('css', 'div[data-contextual-id*="layout_builder_test"]');
}

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