Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / views / tests / src / FunctionalJavascript / ExposedFilterAJAXTest.php
index 974aa2da424f7701bf1c6db25b377d7c46484b14..c6cbaf5764125328de5e807b31ac581d536f1058 100644 (file)
@@ -2,7 +2,7 @@
 
 namespace Drupal\Tests\views\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\simpletest\ContentTypeCreationTrait;
 use Drupal\simpletest\NodeCreationTrait;
 
@@ -11,7 +11,7 @@ use Drupal\simpletest\NodeCreationTrait;
  *
  * @group views
  */
-class ExposedFilterAJAXTest extends JavascriptTestBase {
+class ExposedFilterAJAXTest extends WebDriverTestBase {
 
   use ContentTypeCreationTrait;
   use NodeCreationTrait;
@@ -19,12 +19,14 @@ class ExposedFilterAJAXTest extends JavascriptTestBase {
   /**
    * {@inheritdoc}
    */
-  public static $modules = ['node', 'views'];
+  public static $modules = ['node', 'views', 'views_test_modal'];
 
   /**
-   * Tests if exposed filtering via AJAX works for the "Content" View.
+   * {@inheritdoc}
    */
-  public function testExposedFiltering() {
+  protected function setUp() {
+    parent::setUp();
+
     // Enable AJAX on the /admin/content View.
     \Drupal::configFactory()->getEditable('views.view.content')
       ->set('display.default.display_options.use_ajax', TRUE)
@@ -40,9 +42,15 @@ class ExposedFilterAJAXTest extends JavascriptTestBase {
       'administer site configuration',
       'access content',
       'access content overview',
+      'edit any page content',
     ]);
     $this->drupalLogin($user);
+  }
 
+  /**
+   * Tests if exposed filtering via AJAX works for the "Content" View.
+   */
+  public function testExposedFiltering() {
     // Visit the View page.
     $this->drupalGet('admin/content');
 
@@ -71,6 +79,16 @@ class ExposedFilterAJAXTest extends JavascriptTestBase {
     $this->assertContains('Page Two', $html);
     $this->assertNotContains('Page One', $html);
 
+    // Submit bulk actions form to ensure that the previous AJAX submit does not
+    // break it.
+    $this->submitForm([
+      'action' => 'node_make_sticky_action',
+      'node_bulk_form[0]' => TRUE,
+    ], t('Apply to selected items'));
+
+    // Verify that the action was performed.
+    $this->assertSession()->pageTextContains('Make content sticky was applied to 1 item.');
+
     // Reset the form.
     $this->submitForm([], t('Reset'));
     $this->assertSession()->assertWaitOnAjaxRequest();
@@ -80,4 +98,52 @@ class ExposedFilterAJAXTest extends JavascriptTestBase {
     $this->assertFalse($session->getPage()->hasButton('Reset'));
   }
 
+  /**
+   * Tests if exposed filtering via AJAX works in a modal.
+   */
+  public function testExposedFiltersInModal() {
+    $this->drupalGet('views-test-modal/modal');
+
+    $assert = $this->assertSession();
+
+    $assert->elementExists('named', ['link', 'Administer content'])->click();
+    $dialog = $assert->waitForElementVisible('css', '.views-test-modal');
+
+    $session = $this->getSession();
+    // Ensure that the Content we're testing for is present.
+    $html = $session->getPage()->getHtml();
+    $this->assertContains('Page One', $html);
+    $this->assertContains('Page Two', $html);
+
+    // Search for "Page One".
+    $session->getPage()->fillField('title', 'Page One');
+    $assert->elementExists('css', '.ui-dialog-buttonpane')->pressButton('Filter');
+    $this->assertSession()->assertWaitOnAjaxRequest();
+
+    // Verify that only the "Page One" Node is present.
+    $html = $session->getPage()->getHtml();
+    $this->assertContains('Page One', $html);
+    $this->assertNotContains('Page Two', $html);
+
+    // Close and re-open the modal.
+    $assert->buttonExists('Close', $dialog)->press();
+    $assert->elementExists('named', ['link', 'Administer content'])->click();
+    $assert->waitForElementVisible('css', '.views-test-modal');
+
+    // Ensure that the Content we're testing for is present.
+    $html = $session->getPage()->getHtml();
+    $this->assertContains('Page One', $html);
+    $this->assertContains('Page Two', $html);
+
+    // Search for "Page One".
+    $session->getPage()->fillField('title', 'Page One');
+    $assert->elementExists('css', '.ui-dialog-buttonpane')->pressButton('Filter');
+    $this->assertSession()->assertWaitOnAjaxRequest();
+
+    // Verify that only the "Page One" Node is present.
+    $html = $session->getPage()->getHtml();
+    $this->assertContains('Page One', $html);
+    $this->assertNotContains('Page Two', $html);
+  }
+
 }