From ff7bfe3ee6bb60cf652be1c06ba557b37faa0960 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Tue, 13 Feb 2024 19:32:06 +0100 Subject: [PATCH] EWPP-3953: Fix tests. --- .../ListPageLinkDisplayPluginTest.php | 46 ++-- .../ListPageLinkSourcePluginTest.php | 8 + .../OpenVocabulariesFiltersTest.php | 114 +++++----- .../ListPagePluginFormTestBase.php | 57 +++-- .../ListPagesExposedFiltersTest.php | 42 ++-- .../ListPagesFiltersTest.php | 209 +++++++++--------- .../ListPagesPresetFiltersTest.php | 88 ++++---- .../ListPagesSortTest.php | 88 +++++--- 8 files changed, 332 insertions(+), 320 deletions(-) diff --git a/modules/oe_list_pages_link_list_displays/tests/src/FunctionalJavascript/ListPageLinkDisplayPluginTest.php b/modules/oe_list_pages_link_list_displays/tests/src/FunctionalJavascript/ListPageLinkDisplayPluginTest.php index e63592d1..a49b5381 100644 --- a/modules/oe_list_pages_link_list_displays/tests/src/FunctionalJavascript/ListPageLinkDisplayPluginTest.php +++ b/modules/oe_list_pages_link_list_displays/tests/src/FunctionalJavascript/ListPageLinkDisplayPluginTest.php @@ -77,9 +77,9 @@ public function testListPageLinkListDisplayForm(): void { $page = $this->getSession()->getPage(); $page->fillField('Title', 'List page for ct1'); - $page->selectFieldOption('Source bundle', 'Content type one'); - $this->assertSession()->assertWaitOnAjaxRequest(); - $display = $this->assertSession()->selectExists('Display'); + $assert_session = $this->assertSession(); + $this->assertTrue($assert_session->optionExists('Source bundle', 'Content type one')->isSelected()); + $display = $assert_session->selectExists('Display'); $this->assertEquals('required', $display->getAttribute('required')); $this->assertFieldSelectOptions('Display', [ 'same_configuration_display_one', @@ -94,8 +94,8 @@ public function testListPageLinkListDisplayForm(): void { // Pick a display with no configuration. $page->selectFieldOption('Display', 'Title'); - $this->assertSession()->assertWaitOnAjaxRequest(); - $this->assertSession()->pageTextContains('This plugin does not have any configuration options.'); + $assert_session->assertWaitOnAjaxRequest(); + $assert_session->pageTextContains('This plugin does not have any configuration options.'); $page->pressButton('Save'); // Assert we see the results as just titles. @@ -116,18 +116,18 @@ public function testListPageLinkListDisplayForm(): void { $this->clickLink('List Page'); $this->assertEquals('title', $page->findField('Display')->find('css', 'option[selected="selected"]')->getValue()); $page->selectFieldOption('Display', 'Titles with optional link'); - $this->assertSession()->assertWaitOnAjaxRequest(); - $this->assertSession()->pageTextNotContains('This plugin does not have any configuration options.'); + $assert_session->assertWaitOnAjaxRequest(); + $assert_session->pageTextNotContains('This plugin does not have any configuration options.'); // By default, the Link checkbox is checked. $checkbox = $page->find('css', '.form-item-emr-plugins-oe-list-page-wrapper-display-plugin-configuration-wrapper-test-configurable-title-link input'); $this->assertTrue($checkbox->isChecked()); // Switch again to another plugin for testing. $page->selectFieldOption('Display', 'Same configuration display one.'); - $this->assertSession()->assertWaitOnAjaxRequest(); - $this->assertSession()->fieldExists('The value'); + $assert_session->assertWaitOnAjaxRequest(); + $assert_session->fieldExists('The value'); // Switch back and save. $page->selectFieldOption('Display', 'Titles with optional link'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert_session->assertWaitOnAjaxRequest(); $page->pressButton('Save'); // We should see the titles in the same way: linked. $links = $page->findAll('css', '.field--name-extra-field-oe-list-page-resultsnodeoe-list-page ul li a'); @@ -221,17 +221,16 @@ public function testBackendSortWithDisplayPlugins(): void { $this->goToListPageConfiguration(); // Select node. - $this->getSession()->getPage()->selectFieldOption('Source entity type', 'node'); - $this->assertSession()->assertWaitOnAjaxRequest(); - $this->getSession()->getPage()->selectFieldOption('Source bundle', 'content_type_one'); - $this->assertSession()->assertWaitOnAjaxRequest(); - $this->assertSession()->selectExists('Sort'); - $this->assertTrue($this->assertSession()->optionExists('Sort', 'Default')->isSelected()); + $assert_session = $this->assertSession(); + $this->assertTrue($assert_session->optionExists('Source entity type', 'node')->isSelected()); + $this->assertTrue($assert_session->optionExists('Source bundle', 'content_type_one')->isSelected()); + $assert_session->selectExists('Sort'); + $this->assertTrue($assert_session->optionExists('Sort', 'Default')->isSelected()); $this->getSession()->getPage()->selectFieldOption('Display', 'Title'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert_session->assertWaitOnAjaxRequest(); $this->getSession()->getPage()->fillField('Title', 'Node title'); $this->getSession()->getPage()->pressButton('Save'); - $this->assertSession()->pageTextContains('List page Node title has been created.'); + $assert_session->pageTextContains('List page Node title has been created.'); // The sorting is by the default sort. $this->assertResultsAreInCorrectOrder([ 'First by created', @@ -284,15 +283,14 @@ public function testPagerOnListPageWithDisplays(): void { $this->goToListPageConfiguration(); // Select node. - $this->getSession()->getPage()->selectFieldOption('Source entity type', 'node'); - $this->assertSession()->assertWaitOnAjaxRequest(); - $this->getSession()->getPage()->selectFieldOption('Source bundle', 'content_type_one'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert_session = $this->assertSession(); + $this->assertTrue($assert_session->optionExists('Source entity type', 'node')->isSelected()); + $this->assertTrue($assert_session->optionExists('Source bundle', 'content_type_one')->isSelected()); $this->getSession()->getPage()->selectFieldOption('Display', 'Title'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert_session->assertWaitOnAjaxRequest(); $this->getSession()->getPage()->fillField('Title', 'Node title'); $this->getSession()->getPage()->pressButton('Save'); - $this->assertSession()->pageTextContains('List page Node title has been created.'); + $assert_session->pageTextContains('List page Node title has been created.'); // The sorting is by the default sort. $first_ten = array_splice($expected_order, 0, 10); diff --git a/modules/oe_list_pages_link_list_source/tests/src/FunctionalJavascript/ListPageLinkSourcePluginTest.php b/modules/oe_list_pages_link_list_source/tests/src/FunctionalJavascript/ListPageLinkSourcePluginTest.php index 23dbaaa6..98806606 100644 --- a/modules/oe_list_pages_link_list_source/tests/src/FunctionalJavascript/ListPageLinkSourcePluginTest.php +++ b/modules/oe_list_pages_link_list_source/tests/src/FunctionalJavascript/ListPageLinkSourcePluginTest.php @@ -123,6 +123,14 @@ public function testListPagePresetFilterValidations(): void { $this->drupalLogin($admin); $this->goToListPageConfiguration(); + + $assert_session = $this->assertSession(); + $page = $this->getSession()->getPage(); + $this->assertTrue($assert_session->optionExists('Link source', 'List pages')->isSelected()); + $page->selectFieldOption('Source entity type', 'Content'); + $assert_session->assertWaitOnAjaxRequest(); + $page->selectFieldOption('Source bundle', 'Content type one'); + $assert_session->assertWaitOnAjaxRequest(); $this->assertListPagePresetFilterValidations('configuration[0][link_source][plugin_configuration_wrapper][list_pages][list_page_configuration][wrapper][default_filter_values]'); } diff --git a/modules/oe_list_pages_open_vocabularies/tests/src/FunctionalJavascript/OpenVocabulariesFiltersTest.php b/modules/oe_list_pages_open_vocabularies/tests/src/FunctionalJavascript/OpenVocabulariesFiltersTest.php index ab433966..12b0ff25 100644 --- a/modules/oe_list_pages_open_vocabularies/tests/src/FunctionalJavascript/OpenVocabulariesFiltersTest.php +++ b/modules/oe_list_pages_open_vocabularies/tests/src/FunctionalJavascript/OpenVocabulariesFiltersTest.php @@ -191,17 +191,17 @@ public function testListPagePluginFiltersFormConfiguration(): void { $this->drupalLogin($admin); $this->goToListPageConfiguration(); $page = $this->getSession()->getPage(); - $page->selectFieldOption('Source bundle', 'Content type one'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert = $this->assertSession(); + $this->assertTrue($assert->optionExists('Source bundle', 'Content type one')->isSelected()); $page->checkField('Override default exposed filters'); // By default, the CT exposed filters are Body and Status. - $this->assertSession()->checkboxChecked('Published'); - $this->assertSession()->checkboxChecked('Body'); - $this->assertSession()->checkboxNotChecked('Select one'); - $this->assertSession()->checkboxNotChecked('Created'); - $this->assertSession()->checkboxNotChecked($this->firstAssociation->label()); - $this->assertSession()->checkboxNotChecked($this->secondAssociation->label()); + $assert->checkboxChecked('Published'); + $assert->checkboxChecked('Body'); + $assert->checkboxNotChecked('Select one'); + $assert->checkboxNotChecked('Created'); + $assert->checkboxNotChecked($this->firstAssociation->label()); + $assert->checkboxNotChecked($this->secondAssociation->label()); // Expose the associations fields. $page->checkField($this->firstAssociation->label()); @@ -209,8 +209,8 @@ public function testListPagePluginFiltersFormConfiguration(): void { $page->fillField('Title', 'Node title'); $page->pressButton('Save'); - $this->assertSession()->pageTextContains('one yellow fruit'); - $this->assertSession()->pageTextContains('a green fruit'); + $assert->pageTextContains('one yellow fruit'); + $assert->pageTextContains('a green fruit'); $actual_bundles = $this->getSelectOptions($this->firstAssociation->label()); $expected_bundles = [ '1' => 'yellow color', @@ -228,29 +228,29 @@ public function testListPagePluginFiltersFormConfiguration(): void { // Search on the first association field. $this->getSession()->getPage()->selectFieldOption($this->firstAssociation->label(), 'yellow color'); $this->getSession()->getPage()->pressButton('Search'); - $this->assertSession()->pageTextContains('one yellow fruit'); - $this->assertSession()->pageTextNotContains('a green fruit'); - $this->assertSession()->pageTextNotContains('Leaf'); + $assert->pageTextContains('one yellow fruit'); + $assert->pageTextNotContains('a green fruit'); + $assert->pageTextNotContains('Leaf'); // Reset search. $this->getSession()->getPage()->pressButton('Clear filters'); - $this->assertSession()->pageTextContains('one yellow fruit'); - $this->assertSession()->pageTextContains('a green fruit'); - $this->assertSession()->pageTextContains('Leaf'); + $assert->pageTextContains('one yellow fruit'); + $assert->pageTextContains('a green fruit'); + $assert->pageTextContains('Leaf'); // Search on the other value of the first association. $this->getSession()->getPage()->selectFieldOption($this->firstAssociation->label(), 'green color'); $this->getSession()->getPage()->pressButton('Search'); - $this->assertSession()->pageTextNotContains('one yellow fruit'); - $this->assertSession()->pageTextContains('a green fruit'); - $this->assertSession()->pageTextContains('Leaf'); + $assert->pageTextNotContains('one yellow fruit'); + $assert->pageTextContains('a green fruit'); + $assert->pageTextContains('Leaf'); // Search on the second association. $this->getSession()->getPage()->selectFieldOption($this->secondAssociation->label(), 'yellow color'); $this->getSession()->getPage()->pressButton('Search'); - $this->assertSession()->pageTextNotContains('one yellow fruit'); - $this->assertSession()->pageTextNotContains('a green fruit'); - $this->assertSession()->pageTextContains('Leaf'); + $assert->pageTextNotContains('one yellow fruit'); + $assert->pageTextNotContains('a green fruit'); + $assert->pageTextContains('Leaf'); // Add default values for the first association. $node = $this->drupalGetNodeByTitle('Node title'); @@ -258,12 +258,11 @@ public function testListPagePluginFiltersFormConfiguration(): void { $this->clickLink('List Page'); $page->selectFieldOption('Add default value for', $this->firstAssociation->label()); - $this->assertSession()->assertWaitOnAjaxRequest(); - $assert = $this->assertSession(); + $assert->assertWaitOnAjaxRequest(); $assert->pageTextContains('Set default value for ' . $this->firstAssociation->label()); // Test required fields. $page->pressButton('Set default value'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert->assertWaitOnAjaxRequest(); $assert->pageTextContains($this->firstAssociation->label() . ' field is required.'); $field_id = 'open_vocabularies_tags_vocabulary_tags_vocabulary_node_content_type_one_field_open_vocabularies'; @@ -272,7 +271,7 @@ public function testListPagePluginFiltersFormConfiguration(): void { $filter_selector = $default_value_name_prefix . '[wrapper][edit][' . $association_filter_id . ']'; $this->getSession()->getPage()->fillField($filter_selector . '[' . $field_id . '][0][entity_reference]', 'green color (2)'); $page->pressButton('Set default value'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert->assertWaitOnAjaxRequest(); $expected_set_filters = [ [ 'key' => $this->firstAssociation->label(), @@ -283,9 +282,9 @@ public function testListPagePluginFiltersFormConfiguration(): void { $page->pressButton('Save'); // Results are correct and facet correctly filled. - $this->assertSession()->pageTextNotContains('one yellow fruit'); - $this->assertSession()->pageTextContains('a green fruit'); - $this->assertSession()->pageTextContains('Leaf'); + $assert->pageTextNotContains('one yellow fruit'); + $assert->pageTextContains('a green fruit'); + $assert->pageTextContains('Leaf'); $actual_bundles = $this->getSelectOptions($this->firstAssociation->label()); $expected_bundles = [ '2' => 'green color', @@ -298,12 +297,11 @@ public function testListPagePluginFiltersFormConfiguration(): void { // Add another default value, for the second association. $page->selectFieldOption('Add default value for', $this->secondAssociation->label()); - $this->assertSession()->assertWaitOnAjaxRequest(); - $assert = $this->assertSession(); + $assert->assertWaitOnAjaxRequest(); $assert->pageTextContains('Set default value for ' . $this->secondAssociation->label()); // Test required fields. $page->pressButton('Set default value'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert->assertWaitOnAjaxRequest(); $assert->pageTextContains($this->secondAssociation->label() . ' field is required.'); $field_id = 'open_vocabularies_tags_vocabulary_two_tags_vocabulary_two_node_content_type_one_field_open_vocabularies'; @@ -312,7 +310,7 @@ public function testListPagePluginFiltersFormConfiguration(): void { $filter_selector = $default_value_name_prefix . '[wrapper][edit][' . $association_filter_id . ']'; $this->getSession()->getPage()->fillField($filter_selector . '[' . $field_id . '][0][entity_reference]', 'yellow color (1)'); $page->pressButton('Set default value'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert->assertWaitOnAjaxRequest(); $expected_set_filters = [ [ 'key' => $this->firstAssociation->label(), @@ -327,9 +325,9 @@ public function testListPagePluginFiltersFormConfiguration(): void { $page->pressButton('Save'); // Results are correct and facet correctly filled. - $this->assertSession()->pageTextNotContains('one yellow fruit'); - $this->assertSession()->pageTextNotContains('a green fruit'); - $this->assertSession()->pageTextContains('Leaf'); + $assert->pageTextNotContains('one yellow fruit'); + $assert->pageTextNotContains('a green fruit'); + $assert->pageTextContains('Leaf'); $actual_bundles = $this->getSelectOptions($this->firstAssociation->label()); $expected_bundles = [ '2' => 'green color', @@ -347,19 +345,19 @@ public function testListPagePluginFiltersFormConfiguration(): void { $this->secondAssociation->delete(); $node = $this->drupalGetNodeByTitle('Node title'); $this->drupalGet($node->toUrl()); - $this->assertSession()->pageTextContains('one yellow fruit'); - $this->assertSession()->pageTextContains('a green fruit'); - $this->assertSession()->pageTextContains('Leaf'); + $assert->pageTextContains('one yellow fruit'); + $assert->pageTextContains('a green fruit'); + $assert->pageTextContains('Leaf'); // Can be edited again. $this->drupalGet($node->toUrl('edit-form')); $this->clickLink('List Page'); - $this->assertSession()->fieldNotExists('Tags association'); - $this->assertSession()->fieldNotExists('Tags association two'); + $assert->fieldNotExists('Tags association'); + $assert->fieldNotExists('Tags association two'); $page->pressButton('Save'); - $this->assertSession()->pageTextContains('one yellow fruit'); - $this->assertSession()->pageTextContains('a green fruit'); - $this->assertSession()->pageTextContains('Leaf'); + $assert->pageTextContains('one yellow fruit'); + $assert->pageTextContains('a green fruit'); + $assert->pageTextContains('Leaf'); } /** @@ -369,31 +367,29 @@ public function testListPageContextualFilters(): void { $admin = $this->createUser([], NULL, TRUE); $this->drupalLogin($admin); $this->drupalGet('link_list/add/dynamic'); - $this->getSession()->getPage()->selectFieldOption('Link source', 'List page'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert_session = $this->assertSession(); + $this->assertTrue($assert_session->optionExists('Link source', 'List pages')->isSelected()); $contextual_filter_name_prefix = 'configuration[0][link_source][plugin_configuration_wrapper][list_pages][list_page_configuration][wrapper][contextual_filters]'; $this->getSession()->getPage()->fillField('Administrative title', 'List page plugin test'); $this->getSession()->getPage()->fillField('Title', 'List page list OpenVocabularies'); $this->getSession()->getPage()->selectFieldOption('Link display', 'Title'); - $this->assertSession()->assertWaitOnAjaxRequest(); $page = $this->getSession()->getPage(); - $assert = $this->assertSession(); $page->selectFieldOption('Source entity type', 'Content'); - $assert->assertWaitOnAjaxRequest(); + $assert_session->assertWaitOnAjaxRequest(); $page->selectFieldOption('Source bundle', 'Content type one'); - $assert->assertWaitOnAjaxRequest(); + $assert_session->assertWaitOnAjaxRequest(); // Set a contextual filter for the association. $field_id = 'open_vocabularies_tags_vocabulary_tags_vocabulary_node_content_type_one_field_open_vocabularies'; $association_filter_id = FilterConfigurationFormBuilderBase::generateFilterId($field_id); $expected_contextual_filters = []; $page->selectFieldOption('Add contextual value for', $this->firstAssociation->label()); - $this->assertSession()->assertWaitOnAjaxRequest(); - $assert->pageTextContains('Set contextual options for ' . $this->firstAssociation->label()); + $assert_session->assertWaitOnAjaxRequest(); + $assert_session->pageTextContains('Set contextual options for ' . $this->firstAssociation->label()); $filter_selector = $contextual_filter_name_prefix . '[wrapper][edit][' . $association_filter_id . ']'; $this->getSession()->getPage()->selectFieldOption($filter_selector . '[operator]', 'and'); $page->pressButton('Set options'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert_session->assertWaitOnAjaxRequest(); $expected_contextual_filters['reference'] = [ 'key' => $this->firstAssociation->label(), 'value' => 'All of', @@ -408,14 +404,14 @@ public function testListPageContextualFilters(): void { // Nodes from content type one with same terms appear. $node = $this->drupalGetNodeByTitle('Sun'); $this->drupalGet($node->toUrl()); - $this->assertSession()->pageTextContains('one yellow fruit'); - $this->assertSession()->pageTextNotContains('a green fruit'); - $this->assertSession()->pageTextNotContains('Leaf'); + $assert_session->pageTextContains('one yellow fruit'); + $assert_session->pageTextNotContains('a green fruit'); + $assert_session->pageTextNotContains('Leaf'); $node = $this->drupalGetNodeByTitle('Grass'); $this->drupalGet($node->toUrl()); - $this->assertSession()->pageTextContains('a green fruit'); - $this->assertSession()->pageTextContains('Leaf'); - $this->assertSession()->pageTextNotContains('one yellow fruit'); + $assert_session->pageTextContains('a green fruit'); + $assert_session->pageTextContains('Leaf'); + $assert_session->pageTextNotContains('one yellow fruit'); } /** diff --git a/tests/src/FunctionalJavascript/ListPagePluginFormTestBase.php b/tests/src/FunctionalJavascript/ListPagePluginFormTestBase.php index bc11d259..a3f3d9bb 100644 --- a/tests/src/FunctionalJavascript/ListPagePluginFormTestBase.php +++ b/tests/src/FunctionalJavascript/ListPagePluginFormTestBase.php @@ -42,14 +42,11 @@ protected function bootEnvironment(): void { * The prefix of the preset filter element names. */ public function assertListPagePresetFilterValidations(string $default_value_name_prefix): void { - $this->getSession()->getPage()->selectFieldOption('Source entity type', 'node'); - $this->assertSession()->assertWaitOnAjaxRequest(); - - $this->getSession()->getPage()->selectFieldOption('Source bundle', 'content_type_one'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert = $this->assertSession(); + $this->assertTrue($assert->optionExists('Source entity type', 'node')->isSelected()); + $this->assertTrue($assert->optionExists('Source bundle', 'content_type_one')->isSelected()); $page = $this->getSession()->getPage(); - $assert = $this->assertSession(); // Filter ids. $body_filter_id = DefaultFilterConfigurationBuilder::generateFilterId('body'); @@ -57,29 +54,29 @@ public function assertListPagePresetFilterValidations(string $default_value_name // Do not fill in the title and assert the validation limiting works. $page->selectFieldOption('Add default value for', 'Body'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert->assertWaitOnAjaxRequest(); $page->pressButton('Set default value'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert->assertWaitOnAjaxRequest(); $assert->pageTextContains('Body field is required.'); $assert->pageTextNotContains('Title field is required.'); // Cancel and start over. $page->pressButton('Cancel'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert->assertWaitOnAjaxRequest(); $assert->pageTextNotContains('Title field is required.'); $assert->pageTextNotContains('Body field is required.'); $page->fillField('Title', 'List page for ct1'); // Set preset filter for Body and cancel. $page->selectFieldOption('Add default value for', 'Body'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert->assertWaitOnAjaxRequest(); $assert->pageTextContains('Set default value for Body'); $page = $this->getSession()->getPage(); $filter_selector = $default_value_name_prefix . '[wrapper][edit][' . $body_filter_id . '][body]'; $page->fillField($filter_selector, 'cherry'); $page->pressButton('Cancel'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert->assertWaitOnAjaxRequest(); $assert->pageTextNotContains('Title field is required.'); $assert->pageTextNotContains('Body field is required.'); $this->assertDefaultValueForFilters([ @@ -91,24 +88,23 @@ public function assertListPagePresetFilterValidations(string $default_value_name // Set preset filter for Created. $page->selectFieldOption('Add default value for', 'Created'); - $this->assertSession()->assertWaitOnAjaxRequest(); - $assert = $this->assertSession(); + $assert->assertWaitOnAjaxRequest(); $assert->pageTextContains('Set default value for Created'); $filter_selector = $default_value_name_prefix . '[wrapper][edit][' . $created_filter_id . ']'; // Assert validations. $page->pressButton('Set default value'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert->assertWaitOnAjaxRequest(); $assert->pageTextContains('Created field is required.'); - $assert->pageTextContains('The date is required. Please enter a date in the format'); + $assert->pageTextContains('The date is required.'); $this->getSession()->getPage()->selectFieldOption($filter_selector . '[created_op]', 'In between'); $page->pressButton('Set default value'); - $this->assertSession()->assertWaitOnAjaxRequest(); - $assert->pageTextContains('The date is required. Please enter a date in the format'); + $assert->assertWaitOnAjaxRequest(); + $assert->pageTextContains('The date is required.'); $assert->pageTextContains('The second date is required.'); $this->getSession()->getPage()->fillField($filter_selector . '[created_first_date_wrapper][created_first_date][date]', '10/19/2019'); $this->getSession()->getPage()->fillField($filter_selector . '[created_second_date_wrapper][created_second_date][date]', '10/17/2019'); $page->pressButton('Set default value'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert->assertWaitOnAjaxRequest(); $assert->pageTextContains('The second date cannot be before the first date.'); } @@ -126,8 +122,8 @@ protected function assertListPageEntityTypeSelection(): void { 'taxonomy_term' => 'Taxonomy term', ]; $this->assertEquals($expected_entity_types, $actual_entity_types); - $this->getSession()->getPage()->selectFieldOption('Source entity type', 'node'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert = $this->assertSession(); + $this->assertTrue($assert->optionExists('Source entity type', 'node')->isSelected()); $actual_bundles = $this->getSelectOptions('Source bundle'); $expected_bundles = [ @@ -139,7 +135,7 @@ protected function assertListPageEntityTypeSelection(): void { // Switch to the taxonomy term and assert that we have different bundles. $this->getSession()->getPage()->selectFieldOption('Source entity type', 'taxonomy_term'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert->assertWaitOnAjaxRequest(); $actual_bundles = $this->getSelectOptions('Source bundle'); $expected_bundles = [ 'vocabulary_one' => 'Vocabulary one', @@ -152,11 +148,11 @@ protected function assertListPageEntityTypeSelection(): void { // Select a bundle, then change back to Node. Wait for all the Ajax // requests to complete to ensure the callbacks work work. $this->getSession()->getPage()->selectFieldOption('Source bundle', 'vocabulary_one'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert->assertWaitOnAjaxRequest(); $this->getSession()->getPage()->selectFieldOption('Source entity type', 'node'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert->assertWaitOnAjaxRequest(); $this->getSession()->getPage()->selectFieldOption('Source bundle', 'content_type_one'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert->assertWaitOnAjaxRequest(); // Set state values to trigger the test event subscriber and make some // limitations. @@ -178,8 +174,7 @@ protected function assertListPageEntityTypeSelection(): void { 'taxonomy_term' => 'Taxonomy term', ]; $this->assertEquals($expected_entity_types, $actual_entity_types); - $this->getSession()->getPage()->selectFieldOption('Source entity type', 'node'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $this->assertTrue($assert->optionExists('Source entity type', 'node')->isSelected()); $actual_bundles = $this->getSelectOptions('Source bundle'); $expected_bundles = [ 'content_type_one' => 'Content type one', @@ -187,7 +182,7 @@ protected function assertListPageEntityTypeSelection(): void { ]; $this->assertEquals($expected_bundles, $actual_bundles); $this->getSession()->getPage()->selectFieldOption('Source entity type', 'taxonomy_term'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert->assertWaitOnAjaxRequest(); $actual_bundles = $this->getSelectOptions('Source bundle'); $expected_bundles = [ 'vocabulary_one' => 'Vocabulary one', @@ -195,7 +190,7 @@ protected function assertListPageEntityTypeSelection(): void { ]; $this->assertEquals($expected_bundles, $actual_bundles); $this->getSession()->getPage()->selectFieldOption('Source bundle', 'vocabulary_one'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert->assertWaitOnAjaxRequest(); } /** @@ -342,10 +337,8 @@ public function assertListPagePresetFilters(string $default_value_name_prefix, s $page = $this->getSession()->getPage(); $assert = $this->assertSession(); - $page->selectFieldOption('Source entity type', 'Content'); - $assert->assertWaitOnAjaxRequest(); - $page->selectFieldOption('Source bundle', 'Content type one'); - $assert->assertWaitOnAjaxRequest(); + $this->assertTrue($assert->optionExists('Source entity type', 'node')->isSelected()); + $this->assertTrue($assert->optionExists('Source bundle', 'content_type_one')->isSelected()); $expected_set_filters = []; diff --git a/tests/src/FunctionalJavascript/ListPagesExposedFiltersTest.php b/tests/src/FunctionalJavascript/ListPagesExposedFiltersTest.php index 67a3b6aa..7c97ea17 100755 --- a/tests/src/FunctionalJavascript/ListPagesExposedFiltersTest.php +++ b/tests/src/FunctionalJavascript/ListPagesExposedFiltersTest.php @@ -63,7 +63,8 @@ public function testListPagePluginFiltersFormConfiguration(): void { ]; $this->assertEquals($expected_entity_types, $actual_entity_types); // By default, Node is selected if there are no stored values. - $this->assertTrue($this->assertSession()->optionExists('Source entity type', 'Content')->isSelected()); + $assert_session = $this->assertSession(); + $this->assertTrue($assert_session->optionExists('Source entity type', 'Content')->isSelected()); $actual_bundles = $this->getSelectOptions('Source bundle'); $expected_bundles = [ @@ -73,14 +74,13 @@ public function testListPagePluginFiltersFormConfiguration(): void { ]; $this->assertEquals($expected_bundles, $actual_bundles); $page = $this->getSession()->getPage(); - $page->selectFieldOption('Source bundle', 'Content type one'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $this->assertTrue($assert_session->optionExists('Source bundle', 'Content type one')->isSelected()); $page->checkField('Override default exposed filters'); // By default, the CT exposed filters are Body and Status. - $this->assertSession()->checkboxChecked('Published'); - $this->assertSession()->checkboxChecked('Body'); - $this->assertSession()->checkboxNotChecked('Select one'); - $this->assertSession()->checkboxNotChecked('Created'); + $assert_session->checkboxChecked('Published'); + $assert_session->checkboxChecked('Body'); + $assert_session->checkboxNotChecked('Select one'); + $assert_session->checkboxNotChecked('Created'); $page->uncheckField('Body'); $page->checkField('Select one'); $page->fillField('Title', 'Node title'); @@ -103,7 +103,7 @@ public function testListPagePluginFiltersFormConfiguration(): void { $this->drupalGet($node->toUrl('edit-form')); $this->clickLink('List Page'); $page->selectFieldOption('Source bundle', 'Content type two'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert_session->assertWaitOnAjaxRequest(); $page->checkField('Select two'); $page->pressButton('Save'); @@ -121,8 +121,8 @@ public function testListPagePluginFiltersFormConfiguration(): void { $this->drupalGet($node->toUrl('edit-form')); $this->clickLink('List Page'); - $this->assertSession()->checkboxChecked('Select two'); - $this->assertSession()->checkboxNotChecked('Facet for status'); + $assert_session->checkboxChecked('Select two'); + $assert_session->checkboxNotChecked('Facet for status'); // Unselect all the exposed filters and assert that we have overridden // the list page to not show any exposed filters. @@ -165,21 +165,21 @@ public function testListPagePluginFiltersFormConfiguration(): void { // Disable the overridden exposed filters to return back to the defaults. $this->drupalGet($node->toUrl('edit-form')); $this->clickLink('List Page'); - $this->assertSession()->checkboxChecked('Override default exposed filters'); - $this->assertSession()->checkboxChecked('Select two'); - $this->assertSession()->checkboxChecked('Facet for status'); + $assert_session->checkboxChecked('Override default exposed filters'); + $assert_session->checkboxChecked('Select two'); + $assert_session->checkboxChecked('Facet for status'); // Switch to other ct and check overridden is maintained. $page->selectFieldOption('Source bundle', 'Content type one'); - $this->assertSession()->assertWaitOnAjaxRequest(); - $this->assertSession()->checkboxChecked('Published'); - $this->assertSession()->checkboxChecked('Body'); - $this->assertSession()->checkboxNotChecked('Select one'); - $this->assertSession()->checkboxNotChecked('Created'); + $assert_session->assertWaitOnAjaxRequest(); + $assert_session->checkboxChecked('Published'); + $assert_session->checkboxChecked('Body'); + $assert_session->checkboxNotChecked('Select one'); + $assert_session->checkboxNotChecked('Created'); // Switch back. $page->selectFieldOption('Source bundle', 'Content type two'); - $this->assertSession()->assertWaitOnAjaxRequest(); - $this->assertSession()->checkboxChecked('Select two'); - $this->assertSession()->checkboxNotChecked('Facet for status'); + $assert_session->assertWaitOnAjaxRequest(); + $assert_session->checkboxChecked('Select two'); + $assert_session->checkboxNotChecked('Facet for status'); $page->uncheckField('Override default exposed filters'); $page->pressButton('Save'); diff --git a/tests/src/FunctionalJavascript/ListPagesFiltersTest.php b/tests/src/FunctionalJavascript/ListPagesFiltersTest.php index e981ffec..096073e7 100755 --- a/tests/src/FunctionalJavascript/ListPagesFiltersTest.php +++ b/tests/src/FunctionalJavascript/ListPagesFiltersTest.php @@ -52,21 +52,21 @@ public function testListPageFilters(): void { $this->drupalGet('/node/add/oe_list_page'); $this->clickLink('List Page'); $page = $this->getSession()->getPage(); - $page->selectFieldOption('Source bundle', 'Content type one'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert = $this->assertSession(); + $this->assertTrue($assert->optionExists('Source bundle', 'Content type one')->isSelected()); $page->checkField('Override default exposed filters'); $page->checkField('Select one'); $page->checkField('Published'); $page->fillField('Title', 'List page for ct1'); $page->pressButton('Save'); - $this->assertSession()->pageTextContains('List page for ct1'); + $assert->pageTextContains('List page for ct1'); // Create list for content type two. $this->drupalGet('/node/add/oe_list_page'); $this->clickLink('List Page'); $page = $this->getSession()->getPage(); $page->selectFieldOption('Source bundle', 'Content type two'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert->assertWaitOnAjaxRequest(); $page->fillField('Title', 'List page for ct2'); $page->pressButton('Save'); @@ -74,8 +74,7 @@ public function testListPageFilters(): void { $this->drupalGet('/node/add/oe_list_page'); $this->clickLink('List Page'); $page = $this->getSession()->getPage(); - $page->selectFieldOption('Source bundle', 'Content type one'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $this->assertTrue($assert->optionExists('Source bundle', 'Content type one')->isSelected()); $page->checkField('Override default exposed filters'); $page->uncheckField('Body'); $page->uncheckField('Published'); @@ -112,25 +111,23 @@ public function testListPageFilters(): void { // Check fields are visible in list nodes. $node = $this->drupalGetNodeByTitle('List page for ct1'); $this->drupalGet($node->toUrl()); - $this->assertSession()->fieldExists('Select one'); - $this->assertSession()->fieldExists('Published'); - $this->assertSession()->fieldNotExists('Created'); - $assert = $this->assertSession(); + $assert->fieldExists('Select one'); + $assert->fieldExists('Published'); + $assert->fieldNotExists('Created'); $assert->pageTextContains('that yellow fruit'); $assert->pageTextNotContains('that red fruit'); $node = $this->drupalGetNodeByTitle('List page for ct2'); $this->drupalGet($node->toUrl()); - $this->assertSession()->fieldExists('Select two'); - $this->assertSession()->fieldNotExists('Published'); - $this->assertSession()->fieldNotExists('Created'); + $assert->fieldExists('Select two'); + $assert->fieldNotExists('Published'); + $assert->fieldNotExists('Created'); $assert->pageTextContains('that red fruit'); $assert->pageTextNotContains('that yellow fruit'); $node = $this->drupalGetNodeByTitle('Another List page for ct1'); $this->drupalGet($node->toUrl()); - $this->assertSession()->fieldNotExists('Select one'); - $this->assertSession()->fieldNotExists('Published'); - $this->assertSession()->fieldNotExists('Created'); - $assert = $this->assertSession(); + $assert->fieldNotExists('Select one'); + $assert->fieldNotExists('Published'); + $assert->fieldNotExists('Created'); $assert->pageTextContains('that yellow fruit'); $assert->pageTextNotContains('that red fruit'); } @@ -224,8 +221,8 @@ public function testSelectedListPageFilters(): void { $this->drupalGet('/node/add/oe_list_page'); $this->clickLink('List Page'); $page = $this->getSession()->getPage(); - $page->selectFieldOption('Source bundle', 'Content type one'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert_session = $this->assertSession(); + $this->assertTrue($assert_session->optionExists('Source bundle', 'Content type one')->isSelected()); $page->checkField('Override default exposed filters'); $page->checkField('Select one'); $page->checkField('Published'); @@ -238,14 +235,14 @@ public function testSelectedListPageFilters(): void { $node = $this->drupalGetNodeByTitle('List page for ct1'); $this->drupalGet($node->toUrl()); - $this->assertSession()->pageTextContains('one yellow fruit'); - $this->assertSession()->pageTextContains('another yellow fruit'); - $this->assertSession()->linkNotExistsExact('Yes'); - $this->assertSession()->linkNotExistsExact('test1'); - $this->assertSession()->linkNotExistsExact('test2'); - $this->assertSession()->linkNotExistsExact('Future'); + $assert_session->pageTextContains('one yellow fruit'); + $assert_session->pageTextContains('another yellow fruit'); + $assert_session->linkNotExistsExact('Yes'); + $assert_session->linkNotExistsExact('test1'); + $assert_session->linkNotExistsExact('test2'); + $assert_session->linkNotExistsExact('Future'); // Past is showing up but it's not a link. - $this->assertSession()->linkNotExistsExact('Past'); + $assert_session->linkNotExistsExact('Past'); // We have a default status facet, configured to show Past items. $spans = $this->getSession()->getPage()->findAll('css', '.field--name-extra-field-oe-list-page-selected-filtersnodeoe-list-page span'); $this->assertCount(2, $spans); @@ -260,44 +257,44 @@ public function testSelectedListPageFilters(): void { $this->getSession()->getPage()->selectFieldOption('Select one', 'test1', TRUE); $this->getSession()->getPage()->selectFieldOption('Select one', 'test2', TRUE); $this->getSession()->getPage()->pressButton('Search'); - $this->assertSession()->pageTextContains('one yellow fruit'); - $this->assertSession()->pageTextContains('another yellow fruit'); - $this->assertSession()->elementExists('css', '.field--name-extra-field-oe-list-page-selected-filtersnodeoe-list-page'); - $this->assertTrue($this->assertSession()->optionExists('Published', 'Yes')->isSelected()); - $this->assertTrue($this->assertSession()->optionExists('Select one', 'test1')->isSelected()); - $this->assertTrue($this->assertSession()->optionExists('Select one', 'test2')->isSelected()); - $this->assertSession()->linkExistsExact('Yes'); - $this->assertSession()->linkExistsExact('test1'); - $this->assertSession()->linkExistsExact('test2'); - $this->assertSession()->linkNotExistsExact('Future'); + $assert_session->pageTextContains('one yellow fruit'); + $assert_session->pageTextContains('another yellow fruit'); + $assert_session->elementExists('css', '.field--name-extra-field-oe-list-page-selected-filtersnodeoe-list-page'); + $this->assertTrue($assert_session->optionExists('Published', 'Yes')->isSelected()); + $this->assertTrue($assert_session->optionExists('Select one', 'test1')->isSelected()); + $this->assertTrue($assert_session->optionExists('Select one', 'test2')->isSelected()); + $assert_session->linkExistsExact('Yes'); + $assert_session->linkExistsExact('test1'); + $assert_session->linkExistsExact('test2'); + $assert_session->linkNotExistsExact('Future'); // Since we have other filters now, the Past status becomes a link as it // can be removed. - $this->assertSession()->linkExistsExact('Past'); + $assert_session->linkExistsExact('Past'); $this->assertSelectedFiltersLabels(['Period', 'Select one', 'Published']); // Remove test2 from the selected filters. $this->getSession()->getPage()->clickLink('test2'); - $this->assertSession()->pageTextContains('one yellow fruit'); + $assert_session->pageTextContains('one yellow fruit'); // The filter was removed, so we should only see the first node. - $this->assertSession()->pageTextNotContains('another yellow fruit'); - $this->assertSession()->linkExistsExact('Yes'); - $this->assertSession()->linkExistsExact('test1'); - $this->assertSession()->linkNotExistsExact('test2'); - $this->assertSession()->linkNotExistsExact('Future'); - $this->assertSession()->linkExistsExact('Past'); + $assert_session->pageTextNotContains('another yellow fruit'); + $assert_session->linkExistsExact('Yes'); + $assert_session->linkExistsExact('test1'); + $assert_session->linkNotExistsExact('test2'); + $assert_session->linkNotExistsExact('Future'); + $assert_session->linkExistsExact('Past'); $this->assertSelectedFiltersLabels(['Period', 'Select one', 'Published']); // Remove test1 as well. $this->getSession()->getPage()->clickLink('test1'); // Both nodes should now be shown as they are both published. - $this->assertSession()->pageTextContains('one yellow fruit'); - $this->assertSession()->pageTextContains('another yellow fruit'); - $this->assertSession()->linkNotExistsExact('test1'); - $this->assertSession()->linkNotExistsExact('test2'); - $this->assertSession()->linkNotExistsExact('Future'); - $this->assertSession()->linkExistsExact('Past'); + $assert_session->pageTextContains('one yellow fruit'); + $assert_session->pageTextContains('another yellow fruit'); + $assert_session->linkNotExistsExact('test1'); + $assert_session->linkNotExistsExact('test2'); + $assert_session->linkNotExistsExact('Future'); + $assert_session->linkExistsExact('Past'); $this->assertSelectedFiltersLabels(['Period', 'Published']); // Filter by date. @@ -306,30 +303,30 @@ public function testSelectedListPageFilters(): void { $this->getSession()->getPage()->selectFieldOption('Created', 'After'); $this->getSession()->getPage()->fillField('created_first_date_wrapper[created_first_date][date]', '10/19/2019'); $this->getSession()->getPage()->pressButton('Search'); - $this->assertSession()->pageTextContains('one yellow fruit'); - $this->assertSession()->pageTextContains('another yellow fruit'); - $this->assertSession()->linkExistsExact('After 19 October 2019'); - $this->assertSession()->linkExistsExact('Past'); + $assert_session->pageTextContains('one yellow fruit'); + $assert_session->pageTextContains('another yellow fruit'); + $assert_session->linkExistsExact('After 19 October 2019'); + $assert_session->linkExistsExact('Past'); $this->getSession()->getPage()->fillField('created_first_date_wrapper[created_first_date][date]', '10/22/2019'); $this->getSession()->getPage()->pressButton('Search'); - $this->assertSession()->pageTextNotContains('one yellow fruit'); - $this->assertSession()->pageTextContains('another yellow fruit'); - $this->assertSession()->linkExistsExact('After 22 October 2019'); - $this->assertSession()->linkExistsExact('Past'); + $assert_session->pageTextNotContains('one yellow fruit'); + $assert_session->pageTextContains('another yellow fruit'); + $assert_session->linkExistsExact('After 22 October 2019'); + $assert_session->linkExistsExact('Past'); $this->getSession()->getPage()->selectFieldOption('Created', 'Before'); $this->getSession()->getPage()->pressButton('Search'); - $this->assertSession()->pageTextContains('one yellow fruit'); - $this->assertSession()->pageTextNotContains('another yellow fruit'); - $this->assertSession()->linkExistsExact('Before 22 October 2019'); - $this->assertSession()->linkExistsExact('Past'); + $assert_session->pageTextContains('one yellow fruit'); + $assert_session->pageTextNotContains('another yellow fruit'); + $assert_session->linkExistsExact('Before 22 October 2019'); + $assert_session->linkExistsExact('Past'); $this->getSession()->getPage()->selectFieldOption('Created', 'In between'); $this->getSession()->getPage()->fillField('created_first_date_wrapper[created_first_date][date]', '10/19/2019'); $this->getSession()->getPage()->fillField('created_second_date_wrapper[created_second_date][date]', '10/26/2019'); $this->getSession()->getPage()->pressButton('Search'); - $this->assertSession()->pageTextContains('one yellow fruit'); - $this->assertSession()->pageTextContains('another yellow fruit'); - $this->assertSession()->linkExistsExact('Between 19 October 2019 and 26 October 2019'); + $assert_session->pageTextContains('one yellow fruit'); + $assert_session->pageTextContains('another yellow fruit'); + $assert_session->linkExistsExact('Between 19 October 2019 and 26 October 2019'); // Test that the full text widget-based filter shows also the selected // value. @@ -338,51 +335,51 @@ public function testSelectedListPageFilters(): void { $this->getSession()->getPage()->selectFieldOption('Select one', 'test1', TRUE); $this->getSession()->getPage()->pressButton('Search'); $this->assertSelectedFiltersLabels(['Period', 'Body', 'Select one']); - $this->assertSession()->linkExistsExact('banana'); - $this->assertSession()->linkExistsExact('test1'); - $this->assertSession()->pageTextContains('one yellow fruit'); - $this->assertSession()->pageTextNotContains('another yellow fruit'); + $assert_session->linkExistsExact('banana'); + $assert_session->linkExistsExact('test1'); + $assert_session->pageTextContains('one yellow fruit'); + $assert_session->pageTextNotContains('another yellow fruit'); // Remove the select field and assert we still show the link with the // text filter. $this->getSession()->getPage()->clickLink('test1'); $this->assertSelectedFiltersLabels(['Period', 'Body']); - $this->assertSession()->linkExistsExact('banana'); - $this->assertSession()->linkNotExistsExact('test1'); - $this->assertSession()->pageTextContains('one yellow fruit'); - $this->assertSession()->pageTextNotContains('another yellow fruit'); + $assert_session->linkExistsExact('banana'); + $assert_session->linkNotExistsExact('test1'); + $assert_session->pageTextContains('one yellow fruit'); + $assert_session->pageTextNotContains('another yellow fruit'); // Add back the select and remove the text filter. $this->getSession()->getPage()->selectFieldOption('Select one', 'test1', TRUE); $this->getSession()->getPage()->pressButton('Search'); $this->assertSelectedFiltersLabels(['Period', 'Body', 'Select one']); - $this->assertSession()->linkExistsExact('banana'); - $this->assertSession()->linkExistsExact('test1'); - $this->assertSession()->pageTextContains('one yellow fruit'); - $this->assertSession()->pageTextNotContains('another yellow fruit'); + $assert_session->linkExistsExact('banana'); + $assert_session->linkExistsExact('test1'); + $assert_session->pageTextContains('one yellow fruit'); + $assert_session->pageTextNotContains('another yellow fruit'); $this->getSession()->getPage()->clickLink('banana'); $this->assertSelectedFiltersLabels(['Period', 'Select one']); - $this->assertSession()->linkNotExistsExact('banana'); - $this->assertSession()->linkExistsExact('test1'); - $this->assertSession()->pageTextContains('one yellow fruit'); - $this->assertSession()->pageTextNotContains('another yellow fruit'); + $assert_session->linkNotExistsExact('banana'); + $assert_session->linkExistsExact('test1'); + $assert_session->pageTextContains('one yellow fruit'); + $assert_session->pageTextNotContains('another yellow fruit'); // Test the period filter with a default status. $this->getSession()->getPage()->pressButton('Clear filters'); $this->getSession()->getPage()->selectFieldOption('Published', 'Yes', TRUE); $this->getSession()->getPage()->pressButton('Search'); - $this->assertSession()->linkNotExistsExact('Future'); - $this->assertSession()->linkExistsExact('Past'); + $assert_session->linkNotExistsExact('Future'); + $assert_session->linkExistsExact('Past'); $this->getSession()->getPage()->selectFieldOption('Period', 'Future', TRUE); $this->getSession()->getPage()->selectFieldOption('Period', 'Past', TRUE); $this->getSession()->getPage()->pressButton('Search'); // Now both default status values are links. - $this->assertSession()->linkExistsExact('Future'); - $this->assertSession()->linkExistsExact('Past'); + $assert_session->linkExistsExact('Future'); + $assert_session->linkExistsExact('Past'); // Remove Past and assert that Future remains a link because it is not // configured as the default status. $this->clickLink('Past'); - $this->assertSession()->linkExistsExact('Future'); + $assert_session->linkExistsExact('Future'); // The Past link is gone, and also as a simple string. - $this->assertSession()->linkNotExistsExact('Past'); + $assert_session->linkNotExistsExact('Past'); $spans = $this->getSession()->getPage()->findAll('css', '.field--name-extra-field-oe-list-page-selected-filtersnodeoe-list-page span'); $this->assertCount(2, $spans); $this->assertEquals('Period', $spans[0]->getText()); @@ -393,28 +390,28 @@ public function testSelectedListPageFilters(): void { $this->getSession()->getPage()->selectFieldOption('Select one', 'test1', TRUE); $this->getSession()->getPage()->fillField('Body', 'no results'); $this->getSession()->getPage()->pressButton('Search'); - $this->assertSession()->pageTextNotContains('one yellow fruit'); - $this->assertSession()->pageTextNotContains('another yellow fruit'); + $assert_session->pageTextNotContains('one yellow fruit'); + $assert_session->pageTextNotContains('another yellow fruit'); $this->assertSelectedFiltersLabels(['Period', 'Body', 'Select one']); // Test that processors are used in building the selected filters. $this->drupalGet($node->toUrl()); $this->getSession()->getPage()->selectFieldOption('Country', 'Belgium'); $this->getSession()->getPage()->pressButton('Search'); - $this->assertSession()->pageTextContains('one yellow fruit'); - $this->assertSession()->pageTextNotContains('another yellow fruit'); - $this->assertSession()->linkNotExistsExact('BE'); - $this->assertSession()->linkExistsExact('Belgium'); + $assert_session->pageTextContains('one yellow fruit'); + $assert_session->pageTextNotContains('another yellow fruit'); + $assert_session->linkNotExistsExact('BE'); + $assert_session->linkExistsExact('Belgium'); $this->assertSelectedFiltersLabels(['Period', 'Country']); // Test that even without results, the processors are used for the selected // filters. $this->getSession()->getPage()->fillField('Body', 'no results'); $this->getSession()->getPage()->pressButton('Search'); - $this->assertSession()->pageTextNotContains('one yellow fruit'); - $this->assertSession()->pageTextNotContains('another yellow fruit'); - $this->assertSession()->linkNotExistsExact('BE'); - $this->assertSession()->linkExistsExact('Belgium'); + $assert_session->pageTextNotContains('one yellow fruit'); + $assert_session->pageTextNotContains('another yellow fruit'); + $assert_session->linkNotExistsExact('BE'); + $assert_session->linkExistsExact('Belgium'); $this->assertSelectedFiltersLabels(['Period', 'Body', 'Country']); } @@ -447,19 +444,19 @@ public function testListPagePagerInfo(): void { $this->drupalGet('/node/add/oe_list_page'); $this->clickLink('List Page'); $page = $this->getSession()->getPage(); - $page->selectFieldOption('Source bundle', 'Content type one'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert_session = $this->assertSession(); + $this->assertTrue($assert_session->optionExists('Source bundle', 'Content type one')->isSelected()); $page->fillField('Title', 'List page for ct1'); $page->pressButton('Save'); // By default we show only 10 results. $this->assertCount(10, $this->getSession()->getPage()->findAll('css', '.node--type-content-type-one')); - $this->assertSession()->pageTextContains('Showing results 1 to 10'); + $assert_session->pageTextContains('Showing results 1 to 10'); $this->getSession()->getPage()->clickLink('Next'); - $this->assertSession()->pageTextContains('Showing results 10 to 20'); + $assert_session->pageTextContains('Showing results 10 to 20'); $this->getSession()->getPage()->clickLink('Next'); - $this->assertSession()->pageTextContains('Showing results 20 to 23'); + $assert_session->pageTextContains('Showing results 20 to 23'); // Update the node to show 20 results. $node = $this->drupalGetNodeByTitle('List page for ct1'); @@ -468,15 +465,15 @@ public function testListPagePagerInfo(): void { $this->getSession()->getPage()->selectFieldOption('The number of items to show per page', '20'); $page->pressButton('Save'); $this->assertCount(20, $this->getSession()->getPage()->findAll('css', '.node--type-content-type-one')); - $this->assertSession()->pageTextContains('Showing results 1 to 20'); + $assert_session->pageTextContains('Showing results 1 to 20'); $this->getSession()->getPage()->clickLink('Next'); - $this->assertSession()->pageTextContains('Showing results 20 to 23'); + $assert_session->pageTextContains('Showing results 20 to 23'); // Search to trigger no results. $this->getSession()->getPage()->fillField('Body', 'not going to find anything'); $this->getSession()->getPage()->pressButton('Search'); - $this->assertSession()->pageTextContains('No results have been found'); - $this->assertSession()->pageTextNotContains('Showing results'); + $assert_session->pageTextContains('No results have been found'); + $assert_session->pageTextNotContains('Showing results'); } /** diff --git a/tests/src/FunctionalJavascript/ListPagesPresetFiltersTest.php b/tests/src/FunctionalJavascript/ListPagesPresetFiltersTest.php index e3f5a84f..4eaca7fb 100755 --- a/tests/src/FunctionalJavascript/ListPagesPresetFiltersTest.php +++ b/tests/src/FunctionalJavascript/ListPagesPresetFiltersTest.php @@ -181,16 +181,16 @@ public function testListPageDefaultStatusPresetFilters(): void { $this->getSession()->getPage()->fillField('Title', 'List page for ct1'); $this->clickLink('List Page'); - $this->getSession()->getPage()->selectFieldOption('Source bundle', 'content_type_one'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert_session = $this->assertSession(); + $this->assertTrue($assert_session->optionExists('Source bundle', 'content_type_one')->isSelected()); $this->getSession()->getPage()->pressButton('Save'); // We should only see the past nodes by default because we have the facet // configured to show the past events. - $this->assertSession()->pageTextContains('Past node 1'); - $this->assertSession()->pageTextContains('Past node 2'); - $this->assertSession()->pageTextContains('Facet for end_value: Past items'); - $this->assertSession()->pageTextNotContains('Future node'); + $assert_session->pageTextContains('Past node 1'); + $assert_session->pageTextContains('Past node 2'); + $assert_session->pageTextContains('Facet for end_value: Past items'); + $assert_session->pageTextNotContains('Future node'); $node = $this->drupalGetNodeByTitle('List page for ct1'); $this->drupalGet($node->toUrl('edit-form')); @@ -198,33 +198,33 @@ public function testListPageDefaultStatusPresetFilters(): void { // Set preset filter for default date facet. $this->getSession()->getPage()->selectFieldOption('Add default value for', 'Facet for end_value'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert_session->assertWaitOnAjaxRequest(); $filter_id = DefaultFilterConfigurationBuilder::generateFilterId($facet->id()); $filter_selector = 'emr_plugins_oe_list_page[wrapper][default_filter_values][wrapper][edit][' . $filter_id . ']'; $this->getSession()->getPage()->selectFieldOption($filter_selector . '[' . $facet->id() . '][0][list]', DateStatus::UPCOMING); $this->getSession()->getPage()->pressButton('Set default value'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert_session->assertWaitOnAjaxRequest(); $this->getSession()->getPage()->pressButton('Save'); // The preset filter took over the default status. - $this->assertSession()->pageTextNotContains('Past node 1'); - $this->assertSession()->pageTextNotContains('Past node 2'); - $this->assertSession()->pageTextNotContains('Facet for end_value'); - $this->assertSession()->pageTextContains('Future node'); + $assert_session->pageTextNotContains('Past node 1'); + $assert_session->pageTextNotContains('Past node 2'); + $assert_session->pageTextNotContains('Facet for end_value'); + $assert_session->pageTextContains('Future node'); // Include both upcoming and past. $this->drupalGet($node->toUrl('edit-form')); $this->clickLink('List Page'); $this->getSession()->getPage()->pressButton('default-edit-' . $filter_id . '-' . $ajax_wrapper_id); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert_session->assertWaitOnAjaxRequest(); $this->getSession()->getPage()->selectFieldOption('emr_plugins_oe_list_page[wrapper][default_filter_values][wrapper][edit][' . $filter_id . '][oe_list_pages_filter_operator]', 'Any of'); $this->getSession()->getPage()->selectFieldOption($filter_selector . '[' . $facet->id() . '][1][list]', DateStatus::PAST); $this->getSession()->getPage()->pressButton('Set default value'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert_session->assertWaitOnAjaxRequest(); $this->getSession()->getPage()->pressButton('Save'); - $this->assertSession()->pageTextContains('Past node 1'); - $this->assertSession()->pageTextContains('Past node 2'); - $this->assertSession()->pageTextContains('Future node'); - $this->assertSession()->pageTextNotContains('Facet for end_value'); + $assert_session->pageTextContains('Past node 1'); + $assert_session->pageTextContains('Past node 2'); + $assert_session->pageTextContains('Future node'); + $assert_session->pageTextNotContains('Facet for end_value'); } /** @@ -271,13 +271,13 @@ public function testCustomFieldWithDefaultStatus(): void { $this->getSession()->getPage()->fillField('Title', 'List page for ct1'); $this->clickLink('List Page'); - $this->getSession()->getPage()->selectFieldOption('Source bundle', 'content_type_one'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert_session = $this->assertSession(); + $this->assertTrue($assert_session->optionExists('Source bundle', 'content_type_one')->isSelected()); $this->getSession()->getPage()->pressButton('Save'); // We should only see Node 1 as the default value of Foo face is set to 1. - $this->assertSession()->pageTextContains('Node 1'); - $this->assertSession()->pageTextNotContains('Node 2'); + $assert_session->pageTextContains('Node 1'); + $assert_session->pageTextNotContains('Node 2'); $node = $this->drupalGetNodeByTitle('List page for ct1'); $this->drupalGet($node->toUrl('edit-form')); @@ -285,17 +285,17 @@ public function testCustomFieldWithDefaultStatus(): void { // Set preset filter for the Foo facet. $this->getSession()->getPage()->selectFieldOption('Add default value for', 'Foo'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert_session->assertWaitOnAjaxRequest(); $filter_id = DefaultFilterConfigurationBuilder::generateFilterId($facet->id()); $filter_selector = 'emr_plugins_oe_list_page[wrapper][default_filter_values][wrapper][edit][' . $filter_id . ']'; $this->getSession()->getPage()->selectFieldOption($filter_selector . '[' . $facet->id() . '][0][list]', '2'); $this->getSession()->getPage()->pressButton('Set default value'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert_session->assertWaitOnAjaxRequest(); $this->getSession()->getPage()->pressButton('Save'); // We should only see Node 2 as the Foo facet was set to 2. - $this->assertSession()->pageTextNotContains('Node 1'); - $this->assertSession()->pageTextContains('Node 2'); + $assert_session->pageTextNotContains('Node 1'); + $assert_session->pageTextContains('Node 2'); } /** @@ -385,15 +385,15 @@ public function testPresetFilterResultsNarrowing(): void { $this->getSession()->getPage()->fillField('Title', 'List page for ct1'); $this->clickLink('List Page'); - $this->getSession()->getPage()->selectFieldOption('Source bundle', 'content_type_one'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert_session = $this->assertSession(); + $this->assertTrue($assert_session->optionExists('Source bundle', 'content_type_one')->isSelected()); $this->getSession()->getPage()->checkField('Override default exposed filters'); $this->getSession()->getPage()->checkField('Select one'); $this->getSession()->getPage()->checkField('Created'); $this->getSession()->getPage()->pressButton('Save'); foreach ($all_nodes as $node) { - $this->assertSession()->pageTextContains($node->label()); + $assert_session->pageTextContains($node->label()); } $node = $this->drupalGetNodeByTitle('List page for ct1'); @@ -403,25 +403,25 @@ public function testPresetFilterResultsNarrowing(): void { $this->setListPageFilters($node, $filters); $this->getSession()->reload(); $this->assertResultCount(2); - $this->assertSession()->pageTextContains('test 1'); - $this->assertSession()->pageTextContains('test 1 and 2'); + $assert_session->pageTextContains('test 1'); + $assert_session->pageTextContains('test 1 and 2'); // Only the narrowing options should exist in the exposed form of this facet // which has default values. $this->assertSelectOptions('Select one', ['test1', 'test2']); - $this->assertSession()->linkNotExistsExact('test1'); + $assert_session->linkNotExistsExact('test1'); $this->getSession()->getPage()->selectFieldOption('Select one', 'test1'); $this->getSession()->getPage()->pressButton('Search'); $this->assertResultCount(2); - $this->assertSession()->pageTextContains('test 1'); - $this->assertSession()->pageTextContains('test 1 and 2'); + $assert_session->pageTextContains('test 1'); + $assert_session->pageTextContains('test 1 and 2'); // Now we have an active filter so we show the selected filters. - $this->assertSession()->linkExistsExact('test1'); + $assert_session->linkExistsExact('test1'); $this->getSession()->getPage()->clickLink('test1'); $this->getSession()->getPage()->selectFieldOption('Select one', 'test2'); $this->getSession()->getPage()->pressButton('Search'); $this->assertResultCount(1); // Now the query is test1 AND test2. - $this->assertSession()->pageTextContains('test 1 and 2'); + $assert_session->pageTextContains('test 1 and 2'); $node = $this->drupalGetNodeByTitle('List page for ct1'); $filters = [ @@ -434,9 +434,9 @@ public function testPresetFilterResultsNarrowing(): void { $this->getSession()->getPage()->pressButton('Clear filters'); $this->assertResultCount(3); - $this->assertSession()->pageTextContains('test 1'); - $this->assertSession()->pageTextContains('test 2'); - $this->assertSession()->pageTextContains('test 1 and 2'); + $assert_session->pageTextContains('test 1'); + $assert_session->pageTextContains('test 2'); + $assert_session->pageTextContains('test 1 and 2'); // Add a date default filter that includes all results. $filters = [ @@ -445,15 +445,15 @@ public function testPresetFilterResultsNarrowing(): void { $this->setListPageFilters($node, $filters); $this->getSession()->reload(); foreach ($all_nodes as $node) { - $this->assertSession()->pageTextContains($node->label()); + $assert_session->pageTextContains($node->label()); } - $this->assertSession()->linkNotExists('Between'); + $assert_session->linkNotExists('Between'); $this->getSession()->getPage()->selectFieldOption('Select one', 'test3'); $this->getSession()->getPage()->pressButton('Search'); $this->assertResultCount(1); - $this->assertSession()->pageTextContains('test 3'); - $this->assertSession()->linkExistsExact('test3'); + $assert_session->pageTextContains('test 3'); + $assert_session->linkExistsExact('test3'); $this->getSession()->getPage()->pressButton('Clear filters'); // Narrow down the results by one old record. @@ -461,7 +461,7 @@ public function testPresetFilterResultsNarrowing(): void { $this->getSession()->getPage()->fillField('created_first_date_wrapper[created_first_date][date]', '01/01/2011'); $this->getSession()->getPage()->pressButton('Search'); $this->assertResultCount(count($all_nodes) - 1); - $this->assertSession()->pageTextNotContains('past node'); + $assert_session->pageTextNotContains('past node'); } /** diff --git a/tests/src/FunctionalJavascript/ListPagesSortTest.php b/tests/src/FunctionalJavascript/ListPagesSortTest.php index 68c80693..48b0dc19 100644 --- a/tests/src/FunctionalJavascript/ListPagesSortTest.php +++ b/tests/src/FunctionalJavascript/ListPagesSortTest.php @@ -109,39 +109,35 @@ public function testBackendSort(): void { $this->goToListPageConfiguration(); // No sort field visible. - $this->assertSession()->fieldNotExists('Sort'); - - // Select node. - $this->getSession()->getPage()->selectFieldOption('Source entity type', 'node'); - $this->assertSession()->assertWaitOnAjaxRequest(); - $this->assertSession()->fieldNotExists('Sort'); + $assert_session = $this->assertSession(); + $this->assertTrue($assert_session->optionExists('Source entity type', 'node')->isSelected()); + $assert_session->fieldNotExists('Sort'); // Select a bundle with no default sort (normally this should not happen // but in case the bundle is not fully configured). $this->getSession()->getPage()->selectFieldOption('Source bundle', 'content_type_two'); - $this->assertSession()->assertWaitOnAjaxRequest(); - $this->assertSession()->fieldNotExists('Sort'); + $assert_session->assertWaitOnAjaxRequest(); + $assert_session->fieldNotExists('Sort'); // Select a bundle that has the sort configured and assert we don't see the // sort field (as we only have 1 sort option). $this->getSession()->getPage()->selectFieldOption('Source bundle', 'content_type_one'); - $this->assertSession()->assertWaitOnAjaxRequest(); - $this->assertSession()->fieldNotExists('Sort'); + $assert_session->assertWaitOnAjaxRequest(); + $assert_session->fieldNotExists('Sort'); // Subscribe to the event and provide another sort option. \Drupal::state()->set('oe_list_pages_test.alter_sort_options', TRUE); $this->goToListPageConfiguration(); - $this->getSession()->getPage()->selectFieldOption('Source entity type', 'node'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $this->assertTrue($assert_session->optionExists('Source entity type', 'node')->isSelected()); // This bundle only has the event subscriber sort so no Sort select should // show up. $this->getSession()->getPage()->selectFieldOption('Source bundle', 'content_type_two'); - $this->assertSession()->assertWaitOnAjaxRequest(); - $this->assertSession()->fieldNotExists('Sort'); + $assert_session->assertWaitOnAjaxRequest(); + $assert_session->fieldNotExists('Sort'); // Save the node and assert we have no sort info in the entity meta. $this->getSession()->getPage()->fillField('Title', 'Node title'); $this->getSession()->getPage()->pressButton('Save'); - $this->assertSession()->pageTextContains('List page Node title has been created.'); + $assert_session->pageTextContains('List page Node title has been created.'); $this->assertEmpty($this->getSortInformationFromNodeMeta('Node title')); // Edit the node and switch to the content type which has more options due @@ -150,8 +146,8 @@ public function testBackendSort(): void { $this->drupalGet($node->toUrl('edit-form')); $this->clickLink('List Page'); $this->getSession()->getPage()->selectFieldOption('Source bundle', 'content_type_one'); - $this->assertSession()->assertWaitOnAjaxRequest(); - $this->assertSession()->selectExists('Sort'); + $assert_session->assertWaitOnAjaxRequest(); + $assert_session->selectExists('Sort'); $actual_options = $this->getSelectOptions('Sort'); $expected_options = [ 'created__DESC' => 'Default', @@ -159,7 +155,7 @@ public function testBackendSort(): void { ]; $this->assertEquals($expected_options, $actual_options); // Assert also that the Default option is selected. - $this->assertTrue($this->assertSession()->optionExists('Sort', 'Default')->isSelected()); + $this->assertTrue($assert_session->optionExists('Sort', 'Default')->isSelected()); // Save the node with the default sort selected and assert that again, no // sort has been saved in the meta because the defaults should not be saved. @@ -194,7 +190,7 @@ public function testBackendSort(): void { // Switch back to the default sort. $this->drupalGet($node->toUrl('edit-form')); $this->clickLink('List Page'); - $this->assertTrue($this->assertSession()->optionExists('Sort', 'Boolean')->isSelected()); + $this->assertTrue($assert_session->optionExists('Sort', 'Boolean')->isSelected()); $this->getSession()->getPage()->selectFieldOption('Sort', 'created__DESC'); $this->getSession()->getPage()->pressButton('Save'); $this->assertEmpty($this->getSortInformationFromNodeMeta('Node title')); @@ -214,15 +210,14 @@ public function testFrontendSort(): void { $admin = $this->createUser([], NULL, TRUE); $this->drupalLogin($admin); $this->goToListPageConfiguration(); - $this->getSession()->getPage()->selectFieldOption('Source entity type', 'node'); - $this->assertSession()->assertWaitOnAjaxRequest(); - $this->getSession()->getPage()->selectFieldOption('Source bundle', 'content_type_one'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $assert_session = $this->assertSession(); + $this->assertTrue($assert_session->optionExists('Source entity type', 'node')->isSelected()); + $this->assertTrue($assert_session->optionExists('Source bundle', 'content_type_one')->isSelected()); // Since we don't disallow the sort exposing, assert the checkbox is there. - $this->assertSession()->checkboxNotChecked('Expose sort'); + $assert_session->checkboxNotChecked('Expose sort'); $this->getSession()->getPage()->fillField('Title', 'Node title'); $this->getSession()->getPage()->pressButton('Save'); - $this->assertSession()->pageTextContains('List page Node title has been created.'); + $assert_session->pageTextContains('List page Node title has been created.'); $this->assertResultsAreInCorrectOrder([ 'First by created', 'Second by created', @@ -233,30 +228,30 @@ public function testFrontendSort(): void { // Since we don't have any other sort options and the sort is not even // exposed, we shouldn't see the sort element. - $this->assertSession()->fieldNotExists('Sort by'); + $assert_session->fieldNotExists('Sort by'); // Disallow the sort exposing, assert the form checkbox is gone, then allow // back to expose the sort. \Drupal::state()->set('oe_list_pages_test.disallow_frontend_sort', TRUE); $node = $this->drupalGetNodeByTitle('Node title'); $this->drupalGet($node->toUrl('edit-form')); - $this->assertSession()->fieldNotExists('Expose sort'); + $assert_session->fieldNotExists('Expose sort'); \Drupal::state()->set('oe_list_pages_test.disallow_frontend_sort', FALSE); $this->getSession()->reload(); - $this->assertSession()->fieldExists('Expose sort'); + $assert_session->fieldExists('Expose sort'); $this->clickLink('List Page'); $this->getSession()->getPage()->checkField('Expose sort'); $this->getSession()->getPage()->pressButton('Save'); - $this->assertSession()->pageTextContains('List page Node title has been updated.'); + $assert_session->pageTextContains('List page Node title has been updated.'); $this->drupalGet($node->toUrl()); // Still no exposed sort as we only have 1 sort option. - $this->assertSession()->fieldNotExists('Sort by'); + $assert_session->fieldNotExists('Sort by'); // Implement the subscriber and provide another sort option. \Drupal::state()->set('oe_list_pages_test.alter_sort_options', TRUE); $this->getSession()->reload(); - $this->assertSession()->fieldExists('Sort by'); + $assert_session->fieldExists('Sort by'); $this->assertEquals([ 'created__DESC' => 'Default', 'field_test_boolean__DESC' => 'From 1 to 0', @@ -265,15 +260,16 @@ public function testFrontendSort(): void { // Disallow the sort and reload to assert the exposed sort is gone. \Drupal::state()->set('oe_list_pages_test.disallow_frontend_sort', TRUE); $this->getSession()->reload(); - $this->assertSession()->fieldNotExists('Sort by'); + $assert_session->fieldNotExists('Sort by'); \Drupal::state()->set('oe_list_pages_test.disallow_frontend_sort', FALSE); $this->getSession()->reload(); - $this->assertSession()->fieldExists('Sort by'); + $assert_session->fieldExists('Sort by'); // Change the sort. + $this->markPageToDetectReload(); $this->getSession()->getPage()->selectFieldOption('Sort by', 'From 1 to 0'); - $this->assertSession()->assertWaitOnAjaxRequest(); + $this->waitForPageReload(); $this->assertResultsAreInCorrectOrder([ 'First by boolean field', 'First by created', @@ -363,4 +359,28 @@ protected function goToListPageConfiguration(): void { $this->clickLink('List Page'); } + /** + * Marks a page so that we can detect when a reload has been completed. + * + * The class will not be present upon reload. + */ + protected function markPageToDetectReload(): void { + $script = <<getSession()->executeScript($script); + $this->assertTrue($this->assertSession()->elementExists('css', 'body')->hasClass('marked-for-reload')); + } + + /** + * Waits until the page has been reloaded. + * + * Must be preceded by ::markPageToDetectReload() or it won't have any effect. + */ + protected function waitForPageReload(): void { + $this->assertNotNull($this->assertSession()->waitForElement('css', 'body:not(.marked-for-reload)')); + } + }