diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 16d1d347e8..041e449713 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,11 +8,19 @@ jobs: runs-on: ubuntu-latest steps: + # Use GitHub App token as a workaround to allow bypassing branch-protection rules + # https://github.com/orgs/community/discussions/13836#discussioncomment-8535364 + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.GH_TOKENS_APP_ID }} + private-key: ${{ secrets.GH_TOKENS_APP_PRIVATE_KEY }} + - name: checkout repository uses: actions/checkout@v4 with: + token: ${{ steps.app-token.outputs.token }} fetch-depth: 0 - persist-credentials: false - name: Install uses: ./.github/actions/install @@ -34,4 +42,4 @@ jobs: uses: ./.github/actions/release-alpha with: npm_token: ${{ secrets.NPM_TOKEN_GRANULAR_ACCESS }} - github_token: ${{ secrets.SUPPORT_TOKEN }} + github_token: ${{ steps.app-token.outputs.token }} diff --git a/.github/workflows/edocs-dynamic-sync.yml b/.github/workflows/edocs-dynamic-sync.yml index 2ea720a5af..a882582b61 100644 --- a/.github/workflows/edocs-dynamic-sync.yml +++ b/.github/workflows/edocs-dynamic-sync.yml @@ -4,9 +4,18 @@ jobs: connect-with-edocs: runs-on: ubuntu-latest steps: + # Use GitHub App token as a workaround to allow bypassing branch-protection rules + # https://github.com/orgs/community/discussions/13836#discussioncomment-8535364 + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.GH_TOKENS_APP_ID }} + private-key: ${{ secrets.GH_TOKENS_APP_PRIVATE_KEY }} + - name: Checkout X mono-repo uses: actions/checkout@v4 with: + token: ${{ steps.app-token.outputs.token }} fetch-depth: 0 - name: Get X Components Version id: package-version @@ -23,5 +32,5 @@ jobs: --url https://api.github.com/repos/empathyco/docs-framework/actions/workflows/93444504/dispatches \ --data '{"ref": "main", "inputs": {"branchName": "${{ env.BRANCH_NAME }}", "version": "${{ steps.package-version.outputs.current-version }}"}}' env: - GITHUB_TOKEN: ${{ secrets.SUPPORT_TOKEN }} + GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 1d7178f1cd..f57d24c2d2 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -9,10 +9,18 @@ jobs: options: --user 1001 steps: + # Use GitHub App token as a workaround to allow bypassing branch-protection rules + # https://github.com/orgs/community/discussions/13836#discussioncomment-8535364 + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.GH_TOKENS_APP_ID }} + private-key: ${{ secrets.GH_TOKENS_APP_PRIVATE_KEY }} + - uses: actions/checkout@v4 with: + token: ${{ steps.app-token.outputs.token }} fetch-depth: 0 - persist-credentials: false # Install pnpm because it is not included in our container image - name: install pnpm @@ -51,6 +59,6 @@ jobs: - name: push tags uses: ad-m/github-push-action@master with: - github_token: ${{ secrets.SUPPORT_TOKEN }} + github_token: ${{ steps.app-token.outputs.token }} branch: ${{ github.ref }} tags: true diff --git a/.github/workflows/release-alpha.yml b/.github/workflows/release-alpha.yml index 473a3cf2c3..5eb6681145 100644 --- a/.github/workflows/release-alpha.yml +++ b/.github/workflows/release-alpha.yml @@ -9,11 +9,19 @@ jobs: options: --user 1001 steps: + # Use GitHub App token as a workaround to allow bypassing branch-protection rules + # https://github.com/orgs/community/discussions/13836#discussioncomment-8535364 + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.GH_TOKENS_APP_ID }} + private-key: ${{ secrets.GH_TOKENS_APP_PRIVATE_KEY }} + - name: checkout repository uses: actions/checkout@v4 with: + token: ${{ steps.app-token.outputs.token }} fetch-depth: 0 - persist-credentials: false # Install pnpm because it is not included in our container image - name: install pnpm @@ -28,4 +36,4 @@ jobs: uses: ./.github/actions/release-alpha with: npm_token: ${{ secrets.NPM_TOKEN_GRANULAR_ACCESS }} - github_token: ${{ secrets.SUPPORT_TOKEN }} + github_token: ${{ steps.app-token.outputs.token }} diff --git a/packages/_vue3-migration-test/CHANGELOG.md b/packages/_vue3-migration-test/CHANGELOG.md index 8ed2aadd1a..dee3448d60 100644 --- a/packages/_vue3-migration-test/CHANGELOG.md +++ b/packages/_vue3-migration-test/CHANGELOG.md @@ -3,6 +3,33 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.0-alpha.24](https://github.com/empathyco/x/compare/vue3-migration-test@1.0.0-alpha.23...vue3-migration-test@1.0.0-alpha.24) (2024-06-05) + + +### Features + +* migrate PartialQueryButton and PartialResultsList (#1501) ([5e87123](https://github.com/empathyco/x/commit/5e87123d4a6c1edeb05f83c31ee8f096b5558e0f)) + + + +## [1.0.0-alpha.23](https://github.com/empathyco/x/compare/vue3-migration-test@1.0.0-alpha.22...vue3-migration-test@1.0.0-alpha.23) (2024-06-04) + + +### Features + +* add BaseEventsModal to the playground ([3e437c5](https://github.com/empathyco/x/commit/3e437c56d4e3f314b373b486e8926c4f4b028fc6)) + + + +## [1.0.0-alpha.22](https://github.com/empathyco/x/compare/vue3-migration-test@1.0.0-alpha.21...vue3-migration-test@1.0.0-alpha.22) (2024-06-04) + + +### Features + +* **base-id-modal:** migrate to composition API (#1500) ([6274c67](https://github.com/empathyco/x/commit/6274c676946536c9c1c4e54205ebda18c79b8f55)) + + + ## [1.0.0-alpha.21](https://github.com/empathyco/x/compare/vue3-migration-test@1.0.0-alpha.20...vue3-migration-test@1.0.0-alpha.21) (2024-05-31) diff --git a/packages/_vue3-migration-test/package.json b/packages/_vue3-migration-test/package.json index 88f56b6fac..1960ee29e8 100644 --- a/packages/_vue3-migration-test/package.json +++ b/packages/_vue3-migration-test/package.json @@ -1,7 +1,7 @@ { "name": "vue3-migration-test", "private": "true", - "version": "1.0.0-alpha.21", + "version": "1.0.0-alpha.24", "scripts": { "dev": "vite", "preview": "vite preview", diff --git a/packages/_vue3-migration-test/src/components/index.ts b/packages/_vue3-migration-test/src/components/index.ts index 0210867c1e..45c4690d74 100644 --- a/packages/_vue3-migration-test/src/components/index.ts +++ b/packages/_vue3-migration-test/src/components/index.ts @@ -12,3 +12,5 @@ export { default as TestHighlight } from './test-highlight.vue'; export { default as TestBaseResultImages } from './result/test-base-result-images.vue'; export { default as TestBasePanel } from './panels/test-base-panel.vue'; export { default as TestBaseKeyboardNavigation } from './test-base-keyboard-navigation.vue'; +export { default as TestBaseEventsModal } from './modals/test-base-events-modal.vue'; +export { default as TestBaseIdModal } from './modals/test-base-id-modal.vue'; diff --git a/packages/_vue3-migration-test/src/components/modals/test-base-events-modal.vue b/packages/_vue3-migration-test/src/components/modals/test-base-events-modal.vue new file mode 100644 index 0000000000..935e5363a2 --- /dev/null +++ b/packages/_vue3-migration-test/src/components/modals/test-base-events-modal.vue @@ -0,0 +1,43 @@ + + + Open modal + + Hello + The modal is working with events!! + Close modal + + + + + + + diff --git a/packages/_vue3-migration-test/src/components/modals/test-base-id-modal.vue b/packages/_vue3-migration-test/src/components/modals/test-base-id-modal.vue new file mode 100644 index 0000000000..8819f09120 --- /dev/null +++ b/packages/_vue3-migration-test/src/components/modals/test-base-id-modal.vue @@ -0,0 +1,33 @@ + + + Open + + Hello + The base id modal is working + Close + + + + + + + diff --git a/packages/_vue3-migration-test/src/router.ts b/packages/_vue3-migration-test/src/router.ts index d40529c6d0..ee2b75b2bc 100644 --- a/packages/_vue3-migration-test/src/router.ts +++ b/packages/_vue3-migration-test/src/router.ts @@ -24,10 +24,15 @@ import { TestSlidingPanel, TestBaseSuggestions, TestHighlight, + TestHistoryQueries, + TestMyHistory, TestBaseResultImages, TestBasePanel, TestBaseKeyboardNavigation, - TestRelatedTags + TestRelatedTags, + TestPartialResultsList, + TestBaseEventsModal, + TestBaseIdModal } from './'; const routes = [ @@ -151,6 +156,16 @@ const routes = [ name: 'Highlight', component: TestHighlight }, + { + path: '/history-queries', + name: 'HistoryQueries', + component: TestHistoryQueries + }, + { + path: '/my-history', + name: 'MyHistory', + component: TestMyHistory + }, { path: '/base-result-images', name: 'BaseResultImages', @@ -170,6 +185,21 @@ const routes = [ path: '/related-tags', name: 'RelatedTags', component: TestRelatedTags + }, + { + path: '/partial-results-list', + name: 'PartialResultsList', + component: TestPartialResultsList + }, + { + path: '/base-events-modal', + name: 'BaseEventsModal', + component: TestBaseEventsModal + }, + { + path: '/test-base-id-modal', + name: 'TestBaseIdModal', + component: TestBaseIdModal } ]; diff --git a/packages/_vue3-migration-test/src/x-modules/history-queries/components/index.ts b/packages/_vue3-migration-test/src/x-modules/history-queries/components/index.ts new file mode 100644 index 0000000000..b13804333c --- /dev/null +++ b/packages/_vue3-migration-test/src/x-modules/history-queries/components/index.ts @@ -0,0 +1,2 @@ +export { default as TestHistoryQueries } from './test-history-queries.vue'; +export { default as TestMyHistory } from './test-my-history.vue'; diff --git a/packages/_vue3-migration-test/src/x-modules/history-queries/components/test-history-queries.vue b/packages/_vue3-migration-test/src/x-modules/history-queries/components/test-history-queries.vue new file mode 100644 index 0000000000..6d9928394e --- /dev/null +++ b/packages/_vue3-migration-test/src/x-modules/history-queries/components/test-history-queries.vue @@ -0,0 +1,16 @@ + + + + + + + Clear previous searches + + + + diff --git a/packages/_vue3-migration-test/src/x-modules/history-queries/components/test-my-history.vue b/packages/_vue3-migration-test/src/x-modules/history-queries/components/test-my-history.vue new file mode 100644 index 0000000000..bd1eea8d94 --- /dev/null +++ b/packages/_vue3-migration-test/src/x-modules/history-queries/components/test-my-history.vue @@ -0,0 +1,33 @@ + + + + {{ date }} + + + + + + {{ suggestion.query }} + + + {{ formatTime(suggestion.timestamp) }} + + + + + x + + + + + + + + + diff --git a/packages/_vue3-migration-test/src/x-modules/history-queries/index.ts b/packages/_vue3-migration-test/src/x-modules/history-queries/index.ts new file mode 100644 index 0000000000..07635cbbc8 --- /dev/null +++ b/packages/_vue3-migration-test/src/x-modules/history-queries/index.ts @@ -0,0 +1 @@ +export * from './components'; diff --git a/packages/_vue3-migration-test/src/x-modules/index.ts b/packages/_vue3-migration-test/src/x-modules/index.ts index 77e40483c6..5c21a8ab4f 100644 --- a/packages/_vue3-migration-test/src/x-modules/index.ts +++ b/packages/_vue3-migration-test/src/x-modules/index.ts @@ -6,3 +6,4 @@ export * from './search-box'; export { default as TestElementsList } from './test-elements-list.vue'; export * from './scroll'; export * from './related-tags'; +export * from './history-queries'; diff --git a/packages/_vue3-migration-test/src/x-modules/search/components/index.ts b/packages/_vue3-migration-test/src/x-modules/search/components/index.ts index 32ee402482..b1a112de7d 100644 --- a/packages/_vue3-migration-test/src/x-modules/search/components/index.ts +++ b/packages/_vue3-migration-test/src/x-modules/search/components/index.ts @@ -1,3 +1,4 @@ export { default as TestSortDropdown } from './test-sort-dropdown.vue'; export { default as TestSortList } from './test-sort-list.vue'; export { default as TestSortPickerList } from './test-sort-picker-list.vue'; +export { default as TestPartialResultsList } from './test-partial-results-list.vue'; diff --git a/packages/_vue3-migration-test/src/x-modules/search/components/test-partial-results-list.vue b/packages/_vue3-migration-test/src/x-modules/search/components/test-partial-results-list.vue new file mode 100644 index 0000000000..463b8cca0b --- /dev/null +++ b/packages/_vue3-migration-test/src/x-modules/search/components/test-partial-results-list.vue @@ -0,0 +1,50 @@ + + + + {{ partialResult.query }} + + {{ item.id }} + + + Ver todos {{ query }} + + + + + + The user has clicked on a partial query button!! + Restart + + + + + + 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 dae572726c..2ab2f330a1 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 @@ -3,6 +3,7 @@ import { getBannersStub } from '../../../../x-components/src/__stubs__/banners-s 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: { @@ -11,6 +12,7 @@ export const searchXModule = { results: getResultsStub(10), promoteds: getPromotedsStub(), banners: getBannersStub(), + partialResults: getPartialResultsStub(), status: 'success' } } diff --git a/packages/x-components/CHANGELOG.md b/packages/x-components/CHANGELOG.md index c9027b2e2e..54388ff68c 100644 --- a/packages/x-components/CHANGELOG.md +++ b/packages/x-components/CHANGELOG.md @@ -3,6 +3,79 @@ 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.39](https://github.com/empathyco/x/compare/@empathyco/x-components@5.0.0-alpha.34...@empathyco/x-components@5.0.0-alpha.39) (2024-06-11) + + +### Bug Fixes + +* **semantic-queries:** cancel track no results query on QueryPreviewUnmounted event (#1507) ([cc6518e](https://github.com/empathyco/x/commit/cc6518efe8e00bf02240ca54e39ef77d05a3139f)) + + +### Continuous Integration + +* add token to checkout action (#1511) ([c7cd70a](https://github.com/empathyco/x/commit/c7cd70a5b6df5701b5e46b4558b82485bc40f953)) +* fix package version and remove `persist-credentials` (#1513) ([c3add80](https://github.com/empathyco/x/commit/c3add8033ac5515e715e1ffff636b6df8133bccc)) + + + +## [5.0.0-alpha.38](https://github.com/empathyco/x/compare/@empathyco/x-components@5.0.0-alpha.37...@empathyco/x-components@5.0.0-alpha.38) (2024-06-11) + +**Note:** Version bump only for package @empathyco/x-components + +## [5.0.0-alpha.37](https://github.com/empathyco/x/compare/@empathyco/x-components@5.0.0-alpha.36...@empathyco/x-components@5.0.0-alpha.37) (2024-06-10) + +**Note:** Version bump only for package @empathyco/x-components + +## [5.0.0-alpha.36](https://github.com/empathyco/x/compare/@empathyco/x-components@5.0.0-alpha.35...@empathyco/x-components@5.0.0-alpha.36) (2024-06-10) + +**Note:** Version bump only for package @empathyco/x-components + +## [5.0.0-alpha.35](https://github.com/empathyco/x/compare/@empathyco/x-components@5.0.0-alpha.34...@empathyco/x-components@5.0.0-alpha.35) (2024-06-07) + +**Note:** Version bump only for package @empathyco/x-components + + +## [5.0.0-alpha.34](https://github.com/empathyco/x/compare/@empathyco/x-components@5.0.0-alpha.33...@empathyco/x-components@5.0.0-alpha.34) (2024-06-06) + +**Note:** Version bump only for package @empathyco/x-components + + +## [5.0.0-alpha.33](https://github.com/empathyco/x/compare/@empathyco/x-components@5.0.0-alpha.32...@empathyco/x-components@5.0.0-alpha.33) (2024-06-05) + + +### Code Refactoring + +* **keyboard-navigation:** use xBus only (#1502) ([8bb3c60](https://github.com/empathyco/x/commit/8bb3c604f308598a124719345bb4cf15a4d83103)) + + + +## [5.0.0-alpha.32](https://github.com/empathyco/x/compare/@empathyco/x-components@5.0.0-alpha.31...@empathyco/x-components@5.0.0-alpha.32) (2024-06-05) + + +### Features + +* migrate PartialQueryButton and PartialResultsList (#1501) ([5e87123](https://github.com/empathyco/x/commit/5e87123d4a6c1edeb05f83c31ee8f096b5558e0f)) + + + +## [5.0.0-alpha.31](https://github.com/empathyco/x/compare/@empathyco/x-components@5.0.0-alpha.30...@empathyco/x-components@5.0.0-alpha.31) (2024-06-04) + + +### Features + +* migrate BaseEventsModal to composition API ([7ef04b6](https://github.com/empathyco/x/commit/7ef04b65bcef2eb9b9dc5bc107bc02823831d444)) + + + +## [5.0.0-alpha.30](https://github.com/empathyco/x/compare/@empathyco/x-components@5.0.0-alpha.29...@empathyco/x-components@5.0.0-alpha.30) (2024-06-04) + + +### Features + +* **base-id-modal:** migrate to composition API (#1500) ([6274c67](https://github.com/empathyco/x/commit/6274c676946536c9c1c4e54205ebda18c79b8f55)) + + + ## [5.0.0-alpha.29](https://github.com/empathyco/x/compare/@empathyco/x-components@5.0.0-alpha.28...@empathyco/x-components@5.0.0-alpha.29) (2024-05-31) @@ -228,10 +301,10 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### ⚠ BREAKING CHANGES -* **ColumnPickerMixin:** `BaseColumnPickerDropdown` component will no longer emit the `change` event, use `update:modelValue` instead. +* **ColumnPickerMixin:** `BaseColumnPickerDropdown` component will no longer emit the `change` event, use `update:modelValue` instead. `BaseColumnPickerDropdown` prop for the selected columns was renamed from `value` to `modelValue`. -`BaseColumnPickerList` component will no longer emit the `change` event, use `update:modelValue` instead. +`BaseColumnPickerList` component will no longer emit the `change` event, use `update:modelValue` instead. `BaseColumnPickerList` prop for the selected columns was renamed from `value` to `modelValue`. `ColumnPickerMixin` has been removed. @@ -300,7 +373,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### ⚠ BREAKING CHANGES -* **sort-mixin:** base-dropdown component will no longer emit the `change` event, use `update:modelValue` instead. +* **sort-mixin:** base-dropdown component will no longer emit the `change` event, use `update:modelValue` instead. base-dropdown prop for the selected item was renamed from `value` to `modelValue`. ### Code Refactoring diff --git a/packages/x-components/package.json b/packages/x-components/package.json index db9a4826da..0a184d2e04 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.29", + "version": "5.0.0-alpha.39", "description": "Empathy X Components", "author": "Empathy Systems Corporation S.L.", "license": "Apache-2.0", diff --git a/packages/x-components/src/components/base-grid.vue b/packages/x-components/src/components/base-grid.vue index 3f58af7c02..1d4a096948 100644 --- a/packages/x-components/src/components/base-grid.vue +++ b/packages/x-components/src/components/base-grid.vue @@ -114,7 +114,10 @@ * * @internal */ - const injectedListItems = inject>(LIST_ITEMS_KEY as string); + const injectedListItems = inject | undefined>( + LIST_ITEMS_KEY as string, + undefined + ); const gridEl = ref(null); diff --git a/packages/x-components/src/components/base-keyboard-navigation.vue b/packages/x-components/src/components/base-keyboard-navigation.vue index e4bf015386..f341fed1ed 100644 --- a/packages/x-components/src/components/base-keyboard-navigation.vue +++ b/packages/x-components/src/components/base-keyboard-navigation.vue @@ -18,7 +18,7 @@ import { ArrowKey, EventsForDirectionLimit, TakeNavigationControl } from '../utils/types'; import { XEventsOf } from '../wiring/events.types'; import { WireMetadata } from '../wiring/wiring.types'; - import { use$x, useXBus } from '../composables'; + import { useXBus } from '../composables'; /** * Base component to handle keyboard navigation for elements inside it. It has a required slot to @@ -56,8 +56,6 @@ }, setup: function (props) { const el = ref(); - - const $x = use$x(); const xBus = useXBus(); /** @@ -132,7 +130,7 @@ function emitDirectionalLimitReached(direction: ArrowKey): void { const xEvent = props.eventsForDirectionLimit?.[direction]; if (xEvent) { - $x.emit(xEvent, undefined, { target: elementToFocus }); + xBus.emit(xEvent, undefined, { target: elementToFocus }); } } diff --git a/packages/x-components/src/components/layouts/fixed-header-and-asides-layout.vue b/packages/x-components/src/components/layouts/fixed-header-and-asides-layout.vue index 4aed8568ef..a6c20def62 100644 --- a/packages/x-components/src/components/layouts/fixed-header-and-asides-layout.vue +++ b/packages/x-components/src/components/layouts/fixed-header-and-asides-layout.vue @@ -88,8 +88,8 @@ diff --git a/packages/x-components/src/components/modals/base-id-modal.vue b/packages/x-components/src/components/modals/base-id-modal.vue index 7224bdb5b6..4525b49d41 100644 --- a/packages/x-components/src/components/modals/base-id-modal.vue +++ b/packages/x-components/src/components/modals/base-id-modal.vue @@ -1,21 +1,23 @@ 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 804fbbd5e0..3c103d9160 100644 --- a/packages/x-components/src/composables/__tests__/use-getter.spec.ts +++ b/packages/x-components/src/composables/__tests__/use-getter.spec.ts @@ -1,72 +1,49 @@ -import { ComputedRef, defineComponent } from 'vue'; -import Vuex, { Store } from 'vuex'; -import { createLocalVue, mount } from '@vue/test-utils'; -import { Dictionary } from '@empathyco/x-utils'; +import { defineComponent } from 'vue'; +import { mount } from '@vue/test-utils'; import { installNewXPlugin } from '../../__tests__/utils'; import { useGetter } from '../use-getter'; -import { historyQueriesXStoreModule } from '../../x-modules/history-queries'; -import { AnyXStoreModule } from '../../store/index'; +import { useRegisterXModule } from '../use-register-x-module'; import { ExtractGetters } from '../../x-modules/x-modules.types'; - -const renderUseGetterTest = (getters: string[]): renderUseGetterTestAPI => { - const testComponent = defineComponent({ - setup() { - const historyQueriesGetter = useGetter( - 'historyQueries', - getters as (keyof ExtractGetters<'historyQueries'>)[] - ); - return { - historyQueriesGetter - }; - } - }); - - const localVue = createLocalVue(); - localVue.use(Vuex); - - const store = new Store({ - modules: { - x: { - namespaced: true, - modules: { - historyQueries: { namespaced: true, ...historyQueriesXStoreModule } as AnyXStoreModule - } - } - } +import { useStore } from '../use-store'; +import { XPlugin } from '../../plugins'; +import { historyQueriesXModule } from '../../x-modules/history-queries/x-module'; + +jest.mock('../use-store'); + +function render(modulePaths: (keyof ExtractGetters<'historyQueries'>)[]) { + installNewXPlugin(); + (useStore as jest.Mock).mockReturnValue(XPlugin.store); + + const component = defineComponent({ + xModule: 'historyQueries', + setup: () => { + useRegisterXModule(historyQueriesXModule); + const historyQueriesGetter = useGetter('historyQueries', modulePaths); + return { historyQueriesGetter }; + }, + template: `` }); - installNewXPlugin({ store }, localVue); - const wrapper = mount(testComponent, { - localVue, - store - }); + const wrapper = mount(component); - return { - store, - historyQueriesGetter: (wrapper.vm as any).historyQueriesGetter - }; -}; + return (wrapper as any).vm.historyQueriesGetter; +} describe('testing useGetter composable', () => { it('maps store getters', () => { - const { historyQueriesGetter, store } = renderUseGetterTest(['storageKey', 'historyQueries']); - expect(historyQueriesGetter.storageKey.value).toEqual('history-queries'); - expect(historyQueriesGetter.historyQueries.value).toHaveLength(0); + const { storageKey, historyQueries } = render(['storageKey', 'historyQueries']); + expect(storageKey.value).toEqual('history-queries'); + expect(historyQueries.value).toHaveLength(0); // eslint-disable-next-line @typescript-eslint/no-unsafe-call - store.dispatch('x/historyQueries/addQueryToHistory', 'chorizo'); + XPlugin.store.dispatch('x/historyQueries/addQueryToHistory', 'chorizo'); - expect(historyQueriesGetter.historyQueries.value).toHaveLength(1); + expect(historyQueries.value).toHaveLength(1); }); it('does not return not requested getters', () => { - const { historyQueriesGetter } = renderUseGetterTest(['storageKey']); - expect(historyQueriesGetter.storageKey).toBeDefined(); - expect(historyQueriesGetter.historyQueries).toBeUndefined(); + const { storageKey, historyQueries } = render(['storageKey']); + expect(storageKey).toBeDefined(); + expect(historyQueries).toBeUndefined(); }); }); - -type renderUseGetterTestAPI = { - historyQueriesGetter: Dictionary>; - store: Store; -}; diff --git a/packages/x-components/src/x-modules/history-queries/components/clear-history-queries.vue b/packages/x-components/src/x-modules/history-queries/components/clear-history-queries.vue index dfa8de8c27..b30d3b6a6a 100644 --- a/packages/x-components/src/x-modules/history-queries/components/clear-history-queries.vue +++ b/packages/x-components/src/x-modules/history-queries/components/clear-history-queries.vue @@ -13,15 +13,12 @@ diff --git a/packages/x-components/src/x-modules/history-queries/components/history-queries-switch.vue b/packages/x-components/src/x-modules/history-queries/components/history-queries-switch.vue index f32ea08109..44026e2fc9 100644 --- a/packages/x-components/src/x-modules/history-queries/components/history-queries-switch.vue +++ b/packages/x-components/src/x-modules/history-queries/components/history-queries-switch.vue @@ -3,14 +3,13 @@ diff --git a/packages/x-components/src/x-modules/history-queries/components/history-queries.vue b/packages/x-components/src/x-modules/history-queries/components/history-queries.vue index fd5fd310a5..1243fc01f6 100644 --- a/packages/x-components/src/x-modules/history-queries/components/history-queries.vue +++ b/packages/x-components/src/x-modules/history-queries/components/history-queries.vue @@ -1,7 +1,7 @@ @@ -47,13 +47,10 @@ diff --git a/packages/x-components/src/x-modules/history-queries/components/history-query.vue b/packages/x-components/src/x-modules/history-queries/components/history-query.vue index 05736a0649..e3450665c0 100644 --- a/packages/x-components/src/x-modules/history-queries/components/history-query.vue +++ b/packages/x-components/src/x-modules/history-queries/components/history-query.vue @@ -40,14 +40,11 @@ diff --git a/packages/x-components/src/x-modules/history-queries/components/my-history.vue b/packages/x-components/src/x-modules/history-queries/components/my-history.vue index 8f7135c2ec..c789d4a3bd 100644 --- a/packages/x-components/src/x-modules/history-queries/components/my-history.vue +++ b/packages/x-components/src/x-modules/history-queries/components/my-history.vue @@ -57,18 +57,16 @@
The modal is working with events!!
The base id modal is working
{{ suggestion.query }}
+ {{ formatTime(suggestion.timestamp) }} +