ItemLayoutFieldBlockTest.php in Drupal 10
File
core/modules/layout_builder/tests/src/FunctionalJavascript/ItemLayoutFieldBlockTest.php
View source
<?php
namespace Drupal\Tests\layout_builder\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay;
class ItemLayoutFieldBlockTest extends WebDriverTestBase {
protected static $modules = [
'node',
'layout_builder',
];
protected $defaultTheme = 'stark';
protected function setUp() : void {
parent::setUp();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
]));
$this
->createContentType([
'type' => 'bundle_with_layout_overrides',
]);
LayoutBuilderEntityViewDisplay::load('node.bundle_with_layout_overrides.default')
->enableLayoutBuilder()
->setOverridable()
->save();
$this
->createContentType([
'type' => 'filler_bundle',
]);
}
public function testAddAjaxBlock() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$node = $this
->createNode([
'type' => 'bundle_with_layout_overrides',
'body' => [
[
'value' => 'The node body',
],
],
]);
$node
->save();
$this
->drupalGet('node/1/layout');
$this
->clickLink('Add block');
$assert_session
->assertWaitOnAjaxRequest();
$valid_links = $page
->findAll('css', 'a[href$="field_block%3Anode%3Abundle_with_layout_overrides%3Abody"]');
$this
->assertCount(1, $valid_links);
$invalid_links = $page
->findAll('css', 'a[href$="field_block%3Anode%3Afiller_bundle%3Abody"]');
$this
->assertCount(0, $invalid_links);
}
}