3 namespace Drupal\Tests\layout_builder\FunctionalJavascript;
5 use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
8 * Field blocks tests for the override layout.
10 * @group layout_builder
12 class ItemLayoutFieldBlockTest extends WebDriverTestBase {
17 protected static $modules = [
25 protected function setUp() {
28 $this->drupalLogin($this->drupalCreateUser([
29 'configure any layout',
30 'administer node display',
31 'administer node fields',
34 // We need more then one content type for this test.
35 $this->createContentType(['type' => 'bundle_with_layout_overrides']);
36 $this->createContentType(['type' => 'filler_bundle']);
40 * Tests configuring a field block for a user field.
42 public function testAddAjaxBlock() {
43 $assert_session = $this->assertSession();
44 $page = $this->getSession()->getPage();
46 // Allow overrides for the layout.
47 $this->drupalGet('admin/structure/types/manage/bundle_with_layout_overrides/display/default');
48 $page->checkField('layout[enabled]');
49 $page->checkField('layout[allow_custom]');
50 $page->pressButton('Save');
52 // Start by creating a node of type with layout overrides.
53 $node = $this->createNode([
54 'type' => 'bundle_with_layout_overrides',
57 'value' => 'The node body',
63 // Open single item layout page.
64 $this->drupalGet('node/1/layout');
67 $this->clickLink('Add Block');
68 $assert_session->assertWaitOnAjaxRequest();
70 // Validate that only field blocks for layouted bundle are present.
71 $valid_links = $page->findAll('css', 'a[href$="field_block%3Anode%3Abundle_with_layout_overrides%3Abody"]');
72 $this->assertCount(1, $valid_links);
73 $invalid_links = $page->findAll('css', 'a[href$="field_block%3Anode%3Afiller_bundle%3Abody"]');
74 $this->assertCount(0, $invalid_links);