You are here

public function LayoutBuilderTest::testLayoutBuilderEmbedForm in Block Style Plugins 8.2

Tests that style config can be embeded directly on Layout Builder's form.

File

tests/src/FunctionalJavascript/LayoutBuilderTest.php, line 241

Class

LayoutBuilderTest
Layout Builder tests.

Namespace

Drupal\Tests\block_style_plugins\FunctionalJavascript

Code

public function testLayoutBuilderEmbedForm() {
  $assert = $this
    ->assertSession();
  $page = $this
    ->getSession()
    ->getPage();
  $block_css_locator = '.block-system-breadcrumb-block';
  $this
    ->drupalGet('node/1/layout');

  // Add a new block.
  $this
    ->clickLink('Add block');
  $assert
    ->assertWaitOnAjaxRequest();
  $this
    ->clickLink('Breadcrumbs');
  $assert
    ->assertWaitOnAjaxRequest();

  // A form for "Embed on Layout Builder Form" should be on the block config.
  $assert
    ->pageTextContains('Embed on Layout Builder Form');
  $assert
    ->pageTextNotContains('Simple Class');

  // Configure the styles.
  $page
    ->fillField('third_party_settings[block_style_plugins][embed_on_layout_builder][test_embedded_field]', 'test-class');
  $page
    ->pressButton('Add block');
  $assert
    ->assertNoElementAfterWait('css', '#drupal-off-canvas');
  $assert
    ->assertWaitOnAjaxRequest();

  // Check to see if classes were applied.
  $block_element = $assert
    ->waitForElementVisible('css', $block_css_locator);
  $block_element
    ->hasClass('test-class');
}