+ public function testBlockPlaceholder() {
+ $assert_session = $this->assertSession();
+ $page = $this->getSession()->getPage();
+
+ $this->drupalLogin($this->drupalCreateUser([
+ 'configure any layout',
+ 'administer node display',
+ ]));
+
+ $field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
+ $this->drupalPostForm("$field_ui_prefix/display/default", ['layout[enabled]' => TRUE], 'Save');
+
+ // Customize the default view mode.
+ $this->drupalGet("$field_ui_prefix/display-layout/default");
+
+ // Add a block whose content is controlled by state and is empty by default.
+ $this->clickLink('Add Block');
+ $this->clickLink('Test block caching');
+ $page->fillField('settings[label]', 'The block label');
+ $page->pressButton('Add Block');
+
+ $block_content = 'I am content';
+ $placeholder_content = 'Placeholder for the "The block label" block';
+
+ // The block placeholder is displayed and there is no content.
+ $assert_session->pageTextContains($placeholder_content);
+ $assert_session->pageTextNotContains($block_content);
+
+ // Set block content and reload the page.
+ \Drupal::state()->set('block_test.content', $block_content);
+ $this->getSession()->reload();
+
+ // The block placeholder is no longer displayed and the content is visible.
+ $assert_session->pageTextNotContains($placeholder_content);
+ $assert_session->pageTextContains($block_content);
+ }
+
+ /**
+ * Tests the Block UI when Layout Builder is installed.
+ */
+ public function testBlockUiListing() {
+ $assert_session = $this->assertSession();
+ $page = $this->getSession()->getPage();
+
+ $this->drupalLogin($this->drupalCreateUser([
+ 'administer blocks',
+ ]));
+
+ $this->drupalGet('admin/structure/block');
+ $page->clickLink('Place block');
+
+ // Ensure that blocks expected to appear are available.
+ $assert_session->pageTextContains('Test HTML block');
+ $assert_session->pageTextContains('Block test');
+ // Ensure that blocks not expected to appear are not available.
+ $assert_session->pageTextNotContains('Body');
+ $assert_session->pageTextNotContains('Content fields');