You are here

public function CKEditorMediaBrowserTest::testEditEmbed in Lightning Media 8.3

Tests that the entity embed dialog opens when editing a pre-existing embed.

File

tests/src/FunctionalJavascript/CKEditorMediaBrowserTest.php, line 153

Class

CKEditorMediaBrowserTest
Tests the media browser's integration with CKEditor.

Namespace

Drupal\Tests\lightning_media\FunctionalJavascript

Code

public function testEditEmbed() {
  $page = $this
    ->getSession()
    ->getPage();
  $media_type = $this
    ->createMediaType('test')
    ->id();
  $this
    ->addMedia([
    'bundle' => $media_type,
    'field_media_test' => $this
      ->randomString(),
  ]);
  $node = $this
    ->drupalCreateNode([
    'type' => 'page',
    'title' => 'Blorf',
    'body' => [
      'value' => '',
      'format' => 'rich_text',
    ],
  ]);
  $this
    ->drupalGet($node
    ->toUrl('edit-form'));
  $this
    ->open();
  $items = $this
    ->waitForItems();
  $this
    ->selectItem($items[0]);
  $page
    ->pressButton('Place');
  $this
    ->waitForEntityBrowserToClose();
  $this
    ->submitEmbedForm();
  $page
    ->pressButton('Save');
  $this
    ->drupalGet($node
    ->toUrl('edit-form'));
  $this
    ->open(FALSE, function ($editor) {
    $this
      ->getSession()
      ->executeScript("CKEDITOR.instances['{$editor}'].widgets.instances[0].focus()");
  });
  $this
    ->waitForEmbedForm();
}