DefaultRestrictionsTest.php in Layout Builder Restrictions 8.2
File
tests/src/FunctionalJavascript/DefaultRestrictionsTest.php
View source
<?php
namespace Drupal\Tests\layout_builder_restrictions\FunctionalJavascript;
class DefaultRestrictionsTest extends LayoutBuilderRestrictionsTestBase {
public function testNewCategoriesRestricted() {
$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-block-categories-restricted"]');
$element
->click();
$page
->pressButton('Save');
$this->container
->get('module_installer')
->install([
'help',
]);
$this
->navigateToNodeSettingsTray($node_id);
$assert_session
->linkNotExists('Help');
$this
->clickLink('Create custom block');
$this
->assertNotEmpty($assert_session
->waitForText('Add a new custom block'));
$assert_session
->linkExists('Basic');
$assert_session
->linkExists('Alternate');
}
public function testNewCategoriesAllowed() {
$blocks = $this
->generateTestBlocks();
$node_id = $this
->generateTestNode();
$this
->getSession()
->resizeWindow(1200, 2000);
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->navigateToManageDisplay();
$page
->checkField('layout[enabled]');
$page
->checkField('layout[allow_custom]');
$page
->pressButton('Save');
$this
->navigateToManageDisplay();
$element = $page
->find('xpath', '//*[@id="edit-layout-builder-restrictions-allowed-block-categories-allowed"]');
$element
->click();
$page
->pressButton('Save');
$this->container
->get('module_installer')
->install([
'help',
]);
$this
->navigateToNodeSettingsTray($node_id);
$assert_session
->linkExists('Help');
$this
->clickLink('Create custom block');
$this
->assertNotEmpty($assert_session
->waitForText('Add a new custom block'));
$assert_session
->linkExists('Basic');
$assert_session
->linkExists('Alternate');
}
}