Commit 8be8343a authored by Illya Klymov's avatar Illya Klymov

Wrap trigger into nextEmit calls

Fix trigger calls
parent 72b6861d
...@@ -27,7 +27,9 @@ describe('AddStageButton', () => { ...@@ -27,7 +27,9 @@ describe('AddStageButton', () => {
wrapper = createComponent(); wrapper = createComponent();
expect(wrapper.emitted().showform).toBeUndefined(); expect(wrapper.emitted().showform).toBeUndefined();
wrapper.trigger('click'); wrapper.trigger('click');
expect(wrapper.emitted().showform.length).toBe(1); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().showform.length).toBe(1);
});
}); });
it('does not have the active class', () => { it('does not have the active class', () => {
......
...@@ -362,6 +362,7 @@ describe('CustomStageForm', () => { ...@@ -362,6 +362,7 @@ describe('CustomStageForm', () => {
return Vue.nextTick(() => { return Vue.nextTick(() => {
selectDropdownOption(wrapper, sel.endEvent, 1); selectDropdownOption(wrapper, sel.endEvent, 1);
return Vue.nextTick();
}); });
}); });
...@@ -394,10 +395,15 @@ describe('CustomStageForm', () => { ...@@ -394,10 +395,15 @@ describe('CustomStageForm', () => {
selectDropdownOption(wrapper, sel.startEvent, startEventIndex); selectDropdownOption(wrapper, sel.startEvent, startEventIndex);
return Vue.nextTick(() => { return Vue.nextTick()
selectDropdownOption(wrapper, sel.endEvent, stopEventIndex); .then(() => {
wrapper.find(sel.name).setValue('Cool stage'); selectDropdownOption(wrapper, sel.endEvent, stopEventIndex);
}); return Vue.nextTick();
})
.then(() => {
wrapper.find(sel.name).setValue('Cool stage');
return Vue.nextTick();
});
}); });
afterEach(() => { afterEach(() => {
...@@ -437,8 +443,10 @@ describe('CustomStageForm', () => { ...@@ -437,8 +443,10 @@ describe('CustomStageForm', () => {
]; ];
wrapper.find(sel.submit).trigger('click'); wrapper.find(sel.submit).trigger('click');
event = findEvent(STAGE_ACTIONS.CREATE); return Vue.nextTick().then(() => {
expect(event[0]).toEqual(res); event = findEvent(STAGE_ACTIONS.CREATE);
expect(event[0]).toEqual(res);
});
}); });
}); });
}); });
......
...@@ -50,8 +50,10 @@ describe('Cycle Analytics LabelsSelector', () => { ...@@ -50,8 +50,10 @@ describe('Cycle Analytics LabelsSelector', () => {
const elem = wrapper.findAll('.dropdown-item').at(2); const elem = wrapper.findAll('.dropdown-item').at(2);
elem.trigger('click'); elem.trigger('click');
expect(wrapper.emitted('selectLabel').length > 0).toBe(true); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('selectLabel')[0]).toContain(groupLabels[1].id); expect(wrapper.emitted('selectLabel').length > 0).toBe(true);
expect(wrapper.emitted('selectLabel')[0]).toContain(groupLabels[1].id);
});
}); });
it('will emit the "clearLabel" event if it is the default item', () => { it('will emit the "clearLabel" event if it is the default item', () => {
...@@ -60,7 +62,9 @@ describe('Cycle Analytics LabelsSelector', () => { ...@@ -60,7 +62,9 @@ describe('Cycle Analytics LabelsSelector', () => {
const elem = wrapper.findAll('.dropdown-item').at(0); const elem = wrapper.findAll('.dropdown-item').at(0);
elem.trigger('click'); elem.trigger('click');
expect(wrapper.emitted('clearLabel').length > 0).toBe(true); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('clearLabel').length > 0).toBe(true);
});
}); });
}); });
}); });
......
...@@ -62,12 +62,14 @@ describe('StageDropdownFilter component', () => { ...@@ -62,12 +62,14 @@ describe('StageDropdownFilter component', () => {
item.trigger('click'); item.trigger('click');
expect(wrapper.emittedByOrder()).toEqual([ return wrapper.vm.$nextTick().then(() => {
{ expect(wrapper.emittedByOrder()).toEqual([
name: 'selected', {
args: [[stages[1], stages[2]]], name: 'selected',
}, args: [[stages[1], stages[2]]],
]); },
]);
});
}); });
}); });
...@@ -77,20 +79,26 @@ describe('StageDropdownFilter component', () => { ...@@ -77,20 +79,26 @@ describe('StageDropdownFilter component', () => {
.at(0) .at(0)
.trigger('click'); .trigger('click');
findDropdownItems() return wrapper.vm
.at(0) .$nextTick()
.trigger('click'); .then(() => {
findDropdownItems()
expect(wrapper.emittedByOrder()).toEqual([ .at(0)
{ .trigger('click');
name: 'selected', return wrapper.vm.$nextTick();
args: [[stages[1], stages[2]]], })
}, .then(() => {
{ expect(wrapper.emittedByOrder()).toEqual([
name: 'selected', {
args: [[stages[1], stages[2], stages[0]]], name: 'selected',
}, args: [[stages[1], stages[2]]],
]); },
{
name: 'selected',
args: [[stages[1], stages[2], stages[0]]],
},
]);
});
}); });
}); });
}); });
......
...@@ -57,12 +57,14 @@ describe('Daterange component', () => { ...@@ -57,12 +57,14 @@ describe('Daterange component', () => {
input.setValue('2019-01-01'); input.setValue('2019-01-01');
input.trigger('change'); input.trigger('change');
expect(wrapper.emittedByOrder()).toEqual([ return wrapper.vm.$nextTick().then(() => {
{ expect(wrapper.emittedByOrder()).toEqual([
name: 'change', {
args: [{ startDate: minDate, endDate }], name: 'change',
}, args: [{ startDate: minDate, endDate }],
]); },
]);
});
}); });
}); });
}); });
......
...@@ -142,12 +142,14 @@ describe('GroupsDropdownFilter component', () => { ...@@ -142,12 +142,14 @@ describe('GroupsDropdownFilter component', () => {
.at(0) .at(0)
.trigger('click'); .trigger('click');
expect(wrapper.emittedByOrder()).toEqual([ return wrapper.vm.$nextTick().then(() => {
{ expect(wrapper.emittedByOrder()).toEqual([
name: 'selected', {
args: [groups[0]], name: 'selected',
}, args: [groups[0]],
]); },
]);
});
}); });
it('should change selection when new group is clicked', () => { it('should change selection when new group is clicked', () => {
...@@ -155,12 +157,14 @@ describe('GroupsDropdownFilter component', () => { ...@@ -155,12 +157,14 @@ describe('GroupsDropdownFilter component', () => {
.at(1) .at(1)
.trigger('click'); .trigger('click');
expect(wrapper.emittedByOrder()).toEqual([ return wrapper.vm.$nextTick().then(() => {
{ expect(wrapper.emittedByOrder()).toEqual([
name: 'selected', {
args: [groups[1]], name: 'selected',
}, args: [groups[1]],
]); },
]);
});
}); });
it('renders an avatar in the dropdown button when the group has an avatar_url', done => { it('renders an avatar in the dropdown button when the group has an avatar_url', done => {
......
...@@ -175,12 +175,14 @@ describe('ProjectsDropdownFilter component', () => { ...@@ -175,12 +175,14 @@ describe('ProjectsDropdownFilter component', () => {
.at(0) .at(0)
.trigger('click'); .trigger('click');
expect(wrapper.emittedByOrder()).toEqual([ return wrapper.vm.$nextTick().then(() => {
{ expect(wrapper.emittedByOrder()).toEqual([
name: 'selected', {
args: [[projects[0]]], name: 'selected',
}, args: [[projects[0]]],
]); },
]);
});
}); });
it('should change selection when new project is clicked', () => { it('should change selection when new project is clicked', () => {
...@@ -188,12 +190,14 @@ describe('ProjectsDropdownFilter component', () => { ...@@ -188,12 +190,14 @@ describe('ProjectsDropdownFilter component', () => {
.at(1) .at(1)
.trigger('click'); .trigger('click');
expect(wrapper.emittedByOrder()).toEqual([ return wrapper.vm.$nextTick().then(() => {
{ expect(wrapper.emittedByOrder()).toEqual([
name: 'selected', {
args: [[projects[1]]], name: 'selected',
}, args: [[projects[1]]],
]); },
]);
});
}); });
it('selection should be emptied when a project is deselected', () => { it('selection should be emptied when a project is deselected', () => {
...@@ -201,16 +205,18 @@ describe('ProjectsDropdownFilter component', () => { ...@@ -201,16 +205,18 @@ describe('ProjectsDropdownFilter component', () => {
project.trigger('click'); project.trigger('click');
project.trigger('click'); project.trigger('click');
expect(wrapper.emittedByOrder()).toEqual([ return wrapper.vm.$nextTick().then(() => {
{ expect(wrapper.emittedByOrder()).toEqual([
name: 'selected', {
args: [[projects[0]]], name: 'selected',
}, args: [[projects[0]]],
{ },
name: 'selected', {
args: [[]], name: 'selected',
}, args: [[]],
]); },
]);
});
}); });
it('renders an avatar in the dropdown button when the project has an avatar_url', done => { it('renders an avatar in the dropdown button when the project has an avatar_url', done => {
...@@ -294,20 +300,26 @@ describe('ProjectsDropdownFilter component', () => { ...@@ -294,20 +300,26 @@ describe('ProjectsDropdownFilter component', () => {
.at(0) .at(0)
.trigger('click'); .trigger('click');
findDropdownItems() return wrapper.vm
.at(1) .$nextTick()
.trigger('click'); .then(() => {
findDropdownItems()
expect(wrapper.emittedByOrder()).toEqual([ .at(1)
{ .trigger('click');
name: 'selected', return wrapper.vm.$nextTick();
args: [[projects[0]]], })
}, .then(() => {
{ expect(wrapper.emittedByOrder()).toEqual([
name: 'selected', {
args: [[projects[0], projects[1]]], name: 'selected',
}, args: [[projects[0]]],
]); },
{
name: 'selected',
args: [[projects[0], projects[1]]],
},
]);
});
}); });
it('should remove from selection when clicked again', () => { it('should remove from selection when clicked again', () => {
...@@ -316,31 +328,36 @@ describe('ProjectsDropdownFilter component', () => { ...@@ -316,31 +328,36 @@ describe('ProjectsDropdownFilter component', () => {
item.trigger('click'); item.trigger('click');
item.trigger('click'); item.trigger('click');
expect(wrapper.emittedByOrder()).toEqual([ return wrapper.vm.$nextTick().then(() => {
{ expect(wrapper.emittedByOrder()).toEqual([
name: 'selected', {
args: [[projects[0]]], name: 'selected',
}, args: [[projects[0]]],
{ },
name: 'selected', {
args: [[]], name: 'selected',
}, args: [[]],
]); },
]);
});
}); });
it('renders the correct placeholder text when multiple projects are selected', done => { it('renders the correct placeholder text when multiple projects are selected', done => {
findDropdownItems() findDropdownItems()
.at(0) .at(0)
.trigger('click'); .trigger('click');
return wrapper.vm
findDropdownItems() .$nextTick()
.at(1) .then(() => {
.trigger('click'); findDropdownItems()
.at(1)
wrapper.vm.$nextTick(() => { .trigger('click');
expect(findDropdownButton().text()).toBe('2 projects selected'); return wrapper.vm.$nextTick();
done(); })
}); .then(() => {
expect(findDropdownButton().text()).toBe('2 projects selected');
done();
});
}); });
}); });
}); });
......
...@@ -45,7 +45,9 @@ describe('Design reply form component', () => { ...@@ -45,7 +45,9 @@ describe('Design reply form component', () => {
ctrlKey: true, ctrlKey: true,
}); });
expect(wrapper.emitted('submitForm')).toBeFalsy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('submitForm')).toBeFalsy();
});
}); });
it('does not emit submitForm event on textarea meta+enter keydown', () => { it('does not emit submitForm event on textarea meta+enter keydown', () => {
...@@ -53,7 +55,9 @@ describe('Design reply form component', () => { ...@@ -53,7 +55,9 @@ describe('Design reply form component', () => {
metaKey: true, metaKey: true,
}); });
expect(wrapper.emitted('submitForm')).toBeFalsy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('submitForm')).toBeFalsy();
});
}); });
}); });
...@@ -71,7 +75,9 @@ describe('Design reply form component', () => { ...@@ -71,7 +75,9 @@ describe('Design reply form component', () => {
it('emits submitForm event on button click', () => { it('emits submitForm event on button click', () => {
findSubmitButton().trigger('click'); findSubmitButton().trigger('click');
expect(wrapper.emitted('submitForm')).toBeTruthy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('submitForm')).toBeTruthy();
});
}); });
it('emits submitForm event on textarea ctrl+enter keydown', () => { it('emits submitForm event on textarea ctrl+enter keydown', () => {
...@@ -79,7 +85,9 @@ describe('Design reply form component', () => { ...@@ -79,7 +85,9 @@ describe('Design reply form component', () => {
ctrlKey: true, ctrlKey: true,
}); });
expect(wrapper.emitted('submitForm')).toBeTruthy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('submitForm')).toBeTruthy();
});
}); });
it('emits submitForm event on textarea meta+enter keydown', () => { it('emits submitForm event on textarea meta+enter keydown', () => {
...@@ -87,19 +95,25 @@ describe('Design reply form component', () => { ...@@ -87,19 +95,25 @@ describe('Design reply form component', () => {
metaKey: true, metaKey: true,
}); });
expect(wrapper.emitted('submitForm')).toBeTruthy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('submitForm')).toBeTruthy();
});
}); });
it('emits input event on changing textarea content', () => { it('emits input event on changing textarea content', () => {
findTextarea().setValue('test2'); findTextarea().setValue('test2');
expect(wrapper.emitted('input')).toBeTruthy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('input')).toBeTruthy();
});
}); });
it('emits cancelForm event on pressing escape button on textarea', () => { it('emits cancelForm event on pressing escape button on textarea', () => {
findTextarea().trigger('keyup.esc'); findTextarea().trigger('keyup.esc');
expect(wrapper.emitted('cancelForm')).toBeTruthy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('cancelForm')).toBeTruthy();
});
}); });
}); });
}); });
...@@ -53,7 +53,9 @@ describe('Design overlay component', () => { ...@@ -53,7 +53,9 @@ describe('Design overlay component', () => {
createComponent(); createComponent();
wrapper.find('.image-diff-overlay-add-comment').trigger('click', { offsetX: 10, offsetY: 10 }); wrapper.find('.image-diff-overlay-add-comment').trigger('click', { offsetX: 10, offsetY: 10 });
expect(wrapper.emitted('openCommentForm')).toEqual([[{ x: 10, y: 10 }]]); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('openCommentForm')).toEqual([[{ x: 10, y: 10 }]]);
});
}); });
describe('when has notes', () => { describe('when has notes', () => {
......
...@@ -322,20 +322,26 @@ describe('Design management index page', () => { ...@@ -322,20 +322,26 @@ describe('Design management index page', () => {
findDesignCheckboxes() findDesignCheckboxes()
.at(0) .at(0)
.trigger('click'); .trigger('click');
findDesignCheckboxes()
.at(1)
.trigger('click');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm
expect(findDeleteButton().exists()).toBe(true); .$nextTick()
expect(findSelectAllButton().text()).toBe('Deselect all'); .then(() => {
findDeleteButton().vm.$emit('deleteSelectedDesigns'); findDesignCheckboxes()
const [{ variables }] = mutate.mock.calls[0]; .at(1)
expect(variables.filenames).toStrictEqual([ .trigger('click');
mockDesigns[0].filename,
mockDesigns[1].filename, return wrapper.vm.$nextTick();
]); })
}); .then(() => {
expect(findDeleteButton().exists()).toBe(true);
expect(findSelectAllButton().text()).toBe('Deselect all');
findDeleteButton().vm.$emit('deleteSelectedDesigns');
const [{ variables }] = mutate.mock.calls[0];
expect(variables.filenames).toStrictEqual([
mockDesigns[0].filename,
mockDesigns[1].filename,
]);
});
}); });
it('adds all designs to selected designs when Select All button is clicked', () => { it('adds all designs to selected designs when Select All button is clicked', () => {
...@@ -352,13 +358,17 @@ describe('Design management index page', () => { ...@@ -352,13 +358,17 @@ describe('Design management index page', () => {
findDesignCheckboxes() findDesignCheckboxes()
.at(0) .at(0)
.trigger('click'); .trigger('click');
findSelectAllButton().vm.$emit('click');
return wrapper.vm.$nextTick().then(() => { return wrapper.vm
expect(findDeleteButton().props().hasSelectedDesigns).toBe(false); .$nextTick()
expect(findSelectAllButton().text()).toBe('Select all'); .then(() => {
expect(wrapper.vm.selectedDesigns).toEqual([]); findSelectAllButton().vm.$emit('click');
}); })
.then(() => {
expect(findDeleteButton().props().hasSelectedDesigns).toBe(false);
expect(findSelectAllButton().text()).toBe('Select all');
expect(wrapper.vm.selectedDesigns).toEqual([]);
});
}); });
}); });
......
...@@ -109,6 +109,7 @@ describe('dashboard', () => { ...@@ -109,6 +109,7 @@ describe('dashboard', () => {
describe('project selector modal', () => { describe('project selector modal', () => {
beforeEach(() => { beforeEach(() => {
wrapper.find(GlButton).trigger('click'); wrapper.find(GlButton).trigger('click');
return wrapper.vm.$nextTick();
}); });
it('should fire the add projects action on ok', () => { it('should fire the add projects action on ok', () => {
......
...@@ -200,7 +200,10 @@ describe('SidebarDatePicker', () => { ...@@ -200,7 +200,10 @@ describe('SidebarDatePicker', () => {
createComponent({ canUpdate: true }); createComponent({ canUpdate: true });
wrapper.find('input').trigger('click'); wrapper.find('input').trigger('click');
expect(wrapper.emitted().toggleDateType).toStrictEqual([[true]]);
return wrapper.vm.$nextTick(() => {
expect(wrapper.emitted().toggleDateType).toStrictEqual([[true]]);
});
}); });
it('emits `toggleCollapse` event when toggle-sidebar emits `toggle` event', () => { it('emits `toggleCollapse` event when toggle-sidebar emits `toggle` event', () => {
......
...@@ -303,25 +303,33 @@ describe('feature flag form', () => { ...@@ -303,25 +303,33 @@ describe('feature flag form', () => {
it('should emit handleSubmit with the updated data', () => { it('should emit handleSubmit with the updated data', () => {
wrapper.find('#feature-flag-name').setValue('feature_flag_2'); wrapper.find('#feature-flag-name').setValue('feature_flag_2');
wrapper
.find('.js-new-scope-name')
.find(EnvironmentsDropdown)
.vm.$emit('selectEnvironment', 'review');
wrapper
.find('.js-add-new-scope')
.find(ToggleButton)
.vm.$emit('change', true);
wrapper.find(ToggleButton).vm.$emit('change', true);
return wrapper.vm return wrapper.vm
.$nextTick() .$nextTick()
.then(() => {
wrapper
.find('.js-new-scope-name')
.find(EnvironmentsDropdown)
.vm.$emit('selectEnvironment', 'review');
return wrapper.vm.$nextTick();
})
.then(() => {
wrapper
.find('.js-add-new-scope')
.find(ToggleButton)
.vm.$emit('change', true);
})
.then(() => {
wrapper.find(ToggleButton).vm.$emit('change', true);
return wrapper.vm.$nextTick();
})
.then(() => { .then(() => {
selectFirstRolloutStrategyOption(0); selectFirstRolloutStrategyOption(0);
return wrapper.vm.$nextTick();
})
.then(() => {
selectFirstRolloutStrategyOption(2); selectFirstRolloutStrategyOption(2);
return wrapper.vm.$nextTick(); return wrapper.vm.$nextTick();
}) })
.then(() => { .then(() => {
......
...@@ -66,8 +66,10 @@ describe('EE IDE TerminalSession', () => { ...@@ -66,8 +66,10 @@ describe('EE IDE TerminalSession', () => {
const button = wrapper.find('button'); const button = wrapper.find('button');
button.trigger('click'); button.trigger('click');
expect(button.text()).toEqual('Stop Terminal'); return wrapper.vm.$nextTick().then(() => {
expect(actions.stopSession).toHaveBeenCalled(); expect(button.text()).toEqual('Stop Terminal');
expect(actions.stopSession).toHaveBeenCalled();
});
}); });
}); });
...@@ -79,8 +81,10 @@ describe('EE IDE TerminalSession', () => { ...@@ -79,8 +81,10 @@ describe('EE IDE TerminalSession', () => {
const button = wrapper.find('button'); const button = wrapper.find('button');
button.trigger('click'); button.trigger('click');
expect(button.text()).toEqual('Restart Terminal'); return wrapper.vm.$nextTick().then(() => {
expect(actions.restartSession).toHaveBeenCalled(); expect(button.text()).toEqual('Restart Terminal');
expect(actions.restartSession).toHaveBeenCalled();
});
}); });
}); });
}); });
...@@ -102,11 +102,16 @@ describe('MavenInstallation', () => { ...@@ -102,11 +102,16 @@ describe('MavenInstallation', () => {
it('should track when the installation tab is clicked', () => { it('should track when the installation tab is clicked', () => {
setupTab().trigger('click'); setupTab().trigger('click');
installationTab().trigger('click'); return wrapper.vm
.$nextTick()
expect(eventSpy).toHaveBeenCalledWith(undefined, TrackingActions.INSTALLATION, { .then(() => {
label, installationTab().trigger('click');
}); })
.then(() => {
expect(eventSpy).toHaveBeenCalledWith(undefined, TrackingActions.INSTALLATION, {
label,
});
});
}); });
}); });
}); });
...@@ -97,11 +97,17 @@ describe('NpmInstallation', () => { ...@@ -97,11 +97,17 @@ describe('NpmInstallation', () => {
it('should track when the installation tab is clicked', () => { it('should track when the installation tab is clicked', () => {
setupTab().trigger('click'); setupTab().trigger('click');
installationTab().trigger('click');
expect(eventSpy).toHaveBeenCalledWith(undefined, TrackingActions.INSTALLATION, { return wrapper.vm
label, .$nextTick()
}); .then(() => {
installationTab().trigger('click');
})
.then(() => {
expect(eventSpy).toHaveBeenCalledWith(undefined, TrackingActions.INSTALLATION, {
label,
});
});
}); });
}); });
}); });
...@@ -81,7 +81,9 @@ describe('RelatedIssuableInput', () => { ...@@ -81,7 +81,9 @@ describe('RelatedIssuableInput', () => {
wrapper.find('li').trigger('click'); wrapper.find('li').trigger('click');
expect(document.activeElement).toBe(wrapper.find({ ref: 'input' }).element); return wrapper.vm.$nextTick().then(() => {
expect(document.activeElement).toBe(wrapper.find({ ref: 'input' }).element);
});
}); });
}); });
......
...@@ -95,7 +95,9 @@ describe('Project List component', () => { ...@@ -95,7 +95,9 @@ describe('Project List component', () => {
getFirstRemoveButton().trigger('click'); getFirstRemoveButton().trigger('click');
expect(wrapper.emitted('projectRemoved')).toHaveLength(1); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('projectRemoved')).toEqual([[projectData]]); expect(wrapper.emitted('projectRemoved')).toHaveLength(1);
expect(wrapper.emitted('projectRemoved')).toEqual([[projectData]]);
});
}); });
}); });
...@@ -146,7 +146,9 @@ describe('EE MRWidget approvals footer', () => { ...@@ -146,7 +146,9 @@ describe('EE MRWidget approvals footer', () => {
button.trigger('click'); button.trigger('click');
expect(wrapper.emittedByOrder()).toEqual([{ name: 'input', args: [true] }]); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emittedByOrder()).toEqual([{ name: 'input', args: [true] }]);
});
}); });
}); });
......
...@@ -223,15 +223,18 @@ describe('ReadyToMerge', () => { ...@@ -223,15 +223,18 @@ describe('ReadyToMerge', () => {
dialog.vm.show = jest.fn(); dialog.vm.show = jest.fn();
vm.handleMergeButtonClick = jest.fn(); vm.handleMergeButtonClick = jest.fn();
findMergeButtonDropdown().trigger('click'); findMergeButtonDropdown().trigger('click');
findMergeImmediatelyButton().trigger('click'); return wrapper.vm.$nextTick().then(() => {
findMergeImmediatelyButton().trigger('click');
return wrapper.vm.$nextTick();
});
}; };
it('should show a warning dialog asking for confirmation if the user is trying to skip the merge train', () => { it('should show a warning dialog asking for confirmation if the user is trying to skip the merge train', () => {
factory({ preferredAutoMergeStrategy: MT_MERGE_STRATEGY }); factory({ preferredAutoMergeStrategy: MT_MERGE_STRATEGY });
clickMergeImmediately(); return clickMergeImmediately().then(() => {
expect(dialog.vm.show).toHaveBeenCalled();
expect(dialog.vm.show).toHaveBeenCalled(); expect(vm.handleMergeButtonClick).not.toHaveBeenCalled();
expect(vm.handleMergeButtonClick).not.toHaveBeenCalled(); });
}); });
it('should perform the merge when the user confirms their intent to merge immediately', () => { it('should perform the merge when the user confirms their intent to merge immediately', () => {
...@@ -245,10 +248,10 @@ describe('ReadyToMerge', () => { ...@@ -245,10 +248,10 @@ describe('ReadyToMerge', () => {
it('should not ask for confirmation in non-merge train scenarios', () => { it('should not ask for confirmation in non-merge train scenarios', () => {
factory({ isPipelineActive: true, onlyAllowMergeIfPipelineSucceeds: false }); factory({ isPipelineActive: true, onlyAllowMergeIfPipelineSucceeds: false });
clickMergeImmediately(); return clickMergeImmediately().then(() => {
expect(dialog.vm.show).not.toHaveBeenCalled();
expect(dialog.vm.show).not.toHaveBeenCalled(); expect(vm.handleMergeButtonClick).toHaveBeenCalled();
expect(vm.handleMergeButtonClick).toHaveBeenCalled(); });
}); });
}); });
......
...@@ -23,7 +23,9 @@ describe('DismissalButton', () => { ...@@ -23,7 +23,9 @@ describe('DismissalButton', () => {
it('should emit dismiss vulnerabilty when clicked', () => { it('should emit dismiss vulnerabilty when clicked', () => {
wrapper.find(LoadingButton).trigger('click'); wrapper.find(LoadingButton).trigger('click');
expect(wrapper.emitted().dismissVulnerability).toBeTruthy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().dismissVulnerability).toBeTruthy();
});
}); });
it('should render the dismiss with comment button', () => { it('should render the dismiss with comment button', () => {
...@@ -32,7 +34,9 @@ describe('DismissalButton', () => { ...@@ -32,7 +34,9 @@ describe('DismissalButton', () => {
it('should emit openDismissalCommentBox when clicked', () => { it('should emit openDismissalCommentBox when clicked', () => {
wrapper.find('.js-dismiss-with-comment').trigger('click'); wrapper.find('.js-dismiss-with-comment').trigger('click');
expect(wrapper.emitted().openDismissalCommentBox).toBeTruthy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().openDismissalCommentBox).toBeTruthy();
});
}); });
}); });
...@@ -50,7 +54,9 @@ describe('DismissalButton', () => { ...@@ -50,7 +54,9 @@ describe('DismissalButton', () => {
it('should emit revertDismissVulnerabilty when clicked', () => { it('should emit revertDismissVulnerabilty when clicked', () => {
wrapper.find(LoadingButton).trigger('click'); wrapper.find(LoadingButton).trigger('click');
expect(wrapper.emitted().revertDismissVulnerability).toBeTruthy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().revertDismissVulnerability).toBeTruthy();
});
}); });
it('should not render the dismiss with comment button', () => { it('should not render the dismiss with comment button', () => {
......
...@@ -23,7 +23,9 @@ describe('DismissalCommentBox', () => { ...@@ -23,7 +23,9 @@ describe('DismissalCommentBox', () => {
metaKey: true, metaKey: true,
}); });
expect(wrapper.emitted().submit).toBeTruthy(); return wrapper.vm.$nextTick(() => {
expect(wrapper.emitted().submit).toBeTruthy();
});
}); });
it('should render the error message', () => { it('should render the error message', () => {
......
...@@ -31,16 +31,21 @@ describe('DismissalCommentModalFooter', () => { ...@@ -31,16 +31,21 @@ describe('DismissalCommentModalFooter', () => {
it('should emit the "addCommentAndDismiss" event when clicked', () => { it('should emit the "addCommentAndDismiss" event when clicked', () => {
wrapper.find(LoadingButton).trigger('click'); wrapper.find(LoadingButton).trigger('click');
expect(wrapper.emitted().addCommentAndDismiss).toBeTruthy(); return wrapper.vm.$nextTick().then(() => {
expect(Tracking.event).toHaveBeenCalledWith( expect(wrapper.emitted().addCommentAndDismiss).toBeTruthy();
'_track_category_', expect(Tracking.event).toHaveBeenCalledWith(
'click_add_comment_and_dismiss', '_track_category_',
); 'click_add_comment_and_dismiss',
);
});
}); });
it('should emit the cancel event when the cancel button is clicked', () => { it('should emit the cancel event when the cancel button is clicked', () => {
wrapper.find('.js-cancel').trigger('click'); wrapper.find('.js-cancel').trigger('click');
expect(wrapper.emitted().cancel).toBeTruthy();
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().cancel).toBeTruthy();
});
}); });
}); });
...@@ -60,8 +65,10 @@ describe('DismissalCommentModalFooter', () => { ...@@ -60,8 +65,10 @@ describe('DismissalCommentModalFooter', () => {
it('should emit the "addCommentAndDismiss" event when clicked', () => { it('should emit the "addCommentAndDismiss" event when clicked', () => {
wrapper.find(LoadingButton).trigger('click'); wrapper.find(LoadingButton).trigger('click');
expect(wrapper.emitted().addDismissalComment).toBeTruthy(); return wrapper.vm.$nextTick().then(() => {
expect(Tracking.event).toHaveBeenCalledWith('_track_category_', 'click_add_comment'); expect(wrapper.emitted().addDismissalComment).toBeTruthy();
expect(Tracking.event).toHaveBeenCalledWith('_track_category_', 'click_add_comment');
});
}); });
}); });
...@@ -81,8 +88,10 @@ describe('DismissalCommentModalFooter', () => { ...@@ -81,8 +88,10 @@ describe('DismissalCommentModalFooter', () => {
it('should emit the "addCommentAndDismiss" event when clicked', () => { it('should emit the "addCommentAndDismiss" event when clicked', () => {
wrapper.find(LoadingButton).trigger('click'); wrapper.find(LoadingButton).trigger('click');
expect(wrapper.emitted().addDismissalComment).toBeTruthy(); return wrapper.vm.$nextTick().then(() => {
expect(Tracking.event).toHaveBeenCalledWith('_track_category_', 'click_edit_comment'); expect(wrapper.emitted().addDismissalComment).toBeTruthy();
expect(Tracking.event).toHaveBeenCalledWith('_track_category_', 'click_edit_comment');
});
}); });
}); });
}); });
......
...@@ -84,10 +84,16 @@ describe('Event Item', () => { ...@@ -84,10 +84,16 @@ describe('Event Item', () => {
it('emits the button events when clicked', () => { it('emits the button events when clicked', () => {
const buttons = wrapper.findAll('.action-buttons > button'); const buttons = wrapper.findAll('.action-buttons > button');
buttons.at(0).trigger('click'); buttons.at(0).trigger('click');
buttons.at(1).trigger('click'); return wrapper.vm
.$nextTick()
expect(wrapper.emitted().fooEvent.length).toEqual(1); .then(() => {
expect(wrapper.emitted().barEvent.length).toEqual(1); buttons.at(1).trigger('click');
return wrapper.vm.$nextTick();
})
.then(() => {
expect(wrapper.emitted().fooEvent.length).toEqual(1);
expect(wrapper.emitted().barEvent.length).toEqual(1);
});
}); });
}); });
}); });
...@@ -32,7 +32,10 @@ describe('Security Reports modal footer', () => { ...@@ -32,7 +32,10 @@ describe('Security Reports modal footer', () => {
it('emits createIssue when create issue button is clicked', () => { it('emits createIssue when create issue button is clicked', () => {
wrapper.find(LoadingButton).trigger('click'); wrapper.find(LoadingButton).trigger('click');
expect(wrapper.emitted().createNewIssue).toBeTruthy();
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().createNewIssue).toBeTruthy();
});
}); });
}); });
...@@ -52,7 +55,10 @@ describe('Security Reports modal footer', () => { ...@@ -52,7 +55,10 @@ describe('Security Reports modal footer', () => {
it('emits createMergeRequest when create merge request button is clicked', () => { it('emits createMergeRequest when create merge request button is clicked', () => {
wrapper.find(LoadingButton).trigger('click'); wrapper.find(LoadingButton).trigger('click');
expect(wrapper.emitted().createMergeRequest).toBeTruthy();
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().createMergeRequest).toBeTruthy();
});
}); });
}); });
...@@ -72,7 +78,10 @@ describe('Security Reports modal footer', () => { ...@@ -72,7 +78,10 @@ describe('Security Reports modal footer', () => {
it('emits downloadPatch when download patch button is clicked', () => { it('emits downloadPatch when download patch button is clicked', () => {
wrapper.find(LoadingButton).trigger('click'); wrapper.find(LoadingButton).trigger('click');
expect(wrapper.emitted().downloadPatch).toBeTruthy();
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().downloadPatch).toBeTruthy();
});
}); });
}); });
......
...@@ -61,15 +61,20 @@ describe('ClusterFormDropdown', () => { ...@@ -61,15 +61,20 @@ describe('ClusterFormDropdown', () => {
beforeEach(() => { beforeEach(() => {
vm.setProps({ items, multiple: true, value }); vm.setProps({ items, multiple: true, value });
return vm.vm.$nextTick().then(() => { return vm.vm
vm.findAll('.js-dropdown-item') .$nextTick()
.at(0) .then(() => {
.trigger('click'); vm.findAll('.js-dropdown-item')
vm.findAll('.js-dropdown-item') .at(0)
.at(1) .trigger('click');
.trigger('click'); return vm.vm.$nextTick();
return vm.vm.$nextTick(); })
}); .then(() => {
vm.findAll('.js-dropdown-item')
.at(1)
.trigger('click');
return vm.vm.$nextTick();
});
}); });
it('emits input event with an array of selected items', () => { it('emits input event with an array of selected items', () => {
......
...@@ -92,7 +92,9 @@ describe('StageNavItem', () => { ...@@ -92,7 +92,9 @@ describe('StageNavItem', () => {
it('emits the `select` event when clicked', () => { it('emits the `select` event when clicked', () => {
expect(wrapper.emitted().select).toBeUndefined(); expect(wrapper.emitted().select).toBeUndefined();
wrapper.trigger('click'); wrapper.trigger('click');
expect(wrapper.emitted().select.length).toBe(1); return wrapper.vm.$nextTick(() => {
expect(wrapper.emitted().select.length).toBe(1);
});
}); });
}); });
......
...@@ -117,7 +117,10 @@ describe('DiffFileHeader component', () => { ...@@ -117,7 +117,10 @@ describe('DiffFileHeader component', () => {
it('when header is clicked emits toggleFile', () => { it('when header is clicked emits toggleFile', () => {
createComponent(); createComponent();
findHeader().trigger('click'); findHeader().trigger('click');
expect(wrapper.emitted().toggleFile).toBeDefined();
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().toggleFile).toBeDefined();
});
}); });
it('when collapseIcon is clicked emits toggleFile', () => { it('when collapseIcon is clicked emits toggleFile', () => {
...@@ -129,7 +132,10 @@ describe('DiffFileHeader component', () => { ...@@ -129,7 +132,10 @@ describe('DiffFileHeader component', () => {
it('when other element in header is clicked does not emits toggleFile', () => { it('when other element in header is clicked does not emits toggleFile', () => {
createComponent({ collapsible: true }); createComponent({ collapsible: true });
findTitleLink().trigger('click'); findTitleLink().trigger('click');
expect(wrapper.emitted().toggleFile).not.toBeDefined();
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().toggleFile).not.toBeDefined();
});
}); });
it('displays a copy to clipboard button', () => { it('displays a copy to clipboard button', () => {
......
...@@ -42,7 +42,9 @@ describe('DiffGutterAvatars', () => { ...@@ -42,7 +42,9 @@ describe('DiffGutterAvatars', () => {
it('should emit toggleDiscussions event on button click', () => { it('should emit toggleDiscussions event on button click', () => {
findCollapseButton().trigger('click'); findCollapseButton().trigger('click');
expect(wrapper.emitted().toggleLineDiscussions).toBeTruthy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().toggleLineDiscussions).toBeTruthy();
});
}); });
}); });
...@@ -72,13 +74,17 @@ describe('DiffGutterAvatars', () => { ...@@ -72,13 +74,17 @@ describe('DiffGutterAvatars', () => {
.at(0) .at(0)
.trigger('click'); .trigger('click');
expect(wrapper.emitted().toggleLineDiscussions).toBeTruthy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().toggleLineDiscussions).toBeTruthy();
});
}); });
it('should emit toggleDiscussions event on more count text click', () => { it('should emit toggleDiscussions event on more count text click', () => {
findMoreCount().trigger('click'); findMoreCount().trigger('click');
expect(wrapper.emitted().toggleLineDiscussions).toBeTruthy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().toggleLineDiscussions).toBeTruthy();
});
}); });
}); });
......
...@@ -36,7 +36,9 @@ describe('EditButton', () => { ...@@ -36,7 +36,9 @@ describe('EditButton', () => {
}); });
wrapper.trigger('click'); wrapper.trigger('click');
expect(wrapper.emitted('showForkMessage')).toBeTruthy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('showForkMessage')).toBeTruthy();
});
}); });
it('doesnt emit a show fork message event if current user cannot fork', () => { it('doesnt emit a show fork message event if current user cannot fork', () => {
...@@ -46,7 +48,9 @@ describe('EditButton', () => { ...@@ -46,7 +48,9 @@ describe('EditButton', () => {
}); });
wrapper.trigger('click'); wrapper.trigger('click');
expect(wrapper.emitted('showForkMessage')).toBeFalsy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('showForkMessage')).toBeFalsy();
});
}); });
it('doesnt emit a show fork message event if current user can modify blob', () => { it('doesnt emit a show fork message event if current user can modify blob', () => {
...@@ -57,6 +61,8 @@ describe('EditButton', () => { ...@@ -57,6 +61,8 @@ describe('EditButton', () => {
}); });
wrapper.trigger('click'); wrapper.trigger('click');
expect(wrapper.emitted('showForkMessage')).toBeFalsy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('showForkMessage')).toBeFalsy();
});
}); });
}); });
...@@ -90,8 +90,13 @@ describe('IDE error message component', () => { ...@@ -90,8 +90,13 @@ describe('IDE error message component', () => {
it('does not dispatch action when already loading', () => { it('does not dispatch action when already loading', () => {
wrapper.find('button').trigger('click'); wrapper.find('button').trigger('click');
actionMock.mockReset(); actionMock.mockReset();
wrapper.find('button').trigger('click'); return wrapper.vm.$nextTick(() => {
expect(actionMock).not.toHaveBeenCalled(); wrapper.find('button').trigger('click');
return wrapper.vm.$nextTick().then(() => {
expect(actionMock).not.toHaveBeenCalled();
});
});
}); });
it('shows loading icon when loading', () => { it('shows loading icon when loading', () => {
......
...@@ -62,7 +62,9 @@ describe('IDE file templates dropdown component', () => { ...@@ -62,7 +62,9 @@ describe('IDE file templates dropdown component', () => {
const item = findItemButtons().at(0); const item = findItemButtons().at(0);
item.trigger('click'); item.trigger('click');
expect(wrapper.emitted().click[0][0]).toBe(itemData); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().click[0][0]).toBe(itemData);
});
}); });
it('renders dropdown title', () => { it('renders dropdown title', () => {
......
...@@ -52,7 +52,10 @@ describe('IDE pipeline stage', () => { ...@@ -52,7 +52,10 @@ describe('IDE pipeline stage', () => {
const id = 5; const id = 5;
createComponent({ stage: { ...defaultProps.stage, id } }); createComponent({ stage: { ...defaultProps.stage, id } });
findHeader().trigger('click'); findHeader().trigger('click');
expect(wrapper.emitted().toggleCollapsed[0][0]).toBe(id);
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().toggleCollapsed[0][0]).toBe(id);
});
}); });
it('emits clickViewLog entity with job', () => { it('emits clickViewLog entity with job', () => {
......
...@@ -339,7 +339,9 @@ describe('Issuable component', () => { ...@@ -339,7 +339,9 @@ describe('Issuable component', () => {
findBulkCheckbox().trigger('click'); findBulkCheckbox().trigger('click');
expect(wrapper.emitted().select).toEqual([[{ issuable, selected: !selected }]]); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().select).toEqual([[{ issuable, selected: !selected }]]);
});
}); });
}); });
}); });
......
...@@ -68,6 +68,9 @@ describe('Job Log Collapsible Section', () => { ...@@ -68,6 +68,9 @@ describe('Job Log Collapsible Section', () => {
}); });
findCollapsibleLine().trigger('click'); findCollapsibleLine().trigger('click');
expect(wrapper.emitted('onClickCollapsibleLine').length).toBe(1);
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('onClickCollapsibleLine').length).toBe(1);
});
}); });
}); });
...@@ -79,7 +79,9 @@ describe('Job Log Header Line', () => { ...@@ -79,7 +79,9 @@ describe('Job Log Header Line', () => {
it('emits toggleLine event', () => { it('emits toggleLine event', () => {
wrapper.trigger('click'); wrapper.trigger('click');
expect(wrapper.emitted().toggleLine.length).toBe(1); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().toggleLine.length).toBe(1);
});
}); });
}); });
......
...@@ -58,8 +58,9 @@ describe('DateTimePickerInput', () => { ...@@ -58,8 +58,9 @@ describe('DateTimePickerInput', () => {
it('input event is emitted when focus is lost', () => { it('input event is emitted when focus is lost', () => {
createComponent(); createComponent();
jest.spyOn(wrapper.vm, '$emit'); jest.spyOn(wrapper.vm, '$emit');
wrapper.find('input').setValue(inputValue); const input = wrapper.find('input');
wrapper.find('input').trigger('blur'); input.setValue(inputValue);
input.trigger('blur');
expect(wrapper.vm.$emit).toHaveBeenCalledWith('input', inputValue); expect(wrapper.vm.$emit).toHaveBeenCalledWith('input', inputValue);
}); });
......
...@@ -18,7 +18,10 @@ describe('DateTimePicker', () => { ...@@ -18,7 +18,10 @@ describe('DateTimePicker', () => {
const cancelButtonElement = () => dateTimePicker.find('button.btn-secondary').element; const cancelButtonElement = () => dateTimePicker.find('button.btn-secondary').element;
const fillInputAndBlur = (input, val) => { const fillInputAndBlur = (input, val) => {
dateTimePicker.find(input).setValue(val); dateTimePicker.find(input).setValue(val);
dateTimePicker.find(input).trigger('blur'); return dateTimePicker.vm.$nextTick().then(() => {
dateTimePicker.find(input).trigger('blur');
return dateTimePicker.vm.$nextTick();
});
}; };
const createComponent = props => { const createComponent = props => {
...@@ -103,52 +106,54 @@ describe('DateTimePicker', () => { ...@@ -103,52 +106,54 @@ describe('DateTimePicker', () => {
it('displays inline error message if custom time range inputs are invalid', done => { it('displays inline error message if custom time range inputs are invalid', done => {
createComponent(); createComponent();
fillInputAndBlur('#custom-time-from', '2019-10-01abc'); fillInputAndBlur('#custom-time-from', '2019-10-01abc')
fillInputAndBlur('#custom-time-to', '2019-10-10abc'); .then(() => fillInputAndBlur('#custom-time-to', '2019-10-10abc'))
.then(() => {
dateTimePicker.vm.$nextTick(() => { expect(dateTimePicker.findAll('.invalid-feedback').length).toBe(2);
expect(dateTimePicker.findAll('.invalid-feedback').length).toBe(2); done();
done(); })
}); .catch(done);
}); });
it('keeps apply button disabled with invalid custom time range inputs', done => { it('keeps apply button disabled with invalid custom time range inputs', done => {
createComponent(); createComponent();
fillInputAndBlur('#custom-time-from', '2019-10-01abc'); fillInputAndBlur('#custom-time-from', '2019-10-01abc')
fillInputAndBlur('#custom-time-to', '2019-09-19'); .then(() => fillInputAndBlur('#custom-time-to', '2019-09-19'))
.then(() => {
dateTimePicker.vm.$nextTick(() => { expect(applyButtonElement().getAttribute('disabled')).toBe('disabled');
expect(applyButtonElement().getAttribute('disabled')).toBe('disabled'); done();
done(); })
}); .catch(done);
}); });
it('enables apply button with valid custom time range inputs', done => { it('enables apply button with valid custom time range inputs', done => {
createComponent(); createComponent();
fillInputAndBlur('#custom-time-from', '2019-10-01'); fillInputAndBlur('#custom-time-from', '2019-10-01')
fillInputAndBlur('#custom-time-to', '2019-10-19'); .then(() => fillInputAndBlur('#custom-time-to', '2019-10-19'))
.then(() => {
dateTimePicker.vm.$nextTick(() => { dateTimePicker.vm.$nextTick(() => {
expect(applyButtonElement().getAttribute('disabled')).toBeNull(); expect(applyButtonElement().getAttribute('disabled')).toBeNull();
done(); done();
}); });
})
.catch(done);
}); });
it('returns an object when apply is clicked', done => { it('returns an object when apply is clicked', done => {
createComponent(); createComponent();
fillInputAndBlur('#custom-time-from', '2019-10-01'); fillInputAndBlur('#custom-time-from', '2019-10-01')
fillInputAndBlur('#custom-time-to', '2019-10-19'); .then(() => fillInputAndBlur('#custom-time-to', '2019-10-19'))
.then(() => {
dateTimePicker.vm.$nextTick(() => { jest.spyOn(dateTimePicker.vm, '$emit');
jest.spyOn(dateTimePicker.vm, '$emit'); applyButtonElement().click();
applyButtonElement().click();
expect(dateTimePicker.vm.$emit).toHaveBeenCalledWith('onApply', {
expect(dateTimePicker.vm.$emit).toHaveBeenCalledWith('onApply', { end: '2019-10-19T00:00:00Z',
end: '2019-10-19T00:00:00Z', start: '2019-10-01T00:00:00Z',
start: '2019-10-01T00:00:00Z', });
}); done();
done(); })
}); .catch(done);
}); });
it('hides the popover with cancel button', done => { it('hides the popover with cancel button', done => {
......
...@@ -24,7 +24,9 @@ describe('JumpToNextDiscussionButton', () => { ...@@ -24,7 +24,9 @@ describe('JumpToNextDiscussionButton', () => {
button.trigger('click'); button.trigger('click');
expect(wrapper.emitted().onClick).toBeTruthy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().onClick.length).toBe(1); expect(wrapper.emitted().onClick).toBeTruthy();
expect(wrapper.emitted().onClick.length).toBe(1);
});
}); });
}); });
...@@ -25,8 +25,10 @@ describe('ReplyPlaceholder', () => { ...@@ -25,8 +25,10 @@ describe('ReplyPlaceholder', () => {
it('emits onClick even on button click', () => { it('emits onClick even on button click', () => {
findButton().trigger('click'); findButton().trigger('click');
expect(wrapper.emitted()).toEqual({ return wrapper.vm.$nextTick().then(() => {
onClick: [[]], expect(wrapper.emitted()).toEqual({
onClick: [[]],
});
}); });
}); });
......
...@@ -33,8 +33,10 @@ describe('resolveDiscussionButton', () => { ...@@ -33,8 +33,10 @@ describe('resolveDiscussionButton', () => {
button.trigger('click'); button.trigger('click');
expect(wrapper.emitted()).toEqual({ return wrapper.vm.$nextTick().then(() => {
onClick: [[]], expect(wrapper.emitted()).toEqual({
onClick: [[]],
});
}); });
}); });
......
...@@ -290,7 +290,10 @@ describe('note_app', () => { ...@@ -290,7 +290,10 @@ describe('note_app', () => {
it('should not render quick actions docs url', () => { it('should not render quick actions docs url', () => {
wrapper.find('.js-note-edit').trigger('click'); wrapper.find('.js-note-edit').trigger('click');
const { quickActionsDocsPath } = mockData.notesDataMock; const { quickActionsDocsPath } = mockData.notesDataMock;
expect(wrapper.find(`.edit-note a[href="${quickActionsDocsPath}"]`).exists()).toBe(false);
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.find(`.edit-note a[href="${quickActionsDocsPath}"]`).exists()).toBe(false);
});
}); });
}); });
......
...@@ -19,6 +19,7 @@ describe('add request form', () => { ...@@ -19,6 +19,7 @@ describe('add request form', () => {
describe('when clicking the button', () => { describe('when clicking the button', () => {
beforeEach(() => { beforeEach(() => {
wrapper.find('button').trigger('click'); wrapper.find('button').trigger('click');
return wrapper.vm.$nextTick();
}); });
it('shows the form', () => { it('shows the form', () => {
...@@ -28,6 +29,7 @@ describe('add request form', () => { ...@@ -28,6 +29,7 @@ describe('add request form', () => {
describe('when pressing escape', () => { describe('when pressing escape', () => {
beforeEach(() => { beforeEach(() => {
wrapper.find('input').trigger('keyup.esc'); wrapper.find('input').trigger('keyup.esc');
return wrapper.vm.$nextTick();
}); });
it('hides the input', () => { it('hides the input', () => {
...@@ -38,7 +40,10 @@ describe('add request form', () => { ...@@ -38,7 +40,10 @@ describe('add request form', () => {
describe('when submitting the form', () => { describe('when submitting the form', () => {
beforeEach(() => { beforeEach(() => {
wrapper.find('input').setValue('http://gitlab.example.com/users/root/calendar.json'); wrapper.find('input').setValue('http://gitlab.example.com/users/root/calendar.json');
wrapper.find('input').trigger('keyup.enter'); return wrapper.vm.$nextTick().then(() => {
wrapper.find('input').trigger('keyup.enter');
return wrapper.vm.$nextTick();
});
}); });
it('emits an event to add the request', () => { it('emits an event to add the request', () => {
...@@ -54,8 +59,9 @@ describe('add request form', () => { ...@@ -54,8 +59,9 @@ describe('add request form', () => {
it('clears the value for next time', () => { it('clears the value for next time', () => {
wrapper.find('button').trigger('click'); wrapper.find('button').trigger('click');
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.find('input').text()).toEqual(''); expect(wrapper.find('input').text()).toEqual('');
});
}); });
}); });
}); });
......
...@@ -53,7 +53,10 @@ describe('Evidence Block', () => { ...@@ -53,7 +53,10 @@ describe('Evidence Block', () => {
it('renders the long sha after expansion', () => { it('renders the long sha after expansion', () => {
wrapper.find('.js-text-expander-prepend').trigger('click'); wrapper.find('.js-text-expander-prepend').trigger('click');
expect(wrapper.find('.js-expanded').text()).toBe(release.evidence_sha);
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.find('.js-expanded').text()).toBe(release.evidence_sha);
});
}); });
}); });
......
...@@ -65,7 +65,9 @@ describe('Assignee component', () => { ...@@ -65,7 +65,9 @@ describe('Assignee component', () => {
jest.spyOn(wrapper.vm, '$emit'); jest.spyOn(wrapper.vm, '$emit');
wrapper.find('.assign-yourself .btn-link').trigger('click'); wrapper.find('.assign-yourself .btn-link').trigger('click');
expect(wrapper.emitted('assign-self')).toBeTruthy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('assign-self')).toBeTruthy();
});
}); });
}); });
......
...@@ -60,7 +60,9 @@ describe('SidebarTodo', () => { ...@@ -60,7 +60,9 @@ describe('SidebarTodo', () => {
createComponent(); createComponent();
wrapper.find('button').trigger('click'); wrapper.find('button').trigger('click');
expect(wrapper.emitted().toggleTodo).toBeTruthy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().toggleTodo).toBeTruthy();
});
}); });
it('renders component container element with proper data attributes', () => { it('renders component container element with proper data attributes', () => {
......
...@@ -42,6 +42,7 @@ describe('Merge Request Collapsible Extension', () => { ...@@ -42,6 +42,7 @@ describe('Merge Request Collapsible Extension', () => {
describe('onClick', () => { describe('onClick', () => {
beforeEach(() => { beforeEach(() => {
wrapper.find('button').trigger('click'); wrapper.find('button').trigger('click');
return wrapper.vm.$nextTick();
}); });
it('rendes the provided slot', () => { it('rendes the provided slot', () => {
......
...@@ -55,8 +55,10 @@ describe('Commits edit component', () => { ...@@ -55,8 +55,10 @@ describe('Commits edit component', () => {
findTextarea().element.value = changedCommitMessage; findTextarea().element.value = changedCommitMessage;
findTextarea().trigger('input'); findTextarea().trigger('input');
expect(wrapper.emitted().input[0]).toEqual([changedCommitMessage]); return wrapper.vm.$nextTick().then(() => {
expect(findTextarea().element.value).toBe(changedCommitMessage); expect(wrapper.emitted().input[0]).toEqual([changedCommitMessage]);
expect(findTextarea().element.value).toBe(changedCommitMessage);
});
}); });
}); });
......
...@@ -136,7 +136,10 @@ describe('Expand button', () => { ...@@ -136,7 +136,10 @@ describe('Expand button', () => {
it('clicking hides itself and shows prepend', () => { it('clicking hides itself and shows prepend', () => {
expect(expanderAppendEl().isVisible()).toBe(true); expect(expanderAppendEl().isVisible()).toBe(true);
expanderAppendEl().trigger('click'); expanderAppendEl().trigger('click');
expect(expanderPrependEl().isVisible()).toBe(true);
return wrapper.vm.$nextTick().then(() => {
expect(expanderPrependEl().isVisible()).toBe(true);
});
}); });
it('clicking hides expanded text', () => { it('clicking hides expanded text', () => {
...@@ -147,12 +150,15 @@ describe('Expand button', () => { ...@@ -147,12 +150,15 @@ describe('Expand button', () => {
.trim(), .trim(),
).toBe(text.expanded); ).toBe(text.expanded);
expanderAppendEl().trigger('click'); expanderAppendEl().trigger('click');
expect(
wrapper return wrapper.vm.$nextTick().then(() => {
.find(ExpandButton) expect(
.text() wrapper
.trim(), .find(ExpandButton)
).not.toBe(text.expanded); .text()
.trim(),
).not.toBe(text.expanded);
});
}); });
describe('when short text is provided', () => { describe('when short text is provided', () => {
...@@ -176,12 +182,15 @@ describe('Expand button', () => { ...@@ -176,12 +182,15 @@ describe('Expand button', () => {
.trim(), .trim(),
).toBe(text.expanded); ).toBe(text.expanded);
expanderAppendEl().trigger('click'); expanderAppendEl().trigger('click');
expect(
wrapper return wrapper.vm.$nextTick().then(() => {
.find(ExpandButton) expect(
.text() wrapper
.trim(), .find(ExpandButton)
).toBe(text.short); .text()
.trim(),
).toBe(text.short);
});
}); });
}); });
}); });
......
...@@ -192,10 +192,12 @@ describe('RelatedIssuableItem', () => { ...@@ -192,10 +192,12 @@ describe('RelatedIssuableItem', () => {
it('triggers onRemoveRequest when clicked', () => { it('triggers onRemoveRequest when clicked', () => {
removeBtn.trigger('click'); removeBtn.trigger('click');
const { relatedIssueRemoveRequest } = wrapper.emitted(); return wrapper.vm.$nextTick().then(() => {
const { relatedIssueRemoveRequest } = wrapper.emitted();
expect(relatedIssueRemoveRequest.length).toBe(1); expect(relatedIssueRemoveRequest.length).toBe(1);
expect(relatedIssueRemoveRequest[0]).toEqual([props.idKey]); expect(relatedIssueRemoveRequest[0]).toEqual([props.idKey]);
});
}); });
}); });
}); });
...@@ -80,7 +80,9 @@ describe('LoadingButton', () => { ...@@ -80,7 +80,9 @@ describe('LoadingButton', () => {
wrapper.trigger('click'); wrapper.trigger('click');
expect(wrapper.emitted('click')).toBeTruthy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('click')).toBeTruthy();
});
}); });
it('does not call given callback when disabled because of loading', () => { it('does not call given callback when disabled because of loading', () => {
...@@ -90,7 +92,9 @@ describe('LoadingButton', () => { ...@@ -90,7 +92,9 @@ describe('LoadingButton', () => {
wrapper.trigger('click'); wrapper.trigger('click');
expect(wrapper.emitted('click')).toBeFalsy(); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('click')).toBeFalsy();
});
}); });
}); });
}); });
...@@ -66,11 +66,17 @@ describe('Markdown field header component', () => { ...@@ -66,11 +66,17 @@ describe('Markdown field header component', () => {
it('emits toggle markdown event when clicking preview', () => { it('emits toggle markdown event when clicking preview', () => {
wrapper.find('.js-preview-link').trigger('click'); wrapper.find('.js-preview-link').trigger('click');
expect(wrapper.emitted('preview-markdown').length).toEqual(1); return wrapper.vm
.$nextTick()
wrapper.find('.js-write-link').trigger('click'); .then(() => {
expect(wrapper.emitted('preview-markdown').length).toEqual(1);
expect(wrapper.emitted('write-markdown').length).toEqual(1);
wrapper.find('.js-write-link').trigger('click');
return wrapper.vm.$nextTick();
})
.then(() => {
expect(wrapper.emitted('write-markdown').length).toEqual(1);
});
}); });
it('does not emit toggle markdown event when triggered from another form', () => { it('does not emit toggle markdown event when triggered from another form', () => {
......
...@@ -29,14 +29,20 @@ describe('modal copy button', () => { ...@@ -29,14 +29,20 @@ describe('modal copy button', () => {
removeAllRanges: jest.fn(), removeAllRanges: jest.fn(),
})); }));
wrapper.trigger('click'); wrapper.trigger('click');
expect(wrapper.emitted().success).not.toBeEmpty();
expect(document.execCommand).toHaveBeenCalledWith('copy'); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().success).not.toBeEmpty();
expect(document.execCommand).toHaveBeenCalledWith('copy');
});
}); });
it("should propagate the clipboard error event if execCommand doesn't work", () => { it("should propagate the clipboard error event if execCommand doesn't work", () => {
document.execCommand = jest.fn(() => false); document.execCommand = jest.fn(() => false);
wrapper.trigger('click'); wrapper.trigger('click');
expect(wrapper.emitted().error).not.toBeEmpty();
expect(document.execCommand).toHaveBeenCalledWith('copy'); return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted().error).not.toBeEmpty();
expect(document.execCommand).toHaveBeenCalledWith('copy');
});
}); });
}); });
}); });
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