diff -u b/core/modules/views_ui/tests/src/FunctionalJavascript/FilterOptionsTest.php b/core/modules/views_ui/tests/src/FunctionalJavascript/FilterOptionsTest.php --- b/core/modules/views_ui/tests/src/FunctionalJavascript/FilterOptionsTest.php +++ b/core/modules/views_ui/tests/src/FunctionalJavascript/FilterOptionsTest.php @@ -15,7 +15,7 @@ /** * {@inheritdoc} */ - public static $modules = ['node', 'views', 'views_ui']; + public static $modules = ['node', 'views', 'views_ui', 'views_ui_test_field']; /** * {@inheritdoc} @@ -53,17 +53,53 @@ $visible_rows = $this->filterVisibleElements($all_rows); $this->assertTrue(count($visible_rows) == count($all_rows)); - // Populate the options search field with the string 'date'. - $options_search->setValue('date'); + // Populate the options search field and test the title field in search. + $options_search->setValue('FIELD_1_TITLE'); // Wait for the filtering to finish by checking on a field that we know // should now be invisible. $page->waitFor(10, function() use ($page) { - return !$page->findField('name[node_field_data.uid]')->isVisible(); + return !$page->findField('name[views.views_test_field_2]')->isVisible(); + }); + + // Find matching rows based on visibility. + $visible_rows = $this->filterVisibleElements($all_rows); + + // Test that greater than zero options have been returned. + $this->assertTrue(count($visible_rows) > 0); + + // Test that the number of rows returned is less than total rows. + $this->assertTrue(count($visible_rows) < count($all_rows)); + + // Test that the first test field is visible. + $field = $page->findField('name[views.views_test_field_1]'); + $this->assertTrue($field->isVisible()); + $field = $page->findField('name[views.views_test_field_2]'); + $this->assertFalse($field->isVisible()); + + // Reset the search value and validate both fields are visible again. + $options_search->setValue(''); + + // Wait for the filtering to finish. + $page->waitFor(10, function() use ($page) { + return $page->findField('name[views.views_test_field_2]')->isVisible(); + }); + + // Assert both fields are visible again. + $field = $page->findField('name[views.views_test_field_1]'); + $this->assertTrue($field->isVisible()); + $field = $page->findField('name[views.views_test_field_2]'); + $this->assertTrue($field->isVisible()); + + // Now search again but this time use the description. + $options_search->setValue('FIELD_1_DESCRIPTION'); + + // Wait for the filtering to finish. + $page->waitFor(10, function() use ($page) { + return !$page->findField('name[views.views_test_field_2]')->isVisible(); }); // Find matching rows based on visibility. - $all_rows = $page->findAll('css', '.filterable-option'); $visible_rows = $this->filterVisibleElements($all_rows); // Test that greater than zero options have been returned. @@ -72,9 +108,11 @@ // Test that the number of rows returned is less than total rows. $this->assertTrue(count($visible_rows) < count($all_rows)); - // Test that one of the return options is 'Updated date'. - $field = $page->findField('name[users_field_data.changed]'); + // Test that the first test field is visible and the second is not. + $field = $page->findField('name[views.views_test_field_1]'); $this->assertTrue($field->isVisible()); + $field = $page->findField('name[views.views_test_field_2]'); + $this->assertFalse($field->isVisible()); } /** @@ -87,7 +125,7 @@ * Array of visible elements. */ protected function filterVisibleElements($elements) { - $elements = array_filter($elements, function($element) { + $elements = array_filter($elements, function(NodeElement $element) { return $element->isVisible(); }); return $elements; only in patch2: unchanged: --- /dev/null +++ b/core/modules/views_ui/tests/modules/views_ui_test_field/views_ui_test_field.info.yml @@ -0,0 +1,8 @@ +name: 'Views test field' +type: module +description: 'Add custom global field for testing purposes.' +package: Testing +version: VERSION +core: 8.x +dependencies: + - views_ui only in patch2: unchanged: --- /dev/null +++ b/core/modules/views_ui/tests/modules/views_ui_test_field/views_ui_test_field.views.inc @@ -0,0 +1,29 @@ + t('Views test field - FIELD_1_TITLE'), + 'help' => t('Provide test field for testing purposes. - FIELD_1_DESCRIPTION'), + 'field' => array( + 'id' => 'views_test_field_1', + ), + ); + $data['views']['views_test_field_2'] = array( + 'title' => t('Secondary field for testing purposes - FIELD_2_TITLE'), + 'help' => t('Provide a secondary field for testing purposes. - FIELD_2_DESCRIPTION'), + 'field' => array( + 'id' => 'views_test_field_2', + ), + ); + + return $data; +}