-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/EMP-4131-replace-layoutsmixin-by-uselay…
…outs-composable # Conflicts: # packages/_vue3-migration-test/src/router.ts
- Loading branch information
Showing
15 changed files
with
621 additions
and
539 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
||
## [1.0.0-alpha.12](https://github.com/empathyco/x/compare/[email protected]@1.0.0-alpha.12) (2024-05-23) | ||
|
||
|
||
### Features | ||
|
||
* **search-box:** migrate search-box x-module components to Composition API (#1476) ([5c2b7bc](https://github.com/empathyco/x/commit/5c2b7bcf47281f9a3bb2ea65a1bfb73c6d850260)) | ||
|
||
|
||
|
||
## [1.0.0-alpha.11](https://github.com/empathyco/x/compare/[email protected]@1.0.0-alpha.11) (2024-05-21) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export * from './facets'; | ||
export * from './next-queries'; | ||
export * from './search'; | ||
export * from './search-box'; | ||
export { default as TestElementsList } from './test-elements-list.vue'; | ||
export * from './scroll'; |
1 change: 1 addition & 0 deletions
1
packages/_vue3-migration-test/src/x-modules/search-box/components/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as TestSearchBox } from './test-search-box.vue'; |
43 changes: 43 additions & 0 deletions
43
packages/_vue3-migration-test/src/x-modules/search-box/components/test-search-box.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<template> | ||
<div style="display: flex; flex-flow: row nowrap"> | ||
<SearchInput | ||
@UserPressedEnterKey="value = 'You have pressed the enter key'" | ||
@UserFocusedSearchBox="hasFocus = true" | ||
@UserBlurredSearchBox="hasFocus = false" | ||
@UserIsTypingAQuery="value = 'Typing...'" | ||
:maxLength="10" | ||
/> | ||
<ClearSearchInput @UserPressedClearSearchBoxButton="value = 'You clear your query'" /> | ||
<SearchButton @UserPressedSearchButton="value = 'You search a query'">Search</SearchButton> | ||
<SearchInputPlaceholder | ||
:messages="placeholderMessages" | ||
animation="div" | ||
style="position: absolute; pointer-events: none; top: -41rem; left: 1rem" | ||
/> | ||
</div> | ||
<br /> | ||
<span>{{ value }}</span> | ||
<br /> | ||
<span>{{ hasFocus ? 'Focused' : 'Unfocused' }}</span> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
import SearchInput from '../../../../../x-components/src/x-modules/search-box/components/search-input.vue'; | ||
import SearchInputPlaceholder from '../../../../../x-components/src/x-modules/search-box/components/search-input-placeholder.vue'; | ||
import SearchButton from '../../../../../x-components/src/x-modules/search-box/components/search-button.vue'; | ||
import ClearSearchInput from '../../../../../x-components/src/x-modules/search-box/components/clear-search-input.vue'; | ||
const value = ref('There are no value yet'); | ||
const hasFocus = ref(false); | ||
const placeholderMessages = [ | ||
'Find shirts', | ||
'Find shoes', | ||
'Find watches', | ||
'Find handbags', | ||
'Find sunglasses' | ||
]; | ||
</script> | ||
|
||
<style scoped></style> |
1 change: 1 addition & 0 deletions
1
packages/_vue3-migration-test/src/x-modules/search-box/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './components'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.18](https://github.com/empathyco/x/compare/@empathyco/[email protected]...@empathyco/[email protected]) (2024-05-23) | ||
|
||
|
||
### Features | ||
|
||
* **search-box:** migrate search-box x-module components to Composition API (#1476) ([5c2b7bc](https://github.com/empathyco/x/commit/5c2b7bcf47281f9a3bb2ea65a1bfb73c6d850260)) | ||
|
||
|
||
|
||
## [5.0.0-alpha.17](https://github.com/empathyco/x/compare/@empathyco/[email protected]...@empathyco/[email protected]) (2024-05-22) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 41 additions & 62 deletions
103
packages/x-components/src/composables/__tests__/use-state.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,54 @@ | ||
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 { useState } from '../use-state'; | ||
import { searchBoxXStoreModule } from '../../x-modules/search-box/index'; | ||
import { AnyXStoreModule } from '../../store/index'; | ||
import { XPlugin } from '../../plugins'; | ||
import { ExtractState } from '../../x-modules/x-modules.types'; | ||
|
||
const renderUseStateTest = (modulePropertyPaths: string[]): renderUseStateTestAPI => { | ||
const testComponent = defineComponent({ | ||
setup() { | ||
const searchBoxState = useState( | ||
'searchBox', | ||
modulePropertyPaths as (keyof ExtractState<'searchBox'>)[] | ||
); | ||
return { | ||
searchBoxState | ||
}; | ||
} | ||
}); | ||
|
||
const localVue = createLocalVue(); | ||
localVue.use(Vuex); | ||
|
||
const store = new Store({ | ||
modules: { | ||
x: { | ||
namespaced: true, | ||
modules: { | ||
searchBox: { namespaced: true, ...searchBoxXStoreModule } as AnyXStoreModule | ||
} | ||
} | ||
} | ||
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'; | ||
|
||
jest.mock('../use-store'); | ||
|
||
function render(modulePaths: (keyof ExtractState<'searchBox'> & string)[]) { | ||
installNewXPlugin(); | ||
(useStore as jest.Mock).mockReturnValue(XPlugin.store); | ||
|
||
const component = defineComponent({ | ||
xModule: 'searchBox', | ||
setup: () => { | ||
useRegisterXModule(searchBoxXModule); | ||
const searchBoxUseState = useState('searchBox', modulePaths); | ||
return { searchBoxUseState }; | ||
}, | ||
template: `<div/>` | ||
}); | ||
installNewXPlugin({ store }, localVue); | ||
|
||
const wrapper = mount(testComponent, { | ||
localVue, | ||
store | ||
}); | ||
const wrapper = mount(component); | ||
|
||
return { | ||
searchBoxState: (wrapper.vm as any).searchBoxState, | ||
store | ||
}; | ||
}; | ||
return (wrapper as any).vm.searchBoxUseState; | ||
} | ||
|
||
describe('testing useState composable', () => { | ||
it('maps store state', () => { | ||
const { searchBoxState, store } = renderUseStateTest(['query', 'inputStatus']); | ||
expect(searchBoxState.query.value).toEqual(''); | ||
expect(searchBoxState.inputStatus.value).toEqual('initial'); | ||
it('should map paths of the store state given', () => { | ||
const { query, inputStatus } = render(['query', 'inputStatus']); | ||
|
||
expect(query).toBeDefined(); | ||
expect(inputStatus).toBeDefined(); | ||
expect(query.value).toEqual(''); | ||
expect(inputStatus.value).toEqual('initial'); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||
store.commit('x/searchBox/setQuery', 'pork shoulder '); | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||
store.commit('x/searchBox/setInputStatus', 'filled'); | ||
XPlugin.store.commit('x/searchBox/setQuery', 'pork shoulder'); | ||
XPlugin.store.commit('x/searchBox/setInputStatus', 'filled'); | ||
|
||
expect(searchBoxState.query.value).toEqual('pork shoulder '); | ||
expect(searchBoxState.inputStatus.value).toEqual('filled'); | ||
expect(query.value).toEqual('pork shoulder'); | ||
expect(inputStatus.value).toEqual('filled'); | ||
}); | ||
|
||
it('does not return not requested state properties', () => { | ||
const { searchBoxState } = renderUseStateTest(['query']); | ||
expect(searchBoxState.query).toBeDefined(); | ||
expect(searchBoxState.inputStatus).toBeUndefined(); | ||
it('should not map paths which were not requested', () => { | ||
const { query, inputStatus } = render(['query']); | ||
|
||
expect(query).toBeDefined(); | ||
expect(inputStatus).toBeUndefined(); | ||
}); | ||
}); | ||
|
||
type renderUseStateTestAPI = { | ||
searchBoxState: Dictionary<ComputedRef<string[]>>; | ||
store: Store<any>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.