| Numéro du ticket | Titre du ticket | |------------------|-----------------| | | | ## Description de la PR ## Modification du .env ## Check list - [ ] Pas de régression - [ ] TU/TI/TF rédigée - [ ] TU/TI/TF OK - [ ] CHANGELOG modifié --------- Co-authored-by: THOLOT DECHENE Matthieu <matthieu@yuno.malio.fr> Co-authored-by: matthieu <matthieu@yuno.malio.fr> Reviewed-on: #58 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #58.
This commit is contained in:
@@ -28,6 +28,7 @@ type InputAutocompleteProps = {
|
||||
debounce?: number
|
||||
minSearchLength?: number
|
||||
allowCreate?: boolean
|
||||
localFilter?: boolean
|
||||
iconName?: string
|
||||
iconPosition?: 'left' | 'right'
|
||||
iconSize?: string | number
|
||||
@@ -427,4 +428,82 @@ describe('MalioInputAutocomplete', () => {
|
||||
|
||||
expect(wrapper.get('input').element.value).toBe('Custom')
|
||||
})
|
||||
|
||||
it('does not filter options when localFilter is false (default)', async () => {
|
||||
const wrapper = mountComponent({options})
|
||||
|
||||
await wrapper.get('input').trigger('focus')
|
||||
await wrapper.get('input').setValue('fr')
|
||||
|
||||
expect(wrapper.findAll('[data-test="option"]')).toHaveLength(3)
|
||||
})
|
||||
|
||||
it('filters options client-side when localFilter is true', async () => {
|
||||
const wrapper = mountComponent({options, localFilter: true})
|
||||
|
||||
await wrapper.get('input').trigger('focus')
|
||||
await wrapper.get('input').setValue('fr')
|
||||
|
||||
const items = wrapper.findAll('[data-test="option"]')
|
||||
expect(items).toHaveLength(1)
|
||||
expect(items[0].text()).toBe('France')
|
||||
})
|
||||
|
||||
it('localFilter is case-insensitive and matches substrings', async () => {
|
||||
const wrapper = mountComponent({options, localFilter: true})
|
||||
|
||||
await wrapper.get('input').trigger('focus')
|
||||
await wrapper.get('input').setValue('GIQ')
|
||||
|
||||
const items = wrapper.findAll('[data-test="option"]')
|
||||
expect(items).toHaveLength(1)
|
||||
expect(items[0].text()).toBe('Belgique')
|
||||
})
|
||||
|
||||
it('localFilter shows all options when input is empty', async () => {
|
||||
const wrapper = mountComponent({options, localFilter: true})
|
||||
|
||||
await wrapper.get('input').trigger('focus')
|
||||
|
||||
expect(wrapper.findAll('[data-test="option"]')).toHaveLength(3)
|
||||
})
|
||||
|
||||
it('localFilter shows the no-results state when nothing matches', async () => {
|
||||
const wrapper = mountComponent({options, localFilter: true})
|
||||
|
||||
await wrapper.get('input').trigger('focus')
|
||||
await wrapper.get('input').setValue('zzzzz')
|
||||
|
||||
expect(wrapper.findAll('[data-test="option"]')).toHaveLength(0)
|
||||
expect(wrapper.find('[data-test="no-results-text"]').exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('keeps the floating label at the same position whether focused or not (no jump)', async () => {
|
||||
const wrapper = mountComponent({options, label: 'Pays', modelValue: 'fr'})
|
||||
|
||||
// when a value is selected and the field is not focused, the label is already floated
|
||||
const labelClasses = wrapper.get('label').classes()
|
||||
expect(labelClasses).toContain('-translate-y-[1.25rem]')
|
||||
// and there is no extra peer-focus translate that would make it jump on click
|
||||
expect(labelClasses).not.toContain('peer-focus:-translate-y-[1.55rem]')
|
||||
})
|
||||
|
||||
it('does not shift inner text horizontally on focus (no focus:pl change)', () => {
|
||||
const wrapper = mountComponent({options})
|
||||
|
||||
const inputClasses = wrapper.get('input').classes()
|
||||
expect(inputClasses).not.toContain('focus:pl-[11px]')
|
||||
})
|
||||
|
||||
it('keeps the bottom border allocation when open (transparent, not zero)', async () => {
|
||||
const wrapper = mountComponent({options})
|
||||
|
||||
await wrapper.get('input').trigger('focus')
|
||||
|
||||
const inputClasses = wrapper.get('input').classes()
|
||||
// border-b-0 would shrink the bottom border to 0px and grow content area by 1px;
|
||||
// border-b-transparent keeps the 1px allocation but hides the line
|
||||
expect(inputClasses).not.toContain('!border-b-0')
|
||||
expect(inputClasses).toContain('!border-b-transparent')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user