addBlock example

/** * Tests that the contextual links inside Layout Builder are removed. */
  public function testContextualLinks() {
    // Skipped due to frequent random test failures.     $page = $this->getSession()->getPage();

    $this->drupalGet('node/1/layout');

    // Add a block that includes an entity contextual link.     $this->addBlock('Test Block View: Teaser block');

    // Add a block that includes a views contextual link.     $this->addBlock('Recent content');

    // Ensure the contextual links are correct before the layout is saved.     $this->assertCorrectContextualLinksInUi();

    // Ensure the contextual links are correct when the Layout Builder is loaded     // after being saved.     $page->hasButton('Save layout');
    $page->pressButton('Save layout');
    
'access contextual links',
    ]));

    $field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';

    $this->drupalGet("{$field_ui_prefix}/display");
    $this->submitForm(['layout[enabled]' => TRUE], 'Save');
    $assert_session->linkExists('Manage layout');
    $this->clickLink('Manage layout');

    // Add a block with a form, another with a link, and one with an iframe.     $this->addBlock('Search form', '#layout-builder .search-block-form');
    $this->addBlock('Block with link', '#link-that-should-be-disabled');
    $this->addBlock('Block with iframe', '#iframe-that-should-be-disabled');

    // Ensure the links and forms are disabled using the defaults before the     // layout is saved.     $this->assertLinksFormIframeNotInteractive();

    $page->pressButton('Save layout');
    $this->clickLink('Manage layout');

    // Ensure the links and forms are disabled using the defaults.
Home | Imprint | This part of the site doesn't use cookies.