From 22c5325666441121e8ee64bfaa4c51ddad11939a Mon Sep 17 00:00:00 2001 From: lauramargar <114984466+lauramargar@users.noreply.github.com> Date: Wed, 12 Jun 2024 17:31:52 +0200 Subject: [PATCH] feat: migrate RTs module to composition API (#1498) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jose A. Cabaneros Co-authored-by: Diego Pascual Co-authored-by: VĂ­ctor CG --- packages/_vue3-migration-test/src/main.ts | 7 +- packages/_vue3-migration-test/src/router.ts | 6 + .../src/x-modules/index.ts | 1 + .../src/x-modules/related-tags/index.ts | 1 + .../related-tags/test-related-tags.vue | 17 + .../plugins/__tests__/x-plugin-alias.spec.ts | 2 +- .../related-tags/components/related-tag.vue | 227 +- .../related-tags/components/related-tags.vue | 93 +- .../src/x-modules/related-tags/x-module.ts | 3 + pnpm-lock.yaml | 11315 ++++------------ 10 files changed, 3157 insertions(+), 8515 deletions(-) create mode 100644 packages/_vue3-migration-test/src/x-modules/related-tags/index.ts create mode 100644 packages/_vue3-migration-test/src/x-modules/related-tags/test-related-tags.vue diff --git a/packages/_vue3-migration-test/src/main.ts b/packages/_vue3-migration-test/src/main.ts index 9f535079cd..72e30f228b 100644 --- a/packages/_vue3-migration-test/src/main.ts +++ b/packages/_vue3-migration-test/src/main.ts @@ -2,6 +2,7 @@ import { QuerySuggestionsRequest, XComponentsAdapter } from '@empathyco/x-types' import { Component, configureCompat, createApp } from 'vue'; import { createStore } from 'vuex'; import { xPlugin } from '../../x-components/src/plugins/x-plugin'; +import { getRelatedTagsStub } from '../../x-components/src/__stubs__/related-tags-stubs.factory'; import { getQuerySuggestionsStub } from '../../x-components/src/__stubs__/query-suggestions-stubs.factory'; import App from './App.vue'; import router from './router'; @@ -28,11 +29,15 @@ 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) }); }) -} as XComponentsAdapter; +} as unknown as XComponentsAdapter; const store = createStore({}); diff --git a/packages/_vue3-migration-test/src/router.ts b/packages/_vue3-migration-test/src/router.ts index 9917df8ffa..082ac05f28 100644 --- a/packages/_vue3-migration-test/src/router.ts +++ b/packages/_vue3-migration-test/src/router.ts @@ -29,6 +29,7 @@ import { TestBaseResultImages, TestBasePanel, TestBaseKeyboardNavigation, + TestRelatedTags, TestPartialResultsList, TestBaseEventsModal, TestBaseIdModal, @@ -181,6 +182,11 @@ const routes = [ name: 'TestBaseKeyboardNavigation', component: TestBaseKeyboardNavigation }, + { + path: '/related-tags', + name: 'RelatedTags', + component: TestRelatedTags + }, { path: '/partial-results-list', name: 'PartialResultsList', diff --git a/packages/_vue3-migration-test/src/x-modules/index.ts b/packages/_vue3-migration-test/src/x-modules/index.ts index f45462a466..f0dcd3688d 100644 --- a/packages/_vue3-migration-test/src/x-modules/index.ts +++ b/packages/_vue3-migration-test/src/x-modules/index.ts @@ -5,5 +5,6 @@ export * from './search'; export * from './search-box'; export { default as TestElementsList } from './test-elements-list.vue'; export * from './scroll'; +export * from './related-tags'; export * from './history-queries'; export * from './query-suggestions'; diff --git a/packages/_vue3-migration-test/src/x-modules/related-tags/index.ts b/packages/_vue3-migration-test/src/x-modules/related-tags/index.ts new file mode 100644 index 0000000000..ae1b28acde --- /dev/null +++ b/packages/_vue3-migration-test/src/x-modules/related-tags/index.ts @@ -0,0 +1 @@ +export { default as TestRelatedTags } from './test-related-tags.vue'; diff --git a/packages/_vue3-migration-test/src/x-modules/related-tags/test-related-tags.vue b/packages/_vue3-migration-test/src/x-modules/related-tags/test-related-tags.vue new file mode 100644 index 0000000000..4bdf1c7323 --- /dev/null +++ b/packages/_vue3-migration-test/src/x-modules/related-tags/test-related-tags.vue @@ -0,0 +1,17 @@ + + + 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 1b04ede1ad..26d872732b 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 @@ -50,7 +50,7 @@ describe('testing plugin alias', () => { popularSearches: undefined, querySuggestions: 'initial', // It is already registered by the `querySuggestionsXModule` import itself recommendations: undefined, - relatedTags: undefined, + relatedTags: 'initial', // It is already registered by the `relatedTagsXModule` import itself search: undefined }, device: null, diff --git a/packages/x-components/src/x-modules/related-tags/components/related-tag.vue b/packages/x-components/src/x-modules/related-tags/components/related-tag.vue index 9ed81a4b90..90fbf0f58f 100644 --- a/packages/x-components/src/x-modules/related-tags/components/related-tag.vue +++ b/packages/x-components/src/x-modules/related-tags/components/related-tag.vue @@ -1,5 +1,6 @@