function CKEditor5Test::testListPlugin
Same name in other branches
- 9 core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php \Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5Test::testListPlugin()
- 10 core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php \Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5Test::testListPlugin()
Tests list plugin.
File
-
core/
modules/ ckeditor5/ tests/ src/ FunctionalJavascript/ CKEditor5Test.php, line 555
Class
- CKEditor5Test
- Tests for CKEditor 5.
Namespace
Drupal\Tests\ckeditor5\FunctionalJavascriptCode
public function testListPlugin() : void {
FilterFormat::create([
'format' => 'test_format',
'name' => 'CKEditor 5 with list',
'roles' => [
RoleInterface::AUTHENTICATED_ID,
],
])->save();
Editor::create([
'format' => 'test_format',
'editor' => 'ckeditor5',
'image_upload' => [
'status' => FALSE,
],
'settings' => [
'toolbar' => [
'items' => [
'sourceEditing',
'numberedList',
],
],
'plugins' => [
'ckeditor5_list' => [
'properties' => [
'reversed' => FALSE,
'startIndex' => FALSE,
],
'multiBlock' => TRUE,
],
'ckeditor5_sourceEditing' => [
'allowed_tags' => [],
],
],
],
])->save();
$this->assertSame([], array_map(function (ConstraintViolationInterface $v) {
return (string) $v->getMessage();
}, iterator_to_array(CKEditor5::validatePair(Editor::load('test_format'), FilterFormat::load('test_format')))));
$ordered_list_html = '<ol><li>apple</li><li>banana</li><li>cantaloupe</li></ol>';
$page = $this->getSession()
->getPage();
$assert_session = $this->assertSession();
$this->drupalGet('node/add/page');
$page->fillField('title[0][value]', 'My test content');
$this->pressEditorButton('Source');
$source_text_area = $assert_session->waitForElement('css', '.ck-source-editing-area textarea');
$source_text_area->setValue($ordered_list_html);
// Click source again to make source inactive and have the numbered list
// splitbutton active.
$this->pressEditorButton('Source');
$numbered_list_dropdown_selector = '.ck-splitbutton__arrow';
// Check that there is no dropdown available for the numbered list because
// both reversed and startIndex are FALSE.
$assert_session->elementNotExists('css', $numbered_list_dropdown_selector);
// Save content so source content is kept after changing the editor config.
$page->pressButton('Save');
$edit_url = $this->getSession()
->getCurrentURL() . '/edit';
$this->drupalGet($edit_url);
$this->waitForEditor();
// Enable the reversed functionality.
$editor = Editor::load('test_format');
$settings = $editor->getSettings();
$settings['plugins']['ckeditor5_list']['properties']['reversed'] = TRUE;
$editor->setSettings($settings);
$editor->save();
$this->getSession()
->reload();
$this->waitForEditor();
$this->click($numbered_list_dropdown_selector);
$reversed_order_button_selector = '.ck.ck-button.ck-numbered-list-properties__reversed-order';
$assert_session->elementExists('css', $reversed_order_button_selector);
$assert_session->elementTextEquals('css', $reversed_order_button_selector, 'Reversed order');
$start_index_element_selector = '.ck.ck-numbered-list-properties__start-index';
$assert_session->elementNotExists('css', $start_index_element_selector);
// Have both the reversed and the start index enabled.
$editor = Editor::load('test_format');
$settings = $editor->getSettings();
$settings['plugins']['ckeditor5_list']['properties']['startIndex'] = TRUE;
$editor->setSettings($settings);
$editor->save();
$this->getSession()
->reload();
$this->waitForEditor();
$this->click($numbered_list_dropdown_selector);
$assert_session->elementExists('css', $reversed_order_button_selector);
$assert_session->elementTextEquals('css', $reversed_order_button_selector, 'Reversed order');
$assert_session->elementExists('css', $start_index_element_selector);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.