diff --git a/packages/_vue3-migration-test/src/App.vue b/packages/_vue3-migration-test/src/App.vue index dadc1fe5ac..627b5fdf38 100644 --- a/packages/_vue3-migration-test/src/App.vue +++ b/packages/_vue3-migration-test/src/App.vue @@ -12,7 +12,16 @@ - + diff --git a/packages/_vue3-migration-test/src/main.ts b/packages/_vue3-migration-test/src/main.ts index 80f0c05f47..9e41ec49d9 100644 --- a/packages/_vue3-migration-test/src/main.ts +++ b/packages/_vue3-migration-test/src/main.ts @@ -1,15 +1,6 @@ -import { QuerySuggestionsRequest, XComponentsAdapter } from '@empathyco/x-types'; import { Component, configureCompat, createApp } from 'vue'; import { createStore } from 'vuex'; -import { getRelatedTagsStub } from '../../x-components/src/__stubs__/related-tags-stubs.factory'; -import { getQuerySuggestionsStub } from '../../x-components/src/__stubs__/query-suggestions-stubs.factory'; -import { - createResultStub, - getBannersStub, - getNextQueriesStub, - getPromotedsStub, - getResultsStub -} from '../../x-components/src/__stubs__/index'; +import { platformAdapter } from '../../x-adapter-platform/src/platform.adapter'; import { XInstaller } from '../../x-components/src/x-installer/x-installer/x-installer'; import App from './App.vue'; import router from './router'; @@ -45,45 +36,7 @@ if (VUE_COMPAT_MODE === 2) { }); } -const adapter = { - relatedTags: () => - new Promise(resolve => { - resolve({ relatedTags: getRelatedTagsStub(10) }); - }), - querySuggestions: (request: QuerySuggestionsRequest) => - new Promise(resolve => { - resolve({ suggestions: getQuerySuggestionsStub(request.query, 5) }); - }), - nextQueries: () => - new Promise(resolve => { - resolve({ - nextQueries: [ - ...getNextQueriesStub(), - { - facets: [], - isCurated: false, - modelName: 'NextQuery', - query: 'next_query_preview', - results: getResultsStub(10), - totalResults: 10 - } - ] - }); - }), - search: () => - new Promise(resolve => { - resolve({ - results: getResultsStub(10), - totalResults: 50, - promoteds: getPromotedsStub(), - banners: getBannersStub() - }); - }), - identifierResults: () => - new Promise(resolve => - resolve({ results: ['123A', '123B', '123C', '123D'].map(id => createResultStub(id)) }) - ) -} as unknown as XComponentsAdapter; +const adapter = platformAdapter; const store = createStore({}); @@ -96,6 +49,7 @@ window.initX = { instance: 'empathy', lang: 'en' }; + new XInstaller({ adapter, store, diff --git a/packages/_vue3-migration-test/src/router.ts b/packages/_vue3-migration-test/src/router.ts index da58d80ff3..5f033152cc 100644 --- a/packages/_vue3-migration-test/src/router.ts +++ b/packages/_vue3-migration-test/src/router.ts @@ -40,10 +40,16 @@ import { TestPopularSearches, TestNextQueries, TestIdentifierResults, - TestExtraParams + TestExtraParams, + TestSearch } from './'; const routes = [ + { + path: '/', + name: 'Home', + component: TestSearch + }, { path: '/animate-width', name: 'AnimateWidth', diff --git a/packages/_vue3-migration-test/src/x-modules/search/x-module.ts b/packages/_vue3-migration-test/src/x-modules/search/x-module.ts index 4abe995261..1a5d9909dd 100644 --- a/packages/_vue3-migration-test/src/x-modules/search/x-module.ts +++ b/packages/_vue3-migration-test/src/x-modules/search/x-module.ts @@ -1,19 +1,15 @@ -import { getResultsStub } from '../../../../x-components/src/__stubs__/results-stubs.factory'; -import { getBannersStub } from '../../../../x-components/src/__stubs__/banners-stubs.factory'; -import { getPromotedsStub } from '../../../../x-components/src/__stubs__/promoteds-stubs.factory'; import { PrivateXModuleOptions } from '../../../../x-components/src/plugins'; import { SearchXModule } from '../../../../x-components/src/x-modules/search'; -import { getPartialResultsStub } from '../../../../x-components/src/__stubs__/partials-results-stubs.factory'; export const searchXModule = { storeModule: { state: { - results: getResultsStub(10), - promoteds: getPromotedsStub(), - banners: getBannersStub(), - status: 'success', - spellcheckedQuery: 'spellcheckedQuery', - partialResults: getPartialResultsStub() + results: [], + promoteds: [], + banners: [], + status: 'initial', + spellcheckedQuery: '', + partialResults: [] } } } as PrivateXModuleOptions; diff --git a/packages/x-components/src/x-modules/search/store/emitters.ts b/packages/x-components/src/x-modules/search/store/emitters.ts index 3e0fc5fc5d..fae5f5bc18 100644 --- a/packages/x-components/src/x-modules/search/store/emitters.ts +++ b/packages/x-components/src/x-modules/search/store/emitters.ts @@ -16,8 +16,24 @@ export const searchEmitters = createStoreEmitters(searchXStoreModule, { }, PageChanged: state => state.page, ResultsChanged: state => state.results, - SearchRequestChanged: (_, getters) => getters.request, - SearchRequestUpdated: (_, getters) => getters.request, + SearchRequestChanged: state => { + return { + query: state.query, + sort: state.sort, + page: state.page, + filters: state.selectedFilters, + extraParams: state.params + }; + }, + SearchRequestUpdated: state => { + return { + query: state.query, + sort: state.sort, + page: state.page, + filters: state.selectedFilters, + extraParams: state.params + }; + }, SearchResponseChanged: { selector: (state, getters) => { return {