public function AjaxBehaviorTest::testAjaxCheckbox in Facets 8
Tests ajax checkbox.
File
- tests/
src/ FunctionalJavascript/ AjaxBehaviorTest.php, line 125
Class
- AjaxBehaviorTest
- Tests for the JS that powers ajax.
Namespace
Drupal\Tests\facets\FunctionalJavascriptCode
public function testAjaxCheckbox() {
// Create facets.
$this
->createFacet('owl');
$this
->createFacet('duck', 'keywords', 'checkbox');
// Go to the views page.
$this
->drupalGet('search-api-test-fulltext');
// Make sure the blocks are shown on the page.
$page = $this
->getSession()
->getPage();
$block_owl = $page
->findById('block-owl-block');
$block_owl
->isVisible();
$block_duck = $page
->findById('block-duck-block');
$block_duck
->isVisible();
$this
->assertSession()
->pageTextContains('Displaying 5 search results');
// Check that the article link exists (and is formatted like a facet) link.
$links = $this
->xpath('//a//span[normalize-space(text())=:label]', [
':label' => 'article',
]);
$this
->assertNotEmpty($links);
// Click the item facet.
$this
->clickLink('item');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->assertSession()
->pageTextContains('Displaying 3 search results');
// Check that the article facet is now gone.
$links = $this
->xpath('//a//span[normalize-space(text())=:label]', [
':label' => 'article',
]);
$this
->assertEmpty($links);
// Click the item facet again, and check that the article facet is back.
$this
->clickLink('item');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->assertSession()
->pageTextContains('Displaying 5 search results');
$links = $this
->xpath('//a//span[normalize-space(text())=:label]', [
':label' => 'article',
]);
$this
->assertNotEmpty($links);
// Check that the strawberry link disappears when filtering on items.
$links = $this
->xpath('//a//span[normalize-space(text())=:label]', [
':label' => 'strawberry',
]);
$this
->assertNotEmpty($links);
$this
->clickLink('item');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$links = $this
->xpath('//a//span[normalize-space(text())=:label]', [
':label' => 'strawberry',
]);
$this
->assertEmpty($links);
$this
->clickLink('item');
$this
->getSession()
->getPage()
->checkField('strawberry');
// Check that the article link exists (and is formatted like a facet) link.
$links = $this
->xpath('//a//span[normalize-space(text())=:label]', [
':label' => 'article',
]);
$this
->assertNotEmpty($links);
// Check that the item link didn't exists.
$links = $this
->xpath('//a//span[normalize-space(text())=:label]', [
':label' => 'item',
]);
$this
->assertEmpty($links);
}