You are here

public function CkEditorMediaBrowserTest::testExposedFilters in Lightning Media 8.2

Tests exposed filters in the media browser.

File

tests/src/ExistingSiteJavascript/CkEditorMediaBrowserTest.php, line 83

Class

CkEditorMediaBrowserTest
@group lightning @group lightning_media

Namespace

Drupal\Tests\lightning_media\ExistingSiteJavascript

Code

public function testExposedFilters() {
  $this
    ->visit('/node/add/page');
  $this
    ->open();
  $this
    ->getSession()
    ->switchToIFrame('entity_browser_iframe_media_browser');

  // All items should be visible.
  $this
    ->assertCount(3, $this
    ->getItems());

  // Try filtering by media type.
  $this->assert
    ->fieldExists('Type')
    ->selectOption('Image');
  $this
    ->applyFilters();
  $this
    ->assertEmpty($this
    ->getItems());

  // Clear the type filter.
  $this->assert
    ->fieldExists('Type')
    ->selectOption('- Any -');
  $this
    ->applyFilters();
  $this
    ->assertCount(3, $this
    ->getItems());

  // Try filtering by keywords.
  $this->assert
    ->fieldExists('Keywords')
    ->setValue('Code Wisdom 1');
  $this
    ->applyFilters();
  $this
    ->assertCount(1, $this
    ->getItems());

  // Clear the keyword filter.
  $this->assert
    ->fieldExists('Keywords')
    ->setValue('');
  $this
    ->applyFilters();
  $this
    ->assertCount(3, $this
    ->getItems());
}