3 namespace Drupal\Tests\layout_builder\Functional;
5 use Drupal\Tests\BrowserTestBase;
8 * Tests functionality of the entity view display with regard to Layout Builder.
10 * @group layout_builder
12 class LayoutDisplayTest extends BrowserTestBase {
17 protected static $modules = ['field_ui', 'layout_builder', 'block', 'node'];
22 protected function setUp() {
25 // @todo The Layout Builder UI relies on local tasks; fix in
26 // https://www.drupal.org/project/drupal/issues/2917777.
27 $this->drupalPlaceBlock('local_tasks_block');
29 $this->createContentType([
30 'type' => 'bundle_with_section_field',
32 $this->createNode(['type' => 'bundle_with_section_field']);
34 $this->drupalLogin($this->drupalCreateUser([
35 'configure any layout',
36 'administer node display',
37 'administer display modes',
42 * Tests the interaction between multiple view modes.
44 public function testMultipleViewModes() {
45 $assert_session = $this->assertSession();
46 $page = $this->getSession()->getPage();
47 $field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field/display';
49 // Enable Layout Builder for the default view modes, and overrides.
50 $this->drupalGet("$field_ui_prefix/default");
51 $page->checkField('layout[enabled]');
52 $page->pressButton('Save');
53 $page->checkField('layout[allow_custom]');
54 $page->pressButton('Save');
56 $this->drupalGet('node/1');
57 $assert_session->pageTextNotContains('Powered by Drupal');
59 $assert_session->linkExists('Layout');
60 $this->clickLink('Layout');
61 $assert_session->linkExists('Add Block');
62 $this->clickLink('Add Block');
63 $assert_session->linkExists('Powered by Drupal');
64 $this->clickLink('Powered by Drupal');
65 $page->pressButton('Add Block');
66 $assert_session->linkExists('Save Layout');
67 $this->clickLink('Save Layout');
68 $assert_session->pageTextContains('Powered by Drupal');
70 // Add a new view mode.
71 $this->drupalGet('admin/structure/display-modes/view/add/node');
72 $page->fillField('label', 'New');
73 $page->fillField('id', 'new');
74 $page->pressButton('Save');
76 // Enable the new view mode.
77 $this->drupalGet("$field_ui_prefix/default");
78 $page->checkField('display_modes_custom[new]');
79 $page->pressButton('Save');
81 // Enable and disable Layout Builder for the new view mode.
82 $this->drupalGet("$field_ui_prefix/new");
83 $page->checkField('layout[enabled]');
84 $page->pressButton('Save');
85 $page->uncheckField('layout[enabled]');
86 $page->pressButton('Save');
87 $page->pressButton('Confirm');
89 // The node using the default view mode still contains its overrides.
90 $this->drupalGet('node/1');
91 $assert_session->pageTextContains('Powered by Drupal');