You are here

public function UiAdminTest::testDefaultClass in Editor Advanced Image 8

Same name and namespace in other branches
  1. 8.2 tests/src/FunctionalJavascript/UiAdminTest.php \Drupal\Tests\editor_advanced_image\FunctionalJavascript\UiAdminTest::testDefaultClass()

Tests a CKEditor editor & storage of default class field.

File

tests/src/FunctionalJavascript/UiAdminTest.php, line 90

Class

UiAdminTest
Tests ckeditor formats admin forms.

Namespace

Drupal\Tests\editor_advanced_image\FunctionalJavascript

Code

public function testDefaultClass() {
  $page = $this
    ->getSession()
    ->getPage();
  $web_assert = $this
    ->assertSession();
  $this
    ->drupalGet('admin/config/content/formats/manage/full_html');

  // Select the "CKEditor" editor.
  $this
    ->fillField('Text editor', 'ckeditor');

  // Wait on CKEditor Ajax call to load plugins forms.
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->assertElementPresent('.vertical-tabs__menu a[href^="#edit-editor-settings-plugins-editoradvancedimage--"]');
  $web_assert
    ->waitForElementVisible('css', '.vertical-tabs__menu a[href^="#edit-editor-settings-plugins-editoradvancedimage--"]', 50);

  // Find & click on the Editor Advanced Plugin Form tab.
  $page
    ->find('css', '.vertical-tabs__menu a[href^="#edit-editor-settings-plugins-editoradvancedimage--"]')
    ->click();

  // Assert that the Editor Advanced Image Form becomes visible.
  $web_assert
    ->waitForElementVisible('css', '#edit-editor-settings-plugins-editoradvancedimage-default-class', 50);

  // Change the default class for 'my-class'.
  $this
    ->fillField('editor[settings][plugins][editoradvancedimage][default_class]', 'my-class');

  // Submit the new value.
  $this
    ->pressButton('edit-actions-submit');

  // Return on the editor configuration.
  $this
    ->drupalGet('admin/config/content/formats/manage/full_html');

  // Ensure the previously filled data has been stored.
  $this
    ->assertFieldByName('editor[settings][plugins][editoradvancedimage][default_class]', 'my-class');
}