Pull merge.
[yaffs-website] / web / core / modules / layout_builder / tests / src / Functional / LayoutDisplayTest.php
1 <?php
2
3 namespace Drupal\Tests\layout_builder\Functional;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8  * Tests functionality of the entity view display with regard to Layout Builder.
9  *
10  * @group layout_builder
11  */
12 class LayoutDisplayTest extends BrowserTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   protected static $modules = ['field_ui', 'layout_builder', 'block', 'node'];
18
19   /**
20    * {@inheritdoc}
21    */
22   protected function setUp() {
23     parent::setUp();
24
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');
28
29     $this->createContentType([
30       'type' => 'bundle_with_section_field',
31     ]);
32     $this->createNode(['type' => 'bundle_with_section_field']);
33
34     $this->drupalLogin($this->drupalCreateUser([
35       'configure any layout',
36       'administer node display',
37       'administer display modes',
38     ], 'foobar'));
39   }
40
41   /**
42    * Tests the interaction between multiple view modes.
43    */
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';
48
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');
55
56     $this->drupalGet('node/1');
57     $assert_session->pageTextNotContains('Powered by Drupal');
58
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');
69
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');
75
76     // Enable the new view mode.
77     $this->drupalGet("$field_ui_prefix/default");
78     $page->checkField('display_modes_custom[new]');
79     $page->pressButton('Save');
80
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');
88
89     // The node using the default view mode still contains its overrides.
90     $this->drupalGet('node/1');
91     $assert_session->pageTextContains('Powered by Drupal');
92   }
93
94 }