Skip to content
代码片段 群组 项目
未验证 提交 e5dcc6d7 编辑于 作者: Heinrich Lee Yu's avatar Heinrich Lee Yu 提交者: GitLab
浏览文件

Merge branch 'hly-fix-backend-autocomplete-filtering-rte' into 'master'

Fix backend filtering in RTE autocomplete

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/183637



Merged-by: default avatarHeinrich Lee Yu <heinrich@gitlab.com>
Approved-by: default avatarSimon Knox <simon@gitlab.com>
No related branches found
No related tags found
2 合并请求!3031Merge per-main-jh to main-jh by luzhiyuan,!3030Merge per-main-jh to main-jh
......@@ -135,7 +135,7 @@ export default class AutocompleteHelper {
});
}
#getDataSource = (referenceType, { command } = {}) => {
#getDataSource = (referenceType, { command, ...options } = {}) => {
const sources = {
user: this.dataSourceUrls.members,
issue: this.dataSourceUrls.issues,
......@@ -214,6 +214,8 @@ export default class AutocompleteHelper {
sorter: sorters[referenceType] || sorters.default,
filter: filters[referenceType],
command,
...options,
});
};
}
......@@ -100,21 +100,6 @@ describe('createDataSource', () => {
{ name: 'abc', description: 'xyz' },
]);
});
describe('if filterOnBackend: true', () => {
it('fetches data from source, passing a `search` param', async () => {
const dataSource = createDataSource({
...dataSourceParams,
filterOnBackend: true,
});
const results = await dataSource.search('bcd');
expect(mock.history.get[0].params).toEqual({ search: 'bcd' });
// results are still filtered out on frontend, on top of backend filtering
expect(results).toEqual([{ name: 'bcd', description: 'wxy' }]);
});
});
});
it('handles source fetch errors', async () => {
......@@ -329,4 +314,14 @@ describe('AutocompleteHelper', () => {
expect(results.map(({ username }) => username)).toMatchSnapshot();
});
describe('if filterOnBackend: true', () => {
it('fetches data passing a `search` param', async () => {
const dataSource = autocompleteHelper.getDataSource('user', { filterOnBackend: true });
await dataSource.search('bcd');
expect(mock.history.get[0].params).toEqual({ search: 'bcd' });
});
});
});
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册