Commit 0ba77670 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch '342745-remove-feature-flag' into 'master'

Remove Apollo error suppression feature flag

See merge request gitlab-org/gitlab!74291
parents c35f040a 65dd9c13
...@@ -9,10 +9,6 @@ import { isNavigatingAway } from '~/lib/utils/is_navigating_away'; ...@@ -9,10 +9,6 @@ import { isNavigatingAway } from '~/lib/utils/is_navigating_away';
* @returns {ApolloLink|null} * @returns {ApolloLink|null}
*/ */
export const getSuppressNetworkErrorsDuringNavigationLink = () => { export const getSuppressNetworkErrorsDuringNavigationLink = () => {
if (!gon.features?.suppressApolloErrorsDuringNavigation) {
return null;
}
return onError(({ networkError }) => { return onError(({ networkError }) => {
if (networkError && isNavigatingAway()) { if (networkError && isNavigatingAway()) {
// Return an observable that will never notify any subscribers with any // Return an observable that will never notify any subscribers with any
......
---
name: suppress_apollo_errors_during_navigation
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/72031
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/342745
milestone: '14.4'
type: development
group: group::foundations
default_enabled: false
...@@ -56,7 +56,6 @@ module Gitlab ...@@ -56,7 +56,6 @@ module Gitlab
push_frontend_feature_flag(:security_auto_fix, default_enabled: false) push_frontend_feature_flag(:security_auto_fix, default_enabled: false)
push_frontend_feature_flag(:improved_emoji_picker, default_enabled: :yaml) push_frontend_feature_flag(:improved_emoji_picker, default_enabled: :yaml)
push_frontend_feature_flag(:new_header_search, default_enabled: :yaml) push_frontend_feature_flag(:new_header_search, default_enabled: :yaml)
push_frontend_feature_flag(:suppress_apollo_errors_during_navigation, current_user, default_enabled: :yaml)
push_frontend_feature_flag(:configure_iac_scanning_via_mr, current_user, default_enabled: :yaml) push_frontend_feature_flag(:configure_iac_scanning_via_mr, current_user, default_enabled: :yaml)
push_frontend_feature_flag(:bootstrap_confirmation_modals, default_enabled: :yaml) push_frontend_feature_flag(:bootstrap_confirmation_modals, default_enabled: :yaml)
end end
......
...@@ -47,107 +47,95 @@ describe('getSuppressNetworkErrorsDuringNavigationLink', () => { ...@@ -47,107 +47,95 @@ describe('getSuppressNetworkErrorsDuringNavigationLink', () => {
subscription = link.request(mockOperation).subscribe(observer); subscription = link.request(mockOperation).subscribe(observer);
}; };
describe('when disabled', () => { it('returns an ApolloLink', () => {
it('returns null', () => { expect(getSuppressNetworkErrorsDuringNavigationLink()).toEqual(expect.any(ApolloLink));
expect(getSuppressNetworkErrorsDuringNavigationLink()).toBe(null);
});
}); });
describe('when enabled', () => { describe('suppression case', () => {
beforeEach(() => { describe('when navigating away', () => {
window.gon = { features: { suppressApolloErrorsDuringNavigation: true } }; beforeEach(() => {
}); isNavigatingAway.mockReturnValue(true);
});
it('returns an ApolloLink', () => {
expect(getSuppressNetworkErrorsDuringNavigationLink()).toEqual(expect.any(ApolloLink));
});
describe('suppression case', () => {
describe('when navigating away', () => {
beforeEach(() => {
isNavigatingAway.mockReturnValue(true);
});
describe('given a network error', () => {
it('does not forward the error', async () => {
const spy = jest.fn();
createSubscription(makeMockNetworkErrorLink(), { describe('given a network error', () => {
next: spy, it('does not forward the error', async () => {
error: spy, const spy = jest.fn();
complete: spy,
});
// It's hard to test for something _not_ happening. The best we can createSubscription(makeMockNetworkErrorLink(), {
// do is wait a bit to make sure nothing happens. next: spy,
await waitForPromises(); error: spy,
expect(spy).not.toHaveBeenCalled(); complete: spy,
}); });
// It's hard to test for something _not_ happening. The best we can
// do is wait a bit to make sure nothing happens.
await waitForPromises();
expect(spy).not.toHaveBeenCalled();
}); });
}); });
}); });
});
describe('non-suppression cases', () => { describe('non-suppression cases', () => {
describe('when not navigating away', () => { describe('when not navigating away', () => {
beforeEach(() => { beforeEach(() => {
isNavigatingAway.mockReturnValue(false); isNavigatingAway.mockReturnValue(false);
}); });
it('forwards successful requests', (done) => { it('forwards successful requests', (done) => {
createSubscription(makeMockSuccessLink(), { createSubscription(makeMockSuccessLink(), {
next({ data }) { next({ data }) {
expect(data).toEqual({ foo: { id: 1 } }); expect(data).toEqual({ foo: { id: 1 } });
}, },
error: () => done.fail('Should not happen'), error: () => done.fail('Should not happen'),
complete: () => done(), complete: () => done(),
});
}); });
});
it('forwards GraphQL errors', (done) => { it('forwards GraphQL errors', (done) => {
createSubscription(makeMockGraphQLErrorLink(), { createSubscription(makeMockGraphQLErrorLink(), {
next({ errors }) { next({ errors }) {
expect(errors).toEqual([{ message: 'foo' }]); expect(errors).toEqual([{ message: 'foo' }]);
}, },
error: () => done.fail('Should not happen'), error: () => done.fail('Should not happen'),
complete: () => done(), complete: () => done(),
});
}); });
});
it('forwards network errors', (done) => { it('forwards network errors', (done) => {
createSubscription(makeMockNetworkErrorLink(), { createSubscription(makeMockNetworkErrorLink(), {
next: () => done.fail('Should not happen'), next: () => done.fail('Should not happen'),
error: (error) => { error: (error) => {
expect(error.message).toBe('NetworkError'); expect(error.message).toBe('NetworkError');
done(); done();
}, },
complete: () => done.fail('Should not happen'), complete: () => done.fail('Should not happen'),
});
}); });
}); });
});
describe('when navigating away', () => { describe('when navigating away', () => {
beforeEach(() => { beforeEach(() => {
isNavigatingAway.mockReturnValue(true); isNavigatingAway.mockReturnValue(true);
}); });
it('forwards successful requests', (done) => { it('forwards successful requests', (done) => {
createSubscription(makeMockSuccessLink(), { createSubscription(makeMockSuccessLink(), {
next({ data }) { next({ data }) {
expect(data).toEqual({ foo: { id: 1 } }); expect(data).toEqual({ foo: { id: 1 } });
}, },
error: () => done.fail('Should not happen'), error: () => done.fail('Should not happen'),
complete: () => done(), complete: () => done(),
});
}); });
});
it('forwards GraphQL errors', (done) => { it('forwards GraphQL errors', (done) => {
createSubscription(makeMockGraphQLErrorLink(), { createSubscription(makeMockGraphQLErrorLink(), {
next({ errors }) { next({ errors }) {
expect(errors).toEqual([{ message: 'foo' }]); expect(errors).toEqual([{ message: 'foo' }]);
}, },
error: () => done.fail('Should not happen'), error: () => done.fail('Should not happen'),
complete: () => done(), complete: () => done(),
});
}); });
}); });
}); });
......
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