You are here

public function CKEditor5AllowedTagsTest::testImageUploadsRemainEnabled in Drupal 10

Tests that when image uploads are enabled in CKEditor 4, they remain in 5.

File

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

Class

CKEditor5AllowedTagsTest
Tests for CKEditor5.

Namespace

Drupal\Tests\ckeditor5\FunctionalJavascript

Code

public function testImageUploadsRemainEnabled() : void {
  FilterFormat::create([
    'format' => 'cke4_image_uploads',
    'name' => 'CKEditor 4, image uploads',
  ])
    ->save();
  Editor::create([
    'format' => 'cke4_image_uploads',
    'editor' => 'ckeditor',
    'settings' => [
      'toolbar' => [
        'rows' => [
          0 => [
            [
              'name' => 'Media',
              'items' => [
                'DrupalImage',
              ],
            ],
          ],
        ],
      ],
      'plugins' => [],
    ],
    'image_upload' => [
      'status' => TRUE,
      'scheme' => 'public',
      'directory' => 'inline-images',
      'max_size' => '',
      'max_dimensions' => [
        'width' => 0,
        'height' => 0,
      ],
    ],
  ])
    ->save();
  $page = $this
    ->getSession()
    ->getPage();
  $assert_session = $this
    ->assertSession();

  // Assert that image uploads are enabled initially.
  $this
    ->drupalGet('admin/config/content/formats/manage/cke4_image_uploads');
  $this
    ->assertTrue($page
    ->hasCheckedField('Enable image uploads'));

  // Switch the text format to CKEditor 5.
  $page
    ->selectFieldOption('editor[editor]', 'ckeditor5');
  $assert_session
    ->assertWaitOnAjaxRequest();

  // Assert that image uploads are still enabled.
  $this
    ->assertTrue($page
    ->hasCheckedField('Enable image uploads'));
}