function MoveBlockFormTest::setUp
Same name in other branches
- 8.9.x core/modules/layout_builder/tests/src/FunctionalJavascript/MoveBlockFormTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\MoveBlockFormTest::setUp()
- 10 core/modules/layout_builder/tests/src/FunctionalJavascript/MoveBlockFormTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\MoveBlockFormTest::setUp()
- 11.x core/modules/layout_builder/tests/src/FunctionalJavascript/MoveBlockFormTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\MoveBlockFormTest::setUp()
Overrides BrowserTestBase::setUp
File
-
core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ MoveBlockFormTest.php, line 36
Class
- MoveBlockFormTest
- Tests moving blocks via the form.
Namespace
Drupal\Tests\layout_builder\FunctionalJavascriptCode
protected function setUp() : void {
parent::setUp();
$page = $this->getSession()
->getPage();
$assert_session = $this->assertSession();
// @todo The Layout Builder UI relies on local tasks; fix in
// https://www.drupal.org/project/drupal/issues/2917777.
$this->drupalPlaceBlock('local_tasks_block');
$this->createContentType([
'type' => 'bundle_with_section_field',
]);
LayoutBuilderEntityViewDisplay::load('node.bundle_with_section_field.default')->enableLayoutBuilder()
->setOverridable()
->save();
$this->createNode([
'type' => 'bundle_with_section_field',
]);
$this->drupalLogin($this->drupalCreateUser([
'configure any layout',
'access contextual links',
]));
$this->drupalGet('node/1/layout');
$expected_block_order = [
'.block-extra-field-blocknodebundle-with-section-fieldlinks',
'.block-field-blocknodebundle-with-section-fieldbody',
];
$this->markTestSkipped("Skipped temporarily for random fails.");
$this->assertRegionBlocksOrder(0, 'content', $expected_block_order);
// Add a top section using the Two column layout.
$page->clickLink('Add section');
$assert_session->waitForElementVisible('css', '#drupal-off-canvas');
$assert_session->assertWaitOnAjaxRequest();
$page->clickLink('Two column');
$assert_session->assertWaitOnAjaxRequest();
$this->assertNotEmpty($assert_session->waitForElementVisible('css', 'input[value="Add section"]'));
$page->pressButton('Add section');
$this->assertRegionBlocksOrder(1, 'content', $expected_block_order);
// Add a 'Powered by Drupal' block in the 'first' region of the new section.
$first_region_block_locator = '[data-layout-delta="0"].layout--twocol-section [data-region="first"] [data-layout-block-uuid]';
$assert_session->elementNotExists('css', $first_region_block_locator);
$assert_session->elementExists('css', '[data-layout-delta="0"].layout--twocol-section [data-region="first"] .layout-builder__add-block')
->click();
$this->assertNotEmpty($assert_session->waitForElementVisible('css', '#drupal-off-canvas a:contains("Powered by Drupal")'));
$assert_session->assertWaitOnAjaxRequest();
$page->clickLink('Powered by Drupal');
$this->assertNotEmpty($assert_session->waitForElementVisible('css', 'input[value="Add block"]'));
$assert_session->assertWaitOnAjaxRequest();
$page->pressButton('Add block');
$assert_session->assertNoElementAfterWait('css', '#drupal-off-canvas');
$this->assertNotEmpty($assert_session->waitForElementVisible('css', $first_region_block_locator));
// Ensure the request has completed before the test starts.
$assert_session->assertWaitOnAjaxRequest();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.