WebformFilterJavaScriptTest.php in Webform 8.5
File
tests/src/FunctionalJavascript/WebformFilterJavaScriptTest.php
View source
<?php
namespace Drupal\Tests\webform\FunctionalJavascript;
class WebformFilterJavaScriptTest extends WebformWebDriverTestBase {
public function testFilter() {
\Drupal::service('theme_installer')
->install([
'seven',
]);
\Drupal::configFactory()
->getEditable('system.theme')
->set('admin', 'seven')
->save();
$session = $this
->getSession();
$page = $session
->getPage();
$assert_session = $this
->assertSession();
$addons_manager = \Drupal::service('webform.addons_manager');
$this
->drupalLogin($this->rootUser);
$this
->drupalGet('/admin/structure/webform/addons');
$assert_session
->fieldExists('text');
$assert_session
->waitForElementVisible('css', '.webform-addons-summary');
$assert_session
->waitForText(count($addons_manager
->getProjects()) . ' add-ons');
$this
->assertTrue($page
->findLink('Address')
->isVisible());
$this
->assertFalse($page
->find('css', '.webform-addons-no-results')
->isVisible());
$this
->assertFalse($page
->find('css', '.webform-form-filter-reset')
->isVisible());
$session
->executeScript("jQuery(':input[name=\"text\"]').val('xxx').keyup()");
$assert_session
->waitForText('0 add-ons');
$this
->assertFalse($page
->findLink('Address')
->isVisible());
$this
->assertTrue($page
->find('css', '.webform-addons-no-results')
->isVisible());
$this
->assertTrue($page
->find('css', '.webform-form-filter-reset')
->isVisible());
$session
->executeScript("jQuery('.webform-form-filter-reset').click()");
$assert_session
->waitForElementVisible('css', '.webform-addons-summary');
$assert_session
->waitForText(count($addons_manager
->getProjects()) . ' add-ons');
$this
->assertTrue($page
->findLink('Address')
->isVisible());
$this
->assertFalse($page
->find('css', '.webform-addons-no-results')
->isVisible());
$this
->assertFalse($page
->find('css', '.webform-form-filter-reset')
->isVisible());
}
}