Commit bf3eff86 authored by Florie Guibert's avatar Florie Guibert

Labels widget - Fix search input

Review feedback
parent fa7d3e3e
...@@ -130,14 +130,14 @@ describe('DropdownContent', () => { ...@@ -130,14 +130,14 @@ describe('DropdownContent', () => {
expect(findDropdownHeader().exists()).toBe(true); expect(findDropdownHeader().exists()).toBe(true);
}); });
it('sets searchKey on input event from header', async () => { it('sets searchKey for labels view on input event from header', async () => {
createComponent(); createComponent();
expect(wrapper.vm.searchKey).toEqual(''); expect(wrapper.vm.searchKey).toEqual('');
findDropdownHeader().vm.$emit('input', '123'); findDropdownHeader().vm.$emit('input', '123');
await nextTick(); await nextTick();
expect(wrapper.vm.searchKey).toEqual('123'); expect(findLabelsView().props('searchKey')).toEqual('123');
}); });
describe('Create view', () => { describe('Create view', () => {
......
import { GlSearchBoxByType } from '@gitlab/ui'; import { GlSearchBoxByType } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import DropdownHeader from '~/vue_shared/components/sidebar/labels_select_widget/dropdown_header.vue'; import DropdownHeader from '~/vue_shared/components/sidebar/labels_select_widget/dropdown_header.vue';
describe('DropdownHeader', () => { describe('DropdownHeader', () => {
...@@ -9,18 +10,20 @@ describe('DropdownHeader', () => { ...@@ -9,18 +10,20 @@ describe('DropdownHeader', () => {
showDropdownContentsCreateView = false, showDropdownContentsCreateView = false,
labelsFetchInProgress = false, labelsFetchInProgress = false,
} = {}) => { } = {}) => {
wrapper = shallowMount(DropdownHeader, { wrapper = extendedWrapper(
propsData: { shallowMount(DropdownHeader, {
showDropdownContentsCreateView, propsData: {
labelsFetchInProgress, showDropdownContentsCreateView,
labelsCreateTitle: 'Create label', labelsFetchInProgress,
labelsListTitle: 'Select label', labelsCreateTitle: 'Create label',
searchKey: '', labelsListTitle: 'Select label',
}, searchKey: '',
stubs: { },
GlSearchBoxByType, stubs: {
}, GlSearchBoxByType,
}); },
}),
);
}; };
afterEach(() => { afterEach(() => {
...@@ -28,7 +31,7 @@ describe('DropdownHeader', () => { ...@@ -28,7 +31,7 @@ describe('DropdownHeader', () => {
}); });
const findSearchInput = () => wrapper.findComponent(GlSearchBoxByType); const findSearchInput = () => wrapper.findComponent(GlSearchBoxByType);
const findGoBackButton = () => wrapper.find('[data-testid="go-back-button"]'); const findGoBackButton = () => wrapper.findByTestId('go-back-button');
beforeEach(() => { beforeEach(() => {
createComponent(); createComponent();
...@@ -57,13 +60,16 @@ describe('DropdownHeader', () => { ...@@ -57,13 +60,16 @@ describe('DropdownHeader', () => {
expect(findGoBackButton().exists()).toBe(false); expect(findGoBackButton().exists()).toBe(false);
}); });
it('when loading labels - renders disabled search input field', async () => { it.each`
createComponent({ labelsFetchInProgress: true }); labelsFetchInProgress | disabled
expect(findSearchInput().props('disabled')).toBe(true); ${true} | ${true}
}); ${false} | ${false}
`(
it('when labels are loaded - renders enabled search input field', async () => { 'when labelsFetchInProgress is $labelsFetchInProgress, renders search input with disabled prop to $disabled',
expect(findSearchInput().props('disabled')).toBe(false); ({ labelsFetchInProgress, disabled }) => {
}); createComponent({ labelsFetchInProgress });
expect(findSearchInput().props('disabled')).toBe(disabled);
},
);
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment