Commit 91b17b06 authored by Eric Eastwood's avatar Eric Eastwood

Fix duplicate related issue reference inserted when using autocomplete

Fix https://gitlab.com/gitlab-org/gitlab-ee/issues/2914
parent 8bd15968
......@@ -85,12 +85,12 @@ export default {
mounted() {
const $input = $(this.$refs.input);
new GfmAutoComplete(this.autoCompleteSources).setup($input, {
this.gfmAutoComplete = new GfmAutoComplete(this.autoCompleteSources);
this.gfmAutoComplete.setup($input, {
issues: true,
});
$input.on('shown-issues.atwho', this.onAutoCompleteToggled.bind(this, true));
$input.on('hidden-issues.atwho', this.onAutoCompleteToggled.bind(this, false));
$input.on('inserted-issues.atwho', this.onInput);
this.$refs.input.focus();
},
......
......@@ -198,6 +198,32 @@ describe('AddIssuableForm', () => {
});
});
it('when using the autocomplete', (done) => {
const $input = $(vm.$refs.input);
vm.gfmAutoComplete.loadData($input, '#', [{
id: 1,
iid: 111,
title: 'foo',
}]);
$input
.val('#')
.trigger('input')
.trigger('click');
$('.atwho-container li').trigger('click');
setTimeout(() => {
Vue.nextTick(() => {
expect(vm.$refs.input.value).toEqual('');
expect(addIssuableFormInputSpy.calls.count()).toEqual(1);
done();
});
});
});
it('when submitting pending issues', () => {
expect(addIssuableFormSubmitSpy).not.toHaveBeenCalled();
......
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