SectionSelectionTest.php in Layout Builder UX 8
File
tests/src/FunctionalJavascript/SectionSelectionTest.php
View source
<?php
namespace Drupal\Tests\lb_ux\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay;
class SectionSelectionTest extends WebDriverTestBase {
protected static $modules = [
'lb_ux',
'node',
'lb_ux_test',
];
protected $defaultTheme = 'stark';
protected function setUp() : void {
parent::setUp();
$this
->createContentType([
'type' => 'bundle_with_section_field',
]);
LayoutBuilderEntityViewDisplay::load('node.bundle_with_section_field.default')
->enableLayoutBuilder()
->setOverridable()
->save();
$this
->drupalLogin($this
->createUser([
'administer node display',
'configure any layout',
'access site reports',
]));
}
public function testBypassSectionConfiguration() {
$page = $this
->getSession()
->getPage();
$assert_session = $this
->assertSession();
$this
->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default/layout');
$assert_session
->elementNotExists('css', '.layout--lb-ux-test-form-no-validation');
$assert_session
->elementNotExists('css', '.layout--lb-ux-test-form-with-validation');
$page
->clickLink('Add section');
$assert_session
->assertWaitOnAjaxRequest();
$page
->clickLink('LB UX form no validation');
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->elementExists('css', '.layout--lb-ux-test-form-no-validation');
$assert_session
->pageTextNotContains('Check 1 2');
$page
->clickLink('Configure Section 1');
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->pageTextContains('Check 1 2');
$page
->pressButton('Update');
$assert_session
->assertWaitOnAjaxRequest();
$page
->clickLink('Add section');
$assert_session
->assertWaitOnAjaxRequest();
$page
->clickLink('LB UX form with validation');
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->elementNotExists('css', '.layout--lb-ux-test-form-with-validation');
$assert_session
->pageTextNotContains("That's not the magic word!");
$page
->pressButton('Add section');
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->elementNotExists('css', '.layout--lb-ux-test-form-with-validation');
$assert_session
->pageTextContains("That's not the magic word!");
$page
->fillField('label', 'Abracadabra');
$page
->pressButton('Add section');
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->elementExists('css', '.layout--lb-ux-test-form-with-validation');
}
}