From 895435abdfbb936ab1e370d2cd360ccf520d376b Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Thu, 4 Mar 2021 18:05:48 +0100 Subject: [PATCH 01/14] feat(ais-dynamic-widgets): add implementation Adds a new widget _ais-experimental-dynamic-widgets_ that can be used to conditionally render other widgets. This condition is based on the search results. At the moment there isn't yet a default way to enforce facet ordering in the Algolia engine, thus the data available to `transformItems` is an empty array. This will change once the Algolia engine adds support for facet ordering and this widget will move out of experimental mode. ```vue ``` See also: https://github.com/algolia/instantsearch.js/pull/4687 --- package.json | 4 +- src/__tests__/index.js | 2 + src/components/DynamicWidgets.js | 89 +++++++++++ src/components/__tests__/DynamicWidgets.js | 178 +++++++++++++++++++++ src/widgets.js | 1 + stories/DynamicWidgets.stories.js | 36 +++++ yarn.lock | 8 +- 7 files changed, 312 insertions(+), 6 deletions(-) create mode 100644 src/components/DynamicWidgets.js create mode 100644 src/components/__tests__/DynamicWidgets.js create mode 100644 stories/DynamicWidgets.stories.js diff --git a/package.json b/package.json index b9f879bba..3cdec1213 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ }, "dependencies": { "algoliasearch-helper": "^3.1.0", - "instantsearch.js": "^4.20.0" + "instantsearch.js": "^4.22.0" }, "peerDependencies": { "algoliasearch": ">= 3.32.0 < 5", @@ -114,7 +114,7 @@ "bundlesize": [ { "path": "./dist/vue-instantsearch.js", - "maxSize": "53.00 kB" + "maxSize": "53.50 kB" }, { "path": "./dist/vue-instantsearch.common.js", diff --git a/src/__tests__/index.js b/src/__tests__/index.js index 7917651e8..9b2aa4652 100644 --- a/src/__tests__/index.js +++ b/src/__tests__/index.js @@ -34,6 +34,8 @@ it('should have `name` the same as the suit class name everywhere', () => { expect(installedName).toBe(name); if (name === 'AisInstantSearchSsr') { expect(suitClass).toBe(`ais-InstantSearch`); + } else if (name === 'AisExperimentalDynamicWidgets') { + expect(suitClass).toBe(`ais-DynamicWidgets`); } else { expect(suitClass).toBe(`ais-${name.substr(3)}`); } diff --git a/src/components/DynamicWidgets.js b/src/components/DynamicWidgets.js new file mode 100644 index 000000000..42007c714 --- /dev/null +++ b/src/components/DynamicWidgets.js @@ -0,0 +1,89 @@ +import { createWidgetMixin } from '../mixins/widget'; +import { EXPERIMENTAL_connectDynamicWidgets } from 'instantsearch.js/es/connectors'; +import { createSuitMixin } from '../mixins/suit'; + +function getVueAttribute(vnode) { + if (vnode.componentOptions && vnode.componentOptions.propsData) { + if (vnode.componentOptions.propsData.attribute) { + return vnode.componentOptions.propsData.attribute; + } + if ( + vnode.componentOptions && + Array.isArray(vnode.componentOptions.propsData.attributes) + ) { + return vnode.componentOptions.propsData.attributes[0]; + } + } + + const children = + vnode.componentOptions && vnode.componentOptions.children + ? vnode.componentOptions.children + : vnode.children; + + if (Array.isArray(children)) { + // return first child with a truthy attribute + return children.reduce( + (acc, curr) => acc || getVueAttribute(curr), + undefined + ); + } + + return undefined; +} + +export default { + name: 'AisExperimentalDynamicWidgets', + mixins: [ + createWidgetMixin({ connector: EXPERIMENTAL_connectDynamicWidgets }), + createSuitMixin({ name: 'DynamicWidgets' }), + ], + props: { + transformItems: { + type: Function, + required: true, + }, + }, + render(createElement) { + const components = new Map(); + (this.$slots.default || []).forEach(vnode => { + const attribute = getVueAttribute(vnode); + if (attribute) { + components.set( + attribute, + createElement( + 'div', + { key: attribute, class: [this.suit('widget')] }, + [vnode] + ) + ); + } + }); + + // by default, render everything, but hidden so that the routing doesn't disappear + if (!this.state) { + const allComponents = []; + components.forEach(vnode => allComponents.push(vnode)); + + return createElement( + 'div', + { attrs: { hidden: true }, class: [this.suit()] }, + allComponents + ); + } + + return createElement( + 'div', + { class: [this.suit()] }, + this.state.attributesToRender.map(attribute => components.get(attribute)) + ); + }, + computed: { + widgetParams() { + return { + transformItems: this.transformItems, + // we do not pass "widgets" to the connector, since Vue is in charge of rendering + widgets: [], + }; + }, + }, +}; diff --git a/src/components/__tests__/DynamicWidgets.js b/src/components/__tests__/DynamicWidgets.js new file mode 100644 index 000000000..bd23d0853 --- /dev/null +++ b/src/components/__tests__/DynamicWidgets.js @@ -0,0 +1,178 @@ +import { createLocalVue, mount } from '@vue/test-utils'; +import DynamicWidgets from '../DynamicWidgets'; +import { __setState } from '../../mixins/widget'; +import { plugin } from '../../plugin'; +jest.mock('../../mixins/widget'); + +it('renders all children without state', () => { + const localVue = createLocalVue(); + + localVue.use(plugin); + + __setState(null); + + const wrapper = mount(DynamicWidgets, { + localVue, + propsData: { + transformItems: items => items, + }, + slots: { + default: ` + + + + + + `, + }, + }); + + // the inner widgets don't render anything because state is falsy, but they are mounted + expect(wrapper.html()).toMatchInlineSnapshot(` + + + +`); +}); + +it('renders nothing without children', () => { + __setState({ + attributesToRender: [], + }); + + const wrapper = mount(DynamicWidgets, { + propsData: { + transformItems: items => items, + }, + }); + expect(wrapper.html()).toMatchInlineSnapshot(` + +
+
+ +`); +}); + +it('renders nothing with empty items', () => { + const localVue = createLocalVue(); + + localVue.use(plugin); + + __setState({ + attributesToRender: [], + items: [], + }); + + const wrapper = mount(DynamicWidgets, { + localVue, + propsData: { + transformItems: items => items, + }, + slots: { + default: ``, + }, + }); + + expect(wrapper.html()).toMatchInlineSnapshot(` + +
+
+ +`); +}); + +it('renders attributesToRender 1', () => { + const localVue = createLocalVue(); + + localVue.use(plugin); + + __setState({ + attributesToRender: ['test1'], + items: [], + }); + + localVue.component('test-component', { + props: { attribute: { type: String } }, + render(h) { + return h('div', {}, this.attribute); + }, + }); + + const wrapper = mount(DynamicWidgets, { + localVue, + propsData: { + transformItems: items => items, + }, + slots: { + default: ` + + + `, + }, + }); + + expect(wrapper.html()).toMatchInlineSnapshot(` + +
+
+
+ test1 +
+
+
+ +`); +}); + +it('renders attributesToRender 2', () => { + const localVue = createLocalVue(); + + localVue.use(plugin); + + __setState({ + attributesToRender: ['test2'], + items: [], + }); + + localVue.component('test-component', { + props: { attribute: { type: String } }, + render(h) { + return h('div', {}, this.attribute); + }, + }); + + const wrapper = mount(DynamicWidgets, { + localVue, + propsData: { + transformItems: items => items, + }, + slots: { + default: ` + + + `, + }, + }); + + expect(wrapper.html()).toMatchInlineSnapshot(` + +
+
+
+
+ +`); +}); diff --git a/src/widgets.js b/src/widgets.js index 5b966dbbb..4ea249cf7 100644 --- a/src/widgets.js +++ b/src/widgets.js @@ -43,3 +43,4 @@ export { } from './components/ToggleRefinement.vue'; export { default as AisVoiceSearch } from './components/VoiceSearch.vue'; export { default as AisRelevantSort } from './components/RelevantSort.vue'; +export { default as AisDynamicWidgets } from './components/DynamicWidgets'; diff --git a/stories/DynamicWidgets.stories.js b/stories/DynamicWidgets.stories.js new file mode 100644 index 000000000..75390c320 --- /dev/null +++ b/stories/DynamicWidgets.stories.js @@ -0,0 +1,36 @@ +import { previewWrapper } from './utils'; +import { storiesOf } from '@storybook/vue'; + +storiesOf('ais-dynamic-widgets', module) + .addDecorator(previewWrapper()) + .add('simple usage', () => ({ + template: ` + + + + + + + + `, + data() { + return { + hierarchicalCategories: [ + 'hierarchicalCategories.lvl0', + 'hierarchicalCategories.lvl1', + 'hierarchicalCategories.lvl2', + ], + }; + }, + methods: { + transformItems(_attributes, { results }) { + if (results._state.query === 'dog') { + return ['categories']; + } + if (results._state.query === 'lego') { + return ['categories', 'brand']; + } + return ['brand', 'hierarchicalCategories.lvl0', 'categories']; + }, + }, + })); diff --git a/yarn.lock b/yarn.lock index 77b81ad05..53854be82 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7892,10 +7892,10 @@ instantsearch.css@7.3.1: resolved "https://registry.yarnpkg.com/instantsearch.css/-/instantsearch.css-7.3.1.tgz#7ab74a8f355091ae040947a9cf5438f379026622" integrity sha512-/kaMDna5D+Q9mImNBHEhb9HgHATDOFKYii7N1Iwvrj+lmD9gBJLqVhUw67gftq2O0QI330pFza+CRscIwB1wQQ== -instantsearch.js@^4.20.0: - version "4.20.0" - resolved "https://registry.yarnpkg.com/instantsearch.js/-/instantsearch.js-4.20.0.tgz#e7ed763a8380384ff59a88f3b56a01c5dedf0fca" - integrity sha512-fO3oqt/WEsUvdx8LB9Fm/MH9pLbl3gHV3ALnFOvbwdIpg+HRe5zZv3C/bE8E0SuTbZo2C6Fxg6rC0MEMTxNVGA== +instantsearch.js@^4.22.0: + version "4.22.0" + resolved "https://registry.yarnpkg.com/instantsearch.js/-/instantsearch.js-4.22.0.tgz#d28c7a2be6b399736f8f2edd6f59d474a0f661a4" + integrity sha512-IPjg/EwhDqFpvCJC1g3DF+i2cAr3SQZ9JPFhuKWC2apnGNfiFkPIQKvHx1pFTQm7FlZe262Xcpqi1ag1KVPGpA== dependencies: "@types/googlemaps" "^3.39.6" algoliasearch-helper "^3.4.4" From 1623dde9089842182ceb5a03c4e4234aabe37a6e Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Mon, 17 May 2021 09:49:44 +0200 Subject: [PATCH 02/14] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3cdec1213..1cbc78275 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,7 @@ }, { "path": "./dist/vue-instantsearch.common.js", - "maxSize": "16.50 kB" + "maxSize": "16.75 kB" } ], "resolutions": { From e889c24c324c382c674d7f7e830f06b5adb8c268 Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Wed, 19 May 2021 13:50:05 +0200 Subject: [PATCH 03/14] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clément Vannicatte <20689156+shortcuts@users.noreply.github.com> --- src/components/DynamicWidgets.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/DynamicWidgets.js b/src/components/DynamicWidgets.js index 42007c714..b03903a22 100644 --- a/src/components/DynamicWidgets.js +++ b/src/components/DynamicWidgets.js @@ -7,10 +7,7 @@ function getVueAttribute(vnode) { if (vnode.componentOptions.propsData.attribute) { return vnode.componentOptions.propsData.attribute; } - if ( - vnode.componentOptions && - Array.isArray(vnode.componentOptions.propsData.attributes) - ) { + if (Array.isArray(vnode.componentOptions.propsData.attributes)) { return vnode.componentOptions.propsData.attributes[0]; } } From 1eac466cf875317780db7f644c6070cf6be191c4 Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Wed, 16 Jun 2021 15:43:29 +0200 Subject: [PATCH 04/14] update to latest IS version --- package.json | 2 +- yarn.lock | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 1cbc78275..6d66a0080 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ }, "dependencies": { "algoliasearch-helper": "^3.1.0", - "instantsearch.js": "^4.22.0" + "instantsearch.js": "^4.24.0" }, "peerDependencies": { "algoliasearch": ">= 3.32.0 < 5", diff --git a/yarn.lock b/yarn.lock index 53854be82..43abe851f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -703,6 +703,11 @@ resolved "https://registry.npmjs.org/@types/googlemaps/-/googlemaps-3.39.7.tgz#70c1af22839976cfd462858c882b54f3006f0b08" integrity sha512-U8ZjnjfGiZXzun8jIDOZ/5Gt5Ky07B9pBhFbgzten1S364bnuueFsCt5e5V7Wn55o26NkLWgc6becL+j401bRw== +"@types/hogan.js@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@types/hogan.js/-/hogan.js-3.0.0.tgz#bf26560f39a38224ab6d0491b06f72c8fbe0953d" + integrity sha512-djkvb/AN43c3lIGCojNQ1FBS9VqqKhcTns5RQnHw4xBT/csy0jAssAsOiJ8NfaaioZaeKYE7XkVRxE5NeSZcaA== + "@types/http-cache-semantics@*": version "4.0.0" resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz#9140779736aa2655635ee756e2467d787cfe8a2a" @@ -1156,10 +1161,10 @@ algoliasearch-helper@^3.1.0: dependencies: events "^1.1.1" -algoliasearch-helper@^3.4.4: - version "3.4.4" - resolved "https://registry.yarnpkg.com/algoliasearch-helper/-/algoliasearch-helper-3.4.4.tgz#f2eb46bc4d2f6fed82c7201b8ac4ce0a1988ae67" - integrity sha512-OjyVLjykaYKCMxxRMZNiwLp8CS310E0qAeIY2NaublcmLAh8/SL19+zYHp7XCLtMem2ZXwl3ywMiA32O9jszuw== +algoliasearch-helper@^3.4.5: + version "3.5.3" + resolved "https://registry.yarnpkg.com/algoliasearch-helper/-/algoliasearch-helper-3.5.3.tgz#fbf8b328bc103efdefde59a7d25eaffe85b2490f" + integrity sha512-DtSlOKAJ6TGkQD6u58g6/ABdMmHf3pAj6xVL5hJF+D4z9ldDRf/f5v6puNIxGOlJRwGVvFGyz34beYNqhLDUbQ== dependencies: events "^1.1.1" @@ -7892,13 +7897,14 @@ instantsearch.css@7.3.1: resolved "https://registry.yarnpkg.com/instantsearch.css/-/instantsearch.css-7.3.1.tgz#7ab74a8f355091ae040947a9cf5438f379026622" integrity sha512-/kaMDna5D+Q9mImNBHEhb9HgHATDOFKYii7N1Iwvrj+lmD9gBJLqVhUw67gftq2O0QI330pFza+CRscIwB1wQQ== -instantsearch.js@^4.22.0: - version "4.22.0" - resolved "https://registry.yarnpkg.com/instantsearch.js/-/instantsearch.js-4.22.0.tgz#d28c7a2be6b399736f8f2edd6f59d474a0f661a4" - integrity sha512-IPjg/EwhDqFpvCJC1g3DF+i2cAr3SQZ9JPFhuKWC2apnGNfiFkPIQKvHx1pFTQm7FlZe262Xcpqi1ag1KVPGpA== +instantsearch.js@^4.24.0: + version "4.24.0" + resolved "https://registry.yarnpkg.com/instantsearch.js/-/instantsearch.js-4.24.0.tgz#220777b0083adb7b912f738b512ecf379dabea85" + integrity sha512-iJ0ieGPPQDxSuobo+TuF2ktSnWAoXBpIP/kQ7HwAiFzLGXCemwOOLN85Z4d7+XbIxUJ+jwN0HQt4WMRO8wQHww== dependencies: "@types/googlemaps" "^3.39.6" - algoliasearch-helper "^3.4.4" + "@types/hogan.js" "^3.0.0" + algoliasearch-helper "^3.4.5" classnames "^2.2.5" events "^1.1.0" hogan.js "^3.0.2" From d9779b5d8a462e5720f849e2e3646dc947267f97 Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Wed, 16 Jun 2021 15:43:46 +0200 Subject: [PATCH 05/14] use a single expression for retrieving all components --- src/components/DynamicWidgets.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/DynamicWidgets.js b/src/components/DynamicWidgets.js index b03903a22..4c1f02bce 100644 --- a/src/components/DynamicWidgets.js +++ b/src/components/DynamicWidgets.js @@ -58,8 +58,7 @@ export default { // by default, render everything, but hidden so that the routing doesn't disappear if (!this.state) { - const allComponents = []; - components.forEach(vnode => allComponents.push(vnode)); + const allComponents = Array.from(components.values()); return createElement( 'div', From 2002f4b5fb8fa893193b4eaf7bc30a1083206fb4 Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Wed, 16 Jun 2021 17:23:16 +0200 Subject: [PATCH 06/14] write more tests --- src/components/__tests__/DynamicWidgets.js | 273 +++++++++++++++++++-- 1 file changed, 252 insertions(+), 21 deletions(-) diff --git a/src/components/__tests__/DynamicWidgets.js b/src/components/__tests__/DynamicWidgets.js index bd23d0853..8fa4f3e9c 100644 --- a/src/components/__tests__/DynamicWidgets.js +++ b/src/components/__tests__/DynamicWidgets.js @@ -4,6 +4,39 @@ import { __setState } from '../../mixins/widget'; import { plugin } from '../../plugin'; jest.mock('../../mixins/widget'); +const MockRefinementList = { + props: { attribute: { type: String } }, + render(h) { + return h('div', { + attrs: { + 'widget-name': 'ais-refinement-list', + attribute: this.attribute, + }, + }); + }, +}; + +const MockMenu = { + props: { attribute: { type: String } }, + render(h) { + return h('div', { + attrs: { 'widget-name': 'ais-menu', attribute: this.attribute }, + }); + }, +}; + +const MockHierarchicalMenu = { + props: { attributes: { type: Array } }, + render(h) { + return h('div', { + attrs: { + 'widget-name': 'ais-hierarchical-menu', + attributes: this.attributes, + }, + }); + }, +}; + it('renders all children without state', () => { const localVue = createLocalVue(); @@ -19,27 +52,43 @@ it('renders all children without state', () => { slots: { default: ` - + - + `, }, + stubs: { + 'ais-refinement-list': MockRefinementList, + 'ais-menu': MockMenu, + 'ais-hierarchical-menu': MockHierarchicalMenu, + }, }); - // the inner widgets don't render anything because state is falsy, but they are mounted expect(wrapper.html()).toMatchInlineSnapshot(` +`); + + attributesToRender = []; + + wrapper.vm.$forceUpdate(); + + expect(wrapper.html()).toMatchInlineSnapshot(` + +
+
+ `); }); From 650b9560bd2eaca248c3755f66b942564eeb6b36 Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Thu, 8 Jul 2021 17:20:08 +0200 Subject: [PATCH 12/14] update instantsearch --- package.json | 2 +- yarn.lock | 29 ++++++++++++++--------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 7f80390b2..14a2b9025 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ }, "dependencies": { "algoliasearch-helper": "^3.1.0", - "instantsearch.js": "^4.24.0" + "instantsearch.js": "^4.25.0" }, "peerDependencies": { "algoliasearch": ">= 3.32.0 < 5", diff --git a/yarn.lock b/yarn.lock index 43abe851f..c6603c491 100644 --- a/yarn.lock +++ b/yarn.lock @@ -698,10 +698,10 @@ "@types/minimatch" "*" "@types/node" "*" -"@types/googlemaps@^3.39.6": - version "3.39.7" - resolved "https://registry.npmjs.org/@types/googlemaps/-/googlemaps-3.39.7.tgz#70c1af22839976cfd462858c882b54f3006f0b08" - integrity sha512-U8ZjnjfGiZXzun8jIDOZ/5Gt5Ky07B9pBhFbgzten1S364bnuueFsCt5e5V7Wn55o26NkLWgc6becL+j401bRw== +"@types/google.maps@^3.45.3": + version "3.45.6" + resolved "https://registry.yarnpkg.com/@types/google.maps/-/google.maps-3.45.6.tgz#441a7bc76424243b307596fc8d282a435a979ebd" + integrity sha512-BzGzxs8UXFxeP8uN/0nRgGbsbpYQxSCKsv/7S8OitU7wwhfFcqQSm5aAcL1nbwueMiJ/VVmIZKPq69s0kX5W+Q== "@types/hogan.js@^3.0.0": version "3.0.0" @@ -1161,10 +1161,10 @@ algoliasearch-helper@^3.1.0: dependencies: events "^1.1.1" -algoliasearch-helper@^3.4.5: - version "3.5.3" - resolved "https://registry.yarnpkg.com/algoliasearch-helper/-/algoliasearch-helper-3.5.3.tgz#fbf8b328bc103efdefde59a7d25eaffe85b2490f" - integrity sha512-DtSlOKAJ6TGkQD6u58g6/ABdMmHf3pAj6xVL5hJF+D4z9ldDRf/f5v6puNIxGOlJRwGVvFGyz34beYNqhLDUbQ== +algoliasearch-helper@^3.5.4: + version "3.5.4" + resolved "https://registry.yarnpkg.com/algoliasearch-helper/-/algoliasearch-helper-3.5.4.tgz#21b20ab8a258daa9dde9aef2daa5e8994cd66077" + integrity sha512-t+FLhXYnPZiwjYe5ExyN962HQY8mi3KwRju3Lyf6OBgtRdx30d6mqvtClXf5NeBihH45Xzj6t4Y5YyvAI432XA== dependencies: events "^1.1.1" @@ -7897,19 +7897,18 @@ instantsearch.css@7.3.1: resolved "https://registry.yarnpkg.com/instantsearch.css/-/instantsearch.css-7.3.1.tgz#7ab74a8f355091ae040947a9cf5438f379026622" integrity sha512-/kaMDna5D+Q9mImNBHEhb9HgHATDOFKYii7N1Iwvrj+lmD9gBJLqVhUw67gftq2O0QI330pFza+CRscIwB1wQQ== -instantsearch.js@^4.24.0: - version "4.24.0" - resolved "https://registry.yarnpkg.com/instantsearch.js/-/instantsearch.js-4.24.0.tgz#220777b0083adb7b912f738b512ecf379dabea85" - integrity sha512-iJ0ieGPPQDxSuobo+TuF2ktSnWAoXBpIP/kQ7HwAiFzLGXCemwOOLN85Z4d7+XbIxUJ+jwN0HQt4WMRO8wQHww== +instantsearch.js@^4.25.0: + version "4.25.0" + resolved "https://registry.yarnpkg.com/instantsearch.js/-/instantsearch.js-4.25.0.tgz#0c631479afa0826af0adee120dc2bbb68e1caeb3" + integrity sha512-146u/zlu+lHjMgykKnvYr5yvM4xB/CHN8jmf5872gYNfjoZlmQ6GAoYwrgRjQrbLAbIZ6hhpXkDhwmoptmvUgQ== dependencies: - "@types/googlemaps" "^3.39.6" + "@types/google.maps" "^3.45.3" "@types/hogan.js" "^3.0.0" - algoliasearch-helper "^3.4.5" + algoliasearch-helper "^3.5.4" classnames "^2.2.5" events "^1.1.0" hogan.js "^3.0.2" preact "^10.0.0" - prop-types "^15.5.10" qs "^6.5.1" interpret@^1.0.0: From 966a8bfedc26ec5a2df4b8dd3585eb1e45baedf5 Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Thu, 8 Jul 2021 17:27:38 +0200 Subject: [PATCH 13/14] address test feedback --- src/components/__tests__/DynamicWidgets.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/__tests__/DynamicWidgets.js b/src/components/__tests__/DynamicWidgets.js index e54c55720..896b37091 100644 --- a/src/components/__tests__/DynamicWidgets.js +++ b/src/components/__tests__/DynamicWidgets.js @@ -115,7 +115,7 @@ it('renders nothing without children', () => { `); }); -it('renders nothing with empty items', () => { +it('renders nothing with empty attributesToRender', () => { const localVue = createLocalVue(); localVue.use(plugin); @@ -134,7 +134,6 @@ it('renders nothing with empty items', () => { }, stubs: { 'ais-refinement-list': MockRefinementList, - 'ais-menu': MockMenu, }, }); From c0d1823fea1f1cab61f6fdc67f1b1a6d7136725a Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Fri, 9 Jul 2021 09:36:20 +0200 Subject: [PATCH 14/14] make the test clearer --- src/components/__tests__/DynamicWidgets.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/__tests__/DynamicWidgets.js b/src/components/__tests__/DynamicWidgets.js index 896b37091..0e22b41de 100644 --- a/src/components/__tests__/DynamicWidgets.js +++ b/src/components/__tests__/DynamicWidgets.js @@ -99,7 +99,7 @@ it('renders all children without state', () => { it('renders nothing without children', () => { __setState({ - attributesToRender: [], + attributesToRender: ['something-that-does-not-show'], }); const wrapper = mount(DynamicWidgets, {