function CKEditor5AllowedTagsTest::testImageUploadsRemainEnabled

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

Tests that when image uploads were enabled, they remain enabled.

File

core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php, line 87

Class

CKEditor5AllowedTagsTest
Tests for CKEditor 5.

Namespace

Drupal\Tests\ckeditor5\FunctionalJavascript

Code

public function testImageUploadsRemainEnabled() : void {
    FilterFormat::create([
        'format' => 'editor_with_image_uploads',
        'name' => 'Text Editor with image uploads enabled',
    ])->save();
    Editor::create([
        'format' => 'editor_with_image_uploads',
        'editor' => 'unicorn',
        'image_upload' => [
            'status' => TRUE,
            'scheme' => 'public',
            'directory' => 'inline-images',
            'max_size' => NULL,
            'max_dimensions' => [
                'width' => NULL,
                'height' => NULL,
            ],
        ],
    ])->save();
    $page = $this->getSession()
        ->getPage();
    $assert_session = $this->assertSession();
    // Assert that image uploads are enabled initially.
    $this->drupalGet('admin/config/content/formats/manage/editor_with_image_uploads');
    $this->assertTrue($page->hasCheckedField('Enable image uploads'));
    // Switch the text format to CKEditor 5.
    $page->selectFieldOption('editor[editor]', 'ckeditor5');
    $assert_session->assertWaitOnAjaxRequest();
    // Enable the image toolbar item. This does NOT enable image uploads: it
    // triggers the image upload settings form to become visible, to allow the
    // image upload status to be checked.
    $this->triggerKeyUp('.ckeditor5-toolbar-item-drupalInsertImage', 'ArrowDown');
    $assert_session->assertWaitOnAjaxRequest();
    // Assert that image uploads are still enabled.
    $this->assertTrue($page->hasCheckedField('Enable image uploads'));
}

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