Commit dd4b1a1b authored by Terri Chu's avatar Terri Chu Committed by Vitaly Slobodin

Sort by similarity in Search Group's Project dropdown

Changelog: changed
parent d2580206
...@@ -30,7 +30,7 @@ export const fetchProjects = ({ commit, state }, search) => { ...@@ -30,7 +30,7 @@ export const fetchProjects = ({ commit, state }, search) => {
if (groupId) { if (groupId) {
// TODO (https://gitlab.com/gitlab-org/gitlab/-/issues/323331): For errors `createFlash` is called twice; in `callback` and in `Api.groupProjects` // TODO (https://gitlab.com/gitlab-org/gitlab/-/issues/323331): For errors `createFlash` is called twice; in `callback` and in `Api.groupProjects`
Api.groupProjects(groupId, search, {}, callback); Api.groupProjects(groupId, search, { order_by: 'similarity' }, callback);
} else { } else {
// The .catch() is due to the API method not handling a rejection properly // The .catch() is due to the API method not handling a rejection properly
Api.projects(search, { order_by: 'id' }, callback).catch(() => { Api.projects(search, { order_by: 'id' }, callback).catch(() => {
......
...@@ -67,7 +67,14 @@ describe('Global Search Store Actions', () => { ...@@ -67,7 +67,14 @@ describe('Global Search Store Actions', () => {
it('calls Api.groupProjects', () => { it('calls Api.groupProjects', () => {
actions.fetchProjects({ commit: mockCommit, state }); actions.fetchProjects({ commit: mockCommit, state });
expect(Api.groupProjects).toHaveBeenCalled(); expect(Api.groupProjects).toHaveBeenCalledWith(
state.query.group_id,
state.query.search,
{
order_by: 'similarity',
},
expect.any(Function),
);
expect(Api.projects).not.toHaveBeenCalled(); expect(Api.projects).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