LayoutBuilderToolbarTest.php in Drupal 10
File
core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderToolbarTest.php
View source
<?php
namespace Drupal\Tests\layout_builder\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
class LayoutBuilderToolbarTest extends WebDriverTestBase {
protected static $modules = [
'block',
'node',
'field_ui',
'layout_builder',
'node',
'toolbar',
];
protected $defaultTheme = 'classy';
protected function setUp() : void {
parent::setUp();
$this
->drupalPlaceBlock('local_tasks_block');
$this
->createContentType([
'type' => 'bundle_with_section_field',
'name' => 'Bundle with section field',
]);
$this
->createNode([
'type' => 'bundle_with_section_field',
'title' => 'The first node title',
'body' => [
[
'value' => 'The first node body',
],
],
]);
}
public function testBackToSiteLink() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'access administration pages',
'administer node display',
'administer node fields',
'access toolbar',
]));
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
$this
->drupalGet("{$field_ui_prefix}/display/default");
$this
->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$assert_session
->linkExists('Manage layout');
$this
->clickLink('Manage layout');
$page
->pressButton('Save layout');
$assert_session
->addressEquals("{$field_ui_prefix}/display/default");
$this
->drupalGet("{$field_ui_prefix}/display/default/layout");
$this
->clickLink('Back to site');
$assert_session
->addressEquals("/user/2");
$this
->drupalGet("{$field_ui_prefix}/display/default/layout/discard-changes");
$page
->pressButton('Confirm');
$this
->clickLink('Back to site');
$assert_session
->addressEquals("/user/2");
$this
->drupalGet("{$field_ui_prefix}/display/default/layout/disable");
$page
->pressButton('Confirm');
$this
->clickLink('Back to site');
$assert_session
->addressEquals("/user/2");
}
}