function LayoutBuilderBlocksTest::testPreviewAwarePlugins

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

Tests preview-aware layout & block plugins.

File

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

Class

LayoutBuilderBlocksTest
Tests the Layout Builder UI with blocks.

Namespace

Drupal\Tests\layout_builder\Functional

Code

public function testPreviewAwarePlugins() : void {
  $assert_session = $this->assertSession();
  $page = $this->getSession()
    ->getPage();
  $this->drupalLogin($this->drupalCreateUser([
    '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('Preview-aware block');
  $page->pressButton('Add block');
  $assert_session->elementExists('css', '.go-birds-preview');
  $assert_session->pageTextContains('The block template is being previewed.');
  $assert_session->pageTextContains('This block is being rendered in preview mode.');
  $page->pressButton('Save layout');
  $this->drupalGet('node/1');
  $assert_session->elementNotExists('css', '.go-birds-preview');
  $assert_session->pageTextNotContains('The block template is being previewed.');
  $assert_session->pageTextContains('This block is being rendered normally.');
}

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