Commit 7f467d82 authored by Enrique Alcántara's avatar Enrique Alcántara

Merge branch 'ss/fix-issues-list-author-token' into 'master'

Fix loading authors in issues list

See merge request gitlab-org/gitlab!74562
parents ffbd0852 d23866a9
<script> <script>
import { GlAvatar, GlFilteredSearchSuggestion } from '@gitlab/ui'; import { GlAvatar, GlFilteredSearchSuggestion } from '@gitlab/ui';
import { compact } from 'lodash';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -59,8 +59,10 @@ export default { ...@@ -59,8 +59,10 @@ export default {
.then((res) => { .then((res) => {
// We'd want to avoid doing this check but // We'd want to avoid doing this check but
// users.json and /groups/:id/members & /projects/:id/users // users.json and /groups/:id/members & /projects/:id/users
// return response differently. // return response differently
this.authors = Array.isArray(res) ? res : res.data;
// TODO: rm when completed https://gitlab.com/gitlab-org/gitlab/-/issues/345756
this.authors = Array.isArray(res) ? compact(res) : compact(res.data);
}) })
.catch(() => .catch(() =>
createFlash({ createFlash({
......
...@@ -112,6 +112,35 @@ describe('AuthorToken', () => { ...@@ -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', () => { it('calls `createFlash` with flash error message when request fails', () => {
jest.spyOn(wrapper.vm.config, 'fetchAuthors').mockRejectedValue({}); 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