You are here

protected function ContextualLinksTest::addBlock in Drupal 9

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

Adds block to the layout via Layout Builder's UI.

Parameters

string $block_name: The block name as it appears in the Add block form.

1 call to ContextualLinksTest::addBlock()
ContextualLinksTest::testContextualLinks in core/modules/layout_builder/tests/src/FunctionalJavascript/ContextualLinksTest.php
Tests that the contextual links inside Layout Builder are removed.

File

core/modules/layout_builder/tests/src/FunctionalJavascript/ContextualLinksTest.php, line 108

Class

ContextualLinksTest
Test contextual links compatibility with the Layout Builder.

Namespace

Drupal\Tests\layout_builder\FunctionalJavascript

Code

protected function addBlock($block_name) {
  $assert_session = $this
    ->assertSession();
  $page = $this
    ->getSession()
    ->getPage();
  $assert_session
    ->linkExists('Add block');
  $page
    ->clickLink('Add block');
  $assert_session
    ->assertWaitOnAjaxRequest();
  $this
    ->assertNotEmpty($assert_session
    ->waitForElementVisible('css', "#drupal-off-canvas a:contains('{$block_name}')"));
  $page
    ->clickLink($block_name);
  $this
    ->assertNotEmpty($assert_session
    ->waitForElementVisible('css', '[data-drupal-selector=\'edit-actions-submit\']'));
  $page
    ->pressButton('Add block');
  $assert_session
    ->assertNoElementAfterWait('css', '#drupal-off-canvas');
  $assert_session
    ->assertWaitOnAjaxRequest();
}