diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-31 21:08:52 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-31 21:08:52 +0000 |
commit | d5d3c03598df712550acf0c6463a61c6e7dcc19e (patch) | |
tree | d0fdf0f9cd6df46aea6ed16b6556f44055efb642 /spec/frontend/error_tracking | |
parent | 0434f38ef1dce4fe640fe1e4542235746ceb943c (diff) | |
download | gitlab-ce-d5d3c03598df712550acf0c6463a61c6e7dcc19e.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/error_tracking')
-rw-r--r-- | spec/frontend/error_tracking/components/error_details_spec.js | 99 | ||||
-rw-r--r-- | spec/frontend/error_tracking/store/actions_spec.js | 64 |
2 files changed, 130 insertions, 33 deletions
diff --git a/spec/frontend/error_tracking/components/error_details_spec.js b/spec/frontend/error_tracking/components/error_details_spec.js index f0578b52922..1e1d20800da 100644 --- a/spec/frontend/error_tracking/components/error_details_spec.js +++ b/spec/frontend/error_tracking/components/error_details_spec.js @@ -1,10 +1,15 @@ import { createLocalVue, shallowMount } from '@vue/test-utils'; import Vuex from 'vuex'; +import { __ } from '~/locale'; import { GlLoadingIcon, GlLink, GlBadge, GlFormInput } from '@gitlab/ui'; import LoadingButton from '~/vue_shared/components/loading_button.vue'; import Stacktrace from '~/error_tracking/components/stacktrace.vue'; import ErrorDetails from '~/error_tracking/components/error_details.vue'; -import { severityLevel, severityLevelVariant } from '~/error_tracking/components/constants'; +import { + severityLevel, + severityLevelVariant, + errorStatus, +} from '~/error_tracking/components/constants'; const localVue = createLocalVue(); localVue.use(Vuex); @@ -56,6 +61,8 @@ describe('ErrorDetails', () => { actions = { startPollingDetails: () => {}, startPollingStacktrace: () => {}, + updateIgnoreStatus: jest.fn(), + updateResolveStatus: jest.fn(), }; getters = { @@ -219,6 +226,96 @@ describe('ErrorDetails', () => { }); }); + describe('Status update', () => { + const findUpdateIgnoreStatusButton = () => + wrapper.find('[data-qa-selector="update_ignore_status_button"]'); + const findUpdateResolveStatusButton = () => + wrapper.find('[data-qa-selector="update_resolve_status_button"]'); + + afterEach(() => { + actions.updateIgnoreStatus.mockClear(); + actions.updateResolveStatus.mockClear(); + }); + + describe('when error is unresolved', () => { + beforeEach(() => { + store.state.details.errorStatus = errorStatus.UNRESOLVED; + mountComponent(); + }); + + it('displays Ignore and Resolve buttons', () => { + expect(findUpdateIgnoreStatusButton().text()).toBe(__('Ignore')); + expect(findUpdateResolveStatusButton().text()).toBe(__('Resolve')); + }); + + it('marks error as ignored when ignore button is clicked', () => { + findUpdateIgnoreStatusButton().trigger('click'); + expect(actions.updateIgnoreStatus.mock.calls[0][1]).toEqual( + expect.objectContaining({ status: errorStatus.IGNORED }), + ); + }); + + it('marks error as resolved when resolve button is clicked', () => { + findUpdateResolveStatusButton().trigger('click'); + expect(actions.updateResolveStatus.mock.calls[0][1]).toEqual( + expect.objectContaining({ status: errorStatus.RESOLVED }), + ); + }); + }); + + describe('when error is ignored', () => { + beforeEach(() => { + store.state.details.errorStatus = errorStatus.IGNORED; + mountComponent(); + }); + + it('displays Undo Ignore and Resolve buttons', () => { + expect(findUpdateIgnoreStatusButton().text()).toBe(__('Undo ignore')); + expect(findUpdateResolveStatusButton().text()).toBe(__('Resolve')); + }); + + it('marks error as unresolved when ignore button is clicked', () => { + findUpdateIgnoreStatusButton().trigger('click'); + expect(actions.updateIgnoreStatus.mock.calls[0][1]).toEqual( + expect.objectContaining({ status: errorStatus.UNRESOLVED }), + ); + }); + + it('marks error as resolved when resolve button is clicked', () => { + findUpdateResolveStatusButton().trigger('click'); + expect(actions.updateResolveStatus.mock.calls[0][1]).toEqual( + expect.objectContaining({ status: errorStatus.RESOLVED }), + ); + }); + }); + + describe('when error is resolved', () => { + beforeEach(() => { + store.state.details.errorStatus = errorStatus.RESOLVED; + mountComponent(); + }); + + it('displays Ignore and Unresolve buttons', () => { + expect(findUpdateIgnoreStatusButton().text()).toBe(__('Ignore')); + expect(findUpdateResolveStatusButton().text()).toBe(__('Unresolve')); + }); + + it('marks error as ignored when ignore button is clicked', () => { + findUpdateIgnoreStatusButton().trigger('click'); + expect(actions.updateIgnoreStatus.mock.calls[0][1]).toEqual( + expect.objectContaining({ status: errorStatus.IGNORED }), + ); + }); + + it('marks error as unresolved when unresolve button is clicked', () => { + findUpdateResolveStatusButton().trigger('click'); + expect(actions.updateResolveStatus.mock.calls[0][1]).toEqual( + expect.objectContaining({ status: errorStatus.UNRESOLVED }), + ); + }); + }); + }); + describe('GitLab issue link', () => { const gitlabIssue = 'https://gitlab.example.com/issues/1'; const findGitLabLink = () => wrapper.find(`[href="${gitlabIssue}"]`); diff --git a/spec/frontend/error_tracking/store/actions_spec.js b/spec/frontend/error_tracking/store/actions_spec.js index 8bc53d94345..e4a895902b3 100644 --- a/spec/frontend/error_tracking/store/actions_spec.js +++ b/spec/frontend/error_tracking/store/actions_spec.js @@ -10,6 +10,8 @@ jest.mock('~/flash.js'); jest.mock('~/lib/utils/url_utility'); let mock; +const commit = jest.fn(); +const dispatch = jest.fn().mockResolvedValue(); describe('Sentry common store actions', () => { beforeEach(() => { @@ -20,26 +22,22 @@ describe('Sentry common store actions', () => { mock.restore(); createFlash.mockClear(); }); + const endpoint = '123/stacktrace'; + const redirectUrl = '/list'; + const status = 'resolved'; + const params = { endpoint, redirectUrl, status }; describe('updateStatus', () => { - const endpoint = '123/stacktrace'; - const redirectUrl = '/list'; - const status = 'resolved'; - it('should handle successful status update', done => { mock.onPut().reply(200, {}); testAction( actions.updateStatus, - { endpoint, redirectUrl, status }, + params, {}, [ { - payload: true, - type: types.SET_UPDATING_RESOLVE_STATUS, - }, - { - payload: false, - type: 'SET_UPDATING_RESOLVE_STATUS', + payload: 'resolved', + type: types.SET_ERROR_STATUS, }, ], [], @@ -52,27 +50,29 @@ describe('Sentry common store actions', () => { it('should handle unsuccessful status update', done => { mock.onPut().reply(400, {}); - testAction( - actions.updateStatus, - { endpoint, redirectUrl, status }, - {}, - [ - { - payload: true, - type: types.SET_UPDATING_RESOLVE_STATUS, - }, - { - payload: false, - type: types.SET_UPDATING_RESOLVE_STATUS, - }, - ], - [], - () => { - expect(visitUrl).not.toHaveBeenCalled(); - expect(createFlash).toHaveBeenCalledTimes(1); - done(); - }, - ); + testAction(actions.updateStatus, params, {}, [], [], () => { + expect(visitUrl).not.toHaveBeenCalled(); + expect(createFlash).toHaveBeenCalledTimes(1); + done(); + }); }); }); + + describe('updateResolveStatus', () => { + it('handles status update', () => + actions.updateResolveStatus({ commit, dispatch }, params).then(() => { + expect(commit).toHaveBeenCalledWith(types.SET_UPDATING_RESOLVE_STATUS, true); + expect(commit).toHaveBeenCalledWith(types.SET_UPDATING_RESOLVE_STATUS, false); + expect(dispatch).toHaveBeenCalledWith('updateStatus', params); + })); + }); + + describe('updateIgnoreStatus', () => { + it('handles status update', () => + actions.updateIgnoreStatus({ commit, dispatch }, params).then(() => { + expect(commit).toHaveBeenCalledWith(types.SET_UPDATING_IGNORE_STATUS, true); + expect(commit).toHaveBeenCalledWith(types.SET_UPDATING_IGNORE_STATUS, false); + expect(dispatch).toHaveBeenCalledWith('updateStatus', params); + })); + }); }); |