You are here

protected function InlineBlockTestBase::addInlineBlockToLayout in Drupal 10

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

Adds an entity block to the layout.

Parameters

string $title: The title field value.

string $body: The body field value.

File

core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTestBase.php, line 137

Class

InlineBlockTestBase
Base class for testing inline blocks.

Namespace

Drupal\Tests\layout_builder\FunctionalJavascript

Code

protected function addInlineBlockToLayout($title, $body) {
  $assert_session = $this
    ->assertSession();
  $page = $this
    ->getSession()
    ->getPage();
  $page
    ->clickLink('Add block');
  $assert_session
    ->assertWaitOnAjaxRequest();
  $this
    ->assertNotEmpty($assert_session
    ->waitForLink('Create custom block'));
  $this
    ->clickLink('Create custom block');
  $assert_session
    ->assertWaitOnAjaxRequest();
  $textarea = $assert_session
    ->waitForElement('css', '[name="settings[block_form][body][0][value]"]');
  $this
    ->assertNotEmpty($textarea);
  $assert_session
    ->fieldValueEquals('Title', '');
  $page
    ->findField('Title')
    ->setValue($title);
  $textarea
    ->setValue($body);
  $page
    ->pressButton('Add block');
  $this
    ->assertDialogClosedAndTextVisible($body, static::INLINE_BLOCK_LOCATOR);
}