From 1df3158cbc5cb01c7acca4c3df554ea980f095ed Mon Sep 17 00:00:00 2001 From: David Featherston Date: Thu, 1 Feb 2024 16:49:39 +1100 Subject: [PATCH 1/2] feat(@dpc-sdp/ripple-tide-search): update results key for interop, collection 'theme' improvements --- .../data-table/custom-collection.feature | 32 ++- .../custom-collection/form-theme-default.json | 214 ++++++++++++++++++ .../custom-collection/form-theme-reverse.json | 214 ++++++++++++++++++ .../table/page-extra-component.json | 2 +- .../table/page-extra-structured.json | 2 +- .../fixtures/search-listing/table/page.json | 2 +- .../components/TideDynamicComponents.vue | 5 +- .../components/custom-collection.ts | 49 +++- .../components/global/TideLandingPage.vue | 1 + .../components/TideSearchListingPage.vue | 13 +- .../components/TideSearchResultsCount.vue | 5 +- .../global/TideCustomCollection.vue | 52 +++-- .../global/TideSearchFilterDependent.vue | 6 +- .../global/TideTideSearchListing.vue | 12 +- packages/ripple-tide-search/types.ts | 48 ++-- .../ripple-ui-forms/src/inputs/checkbox.ts | 3 +- 16 files changed, 601 insertions(+), 59 deletions(-) create mode 100644 examples/nuxt-app/test/fixtures/landingpage/custom-collection/form-theme-default.json create mode 100644 examples/nuxt-app/test/fixtures/landingpage/custom-collection/form-theme-reverse.json diff --git a/examples/nuxt-app/test/features/data-table/custom-collection.feature b/examples/nuxt-app/test/features/data-table/custom-collection.feature index b99273b706..05c684bab4 100644 --- a/examples/nuxt-app/test/features/data-table/custom-collection.feature +++ b/examples/nuxt-app/test/features/data-table/custom-collection.feature @@ -3,13 +3,13 @@ Feature: Custom Collection As an editor I want to be able to add a view of results in a search index to a landing page. Background: - Given the page endpoint for path "/custom-collection" returns fixture "/landingpage/custom-collection" with status 200 Given the site endpoint returns fixture "/site/reference" with status 200 And the search autocomplete request is stubbed with "/search-listing/suggestions/none" fixture Given I am using a "macbook-16" device @mockserver Scenario: Custom collection + Given the page endpoint for path "/custom-collection" returns fixture "/landingpage/custom-collection" with status 200 Given the "/api/tide/elasticsearch/sdp_data_pipelines_scl/_search" network request is stubbed with fixture "/landingpage/custom-collection/response" and status 200 as alias "cslReq" Given I visit the page "/custom-collection" Then the landing page component "TideCustomCollection" should exist @@ -18,8 +18,37 @@ Feature: Custom Collection And the "cslReq" network request should be made to the elasticsearch endpoint And the search listing layout should be "table" + @mockserver + Scenario: Default form theme + Given the page endpoint for path "/custom-collection-theme-default" returns fixture "/landingpage/custom-collection/form-theme-default" with status 200 + Given the "/api/tide/elasticsearch/sdp_data_pipelines_scl/_search" network request is stubbed with fixture "/landingpage/custom-collection/response" and status 200 as alias "cslReq" + Given I visit the page "/custom-collection-theme-default" + Then the landing page component "TideCustomCollection" should exist + And I toggle the content collection filters + Then the custom collection component should have the "default" form theme applied + Then the custom collection search bar field should have the "default" variant applied + Then the custom collection checkbox field labelled "Show archived content" should have the "default" variant applied + Then the custom collection dropdown field labelled "Term filter example" should have the "default" variant applied + Then the custom collection dropdown field labelled "Terms dependent example" should have the "default" variant applied + Then the custom collection dropdown field labelled "Terms dependent child example" should have the "default" variant applied + + @mockserver + Scenario: Reverse form theme + Given the page endpoint for path "/custom-collection-theme-reverse" returns fixture "/landingpage/custom-collection/form-theme-reverse" with status 200 + Given the "/api/tide/elasticsearch/sdp_data_pipelines_scl/_search" network request is stubbed with fixture "/landingpage/custom-collection/response" and status 200 as alias "cslReq" + Given I visit the page "/custom-collection-theme-reverse" + Then the landing page component "TideCustomCollection" should exist + And I toggle the content collection filters + Then the custom collection component should have the "neutral" form theme applied + Then the custom collection search bar field should have the "reverse" variant applied + Then the custom collection checkbox field labelled "Show archived content" should have the "reverse" variant applied + Then the custom collection dropdown field labelled "Term filter example" should have the "reverse" variant applied + Then the custom collection dropdown field labelled "Terms dependent example" should have the "reverse" variant applied + Then the custom collection dropdown field labelled "Terms dependent child example" should have the "reverse" variant applied + @mockserver Scenario: Error + Given the page endpoint for path "/custom-collection" returns fixture "/landingpage/custom-collection" with status 200 Given the "/api/tide/elasticsearch/sdp_data_pipelines_scl/_search" network request is stubbed with fixture "/landingpage/custom-collection/response" and status 400 as alias "cslReq" Given I visit the page "/custom-collection" Then the landing page component "TideCustomCollection" should exist @@ -27,6 +56,7 @@ Feature: Custom Collection @mockserver Scenario: No results + Given the page endpoint for path "/custom-collection" returns fixture "/landingpage/custom-collection" with status 200 Given the "/api/tide/elasticsearch/sdp_data_pipelines_scl/_search" network request is stubbed with fixture "/landingpage/custom-collection/response-no-items" and status 200 as alias "cslReq" Given I visit the page "/custom-collection" Then the landing page component "TideCustomCollection" should exist diff --git a/examples/nuxt-app/test/fixtures/landingpage/custom-collection/form-theme-default.json b/examples/nuxt-app/test/fixtures/landingpage/custom-collection/form-theme-default.json new file mode 100644 index 0000000000..d552648ea7 --- /dev/null +++ b/examples/nuxt-app/test/fixtures/landingpage/custom-collection/form-theme-default.json @@ -0,0 +1,214 @@ +{ + "title": "Custom collection - Form theme", + "changed": "2022-11-02T12:47:29+11:00", + "created": "2022-11-02T12:47:29+11:00", + "type": "landing_page", + "nid": "11dede11-10c0-111e1-1100-000000000330", + "summary": "Page summary", + "showInPageNav": true, + "inPageNavHeadingLevel": "h3", + "background": "default", + "header": { + "title": "Custom collection form theme test", + "summary": "Test landing page title introduction text", + "theme": "default", + "backgroundImage": null + }, + "sidebar": {}, + "headerComponents": [], + "bodyComponents": [ + { + "uuid": "55555555-5555-5555-5555-555555555555", + "component": "TideCustomCollection", + "id": "123", + "title": "Cameras save lives", + "props": { + "searchListingConfig": { + "searchProvider": "elasticsearch", + "index": "sdp_data_pipelines_scl", + "resultsPerPage": 10, + "labels": { + "submit": "Search", + "placeholder": "Enter suburb, postcode, streetname or offence location" + }, + "customSort": [ + { + "suburb": "asc" + } + ], + "formTheme": "default" + }, + "queryConfig": { + "multi_match": { + "query": "{{query}}", + "fields": ["suburb^3", "street^2", "offence_location"] + } + }, + "globalFilters": [], + "userFilters": [ + { + "id": "termFilter", + "component": "TideSearchFilterDropdown", + "filter": { + "type": "term", + "value": "termFilter.keyword" + }, + "aggregations": { + "field": "termFilter", + "source": "taxonomy" + }, + "props": { + "id": "termFilter", + "label": "Term filter example", + "placeholder": "Select a colour", + "multiple": true, + "options": [ + { + "id": "1", + "label": "Red", + "value": "Red" + }, + { + "id": "2", + "label": "Green", + "value": "Green" + } + ] + } + }, + { + "id": "checkboxFilter", + "component": "TideSearchFilterCheckbox", + "filter": { + "type": "terms", + "value": "checkboxFilter.keyword", + "multiple": false + }, + "props": { + "id": "checkboxFilter", + "label": "Checkbox example", + "checkboxLabel": "Show archived content", + "onValue": "Archived" + } + }, + { + "id": "dependentFilter", + "component": "TideSearchFilterDependent", + "columns": "rpl-grid", + "filter": { + "type": "dependent", + "multiple": false, + "value": "field_species_name" + }, + "aggregations": { + "field": "topic", + "source": "taxonomy" + }, + "props": { + "id": "dependentFilter", + "label": "Terms dependent example", + "placeholder": "Select a species", + "dependantLabel": "Terms dependent child example", + "dependantPlaceholder": "All sub species", + "multiple": true, + "options": [ + { + "id": "1", + "label": "Mammals", + "value": "Mammals" + }, + { + "id": "2", + "label": "Dogs", + "value": "Dogs", + "parent": "1" + }, + { + "id": "3", + "label": "Birds", + "value": "Birds" + }, + { + "id": "4", + "label": "Cats", + "value": "Cats", + "parent": "1" + }, + { + "id": "5", + "label": "Parrot", + "value": "Parrot", + "parent": "3" + }, + { + "id": "6", + "label": "Cockatoo", + "value": "Cockatoo", + "parent": "3" + } + ] + } + } + ], + "resultsConfig": { + "layout": { + "component": "TideSearchResultsTable", + "props": { + "columns": [ + { + "label": "Suburb", + "objectKey": "suburb" + }, + { + "label": "Location", + "objectKey": "street" + }, + { + "label": "Last annual test", + "objectKey": "last_annual_test" + } + ] + } + } + } + } + } + ], + "meta": { + "url": "/demo-landing-page", + "langcode": "en", + "description": "Nulla ultricies dignissim leo, posuere vestibulum erat cursus vitae", + "additional": [ + { + "tag": "link", + "attributes": { + "rel": "canonical", + "href": "https://develop.content.reference.sdp.vic.gov.au/demo-landing-page" + } + }, + { + "tag": "meta", + "attributes": { + "name": "title", + "content": "Demo Landing Page | Single Digital Presence Content Management System" + } + }, + { + "tag": "meta", + "attributes": { + "property": "og:image", + "content": "https://develop.content.reference.sdp.vic.gov.au/sites/default/files/tide_demo_content/Melbourne-tram.jpg" + } + } + ], + "keywords": "", + "image": { + "src": "https://develop.content.reference.sdp.vic.gov.au/sites/default/files/tide_demo_content/Melbourne-tram.jpg", + "alt": "Demo: Melbourne tram", + "title": "Demo: Melbourne tram", + "width": 1413, + "height": 785, + "drupal_internal__target_id": 46 + } + } +} diff --git a/examples/nuxt-app/test/fixtures/landingpage/custom-collection/form-theme-reverse.json b/examples/nuxt-app/test/fixtures/landingpage/custom-collection/form-theme-reverse.json new file mode 100644 index 0000000000..0de7fdefe7 --- /dev/null +++ b/examples/nuxt-app/test/fixtures/landingpage/custom-collection/form-theme-reverse.json @@ -0,0 +1,214 @@ +{ + "title": "Custom collection - Form theme", + "changed": "2022-11-02T12:47:29+11:00", + "created": "2022-11-02T12:47:29+11:00", + "type": "landing_page", + "nid": "11dede11-10c0-111e1-1100-000000000330", + "summary": "Page summary", + "showInPageNav": true, + "inPageNavHeadingLevel": "h3", + "background": "default", + "header": { + "title": "Custom collection form theme test", + "summary": "Test landing page title introduction text", + "theme": "default", + "backgroundImage": null + }, + "sidebar": {}, + "headerComponents": [], + "bodyComponents": [ + { + "uuid": "55555555-5555-5555-5555-555555555555", + "component": "TideCustomCollection", + "id": "123", + "title": "Cameras save lives", + "props": { + "searchListingConfig": { + "searchProvider": "elasticsearch", + "index": "sdp_data_pipelines_scl", + "resultsPerPage": 10, + "labels": { + "submit": "Search", + "placeholder": "Enter suburb, postcode, streetname or offence location" + }, + "customSort": [ + { + "suburb": "asc" + } + ], + "formTheme": "reverse" + }, + "queryConfig": { + "multi_match": { + "query": "{{query}}", + "fields": ["suburb^3", "street^2", "offence_location"] + } + }, + "globalFilters": [], + "userFilters": [ + { + "id": "termFilter", + "component": "TideSearchFilterDropdown", + "filter": { + "type": "term", + "value": "termFilter.keyword" + }, + "aggregations": { + "field": "termFilter", + "source": "taxonomy" + }, + "props": { + "id": "termFilter", + "label": "Term filter example", + "placeholder": "Select a colour", + "multiple": true, + "options": [ + { + "id": "1", + "label": "Red", + "value": "Red" + }, + { + "id": "2", + "label": "Green", + "value": "Green" + } + ] + } + }, + { + "id": "checkboxFilter", + "component": "TideSearchFilterCheckbox", + "filter": { + "type": "terms", + "value": "checkboxFilter.keyword", + "multiple": false + }, + "props": { + "id": "checkboxFilter", + "label": "Checkbox example", + "checkboxLabel": "Show archived content", + "onValue": "Archived" + } + }, + { + "id": "dependentFilter", + "component": "TideSearchFilterDependent", + "columns": "rpl-grid", + "filter": { + "type": "dependent", + "multiple": false, + "value": "field_species_name" + }, + "aggregations": { + "field": "topic", + "source": "taxonomy" + }, + "props": { + "id": "dependentFilter", + "label": "Terms dependent example", + "placeholder": "Select a species", + "dependantLabel": "Terms dependent child example", + "dependantPlaceholder": "All sub species", + "multiple": true, + "options": [ + { + "id": "1", + "label": "Mammals", + "value": "Mammals" + }, + { + "id": "2", + "label": "Dogs", + "value": "Dogs", + "parent": "1" + }, + { + "id": "3", + "label": "Birds", + "value": "Birds" + }, + { + "id": "4", + "label": "Cats", + "value": "Cats", + "parent": "1" + }, + { + "id": "5", + "label": "Parrot", + "value": "Parrot", + "parent": "3" + }, + { + "id": "6", + "label": "Cockatoo", + "value": "Cockatoo", + "parent": "3" + } + ] + } + } + ], + "resultsConfig": { + "layout": { + "component": "TideSearchResultsTable", + "props": { + "columns": [ + { + "label": "Suburb", + "objectKey": "suburb" + }, + { + "label": "Location", + "objectKey": "street" + }, + { + "label": "Last annual test", + "objectKey": "last_annual_test" + } + ] + } + } + } + } + } + ], + "meta": { + "url": "/demo-landing-page", + "langcode": "en", + "description": "Nulla ultricies dignissim leo, posuere vestibulum erat cursus vitae", + "additional": [ + { + "tag": "link", + "attributes": { + "rel": "canonical", + "href": "https://develop.content.reference.sdp.vic.gov.au/demo-landing-page" + } + }, + { + "tag": "meta", + "attributes": { + "name": "title", + "content": "Demo Landing Page | Single Digital Presence Content Management System" + } + }, + { + "tag": "meta", + "attributes": { + "property": "og:image", + "content": "https://develop.content.reference.sdp.vic.gov.au/sites/default/files/tide_demo_content/Melbourne-tram.jpg" + } + } + ], + "keywords": "", + "image": { + "src": "https://develop.content.reference.sdp.vic.gov.au/sites/default/files/tide_demo_content/Melbourne-tram.jpg", + "alt": "Demo: Melbourne tram", + "title": "Demo: Melbourne tram", + "width": 1413, + "height": 785, + "drupal_internal__target_id": 46 + } + } +} diff --git a/examples/nuxt-app/test/fixtures/search-listing/table/page-extra-component.json b/examples/nuxt-app/test/fixtures/search-listing/table/page-extra-component.json index 08c7893029..fe990a5968 100644 --- a/examples/nuxt-app/test/fixtures/search-listing/table/page-extra-component.json +++ b/examples/nuxt-app/test/fixtures/search-listing/table/page-extra-component.json @@ -27,7 +27,7 @@ ] } }, - "results": { + "resultsConfig": { "layout": { "component": "TideSearchResultsTable", "props": { diff --git a/examples/nuxt-app/test/fixtures/search-listing/table/page-extra-structured.json b/examples/nuxt-app/test/fixtures/search-listing/table/page-extra-structured.json index a7b115bfc6..fa2e207c39 100644 --- a/examples/nuxt-app/test/fixtures/search-listing/table/page-extra-structured.json +++ b/examples/nuxt-app/test/fixtures/search-listing/table/page-extra-structured.json @@ -27,7 +27,7 @@ ] } }, - "results": { + "resultsConfig": { "layout": { "component": "TideSearchResultsTable", "props": { diff --git a/examples/nuxt-app/test/fixtures/search-listing/table/page.json b/examples/nuxt-app/test/fixtures/search-listing/table/page.json index 68b4b71cc9..25687a44ce 100644 --- a/examples/nuxt-app/test/fixtures/search-listing/table/page.json +++ b/examples/nuxt-app/test/fixtures/search-listing/table/page.json @@ -27,7 +27,7 @@ ] } }, - "results": { + "resultsConfig": { "layout": { "component": "TideSearchResultsTable", "props": { diff --git a/packages/nuxt-ripple/components/TideDynamicComponents.vue b/packages/nuxt-ripple/components/TideDynamicComponents.vue index 57eb37eaae..7cfc9165cb 100644 --- a/packages/nuxt-ripple/components/TideDynamicComponents.vue +++ b/packages/nuxt-ripple/components/TideDynamicComponents.vue @@ -9,10 +9,12 @@ interface Props { components: TideDynamicPageComponent[] fullWidth?: boolean hasSidebar?: boolean + pageBackground?: string } const props = withDefaults(defineProps(), { fullWidth: false, - hasSidebar: false + hasSidebar: false, + pageBackground: 'default' }) const grouped: TideDynamicPageComponent | TideDynamicComponentGroup = @@ -49,6 +51,7 @@ const grouped: TideDynamicPageComponent | TideDynamicComponentGroup = :is="item.component" :hasSidebar="hasSidebar" :hasTitle="!!item.title" + :pageBackground="pageBackground" v-bind="item.props" > diff --git a/packages/ripple-test-utils/step_definitions/components/custom-collection.ts b/packages/ripple-test-utils/step_definitions/components/custom-collection.ts index 1da2215c71..75ba85161c 100644 --- a/packages/ripple-test-utils/step_definitions/components/custom-collection.ts +++ b/packages/ripple-test-utils/step_definitions/components/custom-collection.ts @@ -1,4 +1,4 @@ -import { Then } from '@badeball/cypress-cucumber-preprocessor' +import { Then, When } from '@badeball/cypress-cucumber-preprocessor' Then(`the custom collection component should have a search input bar`, () => { cy.get(`[data-component-type="TideCustomCollection"]`).find('.rpl-search-bar') @@ -14,6 +14,46 @@ Then( } ) +Then( + `the custom collection component should have the {string} form theme applied`, + (theme: string) => { + cy.get(`[data-component-type="TideCustomCollection"]`) + .find(`.tide-search-header--${theme}`) + .should('exist') + } +) + +Then( + `the custom collection search bar field should have the {string} variant applied`, + (theme: string) => { + cy.get(`[data-component-type="TideCustomCollection"]`) + .find(`.rpl-search-bar--${theme}`) + .should('exist') + } +) + +Then( + `the custom collection checkbox field labelled {string} should have the {string} variant applied`, + (label: string, theme: string) => { + cy.get(`[data-component-type="TideCustomCollection"] label`) + .contains(label) + .parents('.rpl-form__outer') + .find(`.rpl-form-option--${theme}`) + .should('exist') + } +) + +Then( + `the custom collection dropdown field labelled {string} should have the {string} variant applied`, + (label: string, theme: string) => { + cy.get(`[data-component-type="TideCustomCollection"] label`) + .contains(label) + .parents('.rpl-form__outer') + .find(`.rpl-form-dropdown--${theme}`) + .should('exist') + } +) + Then( 'the {string} network request should be made to the elasticsearch endpoint', (responseAlias: string) => { @@ -32,3 +72,10 @@ Then( ) } ) + +When(`I toggle the content collection filters`, () => { + cy.get(`[data-component-type="TideCustomCollection"]`) + .find(`button`) + .contains('Refine search') + .click() +}) diff --git a/packages/ripple-tide-landing-page/components/global/TideLandingPage.vue b/packages/ripple-tide-landing-page/components/global/TideLandingPage.vue index 121ef8685e..e5838a9953 100644 --- a/packages/ripple-tide-landing-page/components/global/TideLandingPage.vue +++ b/packages/ripple-tide-landing-page/components/global/TideLandingPage.vue @@ -55,6 +55,7 @@ v-if="page.bodyComponents?.length > 0" :components="page.bodyComponents" :hasSidebar="hasSidebar" + :pageBackground="page.background" />