From 617c3b0d4c07a1054d95c9b4316b86dc5112643e Mon Sep 17 00:00:00 2001 From: Manuel Cid Date: Mon, 17 Jun 2024 11:11:36 +0200 Subject: [PATCH 1/5] feat(search): add the capability to reload the current search (#1515) --- .../src/x-modules/search/events.types.ts | 12 ++++++---- .../src/x-modules/search/store/module.ts | 18 +++++++++------ .../src/x-modules/search/store/types.ts | 17 ++++++++------ .../src/x-modules/search/wiring.ts | 23 ++++++++++++++----- .../tests/e2e/reload-search.feature | 19 +++++++++++++++ .../e2e/reload-search/reload-search.spec.ts | 6 +++++ 6 files changed, 71 insertions(+), 24 deletions(-) create mode 100644 packages/x-components/tests/e2e/reload-search.feature create mode 100644 packages/x-components/tests/e2e/reload-search/reload-search.spec.ts diff --git a/packages/x-components/src/x-modules/search/events.types.ts b/packages/x-components/src/x-modules/search/events.types.ts index 267884e35d..526ea526d8 100644 --- a/packages/x-components/src/x-modules/search/events.types.ts +++ b/packages/x-components/src/x-modules/search/events.types.ts @@ -1,11 +1,11 @@ import { + Banner, Facet, + Promoted, + Redirection, Result, Sort, - Redirection, - TaggingRequest, - Promoted, - Banner + TaggingRequest } from '@empathyco/x-types'; import { InternalSearchRequest, InternalSearchResponse } from './types'; @@ -26,6 +26,10 @@ export interface SearchXEvents { * Payload: The new page number. */ PageChanged: number; + /** + * Reload the current search has been requested. + */ + ReloadSearchRequested: void; /** * Results have been changed. * Payload: The new {@link @empathyco/x-types#Result | results}. diff --git a/packages/x-components/src/x-modules/search/store/module.ts b/packages/x-components/src/x-modules/search/store/module.ts index 2da7948952..1679d1f71d 100644 --- a/packages/x-components/src/x-modules/search/store/module.ts +++ b/packages/x-components/src/x-modules/search/store/module.ts @@ -1,18 +1,18 @@ import { isFacetFilter } from '@empathyco/x-types'; import { setQuery } from '../../../store/utils/query.utils'; -import { setStatus } from '../../../store/utils/status-store.utils'; +import { setStatus } from '../../../store'; import { groupItemsBy } from '../../../utils/array'; import { mergeConfig, setConfig } from '../../../store/utils/config-store.utils'; import { UNKNOWN_FACET_KEY } from '../../facets/store/constants'; import { cancelFetchAndSaveSearchResponse, - fetchAndSaveSearchResponse -} from './actions/fetch-and-save-search-response.action'; -import { fetchSearchResponse } from './actions/fetch-search-response.action'; -import { increasePageAppendingResults } from './actions/increase-page-apending-results.action'; -import { resetRequestOnRefinement } from './actions/reset-request-on-refinement.action'; + fetchAndSaveSearchResponse, + fetchSearchResponse, + increasePageAppendingResults, + resetRequestOnRefinement, + saveSearchResponse +} from './actions'; import { saveOrigin } from './actions/save-origin.action'; -import { saveSearchResponse } from './actions/save-search-response.action'; import { setUrlParams } from './actions/set-url-params.action'; import { query } from './getters/query.getter'; import { request } from './getters/request.getter'; @@ -46,6 +46,10 @@ export const searchXStoreModule: SearchXStoreModule = { resetState(state) { Object.assign(state, resettableState()); }, + resetStateForReload(state) { + const { query, facets, sort, page, ...resettable } = resettableState(); + Object.assign(state, resettable); + }, setQuery, setResults(state, results) { state.results = results; diff --git a/packages/x-components/src/x-modules/search/store/types.ts b/packages/x-components/src/x-modules/search/store/types.ts index 848532f4da..08c457936a 100644 --- a/packages/x-components/src/x-modules/search/store/types.ts +++ b/packages/x-components/src/x-modules/search/store/types.ts @@ -7,17 +7,15 @@ import { Redirection, RelatedTag, Result, - Sort, - TaggingRequest, SearchRequest, - SearchResponse + SearchResponse, + Sort, + TaggingRequest } from '@empathyco/x-types'; import { Dictionary } from '@empathyco/x-utils'; -import { XActionContext, XStoreModule } from '../../../store'; +import { StatusMutations, StatusState, XActionContext, XStoreModule } from '../../../store'; import { QueryMutations, QueryState } from '../../../store/utils/query.utils'; -import { StatusMutations, StatusState } from '../../../store/utils/status-store.utils'; -import { QueryOrigin, QueryOriginInit } from '../../../types/origin'; -import { UrlParams } from '../../../types/url-params'; +import { QueryOrigin, QueryOriginInit, UrlParams } from '../../../types'; import { SearchConfig } from '../config.types'; import { InternalSearchRequest, WatchedInternalSearchRequest } from '../types'; import { ConfigMutations } from '../../../store/utils/config-store.utils'; @@ -108,6 +106,11 @@ export interface SearchMutations * {@link searchXStoreModule} for details. */ resetState(): void; + /** + * Resets the "resettable" part of the Search state like {@link SearchMutations.resetState} but + * maintains the values required to perform the search request again. + */ + resetStateForReload(): void; /** * Sets the banners of the module. * diff --git a/packages/x-components/src/x-modules/search/wiring.ts b/packages/x-components/src/x-modules/search/wiring.ts index 7679bce076..8ed51ef822 100644 --- a/packages/x-components/src/x-modules/search/wiring.ts +++ b/packages/x-components/src/x-modules/search/wiring.ts @@ -1,12 +1,13 @@ -import { filterTruthyPayload, namespacedWireCommitWithoutPayload } from '../../wiring'; import { + createWiring, + filterTruthyPayload, namespacedWireCommit, + namespacedWireCommitWithoutPayload, namespacedWireDispatch, - namespacedWireDispatchWithoutPayload -} from '../../wiring/namespaced-wires.factory'; -import { WirePayload } from '../../wiring/wiring.types'; -import { createWiring } from '../../wiring/wiring.utils'; -import { createRawFilters } from '../../utils/filters'; + namespacedWireDispatchWithoutPayload, + WirePayload +} from '../../wiring'; +import { createRawFilters } from '../../utils'; import { InternalSearchRequest } from './types'; /** @@ -130,6 +131,13 @@ export const setSearchPage = wireCommit('setPage'); */ export const setSearchExtraParams = wireCommit('setParams'); +/** + * Resets the search state to reload the current search. + * + * @public + */ +export const resetStateForReloadWire = wireCommitWithoutPayload('resetStateForReload'); + /** * Resets the search state `isNoResults`. * @@ -272,6 +280,9 @@ export const searchWiring = createWiring({ ResultsChanged: { resetAppending }, + ReloadSearchRequested: { + resetStateForReloadWire + }, SelectedSortProvided: { setSort }, diff --git a/packages/x-components/tests/e2e/reload-search.feature b/packages/x-components/tests/e2e/reload-search.feature new file mode 100644 index 0000000000..8848d2861b --- /dev/null +++ b/packages/x-components/tests/e2e/reload-search.feature @@ -0,0 +1,19 @@ +Feature: Reload search + + Background: + Given a results API with 24 results + And a tracking API with a known response + And no special config for layout view + + Scenario Outline: 1. Search is reloaded when event is emitted + When start button is clicked + Then empathize should be visible + When "" is searched + Then results page number 1 is loaded + And search request contains parameter "query" with value "" + When event ReloadSearchRequested is emitted + Then search request contains parameter "query" with value "" + + Examples: + | query | + | lego | diff --git a/packages/x-components/tests/e2e/reload-search/reload-search.spec.ts b/packages/x-components/tests/e2e/reload-search/reload-search.spec.ts new file mode 100644 index 0000000000..360489b0c6 --- /dev/null +++ b/packages/x-components/tests/e2e/reload-search/reload-search.spec.ts @@ -0,0 +1,6 @@ +import { When } from '@badeball/cypress-cucumber-preprocessor'; + +When('event ReloadSearchRequested is emitted', () => { + // eslint-disable-next-line @typescript-eslint/no-unsafe-call + cy.window().then((w: Window) => w.InterfaceX?.bus.emit('ReloadSearchRequested')); +}); From 4b79c80c0c9ee2c7ac7a88da6dc0c418bedda20a Mon Sep 17 00:00:00 2001 From: empathy/x Date: Mon, 17 Jun 2024 09:27:16 +0000 Subject: [PATCH 2/5] chore(release): publish - @empathyco/x-components@5.0.0-alpha.46 --- packages/x-components/CHANGELOG.md | 9 +++++++++ packages/x-components/package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/x-components/CHANGELOG.md b/packages/x-components/CHANGELOG.md index 1769a801aa..e1a86dd9b6 100644 --- a/packages/x-components/CHANGELOG.md +++ b/packages/x-components/CHANGELOG.md @@ -3,6 +3,15 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.0.0-alpha.46](https://github.com/empathyco/x/compare/@empathyco/x-components@5.0.0-alpha.45...@empathyco/x-components@5.0.0-alpha.46) (2024-06-17) + + +### Features + +* **search:** add the capability to reload the current search (#1515) ([617c3b0](https://github.com/empathyco/x/commit/617c3b0d4c07a1054d95c9b4316b86dc5112643e)) + + + ## [5.0.0-alpha.45](https://github.com/empathyco/x/compare/@empathyco/x-components@5.0.0-alpha.44...@empathyco/x-components@5.0.0-alpha.45) (2024-06-14) diff --git a/packages/x-components/package.json b/packages/x-components/package.json index 0e083b074b..62af49f5dc 100644 --- a/packages/x-components/package.json +++ b/packages/x-components/package.json @@ -1,6 +1,6 @@ { "name": "@empathyco/x-components", - "version": "5.0.0-alpha.45", + "version": "5.0.0-alpha.46", "description": "Empathy X Components", "author": "Empathy Systems Corporation S.L.", "license": "Apache-2.0", From 525b020f033b1e44d95e5b4042c8201636c87287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Antonio=20Caba=C3=B1eros?= Date: Mon, 17 Jun 2024 18:56:45 +0200 Subject: [PATCH 3/5] fix(x-module): deprecate useRegisterXModule composable in favour of register the x-module itself in the import (#1520) --- .../src/composables/__tests__/use-getter.spec.ts | 3 +-- .../src/composables/__tests__/use-state.spec.ts | 3 +-- .../src/composables/use-register-x-module.ts | 1 + .../src/plugins/__tests__/x-plugin-alias.spec.ts | 6 +++--- .../src/x-modules/empathize/components/empathize.vue | 2 -- .../x-components/src/x-modules/empathize/x-module.ts | 3 +++ .../src/x-modules/facets/components/clear-filters.vue | 3 --- .../src/x-modules/facets/components/facets/facets.vue | 3 --- .../components/lists/exclude-filters-with-no-results.vue | 2 -- .../x-modules/facets/components/lists/filters-list.vue | 3 --- .../x-modules/facets/components/lists/filters-search.vue | 2 -- .../facets/components/lists/selected-filters-list.vue | 3 --- .../facets/components/lists/selected-filters.vue | 3 --- .../x-modules/facets/components/lists/sliced-filters.vue | 3 --- .../x-modules/facets/components/lists/sorted-filters.vue | 2 -- .../x-modules/facets/components/preselected-filters.vue | 2 ++ packages/x-components/src/x-modules/facets/x-module.ts | 3 +++ .../next-queries/components/next-queries-list.vue | 5 +---- .../x-components/src/x-modules/next-queries/x-module.ts | 3 +++ .../queries-preview/components/query-preview-list.vue | 3 --- .../queries-preview/components/query-preview.vue | 7 +------ .../src/x-modules/queries-preview/x-module.ts | 3 +++ .../src/x-modules/scroll/components/main-scroll-item.vue | 2 -- .../src/x-modules/scroll/components/main-scroll.vue | 7 +------ packages/x-components/src/x-modules/scroll/x-module.ts | 3 +++ .../search-box/components/clear-search-input.vue | 3 --- .../x-modules/search-box/components/search-button.vue | 3 --- .../search-box/components/search-input-placeholder.vue | 3 --- .../src/x-modules/search-box/components/search-input.vue | 3 --- .../x-components/src/x-modules/search-box/x-module.ts | 4 +++- .../src/x-modules/search/components/banner.vue | 3 +-- .../src/x-modules/search/components/banners-list.vue | 3 --- .../x-modules/search/components/partial-query-button.vue | 3 --- .../x-modules/search/components/partial-results-list.vue | 3 --- .../src/x-modules/search/components/promoted.vue | 4 +--- .../src/x-modules/search/components/promoteds-list.vue | 3 --- .../src/x-modules/search/components/results-list.vue | 9 ++------- .../src/x-modules/search/components/sort-dropdown.vue | 4 ++-- .../src/x-modules/search/components/sort-list.vue | 4 ++-- .../src/x-modules/search/components/sort-picker-list.vue | 4 ++-- 40 files changed, 39 insertions(+), 97 deletions(-) diff --git a/packages/x-components/src/composables/__tests__/use-getter.spec.ts b/packages/x-components/src/composables/__tests__/use-getter.spec.ts index 3c103d9160..70019a0803 100644 --- a/packages/x-components/src/composables/__tests__/use-getter.spec.ts +++ b/packages/x-components/src/composables/__tests__/use-getter.spec.ts @@ -2,7 +2,6 @@ import { defineComponent } from 'vue'; import { mount } from '@vue/test-utils'; import { installNewXPlugin } from '../../__tests__/utils'; import { useGetter } from '../use-getter'; -import { useRegisterXModule } from '../use-register-x-module'; import { ExtractGetters } from '../../x-modules/x-modules.types'; import { useStore } from '../use-store'; import { XPlugin } from '../../plugins'; @@ -17,7 +16,7 @@ function render(modulePaths: (keyof ExtractGetters<'historyQueries'>)[]) { const component = defineComponent({ xModule: 'historyQueries', setup: () => { - useRegisterXModule(historyQueriesXModule); + XPlugin.registerXModule(historyQueriesXModule); const historyQueriesGetter = useGetter('historyQueries', modulePaths); return { historyQueriesGetter }; }, diff --git a/packages/x-components/src/composables/__tests__/use-state.spec.ts b/packages/x-components/src/composables/__tests__/use-state.spec.ts index 771870e030..ef124b8559 100644 --- a/packages/x-components/src/composables/__tests__/use-state.spec.ts +++ b/packages/x-components/src/composables/__tests__/use-state.spec.ts @@ -3,7 +3,6 @@ import { mount } from '@vue/test-utils'; import { installNewXPlugin } from '../../__tests__/utils'; import { XPlugin } from '../../plugins'; import { ExtractState } from '../../x-modules/x-modules.types'; -import { useRegisterXModule } from '../use-register-x-module'; import { useState } from '../use-state'; import { searchBoxXModule } from '../../x-modules/search-box/x-module'; import { useStore } from '../use-store'; @@ -17,7 +16,7 @@ function render(modulePaths: (keyof ExtractState<'searchBox'> & string)[]) { const component = defineComponent({ xModule: 'searchBox', setup: () => { - useRegisterXModule(searchBoxXModule); + XPlugin.registerXModule(searchBoxXModule); const searchBoxUseState = useState('searchBox', modulePaths); return { searchBoxUseState }; }, diff --git a/packages/x-components/src/composables/use-register-x-module.ts b/packages/x-components/src/composables/use-register-x-module.ts index 41bfc0b665..2d421e8cef 100644 --- a/packages/x-components/src/composables/use-register-x-module.ts +++ b/packages/x-components/src/composables/use-register-x-module.ts @@ -8,6 +8,7 @@ import { XPlugin } from '../plugins/x-plugin'; * * @param module - The module associated to the X-Component that is being registered. * @public + * @deprecated Use `XPlugin.registerXModule(xModule)` instead. */ export function useRegisterXModule(module: AnyXModule): void { XPlugin.registerXModule(module); diff --git a/packages/x-components/src/plugins/__tests__/x-plugin-alias.spec.ts b/packages/x-components/src/plugins/__tests__/x-plugin-alias.spec.ts index 217e16ea97..41baa25128 100644 --- a/packages/x-components/src/plugins/__tests__/x-plugin-alias.spec.ts +++ b/packages/x-components/src/plugins/__tests__/x-plugin-alias.spec.ts @@ -46,10 +46,10 @@ describe('testing plugin alias', () => { }, status: { identifierResults: undefined, - nextQueries: undefined, + nextQueries: 'initial', // It is already registered by the `nextQueriesXModule` import itself popularSearches: undefined, querySuggestions: 'initial', // It is already registered by the `querySuggestionsXModule` import itself - recommendations: 'initial', // It is already registered by the `relatedTagsXModule` import itself + recommendations: 'initial', // It is already registered by the `recommendationsXModule` import itself relatedTags: 'initial', // It is already registered by the `relatedTagsXModule` import itself search: 'initial' // It is already registered by the `searchXModule` import itself }, @@ -61,7 +61,7 @@ describe('testing plugin alias', () => { isHistoryQueriesEnabled: false, fromNoResultsWithFilters: false, identifierResults: [], - searchBoxStatus: undefined, + searchBoxStatus: 'initial', // It is already registered by the `searchBoxXModule` import itself isEmpathizeOpen: false, nextQueries: [], noResults: false, diff --git a/packages/x-components/src/x-modules/empathize/components/empathize.vue b/packages/x-components/src/x-modules/empathize/components/empathize.vue index 96c205ed40..4a9f5150e7 100644 --- a/packages/x-components/src/x-modules/empathize/components/empathize.vue +++ b/packages/x-components/src/x-modules/empathize/components/empathize.vue @@ -19,7 +19,6 @@ import { defineComponent, PropType, ref } from 'vue'; import { NoElement } from '../../../components/no-element'; import { useDebounce } from '../../../composables/use-debounce'; - import { useRegisterXModule } from '../../../composables/use-register-x-module'; import { use$x } from '../../../composables/use-$x'; import { AnimationProp } from '../../../types'; import { XEvent } from '../../../wiring'; @@ -58,7 +57,6 @@ } }, setup(props) { - useRegisterXModule(empathizeXModule); const $x = use$x(); const empathizeRef = ref(); diff --git a/packages/x-components/src/x-modules/empathize/x-module.ts b/packages/x-components/src/x-modules/empathize/x-module.ts index 7c48dc9111..16542a9101 100644 --- a/packages/x-components/src/x-modules/empathize/x-module.ts +++ b/packages/x-components/src/x-modules/empathize/x-module.ts @@ -1,3 +1,4 @@ +import { XPlugin } from '../../plugins/x-plugin'; import { XModule } from '../x-modules.types'; import { empathizeEmitters } from './store/emitters'; import { empathizeXStoreModule } from './store/module'; @@ -23,3 +24,5 @@ export const empathizeXModule: EmpathizeXModule = { storeEmitters: empathizeEmitters, wiring: empathizeWiring }; + +XPlugin.registerXModule(empathizeXModule); diff --git a/packages/x-components/src/x-modules/facets/components/clear-filters.vue b/packages/x-components/src/x-modules/facets/components/clear-filters.vue index 265393de7b..9b1e188002 100644 --- a/packages/x-components/src/x-modules/facets/components/clear-filters.vue +++ b/packages/x-components/src/x-modules/facets/components/clear-filters.vue @@ -15,7 +15,6 @@ import { Facet } from '@empathyco/x-types'; import { computed, defineComponent, PropType } from 'vue'; import BaseEventButton from '../../../components/base-event-button.vue'; - import { useRegisterXModule } from '../../../composables/use-register-x-module'; import { VueCSSClasses } from '../../../utils/types'; import { XEventsTypes } from '../../../wiring/events.types'; import { useFacets } from '../composables/use-facets'; @@ -37,8 +36,6 @@ alwaysVisible: Boolean }, setup: function (props) { - useRegisterXModule(facetsXModule); - const { selectedFilters, hasSelectedFilters, isVisible } = useFacets(props); /** diff --git a/packages/x-components/src/x-modules/facets/components/facets/facets.vue b/packages/x-components/src/x-modules/facets/components/facets/facets.vue index 9cc6d91ef4..7cb66653b1 100644 --- a/packages/x-components/src/x-modules/facets/components/facets/facets.vue +++ b/packages/x-components/src/x-modules/facets/components/facets/facets.vue @@ -58,7 +58,6 @@ import { Dictionary, map, objectFilter } from '@empathyco/x-utils'; import Vue, { computed, ComputedRef, defineComponent, PropType } from 'vue'; import { useGetter } from '../../../../composables/use-getter'; - import { useRegisterXModule } from '../../../../composables/use-register-x-module'; import { toKebabCase } from '../../../../utils/string'; import { useFacets } from '../../composables/use-facets'; import { facetsXModule } from '../../x-module'; @@ -118,8 +117,6 @@ renderableFacets: String }, setup: function (props, { slots }) { - useRegisterXModule(facetsXModule); - const { selectedFiltersByFacet } = useFacets(props); const { facets } = useGetter('facets', ['facets']) as { diff --git a/packages/x-components/src/x-modules/facets/components/lists/exclude-filters-with-no-results.vue b/packages/x-components/src/x-modules/facets/components/lists/exclude-filters-with-no-results.vue index bf29ecb616..fbc832e5de 100644 --- a/packages/x-components/src/x-modules/facets/components/lists/exclude-filters-with-no-results.vue +++ b/packages/x-components/src/x-modules/facets/components/lists/exclude-filters-with-no-results.vue @@ -2,7 +2,6 @@ import { Filter, isBooleanFilter } from '@empathyco/x-types'; import { computed, defineComponent, PropType, provide, h } from 'vue'; import { facetsXModule } from '../../x-module'; - import { useRegisterXModule } from '../../../../composables/use-register-x-module'; import { useFiltersInjection } from '../../composables/use-filters-injection'; /** @@ -37,7 +36,6 @@ } }, setup(props, { slots }) { - useRegisterXModule(facetsXModule); const renderedFilters = useFiltersInjection(props); /** diff --git a/packages/x-components/src/x-modules/facets/components/lists/filters-list.vue b/packages/x-components/src/x-modules/facets/components/lists/filters-list.vue index 52f1dde2f3..41b7be589a 100644 --- a/packages/x-components/src/x-modules/facets/components/lists/filters-list.vue +++ b/packages/x-components/src/x-modules/facets/components/lists/filters-list.vue @@ -28,7 +28,6 @@ import { VueCSSClasses } from '../../../../utils/types'; import { facetsXModule } from '../../x-module'; import { AnimationProp } from '../../../../types/animation-prop'; - import { useRegisterXModule } from '../../../../composables/use-register-x-module'; import { useFiltersInjection } from '../../composables/use-filters-injection'; /** @@ -71,8 +70,6 @@ } }, setup(props) { - useRegisterXModule(facetsXModule); - const renderedFilters = useFiltersInjection(props); /** diff --git a/packages/x-components/src/x-modules/facets/components/lists/filters-search.vue b/packages/x-components/src/x-modules/facets/components/lists/filters-search.vue index 7bccb66310..e67e47874e 100644 --- a/packages/x-components/src/x-modules/facets/components/lists/filters-search.vue +++ b/packages/x-components/src/x-modules/facets/components/lists/filters-search.vue @@ -32,7 +32,6 @@ import { normalizeString } from '../../../../utils/normalize'; import { DebouncedFunction, VueCSSClasses } from '../../../../utils/types'; import { facetsXModule } from '../../x-module'; - import { useRegisterXModule } from '../../../../composables/use-register-x-module'; import { useFiltersInjection } from '../../composables/use-filters-injection'; /** @@ -69,7 +68,6 @@ } }, setup(props) { - useRegisterXModule(facetsXModule); const renderedFilters = useFiltersInjection(props); let query = ref(''); diff --git a/packages/x-components/src/x-modules/facets/components/lists/selected-filters-list.vue b/packages/x-components/src/x-modules/facets/components/lists/selected-filters-list.vue index 8515fff460..98f123fb14 100644 --- a/packages/x-components/src/x-modules/facets/components/lists/selected-filters-list.vue +++ b/packages/x-components/src/x-modules/facets/components/lists/selected-filters-list.vue @@ -40,7 +40,6 @@ diff --git a/packages/_vue3-migration-test/src/x-modules/identifier-results/index.ts b/packages/_vue3-migration-test/src/x-modules/identifier-results/index.ts new file mode 100644 index 0000000000..38da673ebb --- /dev/null +++ b/packages/_vue3-migration-test/src/x-modules/identifier-results/index.ts @@ -0,0 +1,2 @@ +export * from './components'; +export * from './x-module'; diff --git a/packages/_vue3-migration-test/src/x-modules/identifier-results/x-module.ts b/packages/_vue3-migration-test/src/x-modules/identifier-results/x-module.ts new file mode 100644 index 0000000000..70ba15093a --- /dev/null +++ b/packages/_vue3-migration-test/src/x-modules/identifier-results/x-module.ts @@ -0,0 +1,21 @@ +import { PrivateXModuleOptions } from '../../../../x-components/src/plugins/x-plugin.types'; +import { IdentifierResultsXModule } from '../../../../x-components/src/x-modules/identifier-results/x-module'; +import { createResultStub } from '../../../../x-components/src/__stubs__/results-stubs.factory'; + +export const identifierResultsXModule: PrivateXModuleOptions = { + storeModule: { + state: { + config: { + debounceInMs: 600, + maxItemsToRequest: 10, + identifierDetectionRegexp: '^[0-9]{2,}$', + separatorChars: '-/ ' + }, + identifierResults: ['123A', '123B', '123C', '123D'].map(id => createResultStub(id)), + origin: null, + query: 'test', + params: {}, + status: 'initial' + } + } +}; diff --git a/packages/_vue3-migration-test/src/x-modules/index.ts b/packages/_vue3-migration-test/src/x-modules/index.ts index d13eb66456..a78483264e 100644 --- a/packages/_vue3-migration-test/src/x-modules/index.ts +++ b/packages/_vue3-migration-test/src/x-modules/index.ts @@ -10,3 +10,4 @@ export * from './history-queries'; export * from './query-suggestions'; export * from './semantic-queries'; export * from './recommendations'; +export * from './identifier-results'; diff --git a/packages/x-components/src/plugins/__tests__/x-plugin-alias.spec.ts b/packages/x-components/src/plugins/__tests__/x-plugin-alias.spec.ts index 41baa25128..bb3c969a0c 100644 --- a/packages/x-components/src/plugins/__tests__/x-plugin-alias.spec.ts +++ b/packages/x-components/src/plugins/__tests__/x-plugin-alias.spec.ts @@ -45,7 +45,7 @@ describe('testing plugin alias', () => { search: '' }, status: { - identifierResults: undefined, + identifierResults: 'initial', // It is already registered by the `identifierResultsXModule` import itself nextQueries: 'initial', // It is already registered by the `nextQueriesXModule` import itself popularSearches: undefined, querySuggestions: 'initial', // It is already registered by the `querySuggestionsXModule` import itself diff --git a/packages/x-components/src/x-modules/identifier-results/components/identifier-result.vue b/packages/x-components/src/x-modules/identifier-results/components/identifier-result.vue index af62e9e9b6..f4231c6736 100644 --- a/packages/x-components/src/x-modules/identifier-results/components/identifier-result.vue +++ b/packages/x-components/src/x-modules/identifier-results/components/identifier-result.vue @@ -9,11 +9,10 @@ diff --git a/packages/x-components/src/x-modules/identifier-results/components/identifier-results.vue b/packages/x-components/src/x-modules/identifier-results/components/identifier-results.vue index c302154074..dd3ea1f051 100644 --- a/packages/x-components/src/x-modules/identifier-results/components/identifier-results.vue +++ b/packages/x-components/src/x-modules/identifier-results/components/identifier-results.vue @@ -17,13 +17,12 @@