You are here

public function CKEditorImagesGalleryTest::testAddImagesGalleryFlow in CKEditor Images Gallery 8

Test Body field and button appeared.

File

tests/src/FunctionalJavascript/CKEditorImagesGalleryTest.php, line 92

Class

CKEditorImagesGalleryTest
Class CKEditorImagesGalleryTest.

Namespace

Drupal\Tests\ckeditor_images_gallery\FunctionalJavascript

Code

public function testAddImagesGalleryFlow() {
  $this
    ->drupalGet('node/add/page');
  $assert_session = $this
    ->assertSession();
  $session = $this
    ->getSession();
  $assert_session
    ->elementExists('css', 'textarea[name="body[0][value]"]');
  $assert_session
    ->elementExists('css', 'a.cke_button__gallery.cke_button');
  $session
    ->getPage()
    ->clickLink('Image gallery');
  $assert_session
    ->waitForElementVisible('css', 'table.cke_dialog_contents');
  $assert_session
    ->elementExists('css', 'a.cke_dialog_ui_button');
  $session
    ->getPage()
    ->clickLink('Upload');
  $windows = $session
    ->getDriver()
    ->getWindowNames();
  $session
    ->getDriver()
    ->switchToWindow($windows[1]);
  $assert_session
    ->waitForElementVisible('css', 'div.file-jpg');
  $assert_session
    ->elementExists('css', '#imce-content');
  $assert_session
    ->elementExists('css', 'div.file-jpg')
    ->doubleClick();
  $session
    ->getDriver()
    ->switchToWindow();
  $assert_session
    ->elementExists('css', '.cke-ig-edit-list img');
  $session
    ->getPage()
    ->clickLink('Upload');
  $windows = $session
    ->getDriver()
    ->getWindowNames();
  $session
    ->getDriver()
    ->switchToWindow($windows[1]);
  $assert_session
    ->waitForElementVisible('css', 'div.file-jpg');
  $assert_session
    ->elementExists('css', '#imce-content');
  $assert_session
    ->elementExists('css', 'div.file-jpg')
    ->doubleClick();
  $session
    ->getDriver()
    ->switchToWindow();
  $selected_image = $session
    ->getPage()
    ->findAll('css', '.cke-ig-edit-list img');
  $this
    ->assertEquals(2, count($selected_image));

  //    $session->getPage()->clickLink('cke_dialog_ui_button_ok');
  $assert_session
    ->elementExists('css', '.cke_dialog_ui_button_ok')
    ->click();
  $session
    ->getPage()
    ->fillField('edit-title-0-value', $this
    ->randomMachineName());
  $session
    ->getPage()
    ->pressButton('edit-submit');
  $assert_session
    ->elementExists('css', '.cke-ig');
  $assert_session
    ->elementExists('css', '.cke-ig img');
}