Commit 715b6bb7 authored by Eulyeon Ko's avatar Eulyeon Ko Committed by Natalia Tepluhina

Suppress all non-nullable field errors for assignee widget graphql queries

parent 7229273e
...@@ -108,10 +108,12 @@ export default { ...@@ -108,10 +108,12 @@ export default {
error({ graphQLErrors }) { error({ graphQLErrors }) {
// TODO This error suppression is temporary (BE fix required) // TODO This error suppression is temporary (BE fix required)
// https://gitlab.com/gitlab-org/gitlab/-/issues/329750 // https://gitlab.com/gitlab-org/gitlab/-/issues/329750
if ( const isNullError = ({ message }) => {
graphQLErrors.length === 1 && return message === 'Cannot return null for non-nullable field GroupMember.user';
graphQLErrors[0]?.message === 'Cannot return null for non-nullable field GroupMember.user' };
) {
if (graphQLErrors?.length > 0 && graphQLErrors.every(isNullError)) {
// only null-related errors exist, suppress them.
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error( console.error(
"Suppressing the error 'Cannot return null for non-nullable field GroupMember.user'. Please see https://gitlab.com/gitlab-org/gitlab/-/issues/329750", "Suppressing the error 'Cannot return null for non-nullable field GroupMember.user'. Please see https://gitlab.com/gitlab-org/gitlab/-/issues/329750",
......
---
title: Suppress all non-nullable field errors for assignee widget graphql queries
to remove assignee fetching error messages in boards
merge_request: 61091
author:
type: fixed
...@@ -95,14 +95,14 @@ describe('User select dropdown', () => { ...@@ -95,14 +95,14 @@ describe('User select dropdown', () => {
createComponent({ participantsQueryHandler: mockError }); createComponent({ participantsQueryHandler: mockError });
await waitForPromises(); await waitForPromises();
expect(wrapper.emitted('error')).toBeTruthy(); expect(wrapper.emitted('error')).toEqual([[], []]);
}); });
it('emits an `error` event if search query was rejected', async () => { it('emits an `error` event if search query was rejected', async () => {
createComponent({ searchQueryHandler: mockError }); createComponent({ searchQueryHandler: mockError });
await waitForSearch(); await waitForSearch();
expect(wrapper.emitted('error')).toBeTruthy(); expect(wrapper.emitted('error')).toEqual([[], []]);
}); });
it('renders current user if they are not in participants or assignees', async () => { it('renders current user if they are not in participants or assignees', async () => {
...@@ -264,4 +264,48 @@ describe('User select dropdown', () => { ...@@ -264,4 +264,48 @@ describe('User select dropdown', () => {
expect(findEmptySearchResults().exists()).toBe(true); expect(findEmptySearchResults().exists()).toBe(true);
}); });
}); });
// TODO Remove this test after the following issue is resolved in the backend
// https://gitlab.com/gitlab-org/gitlab/-/issues/329750
describe('temporary error suppression', () => {
beforeEach(() => {
jest.spyOn(console, 'error').mockImplementation();
});
const nullError = { message: 'Cannot return null for non-nullable field GroupMember.user' };
it.each`
mockErrors
${[nullError]}
${[nullError, nullError]}
`('does not emit errors', async ({ mockErrors }) => {
createComponent({
searchQueryHandler: jest.fn().mockResolvedValue({
errors: mockErrors,
}),
});
await waitForSearch();
expect(wrapper.emitted()).toEqual({});
// eslint-disable-next-line no-console
expect(console.error).toHaveBeenCalled();
});
it.each`
mockErrors
${[{ message: 'serious error' }]}
${[nullError, { message: 'serious error' }]}
`('emits error when non-null related errors are included', async ({ mockErrors }) => {
createComponent({
searchQueryHandler: jest.fn().mockResolvedValue({
errors: mockErrors,
}),
});
await waitForSearch();
expect(wrapper.emitted('error')).toEqual([[]]);
// eslint-disable-next-line no-console
expect(console.error).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