Commit d23866a9 authored by sstern's avatar sstern

Fix loading authors in issues list

Changelog: fixed
parent f81066dc
<script>
import { GlAvatar, GlFilteredSearchSuggestion } from '@gitlab/ui';
import { compact } from 'lodash';
import createFlash from '~/flash';
import { __ } from '~/locale';
......@@ -59,8 +59,10 @@ export default {
.then((res) => {
// We'd want to avoid doing this check but
// users.json and /groups/:id/members & /projects/:id/users
// return response differently.
this.authors = Array.isArray(res) ? res : res.data;
// return response differently
// TODO: rm when completed https://gitlab.com/gitlab-org/gitlab/-/issues/345756
this.authors = Array.isArray(res) ? compact(res) : compact(res.data);
})
.catch(() =>
createFlash({
......
......@@ -112,6 +112,35 @@ describe('AuthorToken', () => {
});
});
// TODO: rm when completed https://gitlab.com/gitlab-org/gitlab/-/issues/345756
describe('when there are null users presents', () => {
const mockAuthorsWithNullUser = mockAuthors.concat([null]);
beforeEach(() => {
jest
.spyOn(wrapper.vm.config, 'fetchAuthors')
.mockResolvedValue({ data: mockAuthorsWithNullUser });
getBaseToken().vm.$emit('fetch-suggestions', 'root');
});
describe('when res.data is present', () => {
it('filters the successful response when null values are present', () => {
return waitForPromises().then(() => {
expect(getBaseToken().props('suggestions')).toEqual(mockAuthors);
});
});
});
describe('when response is an array', () => {
it('filters the successful response when null values are present', () => {
return waitForPromises().then(() => {
expect(getBaseToken().props('suggestions')).toEqual(mockAuthors);
});
});
});
});
it('calls `createFlash` with flash error message when request fails', () => {
jest.spyOn(wrapper.vm.config, 'fetchAuthors').mockRejectedValue({});
......
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