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 @@ -24,10 +24,7 @@ parent::setUp(); $admin_user = $this->drupalCreateUser([ - 'administer site configuration', 'administer views', - 'administer nodes', - 'access content overview', ]); $this->drupalLogin($admin_user); } @@ -48,7 +45,7 @@ // Wait for the popup to open and the search field to be available. $options_search = $web_assert->waitForField('override[controls][options_search]'); - // Assert the count is equal before filtering. + // Validate the amount of visible rows equals the total amount of rows. $all_rows = $page->findAll('css', '.filterable-option'); $visible_rows = $this->filterVisibleElements($all_rows); $this->assertTrue(count($visible_rows) == count($all_rows)); @@ -65,11 +62,8 @@ // 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 only the test_field_1 row is visible. + $this->assertEquals(1, count($visible_rows)); // Test that the first test field is visible. $field = $page->findField('name[views.views_test_field_1]'); @@ -79,8 +73,6 @@ // 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(); }); @@ -102,17 +94,36 @@ // 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 only the test_field_1 row is visible. + $this->assertEquals(1, count($visible_rows) > 0); // 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()); + + // Reset the search value and validate both fields are visible again. + $options_search->setValue(''); + $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()); + + // Assert that the label for the input field is not used for the search. + $options_search->setValue('TEST_FIELD_1_LABEL'); + $page->waitFor(10, function() use ($page) { + return !$page->findField('name[views.views_test_field_1]')->isVisible(); + }); + + // Test that no rows are visible. + $visible_rows = $this->filterVisibleElements($all_rows); + $this->assertEquals(0, count($visible_rows)); } /** only in patch2: unchanged: --- /dev/null +++ b/core/modules/views_ui/tests/modules/views_ui_test_field/views_ui_test_field.module @@ -0,0 +1,18 @@ +