function CKEditor5DialogTest::testCKEditor5FocusInTooltipsInDialog

Same name and namespace in other branches
  1. 9 core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5DialogTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5DialogTest::testCKEditor5FocusInTooltipsInDialog()
  2. 10 core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5DialogTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5DialogTest::testCKEditor5FocusInTooltipsInDialog()

Tests if CKEditor 5 tooltips can be interacted with in dialogs.

File

core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5DialogTest.php, line 36

Class

CKEditor5DialogTest
Tests for CKEditor 5 to ensure correct focus management in dialogs.

Namespace

Drupal\Tests\ckeditor5\FunctionalJavascript

Code

public function testCKEditor5FocusInTooltipsInDialog() : void {
    FilterFormat::create([
        'format' => 'test_format',
        'name' => 'CKEditor 5 with link',
        'roles' => [
            RoleInterface::AUTHENTICATED_ID,
        ],
    ])->save();
    Editor::create([
        'format' => 'test_format',
        'editor' => 'ckeditor5',
        'image_upload' => [
            'status' => FALSE,
        ],
        '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');
    // Focus the editable area first.
    $content_area->click();
    // Then press the button to add a link.
    $this->pressEditorButton('Link');
    $link_url = '/ckeditor5_test/dialog';
    $input = $assert_session->waitForElementVisible('css', '.ck-balloon-panel input.ck-input-text');
    // Make sure the input field can have focus and we can type into it.
    $input->setValue($link_url);
    // Save the new link.
    $page->find('css', '.ck-balloon-panel .ck-button-save')
        ->click();
    // Make sure something was added to the text.
    $this->assertNotEmpty($content_area->getText());
}

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