From fadaf75c019d42d7cfc117bf79bfdef92f7fef56 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Mon, 12 Feb 2024 17:34:05 +0100 Subject: [PATCH 1/8] EWPP-3953: Add Drupal 10.2.x and PHP 8.2 to matrix. --- .drone.yml | 11 +++++------ composer.json | 7 ++----- docker-compose.yml | 12 +++--------- .../oe_list_page_content_type.info.yml | 2 +- .../oe_list_pages_address.info.yml | 2 +- .../oe_list_pages_link_list_displays.info.yml | 2 +- .../oe_list_pages_link_list_source.info.yml | 2 +- .../oe_list_pages_link_list_source_test.info.yml | 2 +- .../oe_list_pages_open_vocabularies.info.yml | 2 +- .../oe_list_pages_open_vocabularies_test.info.yml | 2 +- oe_list_pages.info.yml | 2 +- phpunit.xml.dist | 2 +- .../oe_list_pages_event_subscriber_test.info.yml | 2 +- .../oe_list_pages_filters_test.info.yml | 2 +- 14 files changed, 21 insertions(+), 31 deletions(-) diff --git a/.drone.yml b/.drone.yml index 5b6555d8..72735235 100644 --- a/.drone.yml +++ b/.drone.yml @@ -30,11 +30,10 @@ services: - SPARQL_UPDATE=true - DBA_PASSWORD=dba selenium: - image: registry.fpfis.eu/fpfis/selenium:standalone-chrome-3.141.59-oxygen + image: registry.fpfis.eu/fpfis/selenium:standalone-chrome-4.1.3-20220405 shm_size: 2g environment: - DISPLAY=:99 - - SE_OPTS=-debug - SCREEN_WIDTH=1280 - SCREEN_HEIGHT=800 - NODE_MAX_INSTANCES=5 @@ -89,11 +88,11 @@ pipeline: matrix: include: - - CORE_VERSION: 10.0.0 - PHP_VERSION: 8.1 - - CORE_VERSION: 10.0.0 - PHP_VERSION: 8.2 - CORE_VERSION: 10.1.0 PHP_VERSION: 8.1 - CORE_VERSION: 10.1.0 PHP_VERSION: 8.2 + - CORE_VERSION: 10.2.0 + PHP_VERSION: 8.1 + - CORE_VERSION: 10.2.0 + PHP_VERSION: 8.2 diff --git a/composer.json b/composer.json index 88ba1347..015c797d 100644 --- a/composer.json +++ b/composer.json @@ -22,17 +22,14 @@ "drupal/core-dev": "^10", "drupal/extra_field": "^2.1", "drupal/inline_entity_form": "^1.0-rc15", - "drush/drush": "^11.1", + "drush/drush": "^12", "openeuropa/code-review": "^2.0", "openeuropa/oe_link_lists": "^0.22", - "openeuropa/open_vocabularies": "^1.0.0-alpha12", + "openeuropa/open_vocabularies": "dev-EWPP-3968", "openeuropa/rdf_skos": "^1.0.0-alpha10", "openeuropa/task-runner-drupal-project-symlink": "^1.0.0-beta5", "phpspec/prophecy-phpunit": "^2" }, - "_readme": [ - "Using symfony/validator v6.2.5 for D10 like core-recommended does because 6.3 breaks BC with the signature changes to the ExecutionContextInterface. Can be removed when 6.3.1 comes out." - ], "scripts": { "post-install-cmd": "./vendor/bin/run drupal:site-setup", "post-update-cmd": "./vendor/bin/run drupal:site-setup" diff --git a/docker-compose.yml b/docker-compose.yml index ad886bb5..08794c08 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,22 +30,16 @@ services: - DBA_PASSWORD=dba ports: - "8890:8890" - # If you would like to see what is going on you can run the following on your host: - # docker run --rm -p 4444:4444 -p 5900:5900 --network="host" selenium/standalone-chrome-debug:latest - # Newer version of this image might run into this issue: - # @link https://github.com/elgalu/docker-selenium/issues/20 + # Visit localhost:7900 to access the browser. selenium: - image: selenium/standalone-chrome-debug:3.141.59-oxygen - expose: - - '4444' + image: selenium/standalone-chrome:4.1.3-20220405 environment: - DISPLAY=:99 - SCREEN_WIDTH=1280 - SCREEN_HEIGHT=800 - VNC_NO_PASSWORD=1 ports: - - '4444:4444' - - '5900:5900' + - '7900:7900' shm_size: 2g #### Mac users: uncomment the "volumes" key to enable the NFS file sharing. You can find more information about Docker for Mac here: https://github.com/openeuropa/openeuropa/blob/master/docs/starting/tooling.md#using-docker-on-macos diff --git a/modules/oe_list_page_content_type/oe_list_page_content_type.info.yml b/modules/oe_list_page_content_type/oe_list_page_content_type.info.yml index 67a521e5..5a3bb813 100644 --- a/modules/oe_list_page_content_type/oe_list_page_content_type.info.yml +++ b/modules/oe_list_page_content_type/oe_list_page_content_type.info.yml @@ -3,7 +3,7 @@ description: The OpenEuropa List Page content type. package: OpenEuropa type: module -core_version_requirement: ^9.4 || ^10 +core_version_requirement: ^10 dependencies: - emr:emr_node diff --git a/modules/oe_list_pages_address/oe_list_pages_address.info.yml b/modules/oe_list_pages_address/oe_list_pages_address.info.yml index 57f0c06f..943ad1ee 100644 --- a/modules/oe_list_pages_address/oe_list_pages_address.info.yml +++ b/modules/oe_list_pages_address/oe_list_pages_address.info.yml @@ -3,7 +3,7 @@ description: This submodule adds support for Address fields in List Pages. package: OpenEuropa type: module -core_version_requirement: ^9.4 || ^10 +core_version_requirement: ^10 dependencies: - address:address diff --git a/modules/oe_list_pages_link_list_displays/oe_list_pages_link_list_displays.info.yml b/modules/oe_list_pages_link_list_displays/oe_list_pages_link_list_displays.info.yml index 3467df6c..61ea8b6a 100644 --- a/modules/oe_list_pages_link_list_displays/oe_list_pages_link_list_displays.info.yml +++ b/modules/oe_list_pages_link_list_displays/oe_list_pages_link_list_displays.info.yml @@ -1,7 +1,7 @@ name: List page displays from link lists description: Exposes the link list displays on list pages type: module -core_version_requirement: ^9.4 || ^10 +core_version_requirement: ^10 dependencies: - oe_list_pages:oe_list_pages diff --git a/modules/oe_list_pages_link_list_source/oe_list_pages_link_list_source.info.yml b/modules/oe_list_pages_link_list_source/oe_list_pages_link_list_source.info.yml index ca94a389..57ea96d2 100644 --- a/modules/oe_list_pages_link_list_source/oe_list_pages_link_list_source.info.yml +++ b/modules/oe_list_pages_link_list_source/oe_list_pages_link_list_source.info.yml @@ -3,7 +3,7 @@ description: Provides a link list source plugin that collect links from a list p package: OpenEuropa type: module -core_version_requirement: ^9.4 || ^10 +core_version_requirement: ^10 dependencies: - oe_link_lists:oe_link_lists diff --git a/modules/oe_list_pages_link_list_source/tests/modules/oe_list_pages_link_list_source_test/oe_list_pages_link_list_source_test.info.yml b/modules/oe_list_pages_link_list_source/tests/modules/oe_list_pages_link_list_source_test/oe_list_pages_link_list_source_test.info.yml index d97ba17c..524b9394 100644 --- a/modules/oe_list_pages_link_list_source/tests/modules/oe_list_pages_link_list_source_test/oe_list_pages_link_list_source_test.info.yml +++ b/modules/oe_list_pages_link_list_source/tests/modules/oe_list_pages_link_list_source_test/oe_list_pages_link_list_source_test.info.yml @@ -3,7 +3,7 @@ description: Test module for OpenEuropa List Pages Link List Source package: Testing type: module -core_version_requirement: ^9.4 || ^10 +core_version_requirement: ^10 dependencies: - oe_list_pages_link_list_source:oe_list_pages_link_list_source diff --git a/modules/oe_list_pages_open_vocabularies/oe_list_pages_open_vocabularies.info.yml b/modules/oe_list_pages_open_vocabularies/oe_list_pages_open_vocabularies.info.yml index bfa96012..a73d9785 100644 --- a/modules/oe_list_pages_open_vocabularies/oe_list_pages_open_vocabularies.info.yml +++ b/modules/oe_list_pages_open_vocabularies/oe_list_pages_open_vocabularies.info.yml @@ -3,7 +3,7 @@ description: This submodule adds support for OpenVocabularies fields in List Pag package: OpenEuropa type: module -core_version_requirement: ^9.4 || ^10 +core_version_requirement: ^10 dependencies: - oe_list_pages:oe_list_pages diff --git a/modules/oe_list_pages_open_vocabularies/tests/modules/oe_list_pages_open_vocabularies_test/oe_list_pages_open_vocabularies_test.info.yml b/modules/oe_list_pages_open_vocabularies/tests/modules/oe_list_pages_open_vocabularies_test/oe_list_pages_open_vocabularies_test.info.yml index 83b88133..a026fd78 100644 --- a/modules/oe_list_pages_open_vocabularies/tests/modules/oe_list_pages_open_vocabularies_test/oe_list_pages_open_vocabularies_test.info.yml +++ b/modules/oe_list_pages_open_vocabularies/tests/modules/oe_list_pages_open_vocabularies_test/oe_list_pages_open_vocabularies_test.info.yml @@ -3,7 +3,7 @@ description: Test module for OpenEuropa List Pages Open Vocabularies package: Testing type: module -core_version_requirement: ^9.4 || ^10 +core_version_requirement: ^10 dependencies: - oe_list_pages:oe_list_pages_open_vocabularies diff --git a/oe_list_pages.info.yml b/oe_list_pages.info.yml index 68c487ec..6688be46 100644 --- a/oe_list_pages.info.yml +++ b/oe_list_pages.info.yml @@ -3,7 +3,7 @@ description: The OpenEuropa List Pages allows creation and management of list pa package: OpenEuropa type: module -core_version_requirement: ^9.4 || ^10 +core_version_requirement: ^10 dependencies: - emr:emr_node diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c01f8414..bacc745a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -7,7 +7,7 @@ - + diff --git a/tests/modules/oe_list_pages_event_subscriber_test/oe_list_pages_event_subscriber_test.info.yml b/tests/modules/oe_list_pages_event_subscriber_test/oe_list_pages_event_subscriber_test.info.yml index 1d4dee7c..0bfc7bd5 100755 --- a/tests/modules/oe_list_pages_event_subscriber_test/oe_list_pages_event_subscriber_test.info.yml +++ b/tests/modules/oe_list_pages_event_subscriber_test/oe_list_pages_event_subscriber_test.info.yml @@ -3,7 +3,7 @@ type: module description: The test module for OE List Pages plugin event subscriber. package: Testing -core_version_requirement: ^9.4 || ^10 +core_version_requirement: ^10 dependencies: - oe_list_pages diff --git a/tests/modules/oe_list_pages_filters_test/oe_list_pages_filters_test.info.yml b/tests/modules/oe_list_pages_filters_test/oe_list_pages_filters_test.info.yml index cce5227f..de0360ab 100755 --- a/tests/modules/oe_list_pages_filters_test/oe_list_pages_filters_test.info.yml +++ b/tests/modules/oe_list_pages_filters_test/oe_list_pages_filters_test.info.yml @@ -3,7 +3,7 @@ type: module description: The test module for filters of OE List Pages. package: Testing -core_version_requirement: ^9.4 || ^10 +core_version_requirement: ^10 dependencies: - drupal:link From 1acbff2c206d0d17f364ec85ba6cd192b68beb49 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Mon, 12 Feb 2024 17:34:58 +0100 Subject: [PATCH 2/8] EWPP-3953: Behat is not used in the project. --- behat.yml.dist | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 behat.yml.dist diff --git a/behat.yml.dist b/behat.yml.dist deleted file mode 100644 index 511f3474..00000000 --- a/behat.yml.dist +++ /dev/null @@ -1,21 +0,0 @@ -default: - suites: - default: - paths: - - "%paths.base%/tests/features" - contexts: - - Drupal\DrupalExtension\Context\MinkContext - - Drupal\DrupalExtension\Context\DrupalContext - extensions: - Drupal\MinkExtension: - goutte: ~ - selenium2: ~ - ajax_timeout: 10 - javascript_session: selenium2 - base_url: "${drupal.base_url}" - Drupal\DrupalExtension: - api_driver: "drupal" - drupal: - drupal_root: "${drupal.root}" - formatters: - progress: ~ From 6a00849ec7e04f988e924cfa0ede573b0df17121 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Mon, 12 Feb 2024 17:36:41 +0100 Subject: [PATCH 3/8] EWPP-3953: Drupal supports only 6.x for symfony/options-resolver. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 015c797d..8ff53444 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "drupal/facets": "^2.0", "drupal/multivalue_form_element": "^1.0@beta", "drupal/search_api": "^1.27", - "symfony/options-resolver": "^4.4.30 || ^5 || ^6" + "symfony/options-resolver": "^6" }, "require-dev": { "composer/installers": "^1.11", From 685bb4dc4fbd21fa3f00891b9199216a0d2f62e7 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Mon, 12 Feb 2024 17:38:04 +0100 Subject: [PATCH 4/8] EWPP-3953: Fix coding standards. --- .../oe_list_page_content_type/oe_list_page_content_type.install | 2 +- .../oe_list_pages_link_list_displays.module | 2 +- modules/oe_list_pages_link_list_displays/src/ListBuilder.php | 2 +- .../src/ListDisplaySelectionBuilder.php | 2 +- .../src/OeListPagesLinkListDisplaysServiceProvider.php | 2 +- .../src/FunctionalJavascript/ListPageLinkDisplayPluginTest.php | 2 +- .../oe_list_pages_link_list_source.post_update.php | 2 +- .../src/ContextualAwareProcessorInterface.php | 2 +- .../src/ContextualFilterFieldMapper.php | 2 +- .../src/ContextualFilterValuesProcessor.php | 2 +- .../src/ContextualFiltersConfigurationBuilder.php | 2 +- .../src/ContextualFiltersHelper.php | 2 +- .../src/ContextualFiltersUpdater.php | 2 +- .../src/ContextualPresetFilter.php | 2 +- .../src/EventSubscriber/QuerySubscriber.php | 2 +- .../src/Exception/InapplicableContextualFilter.php | 2 +- .../src/Plugin/LinkSource/ListPageLinkSource.php | 2 +- .../src/FunctionalJavascript/ListPageLinkSourcePluginTest.php | 2 +- .../FunctionalJavascript/ListPageLinkSourceTranslationTest.php | 2 +- .../tests/src/Kernel/ListPageLinkSourcePluginTest.php | 2 +- .../oe_list_pages_open_vocabularies.module | 2 +- .../oe_list_pages_open_vocabularies.post_update.php | 2 +- .../src/Event/AssociationFacetUpdateEvent.php | 2 +- .../src/EventSubscriber/AssociationTranslationSubscriber.php | 2 +- .../src/EventSubscriber/SearchApiFacetTestSubscriber.php | 2 +- .../src/FunctionalJavascript/OpenVocabulariesFiltersTest.php | 2 +- .../tests/src/Kernel/ListPagesSearchApiConfiguratorTest.php | 2 +- .../tests/src/Kernel/ListPagesSearchApiConfiguratorTestBase.php | 2 +- .../Kernel/ListPagesSearchApiConfiguratorTranslationTest.php | 2 +- .../tests/src/Traits/OpenVocabularyTestTrait.php | 2 +- oe_list_pages.module | 2 +- oe_list_pages.post_update.php | 2 +- src/Annotation/MultiselectFilterField.php | 2 +- src/BaseHierarchicalHandler.php | 2 +- src/Controller/ListPageRssController.php | 2 +- src/DefaultFilterConfigurationBuilder.php | 2 +- src/EventSubscriber/QuerySubscriber.php | 2 +- src/FilterConfigurationFormBuilderBase.php | 2 +- src/Form/ListFacetsForm.php | 2 +- src/Form/ListPageConfigurationSubForm.php | 2 +- src/Form/ListPageConfigurationSubformFactory.php | 2 +- src/Form/ListPageSortForm.php | 2 +- src/ListBuilder.php | 2 +- src/ListBuilderInterface.php | 2 +- src/ListExecutionManager.php | 2 +- src/ListExecutionManagerInterface.php | 2 +- src/ListExecutionResults.php | 2 +- src/ListExecutionResultsInterface.php | 2 +- src/ListFacetManagerWrapper.php | 2 +- src/ListPageConfiguration.php | 2 +- src/ListPageConfigurationFactoryInterface.php | 2 +- src/ListPageConfigurationSubformInterface.php | 2 +- src/ListPageDisallowSortEvent.php | 2 +- src/ListPageEvents.php | 2 +- src/ListPageRssAlterEvent.php | 2 +- src/ListPageRssItemAlterEvent.php | 2 +- src/ListPageSortAlterEvent.php | 2 +- src/ListPageSortOptionsResolver.php | 2 +- src/ListPageSourceAlterEvent.php | 2 +- src/ListPageWrapper.php | 2 +- src/ListPresetFilter.php | 2 +- src/ListPresetFilterInterface.php | 2 +- src/ListQueryOptions.php | 2 +- src/ListQueryOptionsInterface.php | 2 +- src/ListSource.php | 2 +- src/ListSourceFactory.php | 2 +- src/ListSourceFactoryInterface.php | 2 +- src/ListSourceInterface.php | 2 +- src/MultiSelectFilterFieldPluginBase.php | 2 +- src/MultiselectFilterFieldPluginInterface.php | 2 +- src/MultiselectFilterFieldPluginManager.php | 2 +- src/Plugin/EntityMetaRelation/ListPage.php | 2 +- src/Plugin/ExtraField/Display/ListPageExtraFieldBase.php | 2 +- src/Plugin/ExtraField/Display/ListPageFilters.php | 2 +- src/Plugin/ExtraField/Display/ListPagePagerInfo.php | 2 +- src/Plugin/ExtraField/Display/ListPageResults.php | 2 +- src/Plugin/ExtraField/Display/ListPageRssLink.php | 2 +- src/Plugin/ExtraField/Display/ListPageSelectedFilters.php | 2 +- src/Plugin/ExtraField/Display/ListPageSortElement.php | 2 +- src/Plugin/ExtraField/Display/ListPageTotalCount.php | 2 +- src/Plugin/MultiselectFilterField/BooleanField.php | 2 +- src/Plugin/MultiselectFilterField/EntityReferenceField.php | 2 +- src/Plugin/MultiselectFilterField/LinkField.php | 2 +- src/Plugin/MultiselectFilterField/ListField.php | 2 +- src/Plugin/MultiselectFilterField/StringField.php | 2 +- src/Plugin/facets/facet_source/ListFacetSource.php | 2 +- src/Plugin/facets/facet_source/ListFacetSourceDeriver.php | 2 +- src/Plugin/facets/processor/DateStatusProcessor.php | 2 +- src/Plugin/facets/processor/DefaultStatusProcessorBase.php | 2 +- src/Plugin/facets/processor/DefaultStatusProcessorInterface.php | 2 +- src/Plugin/facets/query_type/Date.php | 2 +- src/Plugin/facets/query_type/DateStatus.php | 2 +- src/Plugin/facets/query_type/Fulltext.php | 2 +- src/Plugin/facets/query_type/HierarchyQueryType.php | 2 +- src/Plugin/facets/widget/DateWidget.php | 2 +- src/Plugin/facets/widget/FulltextWidget.php | 2 +- src/Plugin/facets/widget/HierarchicalMultiselectWidget.php | 2 +- src/Plugin/facets/widget/ListPagesWidgetBase.php | 2 +- src/Plugin/facets/widget/ListPagesWidgetInterface.php | 2 +- src/Plugin/facets/widget/MultiselectWidget.php | 2 +- src/Plugin/search_api/display/ListDisplay.php | 2 +- src/Plugin/search_api/display/ListDisplayDeriver.php | 2 +- src/SkosConceptHierarchicalHandler.php | 2 +- src/TaxonomyTermHierarchicalHandler.php | 2 +- .../src/EventSubscriber/ListPagesTestSubscriber.php | 2 +- .../oe_list_pages_filters_test.install | 2 +- .../src/Controller/FacetsFormTestController.php | 2 +- .../src/Plugin/MultiselectFilterField/FooFacet.php | 2 +- .../src/Plugin/facets/processor/FooFakeFieldProcessor.php | 2 +- .../src/Plugin/search_api/processor/FooFakeField.php | 2 +- .../Plugin/search_api/processor/FooFakeFieldNoContextual.php | 2 +- tests/src/FunctionalJavascript/FacetsFormTest.php | 2 +- tests/src/FunctionalJavascript/ListPageIndexFormTest.php | 2 +- tests/src/FunctionalJavascript/ListPagePluginFormTestBase.php | 2 +- tests/src/FunctionalJavascript/ListPageRssControllerTest.php | 2 +- tests/src/FunctionalJavascript/ListPagesExposedFiltersTest.php | 2 +- tests/src/FunctionalJavascript/ListPagesFiltersTest.php | 2 +- tests/src/FunctionalJavascript/ListPagesPluginTest.php | 2 +- tests/src/FunctionalJavascript/ListPagesPresetFiltersTest.php | 2 +- tests/src/FunctionalJavascript/ListPagesSortTest.php | 2 +- tests/src/Kernel/DateStatusTest.php | 2 +- tests/src/Kernel/DateWidgetTest.php | 2 +- tests/src/Kernel/FulltextWidgetTest.php | 2 +- tests/src/Kernel/HierarchicalMultiSelectWidgetTest.php | 2 +- tests/src/Kernel/ListBuilderTest.php | 2 +- tests/src/Kernel/ListFacetsFormTest.php | 2 +- tests/src/Kernel/ListPageRssAccessTest.php | 2 +- tests/src/Kernel/ListsEntityMetaTest.php | 2 +- tests/src/Kernel/ListsEntityMetaTestBase.php | 2 +- tests/src/Kernel/ListsQueryTest.php | 2 +- tests/src/Kernel/ListsSourceTest.php | 2 +- tests/src/Kernel/ListsSourceTestBase.php | 2 +- tests/src/Kernel/MultiSelectFilterFieldPluginTest.php | 2 +- tests/src/Kernel/MultiSelectWidgetTest.php | 2 +- tests/src/Traits/FacetsTestTrait.php | 2 +- 135 files changed, 135 insertions(+), 135 deletions(-) diff --git a/modules/oe_list_page_content_type/oe_list_page_content_type.install b/modules/oe_list_page_content_type/oe_list_page_content_type.install index 33283dac..d7848489 100644 --- a/modules/oe_list_page_content_type/oe_list_page_content_type.install +++ b/modules/oe_list_page_content_type/oe_list_page_content_type.install @@ -5,7 +5,7 @@ * OE List Page content type install file. */ -declare(strict_types = 1); +declare(strict_types=1); /** * Implements hook_install(). diff --git a/modules/oe_list_pages_link_list_displays/oe_list_pages_link_list_displays.module b/modules/oe_list_pages_link_list_displays/oe_list_pages_link_list_displays.module index ab69ec7c..7bab7730 100644 --- a/modules/oe_list_pages_link_list_displays/oe_list_pages_link_list_displays.module +++ b/modules/oe_list_pages_link_list_displays/oe_list_pages_link_list_displays.module @@ -5,7 +5,7 @@ * The OpenEuropa List Pages Link List Displays module. */ -declare(strict_types = 1); +declare(strict_types=1); use Drupal\Core\Form\FormStateInterface; diff --git a/modules/oe_list_pages_link_list_displays/src/ListBuilder.php b/modules/oe_list_pages_link_list_displays/src/ListBuilder.php index 78ab1290..5170cfe2 100644 --- a/modules/oe_list_pages_link_list_displays/src/ListBuilder.php +++ b/modules/oe_list_pages_link_list_displays/src/ListBuilder.php @@ -1,6 +1,6 @@ Date: Tue, 13 Feb 2024 19:32:06 +0100 Subject: [PATCH 5/8] EWPP-3953: Fix tests. --- .../ListPageLinkDisplayPluginTest.php | 46 ++-- .../ListPageLinkSourcePluginTest.php | 9 +- .../OpenVocabulariesFiltersTest.php | 114 +++++----- .../ListPagePluginFormTestBase.php | 80 ++++--- .../ListPageRssControllerTest.php | 3 +- .../ListPagesExposedFiltersTest.php | 42 ++-- .../ListPagesFiltersTest.php | 209 +++++++++--------- .../ListPagesPresetFiltersTest.php | 88 ++++---- .../ListPagesSortTest.php | 88 +++++--- 9 files changed, 356 insertions(+), 323 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..a978d36e 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,13 @@ public function testListPagePresetFilterValidations(): void { $this->drupalLogin($admin); $this->goToListPageConfiguration(); + + $assert_session = $this->assertSession(); + $page = $this->getSession()->getPage(); + $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]'); } @@ -1218,7 +1225,7 @@ public function testListPageContextualSelfExclusion(): void { */ protected function goToListPageConfiguration(): void { $this->drupalGet('link_list/add/dynamic'); - $this->getSession()->getPage()->selectFieldOption('Link source', 'List page'); + $this->getSession()->getPage()->selectFieldOption('Link source', 'List pages'); $this->assertSession()->assertWaitOnAjaxRequest(); } 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..8ed8be3e 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,16 @@ 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(); + // The form behaves slightly differently when it's rendered as part of the + // link list source plugin. In that scenario, the entity type and bundle are + // not pre-selected. + $entity_type_select = $assert->selectExists('Source entity type'); + if ($entity_type_select->getValue() !== 'node') { + $entity_type_select->selectOption('node'); + $assert->assertWaitOnAjaxRequest(); + } $actual_bundles = $this->getSelectOptions('Source bundle'); $expected_bundles = [ @@ -139,7 +143,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 +156,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 +182,11 @@ 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(); + $entity_type_select = $assert->selectExists('Source entity type'); + if ($entity_type_select->getValue() !== 'node') { + $entity_type_select->selectOption('node'); + $assert->assertWaitOnAjaxRequest(); + } $actual_bundles = $this->getSelectOptions('Source bundle'); $expected_bundles = [ 'content_type_one' => 'Content type one', @@ -187,7 +194,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 +202,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 +349,19 @@ 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(); + // The form behaves slightly differently when it's rendered as part of the + // link list source plugin. In that scenario, the entity type and bundle are + // not pre-selected. + $entity_type_select = $assert->selectExists('Source entity type'); + if ($entity_type_select->getValue() !== 'node') { + $entity_type_select->selectOption('node'); + $assert->assertWaitOnAjaxRequest(); + } + $bundle_select = $assert->selectExists('Source bundle'); + if ($bundle_select->getValue() !== 'content_type_one') { + $bundle_select->selectOption('content_type_one'); + $assert->assertWaitOnAjaxRequest(); + } $expected_set_filters = []; diff --git a/tests/src/FunctionalJavascript/ListPageRssControllerTest.php b/tests/src/FunctionalJavascript/ListPageRssControllerTest.php index 9386421a..041734d3 100644 --- a/tests/src/FunctionalJavascript/ListPageRssControllerTest.php +++ b/tests/src/FunctionalJavascript/ListPageRssControllerTest.php @@ -84,8 +84,7 @@ public function testListPageRssPage(): 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($this->assertSession()->optionExists('Source bundle', 'Content type one')->isSelected()); $page->fillField('Title', 'List page test'); $page->pressButton('Save'); 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)')); + } + } From 3e7629523d9cb74a92ce5fd7c2efd7e06b8e51ea Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Wed, 14 Feb 2024 17:32:38 +0100 Subject: [PATCH 6/8] EWPP-3953: Remove unneeded patch ignore. --- composer.json | 7 ------- 1 file changed, 7 deletions(-) diff --git a/composer.json b/composer.json index 8ff53444..c085dcec 100644 --- a/composer.json +++ b/composer.json @@ -67,13 +67,6 @@ "locations": { "web-root": "./build" } - }, - "patches-ignore": { - "openeuropa/open_vocabularies": { - "drupal/core": { - "Entity display entities are incorrectly unserialized @see https://www.drupal.org/project/drupal/issues/3171333": "https://www.drupal.org/files/issues/2020-09-17/3171333-6.patch" - } - } } }, "config": { From 6bc50e38a1665af3e61900836bcb1cec591cfabc Mon Sep 17 00:00:00 2001 From: nagyad Date: Fri, 16 Feb 2024 14:17:20 +0100 Subject: [PATCH 7/8] EWPP-3953: Fix dependency. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c085dcec..82a866c0 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "drush/drush": "^12", "openeuropa/code-review": "^2.0", "openeuropa/oe_link_lists": "^0.22", - "openeuropa/open_vocabularies": "dev-EWPP-3968", + "openeuropa/open_vocabularies": "^1.0.0-beta2", "openeuropa/rdf_skos": "^1.0.0-alpha10", "openeuropa/task-runner-drupal-project-symlink": "^1.0.0-beta5", "phpspec/prophecy-phpunit": "^2" From 6269f826a683ede2c6cc1bbbf3ce94e509956478 Mon Sep 17 00:00:00 2001 From: nagyad Date: Fri, 16 Feb 2024 14:34:49 +0100 Subject: [PATCH 8/8] EWPP-3953: Fix dependency. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 82a866c0..5bcfff21 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "drupal/inline_entity_form": "^1.0-rc15", "drush/drush": "^12", "openeuropa/code-review": "^2.0", - "openeuropa/oe_link_lists": "^0.22", + "openeuropa/oe_link_lists": "^1.0", "openeuropa/open_vocabularies": "^1.0.0-beta2", "openeuropa/rdf_skos": "^1.0.0-alpha10", "openeuropa/task-runner-drupal-project-symlink": "^1.0.0-beta5",