You are here

public function TinyMCEIntegrationTest::testImageDialog in TinyMCE 1.x

Tests if the Image button appears and works as expected.

File

tests/src/FunctionalJavascript/TinyMCEIntegrationTest.php, line 136

Class

TinyMCEIntegrationTest
Tests the integration of TinyMCE.

Namespace

Drupal\Tests\tinymce\FunctionalJavascript

Code

public function testImageDialog() {
  $session = $this
    ->getSession();
  $web_assert = $this
    ->assertSession();
  $this
    ->drupalGet('node/add/page');
  $session
    ->getPage();

  // Asserts the Image button is present in the toolbar.
  $web_assert
    ->elementExists('css', '.tox-tinymce .tox-tbtn[title="Insert/edit image"]');

  // Asserts the Tiny cloud notice is displayed and needs to be closed
  // (otherwise the image button will be covered).
  $this
    ->click('.tox-notification__dismiss');

  // Asserts the image dialog opens when clicking on the "More ..." button and
  // the Image button.
  $this
    ->click('.tox-tbtn[title="More..."]');
  $this
    ->assertNotEmpty($web_assert
    ->waitForElement('css', '.tox-tbtn[title="Insert/edit image"]'));
  $this
    ->click('.tox-tbtn[title="Insert/edit image"]');
  $this
    ->assertNotEmpty($web_assert
    ->waitForElement('css', '.tox-dialog'));
  $web_assert
    ->elementContains('css', '.tox-dialog .tox-dialog__title', 'Insert/Edit Image');
}