You are here

public function WidgetTest::testConfirmationAction in Entity reference actions 1.x

Test an action with confirmation page.

File

tests/src/FunctionalJavascript/WidgetTest.php, line 130

Class

WidgetTest
Testing the widget.

Namespace

Drupal\Tests\entity_reference_actions\FunctionalJavascript

Code

public function testConfirmationAction() {

  /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */
  $display_repository = \Drupal::service('entity_display.repository');
  $display_repository
    ->getFormDisplay('entity_test', 'entity_test')
    ->setComponent('field_test', [
    'type' => 'media_library_widget',
    'third_party_settings' => [
      'entity_reference_actions' => [
        'enabled' => TRUE,
      ],
    ],
  ])
    ->save();
  $this
    ->drupalGet('/entity_test/manage/1/edit');
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Delete all media items');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->assertSession()
    ->elementExists('css', '.ui-dialog-buttonpane')
    ->pressButton('Delete');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $this
    ->assertSession()
    ->pageTextContains('Action was successfully applied');
  $this
    ->assertEmpty(Media::load($this->media
    ->id()));
}