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;
*
* @group views
*/
-class PaginationAJAXTest extends JavascriptTestBase {
+class PaginationAJAXTest extends WebDriverTestBase {
use ContentTypeCreationTrait;
use NodeCreationTrait;
$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();
$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');
+ }
+ }
+
}