From b4ded0ba7b4d2cdbed5b1f331cf2083a25ee4d7c Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 10 Feb 2020 09:08:56 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../components/error_tracking_list_spec.js | 29 +++++++++++++++++++--- .../error_tracking/store/list/mutation_spec.js | 25 +++++++++++++++++++ 2 files changed, 50 insertions(+), 4 deletions(-) (limited to 'spec/frontend/error_tracking') diff --git a/spec/frontend/error_tracking/components/error_tracking_list_spec.js b/spec/frontend/error_tracking/components/error_tracking_list_spec.js index 9cf73d54d9b..b632b461eb9 100644 --- a/spec/frontend/error_tracking/components/error_tracking_list_spec.js +++ b/spec/frontend/error_tracking/components/error_tracking_list_spec.js @@ -62,6 +62,7 @@ describe('ErrorTrackingList', () => { sortByField: jest.fn(), fetchPaginatedResults: jest.fn(), updateStatus: jest.fn(), + removeIgnoredResolvedErrors: jest.fn(), }; const state = { @@ -221,6 +222,8 @@ describe('ErrorTrackingList', () => { }); describe('When the ignore button on an error is clicked', () => { + const ignoreErrorButton = () => wrapper.find({ ref: 'ignoreError' }); + beforeEach(() => { store.state.list.loading = false; store.state.list.errors = errorsList; @@ -235,20 +238,30 @@ describe('ErrorTrackingList', () => { }); it('sends the "ignored" status and error ID', () => { - wrapper.find({ ref: 'ignoreError' }).trigger('click'); + ignoreErrorButton().trigger('click'); expect(actions.updateStatus).toHaveBeenCalledWith( expect.anything(), { endpoint: `/project/test/-/error_tracking/${errorsList[0].id}.json`, - redirectUrl: '/error_tracking', status: 'ignored', }, undefined, ); }); + + it('calls an action to remove the item from the list', () => { + ignoreErrorButton().trigger('click'); + expect(actions.removeIgnoredResolvedErrors).toHaveBeenCalledWith( + expect.anything(), + '1', + undefined, + ); + }); }); describe('When the resolve button on an error is clicked', () => { + const resolveErrorButton = () => wrapper.find({ ref: 'resolveError' }); + beforeEach(() => { store.state.list.loading = false; store.state.list.errors = errorsList; @@ -263,17 +276,25 @@ describe('ErrorTrackingList', () => { }); it('sends "resolved" status and error ID', () => { - wrapper.find({ ref: 'resolveError' }).trigger('click'); + resolveErrorButton().trigger('click'); expect(actions.updateStatus).toHaveBeenCalledWith( expect.anything(), { endpoint: `/project/test/-/error_tracking/${errorsList[0].id}.json`, - redirectUrl: '/error_tracking', status: 'resolved', }, undefined, ); }); + + it('calls an action to remove the item from the list', () => { + resolveErrorButton().trigger('click'); + expect(actions.removeIgnoredResolvedErrors).toHaveBeenCalledWith( + expect.anything(), + '1', + undefined, + ); + }); }); describe('When error tracking is disabled and user is not allowed to enable it', () => { diff --git a/spec/frontend/error_tracking/store/list/mutation_spec.js b/spec/frontend/error_tracking/store/list/mutation_spec.js index 44a75b6aa1f..65f11aeeda1 100644 --- a/spec/frontend/error_tracking/store/list/mutation_spec.js +++ b/spec/frontend/error_tracking/store/list/mutation_spec.js @@ -5,6 +5,7 @@ import * as types from '~/error_tracking/store/list/mutation_types'; const ADD_RECENT_SEARCH = mutations[types.ADD_RECENT_SEARCH]; const CLEAR_RECENT_SEARCHES = mutations[types.CLEAR_RECENT_SEARCHES]; const LOAD_RECENT_SEARCHES = mutations[types.LOAD_RECENT_SEARCHES]; +const REMOVE_IGNORED_RESOLVED_ERRORS = mutations[types.REMOVE_IGNORED_RESOLVED_ERRORS]; describe('Error tracking mutations', () => { describe('SET_ERRORS', () => { @@ -114,5 +115,29 @@ describe('Error tracking mutations', () => { expect(localStorage.getItem).toHaveBeenCalledWith('recent-searches/project/errors.json'); }); }); + + describe('REMOVE_IGNORED_RESOLVED_ERRORS', () => { + it('removes ignored or resolved errors from list', () => { + state.errors = [ + { + id: 1, + status: 'unresolved', + }, + { + id: 2, + status: 'ignored', + }, + { + id: 3, + status: 'unresolved', + }, + ]; + const ignoredError = state.errors[2].id; + + REMOVE_IGNORED_RESOLVED_ERRORS(state, ignoredError); + + expect(state.errors).not.toContain(ignoredError); + }); + }); }); }); -- cgit v1.2.3