function AdminUiTest::testPluginSettingsFormSection

Same name in other branches
  1. 9 core/modules/ckeditor5/tests/src/FunctionalJavascript/AdminUiTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\AdminUiTest::testPluginSettingsFormSection()
  2. 11.x core/modules/ckeditor5/tests/src/FunctionalJavascript/AdminUiTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\AdminUiTest::testPluginSettingsFormSection()

Tests the plugin settings form section.

File

core/modules/ckeditor5/tests/src/FunctionalJavascript/AdminUiTest.php, line 275

Class

AdminUiTest
Tests for CKEditor 5 in the admin UI.

Namespace

Drupal\Tests\ckeditor5\FunctionalJavascript

Code

public function testPluginSettingsFormSection() : void {
    $page = $this->getSession()
        ->getPage();
    $assert_session = $this->assertSession();
    $this->createNewTextFormat($page, $assert_session);
    // The default toolbar only enables the configurable heading plugin and the
    // non-configurable bold and italic plugins.
    $assert_session->fieldValueEquals('editor[settings][toolbar][items]', '["heading","bold","italic"]');
    // The heading plugin config form should be present.
    $assert_session->elementExists('css', '[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-heading"]');
    // Remove the heading plugin from the toolbar.
    $this->triggerKeyUp('.ckeditor5-toolbar-item-heading', 'ArrowUp');
    $assert_session->assertWaitOnAjaxRequest();
    // The heading plugin config form should no longer be present.
    $assert_session->elementNotExists('css', '[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-heading"]');
    // The plugin settings wrapper should still be present, but empty.
    $assert_session->elementExists('css', '#plugin-settings-wrapper');
    $assert_session->elementNotContains('css', '#plugin-settings-wrapper', '<div');
    // Enable the source plugin.
    $this->triggerKeyUp('.ckeditor5-toolbar-item-sourceEditing', 'ArrowDown');
    $assert_session->assertWaitOnAjaxRequest();
    // The source plugin config form should be present.
    $assert_session->elementExists('css', '[data-drupal-selector="edit-editor-settings-plugins-ckeditor5-sourceediting"]');
    // The filter-dependent configurable plugin should not be present.
    $assert_session->elementNotExists('css', '[data-drupal-selector="edit-editor-settings-plugins-media-media"]');
    // Enable the filter that the configurable plugin depends on.
    $this->assertTrue($page->hasUncheckedField('filters[media_embed][status]'));
    $page->checkField('filters[media_embed][status]');
    $assert_session->assertWaitOnAjaxRequest();
    // The filter-dependent configurable plugin should be present.
    $assert_session->elementExists('css', '[data-drupal-selector="edit-editor-settings-plugins-media-media"]');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.