View source
<?php
namespace Drupal\Tests\layout_builder_restrictions_by_region\FunctionalJavascript;
use Drupal\Tests\layout_builder_restrictions\FunctionalJavascript\LayoutBuilderRestrictionsTestBase;
class BlockPlacementWhitelistTest extends LayoutBuilderRestrictionsTestBase {
protected static $modules = [
'block',
'layout_builder',
'layout_builder_restrictions',
'layout_builder_restrictions_by_region',
'node',
'field_ui',
'block_content',
];
protected function setUp() : void {
parent::setUp();
$this
->drupalLogin($this
->drupalCreateUser([
'access administration pages',
'administer blocks',
'administer node display',
'administer node fields',
'configure any layout',
'configure layout builder restrictions',
'create and edit custom blocks',
]));
$layout_builder_restrictions_plugins = [
'entity_view_mode_restriction' => [
'weight' => 1,
'enabled' => FALSE,
],
'entity_view_mode_restriction_by_region' => [
'weight' => 0,
'enabled' => TRUE,
],
];
$config = \Drupal::service('config.factory')
->getEditable('layout_builder_restrictions.plugins');
$config
->set('plugin_config', $layout_builder_restrictions_plugins)
->save();
}
public function testBlockRestrictionStorage() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->navigateToManageDisplay();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-layouts"]/summary');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-layouts-layout-restriction-restricted"]');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-layouts-layouts-layout-twocol-section"]');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section"]/summary');
$element
->click();
$assert_session
->checkboxChecked('edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-restriction-behavior-all');
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="all_regions"]', 'All regions');
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="all_regions"]', 'Unrestricted');
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-restriction-behavior-per-region"]');
$element
->click();
$assert_session
->checkboxChecked('edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-restriction-behavior-per-region');
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="first"]', 'First');
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="first"]', 'Unrestricted');
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="second"]', 'Second');
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="second"]', 'Unrestricted');
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="first"]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->checkboxChecked('Allow all existing & new Content fields blocks.');
$assert_session
->checkboxNotChecked('Allow specific Content fields blocks:');
$element = $page
->find('xpath', '//*[starts-with(@id,"edit-allowed-blocks-content-fields-restriction-whitelisted--")]');
$element
->click();
$element = $page
->find('xpath', '//*[starts-with(@id,"edit-submit--")]');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="first"]', 'Restricted');
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="second"]', 'Unrestricted');
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="first"]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->checkboxNotChecked('Allow all existing & new Content fields blocks.');
$assert_session
->checkboxChecked('Allow specific Content fields blocks:');
$page
->pressButton('Close');
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="second"]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->checkboxChecked('Allow all existing & new Content fields blocks.');
$assert_session
->checkboxNotChecked('Allow specific Content fields blocks:');
$page
->pressButton('Close');
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-restriction-behavior-all"]');
$element
->click();
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="all_regions"]', 'Unrestricted');
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="all_regions"]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->checkboxChecked('Allow all existing & new Content fields blocks.');
$assert_session
->checkboxNotChecked('Allow specific Content fields blocks:');
$page
->pressButton('Close');
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-restriction-behavior-per-region"]');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-layouts-layouts-layout-onecol"]');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-onecol"]/summary');
$element
->click();
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-onecol-table"]/tbody/tr[@data-region="all_regions"]', 'Unrestricted');
$page
->pressButton('Save');
$this
->navigateToManageDisplay();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section"]/summary');
$element
->click();
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="first"]', 'Restricted');
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="second"]', 'Unrestricted');
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-restriction-behavior-all"]');
$element
->click();
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="all_regions"]', 'Unrestricted');
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-onecol"]/summary');
$element
->click();
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-onecol-table"]/tbody/tr[@data-region="all_regions"]', 'Unrestricted');
}
public function testBlockRestriction() {
$blocks = $this
->generateTestBlocks();
$node_id = $this
->generateTestNode();
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->navigateToManageDisplay();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-layouts"]/summary');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-layouts-layout-restriction-restricted"]');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-layouts-layouts-layout-twocol-section"]');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section"]/summary');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-restriction-behavior-per-region"]');
$element
->click();
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="first"]', 'Restricted');
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="second"]', 'Unrestricted');
$page
->pressButton('Save');
$this
->navigateToNodeLayout($node_id);
$this
->clickLink('Remove Section 1');
$assert_session
->assertWaitOnAjaxRequest();
$page
->pressButton('Remove');
$assert_session
->assertWaitOnAjaxRequest();
$this
->clickLink('Add section');
$assert_session
->assertWaitOnAjaxRequest();
$this
->clickLink('Two column');
$assert_session
->assertWaitOnAjaxRequest();
$element = $page
->find('xpath', '//*[contains(@class, "ui-dialog-off-canvas")]//*[starts-with(@id,"edit-actions-submit--")]');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$element = $page
->find('xpath', '//*[contains(@class, "layout__region--first")]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->linkExists('Body');
$assert_session
->linkExists('Basic Block 1');
$assert_session
->linkExists('Basic Block 2');
$assert_session
->linkExists('Alternate Block 1');
$this
->clickLink('Create custom block');
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->linkExists('Basic');
$assert_session
->linkExists('Alternate');
$page
->pressButton('Close');
$page
->pressButton('Save');
$this
->navigateToManageDisplay();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section"]/summary');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-restriction-behavior-per-region"]');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="first"]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->checkboxChecked('Allow all existing & new Content fields blocks.');
$assert_session
->checkboxNotChecked('Allow specific Content fields blocks:');
$assert_session
->checkboxChecked('Allow all existing & new Custom block types blocks.');
$assert_session
->checkboxNotChecked('Allow specific Custom block types blocks:');
$element = $page
->find('xpath', '//*[contains(@class, "form-item-allowed-blocks-content-fields-restriction")]/input[@value="whitelisted"]');
$element
->click();
$element = $page
->find('xpath', '//*[contains(@class, "form-item-allowed-blocks-custom-block-types-restriction")]/input[@value="whitelisted"]');
$element
->click();
$element = $page
->find('xpath', '//*[starts-with(@id,"edit-submit--")]');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$page
->pressButton('Save');
$this
->navigateToNodeLayout($node_id);
$element = $page
->find('xpath', '//*[contains(@class, "layout__region--first")]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->linkNotExists('Body');
$assert_session
->linkNotExists('Basic Block 1');
$assert_session
->linkNotExists('Basic Block 2');
$assert_session
->linkNotExists('Alternate Block 1');
$this
->clickLink('Create custom block');
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->linkExists('Basic');
$assert_session
->linkExists('Alternate');
$this
->navigateToManageDisplay();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section"]/summary');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="first"]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->checkboxChecked('Allow specific Content fields blocks:');
$assert_session
->checkboxNotChecked('Allow all existing & new Content fields blocks.');
$assert_session
->checkboxChecked('Allow all existing & new Inline blocks blocks.');
$assert_session
->checkboxNotChecked('Allow specific Inline blocks blocks:');
$element = $page
->find('xpath', '//*[starts-with(@id, "edit-allowed-blocks-inline-blocks-restriction-whitelisted--")]');
$element
->click();
$element = $page
->find('xpath', '//*[starts-with(@id,"edit-submit--")]');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$page
->pressButton('Save');
$this
->navigateToNodeLayout($node_id);
$element = $page
->find('xpath', '//*[contains(@class, "layout__region--first")]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->linkNotExists('Body');
$assert_session
->linkNotExists('Basic Block 1');
$assert_session
->linkNotExists('Basic Block 2');
$assert_session
->linkNotExists('Alternate Block 1');
$assert_session
->linkNotExists('Create custom block');
$this
->navigateToManageDisplay();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section"]/summary');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="first"]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->checkboxChecked('Allow specific Content fields blocks:');
$page
->checkField('allowed_blocks[Content fields][allowed_blocks][field_block:node:bundle_with_section_field:body]');
$page
->checkField('allowed_blocks[Custom block types][allowed_blocks][basic]');
$page
->checkField('allowed_blocks[Inline blocks][allowed_blocks][inline_block:alternate]');
$element = $page
->find('xpath', '//*[starts-with(@id,"edit-submit--")]');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$page
->pressButton('Save');
$this
->navigateToNodeLayout($node_id);
$this
->clickLink('Add block');
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->linkExists('Body');
$assert_session
->linkNotExists('Promoted to front page');
$assert_session
->linkNotExists('Sticky at top of lists');
$assert_session
->linkExists('Basic Block 1');
$assert_session
->linkExists('Basic Block 2');
$assert_session
->linkNotExists('Alternate Block 1');
$this
->clickLink('Create custom block');
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->linkNotExists('Basic');
$assert_session
->linkExists('Alternate');
$this
->navigateToManageDisplay();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section"]/summary');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="first"]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$element = $page
->find('xpath', '//*[starts-with(@id, "edit-allowed-blocks-custom-blocks-restriction-whitelisted--")]');
$element
->click();
$page
->checkField('allowed_blocks[Custom blocks][allowed_blocks][block_content:' . $blocks['Alternate Block 1'] . ']');
$page
->checkField('allowed_blocks[Custom blocks][allowed_blocks][block_content:' . $blocks['Basic Block 1'] . ']');
$element = $page
->find('xpath', '//*[starts-with(@id,"edit-submit--")]');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$page
->pressButton('Save');
$this
->navigateToNodeLayout($node_id);
$element = $page
->find('xpath', '//*[contains(@class, "layout__region--first")]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->linkExists('Basic Block 1');
$assert_session
->linkNotExists('Basic Block 2');
$assert_session
->linkExists('Alternate Block 1');
$this
->navigateToManageDisplay();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section"]/summary');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="second"]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$element = $page
->find('xpath', '//*[starts-with(@id, "edit-allowed-blocks-system-restriction-whitelisted--")]');
$element
->click();
$element = $page
->find('xpath', '//*[starts-with(@id,"edit-submit--")]');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$page
->pressButton('Save');
$this
->navigateToNodeLayout($node_id);
$element = $page
->find('xpath', '//*[contains(@class, "layout__region--first")]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->linkExists('Powered by Drupal');
$page
->pressButton('Close');
$element = $page
->find('xpath', '//*[contains(@class, "layout__region--second")]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->linkNotExists('Powered by Drupal');
$page
->pressButton('Close');
$this
->navigateToManageDisplay();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-layouts"]/summary');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-layouts-layouts-layout-threecol-section"]');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-threecol-section"]/summary');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-threecol-section-restriction-behavior-per-region"]');
$element
->click();
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-threecol-section-table"]/tbody/tr[@data-region="first"]', 'First');
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-threecol-section-table"]/tbody/tr[@data-region="first"]', 'Unrestricted');
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-threecol-section-table"]/tbody/tr[@data-region="second"]', 'Second');
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-threecol-section-table"]/tbody/tr[@data-region="second"]', 'Unrestricted');
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-threecol-section-table"]/tbody/tr[@data-region="third"]', 'Third');
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-threecol-section-table"]/tbody/tr[@data-region="third"]', 'Unrestricted');
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-threecol-section-table"]/tbody/tr[@data-region="first"]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->checkboxChecked('Allow all existing & new Content fields blocks.');
$assert_session
->checkboxNotChecked('Allow specific Content fields blocks:');
$assert_session
->checkboxChecked('Allow all existing & new Custom blocks blocks.');
$assert_session
->checkboxNotChecked('Allow specific Custom blocks blocks:');
$assert_session
->checkboxChecked('Allow all existing & new Inline blocks blocks.');
$assert_session
->checkboxNotChecked('Allow specific Inline blocks blocks:');
$assert_session
->checkboxChecked('Allow all existing & new System blocks.');
$assert_session
->checkboxNotChecked('Allow specific System blocks:');
$assert_session
->checkboxChecked('Allow all existing & new core blocks.');
$assert_session
->checkboxNotChecked('Allow specific core blocks:');
$element = $page
->find('xpath', '//*[starts-with(@id, "edit-allowed-blocks-core-restriction-whitelisted--")]');
$element
->click();
$element = $page
->find('xpath', '//*[starts-with(@id,"edit-submit--")]');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-threecol-section-table"]/tbody/tr[@data-region="third"]', 'Third');
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-threecol-section-table"]/tbody/tr[@data-region="third"]', 'Restricted');
$page
->pressButton('Save');
$this
->navigateToNodeLayout($node_id);
$element = $page
->find('xpath', '//*[contains(@class, "layout__region--first")]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->linkExists('Primary admin actions');
$page
->pressButton('Close');
$element = $page
->find('xpath', '//*[contains(@class, "layout__region--second")]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->linkExists('Primary admin actions');
$page
->pressButton('Close');
$element = $page
->find('xpath', '//*[@data-layout-builder-highlight-id="section-1"]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$this
->clickLink('Three column');
$assert_session
->assertWaitOnAjaxRequest();
$element = $page
->find('xpath', '//*[contains(@class, "ui-dialog-off-canvas")]//*[starts-with(@id,"edit-actions-submit--")]');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$page
->pressButton('Save');
$this
->navigateToNodeLayout($node_id);
$element = $page
->find('xpath', '//*[contains(@class, "layout--threecol-section")]/*[contains(@class, "layout__region--first")]//a');
$element
->click();
$assert_session
->linkNotExists('Primary admin actions');
$this
->navigateToManageDisplay();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section"]/summary');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-restriction-behavior-all"]');
$element
->click();
$assert_session
->elementContains('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="all_regions"]', 'Unrestricted');
$page
->pressButton('Save');
$this
->navigateToNodeLayout($node_id);
$element = $page
->find('xpath', '//*[contains(@class, "layout--twocol-section")]/*[contains(@class, "layout__region--first")]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->linkExists('Promoted to front page');
$page
->pressButton('Close');
$assert_session
->assertWaitOnAjaxRequest();
$element = $page
->find('xpath', '//*[contains(@class, "layout--twocol-section")]/*[contains(@class, "layout__region--second")]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->linkExists('Promoted to front page');
$page
->pressButton('Close');
$assert_session
->assertWaitOnAjaxRequest();
$page
->pressButton('Save');
$this
->navigateToManageDisplay();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section"]/summary');
$element
->click();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-blocks-by-layout-layout-twocol-section-table"]/tbody/tr[@data-region="all_regions"]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->checkboxChecked('Allow all existing & new Content fields blocks.');
$assert_session
->checkboxNotChecked('Allow specific Content fields blocks:');
$element = $page
->find('xpath', '//*[contains(@class, "form-item-allowed-blocks-content-fields-restriction")]/input[@value="whitelisted"]');
$element
->click();
$element = $page
->find('xpath', '//*[starts-with(@id,"edit-submit--")]');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$page
->pressButton('Save');
$this
->navigateToNodeLayout($node_id);
$element = $page
->find('xpath', '//*[contains(@class, "layout--twocol-section")]/*[contains(@class, "layout__region--first")]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->linkNotExists('Promoted to front page');
$page
->pressButton('Close');
$assert_session
->assertWaitOnAjaxRequest();
$element = $page
->find('xpath', '//*[contains(@class, "layout--twocol-section")]/*[contains(@class, "layout__region--second")]//a');
$element
->click();
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->linkNotExists('Promoted to front page');
}
}