CKEditor5DialogTest.php in Drupal 10
File
core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5DialogTest.php
View source
<?php
namespace Drupal\Tests\ckeditor5\FunctionalJavascript;
use Drupal\ckeditor5\Plugin\Editor\CKEditor5;
use Drupal\editor\Entity\Editor;
use Drupal\filter\Entity\FilterFormat;
use Drupal\Tests\ckeditor5\Traits\CKEditor5TestTrait;
use Drupal\user\RoleInterface;
use Symfony\Component\Validator\ConstraintViolation;
class CKEditor5DialogTest extends CKEditor5TestBase {
use CKEditor5TestTrait;
protected static $modules = [
'node',
'ckeditor5',
'ckeditor5_test',
];
public function testCKEditor5FocusInTooltipsInDialog() {
FilterFormat::create([
'format' => 'test_format',
'name' => 'CKEditor 5 with link',
'roles' => [
RoleInterface::AUTHENTICATED_ID,
],
])
->save();
Editor::create([
'format' => 'test_format',
'editor' => 'ckeditor5',
'settings' => [
'toolbar' => [
'items' => [
'link',
],
],
],
])
->save();
$this
->assertSame([], array_map(function (ConstraintViolation $v) {
return (string) $v
->getMessage();
}, iterator_to_array(CKEditor5::validatePair(Editor::load('test_format'), FilterFormat::load('test_format')))));
$page = $this
->getSession()
->getPage();
$assert_session = $this
->assertSession();
$this
->drupalGet('/ckeditor5_test/dialog');
$page
->clickLink('Add Node');
$assert_session
->waitForElementVisible('css', '[role="dialog"]');
$assert_session
->assertWaitOnAjaxRequest();
$content_area = $assert_session
->waitForElementVisible('css', '.ck-editor__editable');
$content_area
->click();
$this
->pressEditorButton('Link');
$link_url = '/ckeditor5_test/dialog';
$input = $assert_session
->waitForElementVisible('css', '.ck-balloon-panel input.ck-input-text');
$input
->setValue($link_url);
$page
->find('css', '.ck-balloon-panel .ck-button-save')
->click();
$this
->assertNotEmpty($content_area
->getText());
}
}