public function LayoutBuilderModalTest::testWithMultipleCustomBlockTypes in Layout Builder Modal 8
Tests interface with multiple custom block types.
File
- tests/
src/ FunctionalJavascript/ LayoutBuilderModalTest.php, line 120
Class
- LayoutBuilderModalTest
- Tests Layout Builder Modal.
Namespace
Drupal\Tests\layout_builder_modal\FunctionalJavascriptCode
public function testWithMultipleCustomBlockTypes() {
$layout_url = 'node/1/layout';
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
// Add a second block type.
$block_type = BlockContentType::create([
'id' => 'foo_block',
'label' => 'Foo block',
]);
$block_type
->save();
block_content_add_body_field($block_type
->id());
$this
->drupalGet($layout_url);
$this
->click('.layout-builder__add-block .layout-builder__link');
$assert_session
->assertWaitOnAjaxRequest();
$this
->clickLink('Create custom block');
$assert_session
->assertWaitOnAjaxRequest();
// Verify that back button works.
$this
->clickLink('Back');
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->elementNotExists('css', '#layout-builder-modal');
$this
->clickLink('Create custom block');
$assert_session
->assertWaitOnAjaxRequest();
$this
->clickLink('Foo block');
$assert_session
->assertWaitOnAjaxRequest();
// Verify that the add block has been opened in the modal.
$assert_session
->elementExists('css', '#layout-builder-modal .layout-builder-add-block');
$assert_session
->fieldValueEquals('Title', '');
$page
->findField('Title')
->setValue('Second block');
$button = $assert_session
->elementExists('css', '#layout-builder-add-block .button--primary');
$button
->press();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->pageTextContains('Second block');
}