EditorAdminTest.php in Drupal 10
File
core/modules/editor/tests/src/FunctionalJavascript/EditorAdminTest.php
View source
<?php
namespace Drupal\Tests\editor\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
class EditorAdminTest extends WebDriverTestBase {
protected $user;
protected static $modules = [
'ckeditor',
'ckeditor5',
];
protected $defaultTheme = 'stark';
protected function setUp() : void {
parent::setUp();
$this->user = $this
->drupalCreateUser([
'access administration pages',
'administer site configuration',
'administer filters',
]);
$this
->drupalLogin($this->user);
}
public function testEditorSelection() {
$page = $this
->getSession()
->getPage();
$assert_session = $this
->assertSession();
$this
->drupalGet('/admin/config/content/formats/add');
$page
->fillField('name', 'Sulaco');
$this
->assertNotEmpty($assert_session
->waitForText('sulaco'));
$page
->selectFieldOption('editor[editor]', 'ckeditor');
$this
->assertNotEmpty($this
->assertSession()
->waitForElementVisible('css', 'ul.ckeditor-toolbar-group-buttons'));
$this
->assertNotEmpty($this
->assertSession()
->waitForElementVisible('css', '#ckeditor-plugin-settings'));
$page
->pressButton('Save configuration');
$this
->drupalGet('/admin/config/content/formats/manage/sulaco');
$page
->selectFieldOption('editor[editor]', '');
$this
->assertNotEmpty($this
->assertSession()
->waitForElementRemoved('css', 'ul.ckeditor-toolbar-group-buttons'));
$page
->selectFieldOption('editor[editor]', 'ckeditor');
$this
->assertNotEmpty($this
->assertSession()
->waitForElementVisible('css', 'ul.ckeditor-toolbar-group-buttons'));
}
public function testEditorCreation() {
$page = $this
->getSession()
->getPage();
$assert_session = $this
->assertSession();
$this
->drupalGet('/admin/config/content/formats/add');
$page
->fillField('name', $this
->randomString());
$page
->selectFieldOption('editor[editor]', 'ckeditor5');
$this
->assertNotEmpty($this
->assertSession()
->waitForElementVisible('css', 'ul.ckeditor5-toolbar-available__buttons'));
$page
->selectFieldOption('editor[editor]', '');
$assert_session
->elementNotExists('css', 'ul.ckeditor-toolbar-group-buttons');
$page
->selectFieldOption('editor[editor]', 'ckeditor');
$this
->assertNotEmpty($this
->assertSession()
->waitForElementVisible('css', 'ul.ckeditor-toolbar-group-buttons'));
}
}