function CKEditor5OffCanvasTest::testOffCanvasStyles

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

Tests if CKEditor is properly styled inside an off-canvas dialog.

File

core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5OffCanvasTest.php, line 27

Class

CKEditor5OffCanvasTest
Tests for CKEditor 5 to ensure correct styling in off-canvas.

Namespace

Drupal\Tests\ckeditor5\FunctionalJavascript

Code

public function testOffCanvasStyles() : void {
    $assert_session = $this->assertSession();
    $page = $this->getSession()
        ->getPage();
    $this->addNewTextFormat();
    $this->drupalGet('/ckeditor5_test/off_canvas');
    // The "Add Node" link triggers an off-canvas dialog with an add node form
    // that includes CKEditor.
    $page->clickLink('Add Node');
    $assert_session->waitForElementVisible('css', '#drupal-off-canvas-wrapper');
    $assert_session->assertWaitOnAjaxRequest();
    $styles = $assert_session->elementExists('css', 'style#ckeditor5-off-canvas-reset');
    $this->assertStringContainsString('#drupal-off-canvas-wrapper [data-drupal-ck-style-fence]', $styles->getHtml());
    $assert_session->elementExists('css', '.ck');
    $ckeditor_toolbar_bg_color = $this->getSession()
        ->evaluateScript('window.getComputedStyle(document.querySelector(\'.ck.ck-toolbar\')).backgroundColor');
    $this->assertEquals('rgb(255, 255, 255)', $ckeditor_toolbar_bg_color, 'Toolbar background-color should be unaffected by off-canvas');
    // Editable area should be visible.
    $assert_session->elementExists('css', '.ck .ck-content');
    $ckeditor_editable_bg_color = $this->getSession()
        ->evaluateScript('window.getComputedStyle(document.querySelector(\'.ck.ck-content\')).backgroundColor');
    $this->assertEquals('rgb(255, 255, 255)', $ckeditor_editable_bg_color, 'Content background-color should be unaffected by off-canvas');
}

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