Commit 77f63da4 authored by Rajat Jain's avatar Rajat Jain

Use reference for Epic in autocompletion

Use reference for Epics in autocompletion
parent aba290fa
...@@ -36,8 +36,8 @@ class GfmAutoCompleteEE extends GfmAutoComplete { ...@@ -36,8 +36,8 @@ class GfmAutoCompleteEE extends GfmAutoComplete {
return tmpl; return tmpl;
}, },
data: GfmAutoComplete.defaultLoadingData, data: GfmAutoComplete.defaultLoadingData,
// eslint-disable-next-line no-template-curly-in-string insertTpl: GfmAutoComplete.Issues.insertTemplateFunction,
insertTpl: '${atwho-at}${id}', skipSpecialCharacterTest: true,
callbacks: { callbacks: {
...defaultCallbacks, ...defaultCallbacks,
beforeSave(merges) { beforeSave(merges) {
...@@ -47,6 +47,7 @@ class GfmAutoCompleteEE extends GfmAutoComplete { ...@@ -47,6 +47,7 @@ class GfmAutoCompleteEE extends GfmAutoComplete {
} }
return { return {
id: m.iid, id: m.iid,
reference: m.reference,
title: m.title.replace(/<(?:.|\n)*?>/gm, ''), title: m.title.replace(/<(?:.|\n)*?>/gm, ''),
search: `${m.iid} ${m.title}`, search: `${m.iid} ${m.title}`,
}; };
......
---
title: Fix Epic autocomplete reference
merge_request: 52663
author:
type: fixed
import $ from 'jquery'; import $ from 'jquery';
import GfmAutoCompleteEE from 'ee/gfm_auto_complete'; import GfmAutoCompleteEE from 'ee/gfm_auto_complete';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import GfmAutoComplete from '~/gfm_auto_complete';
describe('GfmAutoCompleteEE', () => { describe('GfmAutoCompleteEE', () => {
const dataSources = { const dataSources = {
...@@ -17,4 +18,22 @@ describe('GfmAutoCompleteEE', () => { ...@@ -17,4 +18,22 @@ describe('GfmAutoCompleteEE', () => {
it('should have enableMap', () => { it('should have enableMap', () => {
expect(instance.enableMap).not.toBeNull(); expect(instance.enableMap).not.toBeNull();
}); });
describe('Issues.templateFunction', () => {
it('should return html with id and title', () => {
expect(GfmAutoComplete.Issues.templateFunction({ id: 42, title: 'Sample Epic' })).toBe(
'<li><small>42</small> Sample Epic</li>',
);
});
it('should replace id with reference if reference is set', () => {
expect(
GfmAutoComplete.Issues.templateFunction({
id: 42,
title: 'Another Epic',
reference: 'foo&42',
}),
).toBe('<li><small>foo&42</small> Another Epic</li>');
});
});
}); });
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