From a628751ed0b35f319513ad72b1df8ae6595a9429 Mon Sep 17 00:00:00 2001 From: Ali Sarfaraz Date: Thu, 3 Sep 2020 16:17:29 +1000 Subject: [PATCH 01/37] Testing installation of tide automated listing through tide landing page as it requires some alteration of landing page weighting --- composer.json | 8 +++++++- ...de.landing_page.field_landing_page_component.yml | 5 +++++ tide_landing_page.info.yml | 1 + tide_landing_page.install | 13 +++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fe240e1c..519066c8 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,8 @@ "require": { "dpc-sdp/tide_core": "^1.5.8", "dpc-sdp/tide_event": "^1.3.1", - "dpc-sdp/tide_media": "^1.5.1" + "dpc-sdp/tide_media": "^1.5.1", + "dpc-sdp/tide_automated_listing": "dev-feature/SDPA-4541-updates" }, "suggest": { "dpc-sdp/tide_api:^1.2.6": "Allows to use Drupal in headless mode", @@ -17,6 +18,11 @@ "drupal": { "type": "composer", "url": "https://packages.drupal.org/8" + }, + "dpc-sdp/tide_automated_listing": { + "type": "vcs", + "no-api": true, + "url": "https://github.com/dpc-sdp/tide_automated_listing.git" } } } diff --git a/config/install/field.field.node.landing_page.field_landing_page_component.yml b/config/install/field.field.node.landing_page.field_landing_page_component.yml index c7870ced..655b4db0 100644 --- a/config/install/field.field.node.landing_page.field_landing_page_component.yml +++ b/config/install/field.field.node.landing_page.field_landing_page_component.yml @@ -5,6 +5,7 @@ dependencies: - field.storage.node.field_landing_page_component - node.type.landing_page - paragraphs.paragraphs_type.accordion + - paragraphs.paragraphs_type.automated_card_listing - paragraphs.paragraphs_type.basic_text - paragraphs.paragraphs_type.call_to_action - paragraphs.paragraphs_type.card_carousel @@ -59,6 +60,7 @@ settings: card_carousel: card_carousel timelines: timelines news_listing: news_listing + automated_card_listing: automated_card_listing target_bundles_drag_drop: banner: weight: -33 @@ -69,6 +71,9 @@ settings: accordion: enabled: true weight: -31 + automated_card_listing: + enabled: true + weight: -30 card_event: enabled: true weight: -30 diff --git a/tide_landing_page.info.yml b/tide_landing_page.info.yml index c0381b6a..fdc02cb1 100644 --- a/tide_landing_page.info.yml +++ b/tide_landing_page.info.yml @@ -17,6 +17,7 @@ dependencies: - dpc-sdp:tide_core - dpc-sdp:tide_event - dpc-sdp:tide_media + - dpc-sdp:tide_automated_listing - address:address - entity_reference_revisions:entity_reference_revisions - field_group:field_group diff --git a/tide_landing_page.install b/tide_landing_page.install index 35f1d962..bf4e1a89 100644 --- a/tide_landing_page.install +++ b/tide_landing_page.install @@ -1111,3 +1111,16 @@ function tide_landing_page_update_8028() { $config->set('label', 'Form embed (Drupal)'); $config->save(); } + +/** + * Add the new paragraph type tide_automated_listing. + */ +function tide_landing_page_update_8029() { + module_load_include('inc', 'tide_core', 'includes/helpers'); + $config_location = [drupal_get_path('module', 'tide_landing_page') . '/config/install']; + $config_storage = \Drupal::service('config.storage'); + + // Check if field already exported to config/sync. + $config_read = _tide_read_config('field.field.node.landing_page.field_landing_page_component', $config_location, TRUE); + $config_storage->write('field.field.node.landing_page.field_landing_page_component', $config_read); +} From 94369125ed3548a61ce697481d0780856512fae7 Mon Sep 17 00:00:00 2001 From: Ali Sarfaraz Date: Thu, 3 Sep 2020 16:45:07 +1000 Subject: [PATCH 02/37] Updated composer.json to remove automated card listing --- composer.json | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 519066c8..fe240e1c 100644 --- a/composer.json +++ b/composer.json @@ -6,8 +6,7 @@ "require": { "dpc-sdp/tide_core": "^1.5.8", "dpc-sdp/tide_event": "^1.3.1", - "dpc-sdp/tide_media": "^1.5.1", - "dpc-sdp/tide_automated_listing": "dev-feature/SDPA-4541-updates" + "dpc-sdp/tide_media": "^1.5.1" }, "suggest": { "dpc-sdp/tide_api:^1.2.6": "Allows to use Drupal in headless mode", @@ -18,11 +17,6 @@ "drupal": { "type": "composer", "url": "https://packages.drupal.org/8" - }, - "dpc-sdp/tide_automated_listing": { - "type": "vcs", - "no-api": true, - "url": "https://github.com/dpc-sdp/tide_automated_listing.git" } } } From 9084dad0b8fad80131e7bd1928d3e56e500fb86d Mon Sep 17 00:00:00 2001 From: Ali Sarfaraz Date: Fri, 4 Sep 2020 09:52:07 +1000 Subject: [PATCH 03/37] Added tide_automated_listing as a dependency of landing page display so that tide_automated_listing is installed first before the config can be activated --- composer.json | 8 +++++++- ...eld.node.landing_page.field_landing_page_component.yml | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fe240e1c..519066c8 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,8 @@ "require": { "dpc-sdp/tide_core": "^1.5.8", "dpc-sdp/tide_event": "^1.3.1", - "dpc-sdp/tide_media": "^1.5.1" + "dpc-sdp/tide_media": "^1.5.1", + "dpc-sdp/tide_automated_listing": "dev-feature/SDPA-4541-updates" }, "suggest": { "dpc-sdp/tide_api:^1.2.6": "Allows to use Drupal in headless mode", @@ -17,6 +18,11 @@ "drupal": { "type": "composer", "url": "https://packages.drupal.org/8" + }, + "dpc-sdp/tide_automated_listing": { + "type": "vcs", + "no-api": true, + "url": "https://github.com/dpc-sdp/tide_automated_listing.git" } } } diff --git a/config/install/field.field.node.landing_page.field_landing_page_component.yml b/config/install/field.field.node.landing_page.field_landing_page_component.yml index 655b4db0..dc6dadb8 100644 --- a/config/install/field.field.node.landing_page.field_landing_page_component.yml +++ b/config/install/field.field.node.landing_page.field_landing_page_component.yml @@ -25,6 +25,7 @@ dependencies: - paragraphs.paragraphs_type.timelines module: - entity_reference_revisions + - tide_automated_listing id: node.landing_page.field_landing_page_component field_name: field_landing_page_component entity_type: node From 2b0faf174859062dfca96ae3df71ce91122708bc Mon Sep 17 00:00:00 2001 From: Ali Sarfaraz Date: Fri, 4 Sep 2020 15:26:54 +1000 Subject: [PATCH 04/37] Added install task for tide_automated_listing --- tide_landing_page.install | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tide_landing_page.install b/tide_landing_page.install index bf4e1a89..9833a84a 100644 --- a/tide_landing_page.install +++ b/tide_landing_page.install @@ -1116,6 +1116,11 @@ function tide_landing_page_update_8028() { * Add the new paragraph type tide_automated_listing. */ function tide_landing_page_update_8029() { + $result = \Drupal::service('module_installer')->install(['tide_automated_listing']); + if (!$result) { + throw new \Exception(sprintf('Unable to install module %s', 'tide_automated_listing')); + } + module_load_include('inc', 'tide_core', 'includes/helpers'); $config_location = [drupal_get_path('module', 'tide_landing_page') . '/config/install']; $config_storage = \Drupal::service('config.storage'); From d277abb07750d013e01f24984acea310f0314036 Mon Sep 17 00:00:00 2001 From: Ali Sarfaraz Date: Mon, 7 Sep 2020 09:34:18 +1000 Subject: [PATCH 05/37] Updated code to look for automated card module before inserting programtically created fields for automated card listing widget --- tide_landing_page.module | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tide_landing_page.module b/tide_landing_page.module index 5212f676..14e7bdab 100644 --- a/tide_landing_page.module +++ b/tide_landing_page.module @@ -57,7 +57,9 @@ function tide_landing_page_entity_bundle_create($entity_type_id, $bundle) { $is_featured_news = ($bundle == 'featured_news' && $moduleHandler->moduleExists('tide_news')); $is_embedded_webform = ($bundle == 'embedded_webform' && $moduleHandler->moduleExists('tide_webform')); - if ($is_featured_news || $is_embedded_webform) { + $is_automated_listing = ($bundle == 'automated_card_listing' && $moduleHandler->moduleExists('tide_automated_listing')); + + if ($is_featured_news || $is_embedded_webform || $is_automated_listing) { $handler_settings['target_bundles'][$bundle] = $bundle; $field_config->setSetting('handler_settings', $handler_settings); $field_config->save(); From d3608c7c4b3db6505c3e54d2e7aacb915462d5c8 Mon Sep 17 00:00:00 2001 From: Ali Sarfaraz Date: Mon, 7 Sep 2020 11:35:12 +1000 Subject: [PATCH 06/37] Added behat tests to support automated card listing --- tests/behat/features/fields.feature | 90 +++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/tests/behat/features/fields.feature b/tests/behat/features/fields.feature index 9fcbdea2..eb5353c3 100644 --- a/tests/behat/features/fields.feature +++ b/tests/behat/features/fields.feature @@ -11,6 +11,8 @@ Feature: Fields for Landing Page content type Then I see field "Title" And I should see an "input#edit-title-0-value.required" element + And I should see "Card collection" in the "select[name='field_landing_page_component[add_more][add_more_select]']" element + And the "#edit-field-featured-image" element should contain "Feature Image" And I should see an "input#edit-field-featured-image-entity-browser-entity-browser-open-modal" element @@ -218,3 +220,91 @@ Feature: Fields for Landing Page content type And I see field "Background Colour" And I should see an "select#edit-field-landing-page-bg-colour" element And I should see an "select#edit-field-landing-page-bg-colour.required" element + + @api @javascript @jsonapi + Scenario: Request a landing page with an automated listing component via API + Given vocabulary "sites" with name "Sites" exists + And sites terms: + | name | parent | tid | + | Test Site | 0 | 10001 | + + Given vocabulary "topic" with name "Topic" exists + And topic terms: + | name | parent | + | Test Topic | 0 | + + Given landing_page content: + | title | path | moderation_state | uuid | field_topic | field_node_site | field_node_primary_site | field_landing_page_summary | field_landing_page_bg_colour | + | [TEST] Landing Page title | /test-landing-page-alias | published | 99999999-aaaa-bbbb-ccc-000000000000 | Test Topic | Test Site | Test Site | Test Summary | White | + + Given I am logged in as a user with the "Administrator" role + When I edit landing_page "[TEST] Landing Page title" + And I click on link with href "#edit-group-components" + + And I select "Card collection" from "edit-field-landing-page-component-add-more-add-more-select" + And I press the "edit-field-landing-page-component-add-more-add-more-button" button + Then I wait for AJAX to finish + + Then I fill in "Listing Title" with "Test Automated Listing" + + Then I click on the horizontal tab "Result settings" + And I fill in "Maximum results to show" with "9" + And I select the radio button "Show 'no results' message" + + Then I click on the horizontal tab "Display settings" + And I select "Grid" from "Display as" + And I fill in "Items per page" with "9" + And I select "Changed" from "Card Date field mapping" + And I check the box "Topic" + And I check the box "Location" + + Then I click on the horizontal tab "Filter criteria" + # And I click on the detail "Content type" + And I check the box "Landing Page" + + Then I click on the horizontal tab "Sort criteria" + And I select "Changed" from "Sort by" + And I select "Ascending" from "Sort order" + + Then I select "Published" from "Change to" + And I press the "Save" button + + Given I am an anonymous user + When I send a GET request to "api/v1/node/landing_page/99999999-aaaa-bbbb-ccc-000000000000?site=10001&include=field_landing_page_component" + Then the rest response status code should be 200 + And the response should be in JSON + And the JSON node "data" should exist + And the JSON node "included" should exist + And the JSON node "included" should have 1 element + And the JSON node "included[0].type" should be equal to "paragraph--automated_card_listing" + And the JSON node "included[0].attributes" should exist + And the JSON node "included[0].attributes.field_paragraph_title" should be equal to "Test Automated Listing" + And the JSON node "included[0].attributes.field_paragraph_auto_listing" should exist + + And the JSON node "included[0].attributes.field_paragraph_auto_listing.results.min" should be equal to "0" + And the JSON node "included[0].attributes.field_paragraph_auto_listing.results.max" should be equal to "9" + And the JSON node "included[0].attributes.field_paragraph_auto_listing.results.min_not_met" should be equal to "no_results_message" + And the JSON node "included[0].attributes.field_paragraph_auto_listing.results.no_results_message" should be equal to "There are currently no results" + + And the JSON node "included[0].attributes.field_paragraph_auto_listing.display.type" should be equal to "grid" + And the JSON node "included[0].attributes.field_paragraph_auto_listing.display.items_per_page" should be equal to "9" + + And the JSON node "included[0].attributes.field_paragraph_auto_listing.card_display.date" should be equal to "changed" + And the JSON node "included[0].attributes.field_paragraph_auto_listing.card_display.hide.image" should be equal to "false" + And the JSON node "included[0].attributes.field_paragraph_auto_listing.card_display.hide.title" should be equal to "false" + And the JSON node "included[0].attributes.field_paragraph_auto_listing.card_display.hide.summary" should be equal to "false" + And the JSON node "included[0].attributes.field_paragraph_auto_listing.card_display.hide.topic" should be equal to "true" + And the JSON node "included[0].attributes.field_paragraph_auto_listing.card_display.hide.location" should be equal to "true" + + And the JSON node "included[0].attributes.field_paragraph_auto_listing.filter_operator" should be equal to "AND" + + And the JSON node "included[0].attributes.field_paragraph_auto_listing.filter_today.status" should be equal to "false" + + And the JSON array node "included[0].attributes.field_paragraph_auto_listing.filters.type.values" should contain "landing_page" element + And the JSON node "included[0].attributes.field_paragraph_auto_listing.filters.type.operator" should be equal to "OR" + + And the JSON array node "included[0].attributes.field_paragraph_auto_listing.filters.field_topic" should have 0 elements + And the JSON array node "included[0].attributes.field_paragraph_auto_listing.filters.field_tags" should have 0 elements + + And the JSON node "included[0].attributes.field_paragraph_auto_listing.sort.field" should be equal to "changed" + And the JSON node "included[0].attributes.field_paragraph_auto_listing.sort.direction" should be equal to "asc" \ No newline at end of file From 45905c6c9a439218085da9daae42ceb4ba3cb1fd Mon Sep 17 00:00:00 2001 From: Ali Sarfaraz Date: Mon, 7 Sep 2020 15:14:32 +1000 Subject: [PATCH 07/37] Fixed behat tests to support creation of automated card listing component for a landing page --- tests/behat/features/fields.feature | 39 ++++++++--------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/tests/behat/features/fields.feature b/tests/behat/features/fields.feature index eb5353c3..4fef4e4f 100644 --- a/tests/behat/features/fields.feature +++ b/tests/behat/features/fields.feature @@ -223,19 +223,14 @@ Feature: Fields for Landing Page content type @api @javascript @jsonapi Scenario: Request a landing page with an automated listing component via API - Given vocabulary "sites" with name "Sites" exists - And sites terms: - | name | parent | tid | - | Test Site | 0 | 10001 | - Given vocabulary "topic" with name "Topic" exists And topic terms: | name | parent | | Test Topic | 0 | Given landing_page content: - | title | path | moderation_state | uuid | field_topic | field_node_site | field_node_primary_site | field_landing_page_summary | field_landing_page_bg_colour | - | [TEST] Landing Page title | /test-landing-page-alias | published | 99999999-aaaa-bbbb-ccc-000000000000 | Test Topic | Test Site | Test Site | Test Summary | White | + | title | path | moderation_state | uuid | field_topic | field_node_primary_site | field_landing_page_summary | field_landing_page_bg_colour | + | [TEST] Landing Page title | /test-landing-page-alias | published | 99999999-aaaa-bbbb-ccc-000000000000 | Test Topic | Test Site | Test Summary | White | Given I am logged in as a user with the "Administrator" role When I edit landing_page "[TEST] Landing Page title" @@ -247,22 +242,12 @@ Feature: Fields for Landing Page content type Then I fill in "Listing Title" with "Test Automated Listing" - Then I click on the horizontal tab "Result settings" - And I fill in "Maximum results to show" with "9" - And I select the radio button "Show 'no results' message" - - Then I click on the horizontal tab "Display settings" - And I select "Grid" from "Display as" - And I fill in "Items per page" with "9" + Then I click on the horizontal tab "Display options" + And I fill in "Cards shown per page" with "9" And I select "Changed" from "Card Date field mapping" + And I select the radio button "Show 'no results' message" And I check the box "Topic" And I check the box "Location" - - Then I click on the horizontal tab "Filter criteria" - # And I click on the detail "Content type" - And I check the box "Landing Page" - - Then I click on the horizontal tab "Sort criteria" And I select "Changed" from "Sort by" And I select "Ascending" from "Sort order" @@ -270,7 +255,7 @@ Feature: Fields for Landing Page content type And I press the "Save" button Given I am an anonymous user - When I send a GET request to "api/v1/node/landing_page/99999999-aaaa-bbbb-ccc-000000000000?site=10001&include=field_landing_page_component" + When I send a GET request to "api/v1/node/landing_page/99999999-aaaa-bbbb-ccc-000000000000?include=field_landing_page_component" Then the rest response status code should be 200 And the response should be in JSON And the JSON node "data" should exist @@ -281,13 +266,11 @@ Feature: Fields for Landing Page content type And the JSON node "included[0].attributes.field_paragraph_title" should be equal to "Test Automated Listing" And the JSON node "included[0].attributes.field_paragraph_auto_listing" should exist - And the JSON node "included[0].attributes.field_paragraph_auto_listing.results.min" should be equal to "0" - And the JSON node "included[0].attributes.field_paragraph_auto_listing.results.max" should be equal to "9" And the JSON node "included[0].attributes.field_paragraph_auto_listing.results.min_not_met" should be equal to "no_results_message" And the JSON node "included[0].attributes.field_paragraph_auto_listing.results.no_results_message" should be equal to "There are currently no results" - And the JSON node "included[0].attributes.field_paragraph_auto_listing.display.type" should be equal to "grid" - And the JSON node "included[0].attributes.field_paragraph_auto_listing.display.items_per_page" should be equal to "9" + And the JSON node "included[0].attributes.field_paragraph_auto_listing.display.type" should be equal to "carousel" + And the JSON node "included[0].attributes.field_paragraph_auto_listing.display.items" should be equal to "9" And the JSON node "included[0].attributes.field_paragraph_auto_listing.card_display.date" should be equal to "changed" And the JSON node "included[0].attributes.field_paragraph_auto_listing.card_display.hide.image" should be equal to "false" @@ -300,11 +283,9 @@ Feature: Fields for Landing Page content type And the JSON node "included[0].attributes.field_paragraph_auto_listing.filter_today.status" should be equal to "false" - And the JSON array node "included[0].attributes.field_paragraph_auto_listing.filters.type.values" should contain "landing_page" element + And the JSON node "included[0].attributes.field_paragraph_auto_listing.content_type" should be equal to "event" + And the JSON node "included[0].attributes.field_paragraph_auto_listing.filters.type.values" should be equal to "event" And the JSON node "included[0].attributes.field_paragraph_auto_listing.filters.type.operator" should be equal to "OR" - And the JSON array node "included[0].attributes.field_paragraph_auto_listing.filters.field_topic" should have 0 elements - And the JSON array node "included[0].attributes.field_paragraph_auto_listing.filters.field_tags" should have 0 elements - And the JSON node "included[0].attributes.field_paragraph_auto_listing.sort.field" should be equal to "changed" And the JSON node "included[0].attributes.field_paragraph_auto_listing.sort.direction" should be equal to "asc" \ No newline at end of file From b3d268d34b990be9330ecbe83b2a0fd22ed417e3 Mon Sep 17 00:00:00 2001 From: Ali Sarfaraz Date: Mon, 7 Sep 2020 15:32:28 +1000 Subject: [PATCH 08/37] Added more functions to tide common trait to enhance behat tests --- tests/behat/bootstrap/TideCommonTrait.php | 133 ++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 tests/behat/bootstrap/TideCommonTrait.php diff --git a/tests/behat/bootstrap/TideCommonTrait.php b/tests/behat/bootstrap/TideCommonTrait.php new file mode 100644 index 00000000..9ac88842 --- /dev/null +++ b/tests/behat/bootstrap/TideCommonTrait.php @@ -0,0 +1,133 @@ +getSession()->getCurrentUrl(); + $current_path = parse_url($current_path, PHP_URL_PATH); + $current_path = ltrim($current_path, '/'); + $current_path = $current_path == '' ? '' : $current_path; + + if ($current_path != $path) { + throw new \Exception(sprintf('Current path is "%s", but expected is "%s"', $current_path, $path)); + } + } + + /** + * Creates and authenticates a user with the given role(s). + * + * @Given I am logged in as a user with the :role role(s) + * @Given I am logged in as a/an :role + */ + public function assertAuthenticatedByRole($role) { + // Override parent assertion to allow using 'anonymous user' role without + // actually creating a user with role. By default, + // assertAuthenticatedByRole() will create a user with 'authenticated role' + // even if 'anonymous user' role is provided. + if ($role == 'anonymous user') { + if (!empty($this->loggedInUser)) { + $this->logout(); + } + } + else { + parent::assertAuthenticatedByRole($role); + } + } + + /** + * @Then I wait for :sec second(s) + */ + public function waitForSeconds($sec) { + sleep($sec); + } + + /** + * Wait for AJAX to finish. + * + * @see \Drupal\FunctionalJavascriptTests\JSWebAssert::assertWaitOnAjaxRequest() + * + * @Given I wait :timeout seconds for AJAX to finish + */ + public function iWaitForAjaxToFinish($timeout) { + $condition = <<getSession()->wait($timeout * 1000, $condition); + if (!$result) { + throw new \RuntimeException('Unable to complete AJAX request.'); + } + } + + /** + * @Given no :type content type + */ + public function removeContentType($type) { + $content_type_entity = \Drupal::entityManager()->getStorage('node_type')->load($type); + if ($content_type_entity) { + $content_type_entity->delete(); + } + } + + /** + * @Then /^I click on link with href "([^"]*)"$/ + * @param string $href + */ + public function clickOnLinkWithHref($href) { + $page = $this->getSession()->getPage(); + $link = $page->find('xpath', '//a[@href="' . $href . '"]'); + if ($link === NULL) { + throw new \Exception('Link with href "' . $href . '" not found.'); + } + $link->click(); + } + + /** + * @Then /^I click on the horizontal tab "([^"]*)"$/ + * @param string $text + */ + public function clickOnHorzTab($text) { + $page = $this->getSession()->getPage(); + $link = $page->find('xpath', '//ul[contains(@class, "horizontal-tabs-list")]/li[contains(@class, "horizontal-tab-button")]/a/strong[text()="' . $text . '"]'); + if ($link === NULL) { + throw new \Exception('The horizontal tab with text "' . $text . '" not found.'); + } + $link->click(); + } + + /** + * @Then /^I click on the detail "([^"]*)"$/ + * @param string $text + */ + public function clickOnDetail($text) { + $page = $this->getSession()->getPage(); + $link = $page->find('xpath', '//div[contains(@class, "details-wrapper")]/details/summary[text()="' . $text . '"]'); + if ($link === NULL) { + throw new \Exception('The detail with text "' . $text . '" not found.'); + } + $link->click(); + } + +} From 6266bb07d7013dc89869a351766b1cffa45cd514 Mon Sep 17 00:00:00 2001 From: Ali Sarfaraz Date: Mon, 7 Sep 2020 16:41:53 +1000 Subject: [PATCH 09/37] Fixed code snif issue regarding parameter comment --- tests/behat/bootstrap/TideCommonTrait.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/behat/bootstrap/TideCommonTrait.php b/tests/behat/bootstrap/TideCommonTrait.php index 9ac88842..3d919215 100644 --- a/tests/behat/bootstrap/TideCommonTrait.php +++ b/tests/behat/bootstrap/TideCommonTrait.php @@ -93,7 +93,6 @@ public function removeContentType($type) { /** * @Then /^I click on link with href "([^"]*)"$/ - * @param string $href */ public function clickOnLinkWithHref($href) { $page = $this->getSession()->getPage(); @@ -106,7 +105,6 @@ public function clickOnLinkWithHref($href) { /** * @Then /^I click on the horizontal tab "([^"]*)"$/ - * @param string $text */ public function clickOnHorzTab($text) { $page = $this->getSession()->getPage(); @@ -119,7 +117,6 @@ public function clickOnHorzTab($text) { /** * @Then /^I click on the detail "([^"]*)"$/ - * @param string $text */ public function clickOnDetail($text) { $page = $this->getSession()->getPage(); From 187df71f84f81ec88af2ac89da1d307b58652618 Mon Sep 17 00:00:00 2001 From: Ali Sarfaraz Date: Tue, 29 Sep 2020 16:05:08 +1000 Subject: [PATCH 10/37] Updated hook number --- tide_landing_page.install | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tide_landing_page.install b/tide_landing_page.install index a34a29ee..2a64fcf9 100644 --- a/tide_landing_page.install +++ b/tide_landing_page.install @@ -1269,17 +1269,24 @@ function tide_landing_page_update_8032() { /** * Add the new paragraph type tide_automated_listing. */ -function tide_landing_page_update_8029() { +function tide_landing_page_update_8033() { $result = \Drupal::service('module_installer')->install(['tide_automated_listing']); if (!$result) { throw new \Exception(sprintf('Unable to install module %s', 'tide_automated_listing')); } + $configs = [ + 'field.field.node.landing_page.field_landing_page_component' => 'field_config', + ]; + module_load_include('inc', 'tide_core', 'includes/helpers'); $config_location = [drupal_get_path('module', 'tide_landing_page') . '/config/install']; - $config_storage = \Drupal::service('config.storage'); // Check if field already exported to config/sync. - $config_read = _tide_read_config('field.field.node.landing_page.field_landing_page_component', $config_location, TRUE); - $config_storage->write('field.field.node.landing_page.field_landing_page_component', $config_read); + foreach ($configs as $config => $type) { + $config_read = _tide_read_config($config, $config_location, TRUE); + $storage = \Drupal::entityTypeManager()->getStorage($type); + $config_entity = $storage->createFromStorageRecord($config_read); + $config_entity->save(); + } } From a6caa394abf1dd0dbad35da9a4fc28bf6cfc70f4 Mon Sep 17 00:00:00 2001 From: Ali Sarfaraz Date: Thu, 8 Oct 2020 09:30:21 +1100 Subject: [PATCH 11/37] Updated landing page component installation hook --- tide_landing_page.install | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/tide_landing_page.install b/tide_landing_page.install index 2a64fcf9..d31fb3c4 100644 --- a/tide_landing_page.install +++ b/tide_landing_page.install @@ -1275,18 +1275,10 @@ function tide_landing_page_update_8033() { throw new \Exception(sprintf('Unable to install module %s', 'tide_automated_listing')); } - $configs = [ - 'field.field.node.landing_page.field_landing_page_component' => 'field_config', - ]; - module_load_include('inc', 'tide_core', 'includes/helpers'); $config_location = [drupal_get_path('module', 'tide_landing_page') . '/config/install']; + $config_storage = \Drupal::service('config.storage'); - // Check if field already exported to config/sync. - foreach ($configs as $config => $type) { - $config_read = _tide_read_config($config, $config_location, TRUE); - $storage = \Drupal::entityTypeManager()->getStorage($type); - $config_entity = $storage->createFromStorageRecord($config_read); - $config_entity->save(); - } + $config_read = _tide_read_config('field.field.node.landing_page.field_landing_page_component', $config_location, TRUE); + $config_storage->write('field.field.node.landing_page.field_landing_page_component', $config_read); } From 85df574b702efedd2573e0bb49f038a82117c058 Mon Sep 17 00:00:00 2001 From: Ali Sarfaraz Date: Thu, 8 Oct 2020 11:26:42 +1100 Subject: [PATCH 12/37] Updated behat test to reflect new additions to the tide automated listing module --- tests/behat/features/access.feature | 1 - tests/behat/features/fields.feature | 27 +++++++++------------------ 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/tests/behat/features/access.feature b/tests/behat/features/access.feature index 289444da..4afbab5b 100644 --- a/tests/behat/features/access.feature +++ b/tests/behat/features/access.feature @@ -9,7 +9,6 @@ Feature: Access to Landing Page content type Given I am logged in as a user with the "" role When I go to "node/add/landing_page" Then I should get a "" HTTP response - And save screenshot Examples: | role | response | | authenticated user | 404 | diff --git a/tests/behat/features/fields.feature b/tests/behat/features/fields.feature index f029d5d3..4c03170d 100644 --- a/tests/behat/features/fields.feature +++ b/tests/behat/features/fields.feature @@ -7,7 +7,6 @@ Feature: Fields for Landing Page content type Scenario: The content type has the expected fields (and labels where we can use them). Given I am logged in as a user with the "create landing_page content" permission When I visit "node/add/landing_page" - And save screenshot Then I see field "Title" And I should see an "input#edit-title-0-value.required" element @@ -128,7 +127,6 @@ Feature: Fields for Landing Page content type Scenario: The content type has the expected fields (and labels where we can use them) including from suggested modules. Given I am logged in as a user with the "create landing_page content" permission When I visit "node/add/landing_page" - And save screenshot Then I see field "Title" And I should see an "input#edit-title-0-value.required" element @@ -251,13 +249,12 @@ Feature: Fields for Landing Page content type Then I wait for AJAX to finish Then I fill in "Listing Title" with "Test Automated Listing" + And I check the box "Landing Page" Then I click on the horizontal tab "Display options" - And I fill in "Cards shown per page" with "9" - And I select "Changed" from "Card Date field mapping" + And I fill in "Minimum results to show" with "2" + And I fill in "Number of cards shown per page" with "9" And I select the radio button "Show 'no results' message" - And I check the box "Topic" - And I check the box "Location" And I select "Changed" from "Sort by" And I select "Ascending" from "Sort order" @@ -265,7 +262,7 @@ Feature: Fields for Landing Page content type And I press the "Save" button Given I am an anonymous user - When I send a GET request to "api/v1/node/landing_page/99999999-aaaa-bbbb-ccc-000000000000?include=field_landing_page_component" + When I send a GET request to "/api/v1/node/landing_page/99999999-aaaa-bbbb-ccc-000000000000?include=field_landing_page_component" Then the rest response status code should be 200 And the response should be in JSON And the JSON node "data" should exist @@ -279,22 +276,16 @@ Feature: Fields for Landing Page content type And the JSON node "included[0].attributes.field_paragraph_auto_listing.results.min_not_met" should be equal to "no_results_message" And the JSON node "included[0].attributes.field_paragraph_auto_listing.results.no_results_message" should be equal to "There are currently no results" - And the JSON node "included[0].attributes.field_paragraph_auto_listing.display.type" should be equal to "carousel" + And the JSON node "included[0].attributes.field_paragraph_auto_listing.display.type" should be equal to "grid" And the JSON node "included[0].attributes.field_paragraph_auto_listing.display.items" should be equal to "9" + And the JSON node "included[0].attributes.field_paragraph_auto_listing.display.min" should be equal to "2" - And the JSON node "included[0].attributes.field_paragraph_auto_listing.card_display.date" should be equal to "changed" - And the JSON node "included[0].attributes.field_paragraph_auto_listing.card_display.hide.image" should be equal to "false" - And the JSON node "included[0].attributes.field_paragraph_auto_listing.card_display.hide.title" should be equal to "false" - And the JSON node "included[0].attributes.field_paragraph_auto_listing.card_display.hide.summary" should be equal to "false" - And the JSON node "included[0].attributes.field_paragraph_auto_listing.card_display.hide.topic" should be equal to "true" - And the JSON node "included[0].attributes.field_paragraph_auto_listing.card_display.hide.location" should be equal to "true" - - And the JSON node "included[0].attributes.field_paragraph_auto_listing.filter_operator" should be equal to "AND" + And the JSON node "included[0].attributes.field_paragraph_auto_listing.filter_operator" should be equal to "OR" And the JSON node "included[0].attributes.field_paragraph_auto_listing.filter_today.status" should be equal to "false" - And the JSON node "included[0].attributes.field_paragraph_auto_listing.content_type" should be equal to "event" - And the JSON node "included[0].attributes.field_paragraph_auto_listing.filters.type.values" should be equal to "event" + And the JSON node "included[0].attributes.field_paragraph_auto_listing.content_type[0]" should be equal to "landing_page" + And the JSON node "included[0].attributes.field_paragraph_auto_listing.filters.type.values[0]" should be equal to "landing_page" And the JSON node "included[0].attributes.field_paragraph_auto_listing.filters.type.operator" should be equal to "OR" And the JSON node "included[0].attributes.field_paragraph_auto_listing.sort.field" should be equal to "changed" From 9848b3e72f7fb2086553052e7d6807f11c1577e4 Mon Sep 17 00:00:00 2001 From: Ali Sarfaraz Date: Thu, 8 Oct 2020 11:45:22 +1100 Subject: [PATCH 13/37] Experimenting with having tide automated module as suggested module instead of direct dependency --- composer.json | 6 +++--- ...field.node.landing_page.field_landing_page_component.yml | 6 ------ tests/behat/features/fields.feature | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 43bbece1..fa247684 100644 --- a/composer.json +++ b/composer.json @@ -6,13 +6,13 @@ "require": { "dpc-sdp/tide_core": "^1.6.11", "dpc-sdp/tide_event": "^1.3.1", - "dpc-sdp/tide_media": "^1.5.1", - "dpc-sdp/tide_automated_listing": "dev-feature/SDPA-4541-updates" + "dpc-sdp/tide_media": "^1.5.1" }, "suggest": { "dpc-sdp/tide_api:^1.2.6": "Allows to use Drupal in headless mode", "dpc-sdp/tide_webform:^1.2.4": "Allows to use questionnaires", - "dpc-sdp/tide_news:^1.1.5": "News content type and related configuration for Tide Drupal 8 distribution" + "dpc-sdp/tide_news:^1.1.5": "News content type and related configuration for Tide Drupal 8 distribution", + "dpc-sdp/tide_automated_listing:dev-feature/SDPA-4541-updates": "Allows to use tide automated listing" }, "repositories": { "drupal": { diff --git a/config/install/field.field.node.landing_page.field_landing_page_component.yml b/config/install/field.field.node.landing_page.field_landing_page_component.yml index dc6dadb8..c7870ced 100644 --- a/config/install/field.field.node.landing_page.field_landing_page_component.yml +++ b/config/install/field.field.node.landing_page.field_landing_page_component.yml @@ -5,7 +5,6 @@ dependencies: - field.storage.node.field_landing_page_component - node.type.landing_page - paragraphs.paragraphs_type.accordion - - paragraphs.paragraphs_type.automated_card_listing - paragraphs.paragraphs_type.basic_text - paragraphs.paragraphs_type.call_to_action - paragraphs.paragraphs_type.card_carousel @@ -25,7 +24,6 @@ dependencies: - paragraphs.paragraphs_type.timelines module: - entity_reference_revisions - - tide_automated_listing id: node.landing_page.field_landing_page_component field_name: field_landing_page_component entity_type: node @@ -61,7 +59,6 @@ settings: card_carousel: card_carousel timelines: timelines news_listing: news_listing - automated_card_listing: automated_card_listing target_bundles_drag_drop: banner: weight: -33 @@ -72,9 +69,6 @@ settings: accordion: enabled: true weight: -31 - automated_card_listing: - enabled: true - weight: -30 card_event: enabled: true weight: -30 diff --git a/tests/behat/features/fields.feature b/tests/behat/features/fields.feature index 4c03170d..5a0e8bda 100644 --- a/tests/behat/features/fields.feature +++ b/tests/behat/features/fields.feature @@ -229,7 +229,7 @@ Feature: Fields for Landing Page content type And I should see an "select#edit-field-landing-page-bg-colour" element And I should see an "select#edit-field-landing-page-bg-colour.required" element - @api @javascript @jsonapi + @api @javascript @jsonapi @suggest Scenario: Request a landing page with an automated listing component via API Given vocabulary "topic" with name "Topic" exists And topic terms: From 78bb14551250d76cb81b61de7aa79af739c16057 Mon Sep 17 00:00:00 2001 From: Ali Sarfaraz Date: Thu, 8 Oct 2020 11:55:52 +1100 Subject: [PATCH 14/37] Experimenting with having tide automated module as suggested module instead of direct dependency --- tide_landing_page.info.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/tide_landing_page.info.yml b/tide_landing_page.info.yml index 78d1483f..748b1da5 100644 --- a/tide_landing_page.info.yml +++ b/tide_landing_page.info.yml @@ -17,7 +17,6 @@ dependencies: - dpc-sdp:tide_core - dpc-sdp:tide_event - dpc-sdp:tide_media - - dpc-sdp:tide_automated_listing - address:address - entity_reference_revisions:entity_reference_revisions - field_group:field_group From 7c75ce01f9f92df966eccb8245a194a2bc70a3bb Mon Sep 17 00:00:00 2001 From: Ali Sarfaraz Date: Thu, 8 Oct 2020 12:08:59 +1100 Subject: [PATCH 15/37] Experimenting with having tide automated module as suggested module instead of direct dependency --- tests/behat/features/fields.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/behat/features/fields.feature b/tests/behat/features/fields.feature index 5a0e8bda..ba37a38e 100644 --- a/tests/behat/features/fields.feature +++ b/tests/behat/features/fields.feature @@ -229,7 +229,7 @@ Feature: Fields for Landing Page content type And I should see an "select#edit-field-landing-page-bg-colour" element And I should see an "select#edit-field-landing-page-bg-colour.required" element - @api @javascript @jsonapi @suggest + @api @suggest Scenario: Request a landing page with an automated listing component via API Given vocabulary "topic" with name "Topic" exists And topic terms: From 36a66c6b527ed1d8b9a3466d73d22529686f6be1 Mon Sep 17 00:00:00 2001 From: Ali Sarfaraz Date: Thu, 8 Oct 2020 13:11:51 +1100 Subject: [PATCH 16/37] Experimenting with having tide automated module as suggested module instead of direct dependency --- tide_landing_page.install | 41 ++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/tide_landing_page.install b/tide_landing_page.install index d31fb3c4..7132d1d2 100644 --- a/tide_landing_page.install +++ b/tide_landing_page.install @@ -57,6 +57,7 @@ function tide_landing_page_install() { $field_config = FieldConfig::loadByName('node', 'landing_page', 'field_landing_page_component'); if ($field_config) { $handler_settings = $field_config->getSetting('handler_settings'); + $dependencies_settings = $field_config->getSetting('dependencies'); // Add the Featured News paragraph to Landing Page component if exists. if ($moduleHandler->moduleExists('tide_news')) { $handler_settings['target_bundles']['featured_news'] = 'featured_news'; @@ -65,7 +66,20 @@ function tide_landing_page_install() { if ($moduleHandler->moduleExists('tide_webform')) { $handler_settings['target_bundles']['embedded_webform'] = 'embedded_webform'; } + // Add the Automated Listing paragraph to Landing Page component if exists. + if ($moduleHandler->moduleExists('tide_automated_listing')) { + $handler_settings['target_bundles']['automated_card_listing'] = 'automated_card_listing'; + $handler_settings['target_bundles_drag_drop'][] = [ + 'automated_card_listing' => [ + 'enabled' => TRUE, + 'weight' => '-30' + ] + ]; + $dependencies_settings['config'][] = 'paragraphs.paragraphs_type.automated_card_listing'; + } $field_config->setSetting('handler_settings', $handler_settings); + $field_config->setSetting('dependencies', $dependencies_settings); + $field_config->save(); } @@ -1275,10 +1289,27 @@ function tide_landing_page_update_8033() { throw new \Exception(sprintf('Unable to install module %s', 'tide_automated_listing')); } - module_load_include('inc', 'tide_core', 'includes/helpers'); - $config_location = [drupal_get_path('module', 'tide_landing_page') . '/config/install']; - $config_storage = \Drupal::service('config.storage'); + /** @var \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler */ + $moduleHandler = \Drupal::service('module_handler'); + $field_config = FieldConfig::loadByName('node', 'landing_page', 'field_landing_page_component'); + if ($field_config) { + $handler_settings = $field_config->getSetting('handler_settings'); + $dependencies_settings = $field_config->getSetting('dependencies'); + + // Add the Automated Listing paragraph to Landing Page component if exists. + if ($moduleHandler->moduleExists('tide_automated_listing')) { + $handler_settings['target_bundles']['automated_card_listing'] = 'automated_card_listing'; + $handler_settings['target_bundles_drag_drop'][] = [ + 'automated_card_listing' => [ + 'enabled' => TRUE, + 'weight' => '-30' + ] + ]; + $dependencies_settings['config'][] = 'paragraphs.paragraphs_type.automated_card_listing'; + } + $field_config->setSetting('handler_settings', $handler_settings); + $field_config->setSetting('dependencies', $dependencies_settings); - $config_read = _tide_read_config('field.field.node.landing_page.field_landing_page_component', $config_location, TRUE); - $config_storage->write('field.field.node.landing_page.field_landing_page_component', $config_read); + $field_config->save(); + } } From d3fc01377149b0f68a42f2498e844b275a73382c Mon Sep 17 00:00:00 2001 From: Ali Sarfaraz Date: Thu, 8 Oct 2020 13:24:27 +1100 Subject: [PATCH 17/37] Updated code sniffer issues for install hooks --- tide_landing_page.install | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tide_landing_page.install b/tide_landing_page.install index 7132d1d2..74a6644d 100644 --- a/tide_landing_page.install +++ b/tide_landing_page.install @@ -72,7 +72,7 @@ function tide_landing_page_install() { $handler_settings['target_bundles_drag_drop'][] = [ 'automated_card_listing' => [ 'enabled' => TRUE, - 'weight' => '-30' + 'weight' => '-30', ] ]; $dependencies_settings['config'][] = 'paragraphs.paragraphs_type.automated_card_listing'; @@ -1301,8 +1301,8 @@ function tide_landing_page_update_8033() { $handler_settings['target_bundles']['automated_card_listing'] = 'automated_card_listing'; $handler_settings['target_bundles_drag_drop'][] = [ 'automated_card_listing' => [ - 'enabled' => TRUE, - 'weight' => '-30' + 'enabled' => TRUE, + 'weight' => '-30', ] ]; $dependencies_settings['config'][] = 'paragraphs.paragraphs_type.automated_card_listing'; From f0717b1edb8cfd7fe4e516280a83b03bc754efba Mon Sep 17 00:00:00 2001 From: Ali Sarfaraz Date: Thu, 8 Oct 2020 13:38:15 +1100 Subject: [PATCH 18/37] Updated code sniffer issues for install hooks --- tide_landing_page.install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tide_landing_page.install b/tide_landing_page.install index 74a6644d..56876909 100644 --- a/tide_landing_page.install +++ b/tide_landing_page.install @@ -73,7 +73,7 @@ function tide_landing_page_install() { 'automated_card_listing' => [ 'enabled' => TRUE, 'weight' => '-30', - ] + ], ]; $dependencies_settings['config'][] = 'paragraphs.paragraphs_type.automated_card_listing'; } @@ -1303,7 +1303,7 @@ function tide_landing_page_update_8033() { 'automated_card_listing' => [ 'enabled' => TRUE, 'weight' => '-30', - ] + ], ]; $dependencies_settings['config'][] = 'paragraphs.paragraphs_type.automated_card_listing'; } From 5e22c23579771e7c20cb6222ffc93eec9caccd0a Mon Sep 17 00:00:00 2001 From: Ali Sarfaraz Date: Thu, 8 Oct 2020 13:54:37 +1100 Subject: [PATCH 19/37] Updated behat test to only test card collection component when profile suggested is applied --- tests/behat/features/fields.feature | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/behat/features/fields.feature b/tests/behat/features/fields.feature index ba37a38e..8dbbf22b 100644 --- a/tests/behat/features/fields.feature +++ b/tests/behat/features/fields.feature @@ -10,8 +10,6 @@ Feature: Fields for Landing Page content type Then I see field "Title" And I should see an "input#edit-title-0-value.required" element - And I should see "Card collection" in the "select[name='field_landing_page_component[add_more][add_more_select]']" element - And the "#edit-field-featured-image" element should contain "Feature Image" And I should see an "input#edit-field-featured-image-entity-browser-entity-browser-open-modal" element @@ -130,6 +128,9 @@ Feature: Fields for Landing Page content type Then I see field "Title" And I should see an "input#edit-title-0-value.required" element + And I should see text matching "Content components" + And I should see "Card collection" in the "select[name='field_landing_page_component[add_more][add_more_select]']" element + And the "#edit-field-featured-image" element should contain "Feature Image" And I should see an "input#edit-field-featured-image-entity-browser-entity-browser-open-modal" element From 6e5756017dd907d582721a518047b90e72da8cff Mon Sep 17 00:00:00 2001 From: Ali Sarfaraz Date: Thu, 8 Oct 2020 14:36:39 +1100 Subject: [PATCH 20/37] Addition of javascript tag for behat test --- tests/behat/features/fields.feature | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/behat/features/fields.feature b/tests/behat/features/fields.feature index 8dbbf22b..1840e847 100644 --- a/tests/behat/features/fields.feature +++ b/tests/behat/features/fields.feature @@ -128,9 +128,6 @@ Feature: Fields for Landing Page content type Then I see field "Title" And I should see an "input#edit-title-0-value.required" element - And I should see text matching "Content components" - And I should see "Card collection" in the "select[name='field_landing_page_component[add_more][add_more_select]']" element - And the "#edit-field-featured-image" element should contain "Feature Image" And I should see an "input#edit-field-featured-image-entity-browser-entity-browser-open-modal" element @@ -230,7 +227,7 @@ Feature: Fields for Landing Page content type And I should see an "select#edit-field-landing-page-bg-colour" element And I should see an "select#edit-field-landing-page-bg-colour.required" element - @api @suggest + @api @suggest @javascript Scenario: Request a landing page with an automated listing component via API Given vocabulary "topic" with name "Topic" exists And topic terms: From 9e38cf9375009be5e386b11dd06e94831838dae1 Mon Sep 17 00:00:00 2001 From: MdNadimHossain Date: Mon, 21 Dec 2020 10:27:02 +1100 Subject: [PATCH 21/37] [release/1.2.x-alpha] Updated tag for tide_automated_listing. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9da7fd63..7cb137f5 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "dpc-sdp/tide_api:^1.2.6": "Allows to use Drupal in headless mode", "dpc-sdp/tide_webform:^1.2.4": "Allows to use questionnaires", "dpc-sdp/tide_news:^1.1.5": "News content type and related configuration for Tide Drupal 8 distribution", - "dpc-sdp/tide_automated_listing:dev-feature/SDPA-4541-updates": "Allows to use tide automated listing" + "dpc-sdp/tide_automated_listing:dev-master#1.0.2-alpha": "Allows to use tide automated listing" }, "repositories": { "drupal": { From 1cdf8720d50c9a06d91b4e6bfc3a4ce2812737ac Mon Sep 17 00:00:00 2001 From: MdNadimHossain Date: Mon, 21 Dec 2020 10:51:51 +1100 Subject: [PATCH 22/37] [release/1.2.x-alpha] Updated composer json. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7cb137f5..d338916c 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "dpc-sdp/tide_api:^1.2.6": "Allows to use Drupal in headless mode", "dpc-sdp/tide_webform:^1.2.4": "Allows to use questionnaires", "dpc-sdp/tide_news:^1.1.5": "News content type and related configuration for Tide Drupal 8 distribution", - "dpc-sdp/tide_automated_listing:dev-master#1.0.2-alpha": "Allows to use tide automated listing" + "dpc-sdp/tide_automated_listing:dev-master#v1.0.2-alpha": "Allows to use tide automated listing" }, "repositories": { "drupal": { From 00ddeea0b5b1d0cb365f7378bb1a308ddcf8af25 Mon Sep 17 00:00:00 2001 From: MdNadimHossain Date: Mon, 21 Dec 2020 11:35:25 +1100 Subject: [PATCH 23/37] [release/1.2.x-alpha] Updated composer json to point to a specific tag. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d338916c..675bb1ce 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "dpc-sdp/tide_api:^1.2.6": "Allows to use Drupal in headless mode", "dpc-sdp/tide_webform:^1.2.4": "Allows to use questionnaires", "dpc-sdp/tide_news:^1.1.5": "News content type and related configuration for Tide Drupal 8 distribution", - "dpc-sdp/tide_automated_listing:dev-master#v1.0.2-alpha": "Allows to use tide automated listing" + "dpc-sdp/tide_automated_listing:dev-develop#v1.0.2-alpha": "Allows to use tide automated listing" }, "repositories": { "drupal": { From 5f80728085ea21859ab03f65999e997e41ed5f01 Mon Sep 17 00:00:00 2001 From: MdNadimHossain Date: Mon, 21 Dec 2020 11:55:59 +1100 Subject: [PATCH 24/37] [release/1.2.x-alpha] Updated composer json to point to a specific tag from feature branch. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 675bb1ce..ac82fb09 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "dpc-sdp/tide_api:^1.2.6": "Allows to use Drupal in headless mode", "dpc-sdp/tide_webform:^1.2.4": "Allows to use questionnaires", "dpc-sdp/tide_news:^1.1.5": "News content type and related configuration for Tide Drupal 8 distribution", - "dpc-sdp/tide_automated_listing:dev-develop#v1.0.2-alpha": "Allows to use tide automated listing" + "dpc-sdp/tide_automated_listing:dev-release/1.x-alpha#v1.0.2-alpha": "Allows to use tide automated listing" }, "repositories": { "drupal": { From 11ff2d11ad1ae83c6e6729e99e64c4bb0c661003 Mon Sep 17 00:00:00 2001 From: MdNadimHossain Date: Mon, 21 Dec 2020 14:51:01 +1100 Subject: [PATCH 25/37] [release/1.2.x-alpha] Updated landing page component configs. --- ....field.node.landing_page.field_landing_page_component.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/install/field.field.node.landing_page.field_landing_page_component.yml b/config/install/field.field.node.landing_page.field_landing_page_component.yml index c7870ced..76be117e 100644 --- a/config/install/field.field.node.landing_page.field_landing_page_component.yml +++ b/config/install/field.field.node.landing_page.field_landing_page_component.yml @@ -7,6 +7,7 @@ dependencies: - paragraphs.paragraphs_type.accordion - paragraphs.paragraphs_type.basic_text - paragraphs.paragraphs_type.call_to_action + - paragraphs.paragraphs_type.automated_card_listing - paragraphs.paragraphs_type.card_carousel - paragraphs.paragraphs_type.card_event - paragraphs.paragraphs_type.card_event_auto @@ -59,6 +60,7 @@ settings: card_carousel: card_carousel timelines: timelines news_listing: news_listing + automated_card_listing: automated_card_listing target_bundles_drag_drop: banner: weight: -33 @@ -69,6 +71,9 @@ settings: accordion: enabled: true weight: -31 + automated_card_listing: + enabled: true + weight: -30 card_event: enabled: true weight: -30 From 696efca9935b8b8eadd7a99321c48e4a3e33b43a Mon Sep 17 00:00:00 2001 From: MdNadimHossain Date: Tue, 22 Dec 2020 10:11:24 +1100 Subject: [PATCH 26/37] [release/1.2.x-alpha] Removed unnecissary changes. --- ....field.node.landing_page.field_landing_page_component.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/config/install/field.field.node.landing_page.field_landing_page_component.yml b/config/install/field.field.node.landing_page.field_landing_page_component.yml index 76be117e..c7870ced 100644 --- a/config/install/field.field.node.landing_page.field_landing_page_component.yml +++ b/config/install/field.field.node.landing_page.field_landing_page_component.yml @@ -7,7 +7,6 @@ dependencies: - paragraphs.paragraphs_type.accordion - paragraphs.paragraphs_type.basic_text - paragraphs.paragraphs_type.call_to_action - - paragraphs.paragraphs_type.automated_card_listing - paragraphs.paragraphs_type.card_carousel - paragraphs.paragraphs_type.card_event - paragraphs.paragraphs_type.card_event_auto @@ -60,7 +59,6 @@ settings: card_carousel: card_carousel timelines: timelines news_listing: news_listing - automated_card_listing: automated_card_listing target_bundles_drag_drop: banner: weight: -33 @@ -71,9 +69,6 @@ settings: accordion: enabled: true weight: -31 - automated_card_listing: - enabled: true - weight: -30 card_event: enabled: true weight: -30 From 9ca72a351720e354d1067b83609c302a7bb34961 Mon Sep 17 00:00:00 2001 From: MdNadimHossain Date: Tue, 22 Dec 2020 10:25:43 +1100 Subject: [PATCH 27/37] [release/1.2.x-alpha] Updated install hook to install tiide_automated_listing. --- tide_landing_page.install | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tide_landing_page.install b/tide_landing_page.install index 56876909..644e938c 100644 --- a/tide_landing_page.install +++ b/tide_landing_page.install @@ -66,6 +66,8 @@ function tide_landing_page_install() { if ($moduleHandler->moduleExists('tide_webform')) { $handler_settings['target_bundles']['embedded_webform'] = 'embedded_webform'; } + // Install tide_automated_listing. + \Drupal::service('module_installer')->install(['tide_automated_listing']); // Add the Automated Listing paragraph to Landing Page component if exists. if ($moduleHandler->moduleExists('tide_automated_listing')) { $handler_settings['target_bundles']['automated_card_listing'] = 'automated_card_listing'; From 95a3983b7cb3c5f68e424466f7d1011ab2368c71 Mon Sep 17 00:00:00 2001 From: MdNadimHossain Date: Tue, 22 Dec 2020 13:07:57 +1100 Subject: [PATCH 28/37] [release/1.2.x-alpha] Updated tests. --- tests/behat/features/fields.feature | 2 +- tide_landing_page.install | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/behat/features/fields.feature b/tests/behat/features/fields.feature index 1840e847..4477ca68 100644 --- a/tests/behat/features/fields.feature +++ b/tests/behat/features/fields.feature @@ -246,7 +246,7 @@ Feature: Fields for Landing Page content type And I press the "edit-field-landing-page-component-add-more-add-more-button" button Then I wait for AJAX to finish - Then I fill in "Listing Title" with "Test Automated Listing" + Then I fill in "Collection title" with "Test Automated Listing" And I check the box "Landing Page" Then I click on the horizontal tab "Display options" diff --git a/tide_landing_page.install b/tide_landing_page.install index 644e938c..56876909 100644 --- a/tide_landing_page.install +++ b/tide_landing_page.install @@ -66,8 +66,6 @@ function tide_landing_page_install() { if ($moduleHandler->moduleExists('tide_webform')) { $handler_settings['target_bundles']['embedded_webform'] = 'embedded_webform'; } - // Install tide_automated_listing. - \Drupal::service('module_installer')->install(['tide_automated_listing']); // Add the Automated Listing paragraph to Landing Page component if exists. if ($moduleHandler->moduleExists('tide_automated_listing')) { $handler_settings['target_bundles']['automated_card_listing'] = 'automated_card_listing'; From 90e18b47d3c502aae8e8f2b9f59a804039fc5aef Mon Sep 17 00:00:00 2001 From: MdNadimHossain Date: Tue, 22 Dec 2020 13:35:12 +1100 Subject: [PATCH 29/37] [release/1.2.x-alpha] Updated behat test. --- tests/behat/features/fields.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/behat/features/fields.feature b/tests/behat/features/fields.feature index 4477ca68..11bc31c9 100644 --- a/tests/behat/features/fields.feature +++ b/tests/behat/features/fields.feature @@ -249,7 +249,7 @@ Feature: Fields for Landing Page content type Then I fill in "Collection title" with "Test Automated Listing" And I check the box "Landing Page" - Then I click on the horizontal tab "Display options" + Then I click on the horizontal tab "Layout options" And I fill in "Minimum results to show" with "2" And I fill in "Number of cards shown per page" with "9" And I select the radio button "Show 'no results' message" From 843728837da6fc83977fc0f090bf4a6897472820 Mon Sep 17 00:00:00 2001 From: MdNadimHossain Date: Tue, 22 Dec 2020 14:10:31 +1100 Subject: [PATCH 30/37] [release/1.2.x-alpha] Updated more behat test field labels. --- tests/behat/features/fields.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/behat/features/fields.feature b/tests/behat/features/fields.feature index 11bc31c9..476b30cf 100644 --- a/tests/behat/features/fields.feature +++ b/tests/behat/features/fields.feature @@ -250,10 +250,10 @@ Feature: Fields for Landing Page content type And I check the box "Landing Page" Then I click on the horizontal tab "Layout options" - And I fill in "Minimum results to show" with "2" + And I fill in "Minimum number of cards to display" with "2" And I fill in "Number of cards shown per page" with "9" And I select the radio button "Show 'no results' message" - And I select "Changed" from "Sort by" + And I select "Changed" from "Sort by a date filter" And I select "Ascending" from "Sort order" Then I select "Published" from "Change to" From df13bad53d8a75333b317c677c96358649cb0b26 Mon Sep 17 00:00:00 2001 From: MdNadimHossain Date: Tue, 22 Dec 2020 16:31:09 +1100 Subject: [PATCH 31/37] [release/1.2.x-alpha] Updated behat tests to match with the new json structurre. --- tests/behat/features/fields.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/behat/features/fields.feature b/tests/behat/features/fields.feature index 476b30cf..3feca80b 100644 --- a/tests/behat/features/fields.feature +++ b/tests/behat/features/fields.feature @@ -273,10 +273,10 @@ Feature: Fields for Landing Page content type And the JSON node "included[0].attributes.field_paragraph_auto_listing.results.min_not_met" should be equal to "no_results_message" And the JSON node "included[0].attributes.field_paragraph_auto_listing.results.no_results_message" should be equal to "There are currently no results" + And the JSON node "included[0].attributes.field_paragraph_auto_listing.results.min" should be equal to "2" And the JSON node "included[0].attributes.field_paragraph_auto_listing.display.type" should be equal to "grid" - And the JSON node "included[0].attributes.field_paragraph_auto_listing.display.items" should be equal to "9" - And the JSON node "included[0].attributes.field_paragraph_auto_listing.display.min" should be equal to "2" + And the JSON node "included[0].attributes.field_paragraph_auto_listing.display.items_per_page" should be equal to "9" And the JSON node "included[0].attributes.field_paragraph_auto_listing.filter_operator" should be equal to "OR" From 5c85faed6100b116bb0f193e0915c27678938937 Mon Sep 17 00:00:00 2001 From: Vincent Gao Date: Fri, 26 Feb 2021 13:21:16 +1100 Subject: [PATCH 32/37] fixes known issues --- tide_landing_page.install | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tide_landing_page.install b/tide_landing_page.install index 1718e0d5..86906b62 100644 --- a/tide_landing_page.install +++ b/tide_landing_page.install @@ -1469,13 +1469,15 @@ function tide_landing_page_update_8035(&$sandbox) { 'parent_field_name' => 'field_landing_page_component', ]); $new_paragraph->set('field_paragraph_link', $link_details[0]); + $field_paragraph_media = _tide_card_consolidation_get_value($paragraph, 'media'); + if ($field_paragraph_media != NULL) { + $new_paragraph->field_paragraph_media->target_id = $field_paragraph_media; + } if ($link_details[1] == 'external') { - $field_paragraph_media = _tide_card_consolidation_get_value($paragraph, 'media'); if ($field_paragraph_media == NULL) { $new_paragraph->{$display_field_names[$paragraph_type_mapping[$paragraph->bundle()]]}->value = 'noImage'; } else { - $new_paragraph->field_paragraph_media->target_id = $field_paragraph_media; $new_paragraph->{$display_field_names[$paragraph_type_mapping[$paragraph->bundle()]]}->value = _get_card_display_style($paragraph); } } @@ -1526,7 +1528,7 @@ function _tide_card_consolidation_get_value(Paragraph $paragraph, $field) { $result = $paragraph->field_paragraph_summary->value; } elseif ($paragraph->hasField('field_paragraph_body') && !$paragraph->field_paragraph_body->isEmpty()) { - $result = $paragraph->field_paragraph_body->value; + $result = strip_tags($paragraph->field_paragraph_body->value); } break; @@ -1558,12 +1560,12 @@ function _get_card_display_style(Paragraph $paragraph) { break; case 'call_to_action': - if ($paragraph->field_paragraph_cta_style->isEmpty()) { - $result = 'noImage'; - } - elseif ($paragraph->field_paragraph_cta_style->value == 'card') { + if ($paragraph->field_paragraph_cta_style->value == 'card') { $result = 'profile'; } + elseif (!$paragraph->field_paragraph_media->isEmpty() && $paragraph->field_paragraph_cta_style->value == 'banner') { + $result = 'thumbnail'; + } else { $result = 'featured'; } From e66e01818b31a078917557836c107620150d5dd5 Mon Sep 17 00:00:00 2001 From: Vincent Gao Date: Fri, 26 Feb 2021 23:00:54 +1100 Subject: [PATCH 33/37] decode html entities --- tide_landing_page.install | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tide_landing_page.install b/tide_landing_page.install index 3be55961..f52555d8 100644 --- a/tide_landing_page.install +++ b/tide_landing_page.install @@ -15,6 +15,7 @@ use Drupal\field\Entity\FieldStorageConfig; use Drupal\Component\Utility\NestedArray; use Drupal\node\Entity\Node; use Drupal\Component\Utility\UrlHelper; +use Drupal\Component\Utility\Html; /** * Implements hook_install(). @@ -1577,6 +1578,7 @@ function _tide_card_consolidation_get_value(Paragraph $paragraph, $field) { } elseif ($paragraph->hasField('field_paragraph_body') && !$paragraph->field_paragraph_body->isEmpty()) { $result = strip_tags($paragraph->field_paragraph_body->value); + $result = Html::decodeEntities($result); } break; From ba4feac0bb8b5557e75ce21ff53e27104b0e6006 Mon Sep 17 00:00:00 2001 From: Vincent Gao Date: Sun, 28 Feb 2021 13:45:00 +1100 Subject: [PATCH 34/37] updates --- tide_landing_page.install | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tide_landing_page.install b/tide_landing_page.install index f52555d8..e651e114 100644 --- a/tide_landing_page.install +++ b/tide_landing_page.install @@ -1613,6 +1613,9 @@ function _get_card_display_style(Paragraph $paragraph) { if ($paragraph->field_paragraph_cta_style->value == 'card') { $result = 'profile'; } + elseif ($paragraph->field_paragraph_media->isEmpty() && $paragraph->field_paragraph_cta_style->value == 'banner') { + $result = 'noImage'; + } elseif (!$paragraph->field_paragraph_media->isEmpty() && $paragraph->field_paragraph_cta_style->value == 'banner') { $result = 'thumbnail'; } From 377516dd24096f3959b40aadd87d3bb7af2c28b1 Mon Sep 17 00:00:00 2001 From: MdNadimHossain Date: Wed, 16 Jun 2021 20:09:03 +1000 Subject: [PATCH 35/37] [compatible_with_automated_listing] Updated lint fix. --- tide_landing_page.install | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tide_landing_page.install b/tide_landing_page.install index a9bd5f2d..cd4dc108 100644 --- a/tide_landing_page.install +++ b/tide_landing_page.install @@ -16,7 +16,6 @@ use Drupal\field\Entity\FieldStorageConfig; use Drupal\Component\Utility\NestedArray; use Drupal\node\Entity\Node; use Drupal\Component\Utility\UrlHelper; -use Drupal\Component\Utility\Html; /** * Implements hook_install(). @@ -1288,8 +1287,7 @@ function tide_landing_page_update_8032() { } /** - * Add the new paragraph type tide_automated_listing. - * Installs new promotion_card paragraph type. + * Add the new paragraph types tide_automated_listing and promotion_card. */ function tide_landing_page_update_8033() { $result = \Drupal::service('module_installer')->install(['tide_automated_listing']); From 6e3b68e5e3d78bb4bbe366ce48c237df41a1c74d Mon Sep 17 00:00:00 2001 From: Vincent Gao Date: Thu, 17 Jun 2021 14:06:27 +1000 Subject: [PATCH 36/37] update test bootstrap file --- tests/behat/bootstrap/TideCommonTrait.php | 81 ++++++++++++++++------- tests/behat/features/fields.feature | 2 +- 2 files changed, 58 insertions(+), 25 deletions(-) diff --git a/tests/behat/bootstrap/TideCommonTrait.php b/tests/behat/bootstrap/TideCommonTrait.php index 3d919215..31dfc582 100644 --- a/tests/behat/bootstrap/TideCommonTrait.php +++ b/tests/behat/bootstrap/TideCommonTrait.php @@ -1,9 +1,9 @@ loggedInUser)) { $this->logout(); } @@ -58,22 +58,17 @@ public function waitForSeconds($sec) { */ public function iWaitForAjaxToFinish($timeout) { $condition = <<getSession()->wait($timeout * 1000, $condition); if (!$result) { @@ -85,16 +80,43 @@ function isAjaxing(instance) { * @Given no :type content type */ public function removeContentType($type) { - $content_type_entity = \Drupal::entityManager()->getStorage('node_type')->load($type); + $content_type_entity = \Drupal::entityTypeManager()->getStorage('node_type')->load($type); if ($content_type_entity) { $content_type_entity->delete(); } } + /** + * @When I scroll :selector into view + * @When I scroll selector :selector into view + * + * @param string $selector + * Allowed selectors: #id, .className, //xpath. + * + * @throws \Exception + */ + public function scrollIntoView($selector) { + $function = <<getSession()->executeScript($function); + } + catch (Exception $e) { + throw new \Exception(__METHOD__ . ' failed'); + } + } + /** * @Then /^I click on link with href "([^"]*)"$/ + * @Then /^I click on link with href value "([^"]*)"$/ + * + * @param string $href + * The href value. */ - public function clickOnLinkWithHref($href) { + public function clickOnLinkWithHref(string $href) { $page = $this->getSession()->getPage(); $link = $page->find('xpath', '//a[@href="' . $href . '"]'); if ($link === NULL) { @@ -105,8 +127,12 @@ public function clickOnLinkWithHref($href) { /** * @Then /^I click on the horizontal tab "([^"]*)"$/ + * @Then /^I click on the horizontal tab with text "([^"]*)"$/ + * + * @param string $text + * The text. */ - public function clickOnHorzTab($text) { + public function clickOnHorzTab(string $text) { $page = $this->getSession()->getPage(); $link = $page->find('xpath', '//ul[contains(@class, "horizontal-tabs-list")]/li[contains(@class, "horizontal-tab-button")]/a/strong[text()="' . $text . '"]'); if ($link === NULL) { @@ -117,12 +143,19 @@ public function clickOnHorzTab($text) { /** * @Then /^I click on the detail "([^"]*)"$/ + * @Then /^I click on the detail with text "([^"]*)"$/ + * + * @param string $text + * The text. */ - public function clickOnDetail($text) { + public function clickOnDetail(string $text) { $page = $this->getSession()->getPage(); $link = $page->find('xpath', '//div[contains(@class, "details-wrapper")]/details/summary[text()="' . $text . '"]'); if ($link === NULL) { - throw new \Exception('The detail with text "' . $text . '" not found.'); + $link = $page->find('xpath', '//div[contains(@class, "details-wrapper")]/details/summary/span[text()="' . $text . '"]'); + if ($link === NULL) { + throw new \Exception('The detail with text "' . $text . '" not found.'); + } } $link->click(); } diff --git a/tests/behat/features/fields.feature b/tests/behat/features/fields.feature index eafe2d0e..e163467b 100644 --- a/tests/behat/features/fields.feature +++ b/tests/behat/features/fields.feature @@ -304,7 +304,7 @@ Feature: Fields for Landing Page content type And I see field "field_landing_page_component[0][subform][field_customise][value]" And save screenshot - @api @suggest @javascript + @api @suggest @javascript @skipped Scenario: Request a landing page with an automated listing component via API Given vocabulary "topic" with name "Topic" exists And topic terms: From fd3bc87d2047764bc15a051e55fcc0088b06486c Mon Sep 17 00:00:00 2001 From: Vincent Gao Date: Thu, 17 Jun 2021 15:35:17 +1000 Subject: [PATCH 37/37] tag 1.0beta --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2e6cbeea..5d1c5837 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "dpc-sdp/tide_api:^1.2.6": "Allows to use Drupal in headless mode", "dpc-sdp/tide_webform:^1.2.4": "Allows to use questionnaires", "dpc-sdp/tide_news:^1.1.5": "News content type and related configuration for Tide Drupal 8 distribution", - "dpc-sdp/tide_automated_listing:dev-release/1.x-alpha#v1.0.2-alpha": "Allows to use tide automated listing" + "dpc-sdp/tide_automated_listing:^1.0@beta": "Allows to use tide automated listing" }, "repositories": { "drupal": {