function LayoutBuilderDisableInteractionsTest::testFormsLinksDisabled

Same name in other branches
  1. 9 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderDisableInteractionsTest::testFormsLinksDisabled()
  2. 8.9.x core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderDisableInteractionsTest::testFormsLinksDisabled()
  3. 11.x core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderDisableInteractionsTest::testFormsLinksDisabled()

Tests that forms and links are disabled in the Layout Builder preview.

File

core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php, line 98

Class

LayoutBuilderDisableInteractionsTest
Tests the Layout Builder disables interactions of rendered blocks.

Namespace

Drupal\Tests\layout_builder\FunctionalJavascript

Code

public function testFormsLinksDisabled() : void {
    // Resize window due to bug in Chromedriver when clicking on overlays over
    // iFrames.
    // @see https://bugs.chromium.org/p/chromedriver/issues/detail?id=2758
    $this->getSession()
        ->resizeWindow(1200, 1200);
    $assert_session = $this->assertSession();
    $page = $this->getSession()
        ->getPage();
    $this->drupalLogin($this->drupalCreateUser([
        'configure any layout',
        'administer node display',
        'administer node fields',
        'search content',
        '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.
    $this->assertLinksFormIframeNotInteractive();
    // Ensure contextual links were not disabled.
    $this->assertContextualLinksClickable();
    $this->drupalGet("{$field_ui_prefix}/display/default");
    $this->submitForm([
        'layout[allow_custom]' => TRUE,
    ], 'Save');
    $this->drupalGet('node/1/layout');
    // Ensure the links and forms are also disabled in using the override.
    $this->assertLinksFormIframeNotInteractive();
    // Ensure contextual links were not disabled.
    $this->assertContextualLinksClickable();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.