diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-15 18:08:34 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-15 18:08:34 +0000 |
commit | 571d993b49313dd806bd3f6af16d36c26d9d28ca (patch) | |
tree | 06bd12c4b56b97881aef8a00d4d46698de1eb63f /spec/frontend/error_tracking | |
parent | 9044365a91112d426fbbfba07eca595652bbe2df (diff) | |
download | gitlab-ce-571d993b49313dd806bd3f6af16d36c26d9d28ca.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/error_tracking')
3 files changed, 84 insertions, 1 deletions
diff --git a/spec/frontend/error_tracking/components/error_details_spec.js b/spec/frontend/error_tracking/components/error_details_spec.js index b5ce9383eb9..d62bda78e9a 100644 --- a/spec/frontend/error_tracking/components/error_details_spec.js +++ b/spec/frontend/error_tracking/components/error_details_spec.js @@ -29,6 +29,8 @@ describe('ErrorDetails', () => { propsData: { issueId: '123', projectPath: '/root/gitlab-test', + listPath: '/error_tracking', + issueUpdatePath: '/123', issueDetailsPath: '/123/details', issueStackTracePath: '/stacktrace', projectIssuesPath: '/test-project/issues/', @@ -122,6 +124,7 @@ describe('ErrorDetails', () => { expect(wrapper.find(GlLoadingIcon).exists()).toBe(true); expect(wrapper.find(Stacktrace).exists()).toBe(false); expect(wrapper.find(GlBadge).exists()).toBe(false); + expect(wrapper.findAll('button').length).toBe(3); }); describe('Badges', () => { @@ -185,7 +188,7 @@ describe('ErrorDetails', () => { it('should submit the form', () => { window.HTMLFormElement.prototype.submit = () => {}; const submitSpy = jest.spyOn(wrapper.vm.$refs.sentryIssueForm, 'submit'); - wrapper.find('button').trigger('click'); + wrapper.find('[data-qa-selector="create_issue_button"]').trigger('click'); expect(submitSpy).toHaveBeenCalled(); submitSpy.mockRestore(); }); diff --git a/spec/frontend/error_tracking/store/actions_spec.js b/spec/frontend/error_tracking/store/actions_spec.js new file mode 100644 index 00000000000..8bc53d94345 --- /dev/null +++ b/spec/frontend/error_tracking/store/actions_spec.js @@ -0,0 +1,78 @@ +import MockAdapter from 'axios-mock-adapter'; +import testAction from 'helpers/vuex_action_helper'; +import axios from '~/lib/utils/axios_utils'; +import createFlash from '~/flash'; +import * as actions from '~/error_tracking/store/actions'; +import * as types from '~/error_tracking/store/mutation_types'; +import { visitUrl } from '~/lib/utils/url_utility'; + +jest.mock('~/flash.js'); +jest.mock('~/lib/utils/url_utility'); + +let mock; + +describe('Sentry common store actions', () => { + beforeEach(() => { + mock = new MockAdapter(axios); + }); + + afterEach(() => { + mock.restore(); + createFlash.mockClear(); + }); + + 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 }, + {}, + [ + { + payload: true, + type: types.SET_UPDATING_RESOLVE_STATUS, + }, + { + payload: false, + type: 'SET_UPDATING_RESOLVE_STATUS', + }, + ], + [], + () => { + done(); + expect(visitUrl).toHaveBeenCalledWith(redirectUrl); + }, + ); + }); + + 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(); + }, + ); + }); + }); +}); diff --git a/spec/frontend/error_tracking/store/details/actions_spec.js b/spec/frontend/error_tracking/store/details/actions_spec.js index 0866f76aeef..129760bb705 100644 --- a/spec/frontend/error_tracking/store/details/actions_spec.js +++ b/spec/frontend/error_tracking/store/details/actions_spec.js @@ -6,6 +6,8 @@ import * as actions from '~/error_tracking/store/details/actions'; import * as types from '~/error_tracking/store/details/mutation_types'; jest.mock('~/flash.js'); +jest.mock('~/lib/utils/url_utility'); + let mock; describe('Sentry error details store actions', () => { |