You are here

protected function LayoutBuilderDisableInteractionsTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderDisableInteractionsTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php, line 43

Class

LayoutBuilderDisableInteractionsTest
Tests the Layout Builder disables interactions of rendered blocks.

Namespace

Drupal\Tests\layout_builder\FunctionalJavascript

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->createContentType([
    'type' => 'bundle_with_section_field',
  ]);
  $this
    ->createNode([
    'type' => 'bundle_with_section_field',
    'title' => 'The first node title',
    'body' => [
      [
        'value' => 'Node body',
      ],
    ],
  ]);
  $bundle = BlockContentType::create([
    'id' => 'basic',
    'label' => 'Basic block',
    'revision' => 1,
  ]);
  $bundle
    ->save();
  block_content_add_body_field($bundle
    ->id());
  BlockContent::create([
    'type' => 'basic',
    'info' => 'Block with link',
    'body' => [
      // Create a link that should be disabled in Layout Builder preview.
      'value' => '<a id="link-that-should-be-disabled" href="/search/node">Take me away</a>',
      'format' => 'full_html',
    ],
  ])
    ->save();
  BlockContent::create([
    'type' => 'basic',
    'info' => 'Block with iframe',
    'body' => [
      // Add iframe that should be non-interactive in Layout Builder preview.
      'value' => '<iframe id="iframe-that-should-be-disabled" width="1" height="1" src="https://www.youtube.com/embed/gODZzSOelss" frameborder="0"></iframe>',
      'format' => 'full_html',
    ],
  ])
    ->save();
}