Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / views / tests / src / FunctionalJavascript / PaginationAJAXTest.php
index 850c5536f5f222164eb98c6f95299ea071e29a52..de4efd24abdffda4b905f9c7d63a3ead5fb9df64 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;
 use Drupal\views\Tests\ViewTestData;
@@ -12,7 +12,7 @@ use Drupal\views\Tests\ViewTestData;
  *
  * @group views
  */
-class PaginationAJAXTest extends JavascriptTestBase {
+class PaginationAJAXTest extends WebDriverTestBase {
 
   use ContentTypeCreationTrait;
   use NodeCreationTrait;
@@ -86,6 +86,10 @@ class PaginationAJAXTest extends JavascriptTestBase {
     $rows = $page->findAll('css', 'tbody tr');
     $this->assertCount(5, $rows);
     $this->assertContains('Node 6 content', $rows[0]->getHtml());
+    $link = $page->findLink('Go to page 3');
+    // Test that no unwanted parameters are added to the URL.
+    $this->assertEquals('?status=All&type=All&langcode=All&items_per_page=5&order=changed&sort=asc&title=&page=2', $link->getAttribute('href'));
+    $this->assertNoDuplicateAssetsOnPage();
 
     $this->clickLink('Go to page 3');
     $session_assert->assertWaitOnAjaxRequest();
@@ -115,4 +119,17 @@ class PaginationAJAXTest extends JavascriptTestBase {
     $this->assertContains('Node 11 content', $rows[0]->getHtml());
   }
 
+  /**
+   * Assert that assets are not loaded twice on a page.
+   */
+  protected function assertNoDuplicateAssetsOnPage() {
+    /** @var \Behat\Mink\Element\NodeElement[] $scripts */
+    $scripts = $this->getSession()->getPage()->findAll('xpath', '//script');
+    $script_src = [];
+    foreach ($scripts as $script) {
+      $this->assertFalse(in_array($script->getAttribute('src'), $script_src));
+      $script_src[] = $script->getAttribute('src');
+    }
+  }
+
 }