function LayoutBuilderTest::testPreviewAwarePlugins

Tests preview-aware layout & block plugins.

File

core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php, line 707

Class

LayoutBuilderTest
Tests the Layout Builder UI.

Namespace

Drupal\Tests\layout_builder\Functional

Code

public function testPreviewAwarePlugins() {
    $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.