FilterOptionsTest.php in Drupal 10
File
core/modules/views_ui/tests/src/FunctionalJavascript/FilterOptionsTest.php
View source
<?php
namespace Drupal\Tests\views_ui\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
class FilterOptionsTest extends WebDriverTestBase {
protected static $modules = [
'node',
'views',
'views_ui',
'views_ui_test_field',
];
protected $defaultTheme = 'stark';
protected function setUp() : void {
parent::setUp();
$admin_user = $this
->drupalCreateUser([
'administer views',
]);
$this
->drupalLogin($admin_user);
}
public function testFilterOptionsAddFields() {
$this
->drupalGet('admin/structure/views/view/content');
$session = $this
->getSession();
$web_assert = $this
->assertSession();
$page = $session
->getPage();
$page
->clickLink('views-add-field');
$options_search = $web_assert
->waitForField('override[controls][options_search]');
$this
->assertTrue($page
->findField('name[views.views_test_field_1]')
->isVisible());
$this
->assertTrue($page
->findField('name[views.views_test_field_2]')
->isVisible());
$options_search
->setValue('FIELD_1_TITLE');
$page
->waitFor(10, function () use ($page) {
return !$page
->findField('name[views.views_test_field_2]')
->isVisible();
});
$this
->assertTrue($page
->findField('name[views.views_test_field_1]')
->isVisible());
$this
->assertFalse($page
->findField('name[views.views_test_field_2]')
->isVisible());
$options_search
->setValue('FIELD_2_DESCRIPTION');
$page
->waitFor(10, function () use ($page) {
return !$page
->findField('name[views.views_test_field_1]')
->isVisible();
});
$this
->assertTrue($page
->findField('name[views.views_test_field_2]')
->isVisible());
$this
->assertFalse($page
->findField('name[views.views_test_field_1]')
->isVisible());
$options_search
->setValue('FIELD_1_LABEL');
$page
->waitFor(10, function () use ($page) {
return !$page
->findField('name[views.views_test_field_2]')
->isVisible();
});
$this
->assertFalse($page
->findField('name[views.views_test_field_2]')
->isVisible());
$this
->assertFalse($page
->findField('name[views.views_test_field_1]')
->isVisible());
}
}