public function LayoutBuilderUiTest::testNewExtraField in Drupal 10
Same name and namespace in other branches
- 9 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderUiTest::testNewExtraField()
Tests removing newly added extra field.
File
- core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ LayoutBuilderUiTest.php, line 249
Class
- LayoutBuilderUiTest
- Tests the Layout Builder UI.
Namespace
Drupal\Tests\layout_builder\FunctionalJavascriptCode
public function testNewExtraField() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
// At this point layout builder has been enabled for the test content type.
// Install a test module that creates a new extra field then clear cache.
\Drupal::service('module_installer')
->install([
'layout_builder_extra_field_test',
]);
\Drupal::service('entity_field.manager')
->clearCachedFieldDefinitions();
// View the layout and try to remove the new extra field.
$this
->drupalGet(static::FIELD_UI_PREFIX . '/display/default/layout');
$assert_session
->pageTextContains('New Extra Field');
$this
->clickContextualLink('.block-extra-field-blocknodebundle-with-section-fieldlayout-builder-extra-field-test', 'Remove block');
$this
->assertNotEmpty($assert_session
->waitForElementVisible('css', '#drupal-off-canvas'));
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->pageTextContains('Are you sure you want to remove');
$page
->pressButton('Remove');
$assert_session
->assertWaitOnAjaxRequest();
$assert_session
->pageTextNotContains('New Extra Field');
}