You are here

public function LayoutBuilderTest::testLayoutBuilderTemplateSet in Block Style Plugins 8.2

Tests that a template being set will work with Layout Builder.

File

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

Class

LayoutBuilderTest
Layout Builder tests.

Namespace

Drupal\Tests\block_style_plugins\FunctionalJavascript

Code

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

  // Add a new block.
  $this
    ->addNewBlock('Powered by Drupal');

  // Click the contextual link.
  $this
    ->clickContextualLink($block_css_locator, 'Style settings');

  // Choose a style to apply.
  $dropdown = $assert
    ->waitForElementVisible('css', '[name="block_styles"]');
  $dropdown
    ->selectOption('Template Set by Yaml');
  $page
    ->pressButton('Add Style');
  $assert
    ->assertWaitOnAjaxRequest();

  // Configure the styles.
  $page
    ->fillField('settings[test_field]', 'test-class');
  $page
    ->pressButton('Add Styles');
  $assert
    ->assertWaitOnAjaxRequest();

  // Assert that the template applied.
  $assert
    ->responseContains('This is a custom template');

  // Save the Layout.
  $page
    ->pressButton('Save layout');

  // Check to see if the template is still applied.
  $assert
    ->responseContains('This is a custom template');
}