Skip to content
Snippets Groups Projects
Select Git revision
  • 5c9c65d2f31831aebf6dac3ce55c2c1f2517caa6
  • 11.x default protected
  • 10.5.x protected
  • 10.6.x protected
  • 11.2.x protected
  • 11.1.x protected
  • 10.4.x protected
  • 11.0.x protected
  • 10.3.x protected
  • 7.x protected
  • 10.2.x protected
  • 10.1.x protected
  • 9.5.x protected
  • 10.0.x protected
  • 9.4.x protected
  • 9.3.x protected
  • 9.2.x protected
  • 9.1.x protected
  • 8.9.x protected
  • 9.0.x protected
  • 8.8.x protected
  • 10.5.2 protected
  • 11.2.3 protected
  • 10.5.1 protected
  • 11.2.2 protected
  • 11.2.1 protected
  • 11.2.0 protected
  • 10.5.0 protected
  • 11.2.0-rc2 protected
  • 10.5.0-rc1 protected
  • 11.2.0-rc1 protected
  • 10.4.8 protected
  • 11.1.8 protected
  • 10.5.0-beta1 protected
  • 11.2.0-beta1 protected
  • 11.2.0-alpha1 protected
  • 10.4.7 protected
  • 11.1.7 protected
  • 10.4.6 protected
  • 11.1.6 protected
  • 10.3.14 protected
41 results

node.module

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    ViewsUiIntegrationTest.php 2.33 KiB
    <?php
    
    namespace Drupal\Tests\media_library\FunctionalJavascript;
    
    /**
     * Tests Media Library's integration with Views UI.
     *
     * @group media_library
     */
    class ViewsUiIntegrationTest extends MediaLibraryTestBase {
    
      /**
       * {@inheritdoc}
       */
      protected static $modules = ['views_ui'];
    
      /**
       * {@inheritdoc}
       */
      protected function setUp(): void {
        parent::setUp();
    
        // Create a few example media items for use in selection.
        $this->createMediaItems([
          'type_one' => [
            'Horse',
            'Bear',
            'Cat',
            'Dog',
          ],
          'type_two' => [
            'Crocodile',
            'Lizard',
            'Snake',
            'Turtle',
          ],
        ]);
    
        $account = $this->drupalCreateUser(['administer views']);
        $this->drupalLogin($account);
      }
    
      /**
       * Tests that the integration with Views works correctly.
       */
      public function testViewsAdmin() {
        $page = $this->getSession()->getPage();
    
        // Assert that the widget can be seen and that there are 8 items.
        $this->drupalGet('/admin/structure/views/view/media_library/edit/widget');
        $this->waitForElementsCount('css', '.js-media-library-item', 8);
    
        // Assert that filtering works in live preview.
        $page->find('css', '.js-media-library-view .view-filters')->fillField('name', 'snake');
        $page->find('css', '.js-media-library-view .view-filters')->pressButton('Apply filters');
        $this->waitForElementsCount('css', '.js-media-library-item', 1);
    
        // Test the same routine but in the view for the table widget.
        $this->drupalGet('/admin/structure/views/view/media_library/edit/widget_table');
        $this->waitForElementsCount('css', '.js-media-library-item', 8);
    
        // Assert that filtering works in live preview.
        $page->find('css', '.js-media-library-view .view-filters')->fillField('name', 'snake');
        $page->find('css', '.js-media-library-view .view-filters')->pressButton('Apply filters');
        $this->waitForElementsCount('css', '.js-media-library-item', 1);
    
        // We cannot test clicking the 'Insert selected' button in either view
        // because we expect an AJAX error, which would always throw an exception
        // on ::tearDown even if we try to catch it here. If there is an API for
        // marking certain elements 'unsuitable for previewing', we could test that
        // here.
        // @see https://www.drupal.org/project/drupal/issues/3060852
      }
    
    }