function LayoutBuilderTest::testPreviewAwareTemplates

Same name in other branches
  1. 9 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testPreviewAwareTemplates()
  2. 10 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testPreviewAwareTemplates()

Tests preview-aware templates.

File

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

Class

LayoutBuilderTest
Tests the Layout Builder UI.

Namespace

Drupal\Tests\layout_builder\Functional

Code

public function testPreviewAwareTemplates() : 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('1 column layout');
    $page->pressButton('Add section');
    $page->clickLink('Add block');
    $page->clickLink('Preview-aware block');
    $page->pressButton('Add block');
    $assert_session->pageTextContains('This is a preview, indeed');
    $page->pressButton('Save layout');
    $this->drupalGet('node/1');
    $assert_session->pageTextNotContains('This is a preview, indeed');
}

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