function CKEditorIntegrationTest::testDrupalImageCaptionDialog

Same name and namespace in other branches
  1. 8.9.x core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php \Drupal\Tests\ckeditor\FunctionalJavascript\CKEditorIntegrationTest::testDrupalImageCaptionDialog()

Tests if the Drupal Image Caption plugin appears and works as expected.

File

core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php, line 168

Class

CKEditorIntegrationTest
Tests the integration of CKEditor.

Namespace

Drupal\Tests\ckeditor\FunctionalJavascript

Code

public function testDrupalImageCaptionDialog() {
    $web_assert = $this->assertSession();
    // Disable the caption filter.
    $this->filterFormat
        ->setFilterConfig('filter_caption', [
        'status' => FALSE,
    ]);
    $this->filterFormat
        ->save();
    // If the caption filter is disabled, its checkbox should be absent.
    $this->drupalGet('node/add/page');
    $this->waitForEditor();
    $this->pressEditorButton('drupalimage');
    $this->assertNotEmpty($web_assert->waitForElement('css', '.ui-dialog'));
    $web_assert->elementNotExists('css', '.ui-dialog input[name="attributes[hasCaption]"]');
    // Enable the caption filter again.
    $this->filterFormat
        ->setFilterConfig('filter_caption', [
        'status' => TRUE,
    ]);
    $this->filterFormat
        ->save();
    // If the caption filter is enabled, its checkbox should be present.
    $this->drupalGet('node/add/page');
    $this->waitForEditor();
    $this->pressEditorButton('drupalimage');
    $this->assertNotEmpty($web_assert->waitForElement('css', '.ui-dialog'));
    $web_assert->elementExists('css', '.ui-dialog input[name="attributes[hasCaption]"]');
}

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