From 6763d2787670bc03a36a8eb601703e88fc70dece Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 18 Mar 2020 09:09:31 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../components/error_tracking_actions_spec.js | 93 ++++++++++++++++++++++ .../components/error_tracking_list_spec.js | 30 ++++--- .../error_tracking/components/list_mock.json | 9 ++- 3 files changed, 113 insertions(+), 19 deletions(-) create mode 100644 spec/frontend/error_tracking/components/error_tracking_actions_spec.js (limited to 'spec/frontend/error_tracking') diff --git a/spec/frontend/error_tracking/components/error_tracking_actions_spec.js b/spec/frontend/error_tracking/components/error_tracking_actions_spec.js new file mode 100644 index 00000000000..b22805f5227 --- /dev/null +++ b/spec/frontend/error_tracking/components/error_tracking_actions_spec.js @@ -0,0 +1,93 @@ +import { shallowMount } from '@vue/test-utils'; +import { GlButton } from '@gitlab/ui'; +import ErrorTrackingActions from '~/error_tracking/components/error_tracking_actions.vue'; + +describe('Error Tracking Actions', () => { + let wrapper; + + function mountComponent(props) { + wrapper = shallowMount(ErrorTrackingActions, { + propsData: { + error: { + id: '1', + title: 'PG::ConnectionBad: FATAL', + type: 'error', + userCount: 0, + count: '52', + firstSeen: '2019-05-30T07:21:46Z', + lastSeen: '2019-11-06T03:21:39Z', + status: 'unresolved', + }, + ...props, + }, + stubs: { GlButton }, + }); + } + + beforeEach(() => { + mountComponent(); + }); + + afterEach(() => { + if (wrapper) { + wrapper.destroy(); + } + }); + + const findButtons = () => wrapper.findAll(GlButton); + + describe('when error status is unresolved', () => { + it('renders the correct actions buttons to allow ignore and resolve', () => { + expect(findButtons().exists()).toBe(true); + + return wrapper.vm.$nextTick().then(() => { + expect( + findButtons() + .at(0) + .attributes('title'), + ).toBe('Ignore'); + expect( + findButtons() + .at(1) + .attributes('title'), + ).toBe('Resolve'); + }); + }); + }); + + describe('when error status is ignored', () => { + beforeEach(() => { + mountComponent({ error: { status: 'ignored' } }); + }); + + it('renders the correct action button to undo ignore', () => { + expect(findButtons().exists()).toBe(true); + + return wrapper.vm.$nextTick().then(() => { + expect( + findButtons() + .at(0) + .attributes('title'), + ).toBe('Undo Ignore'); + }); + }); + }); + + describe('when error status is resolved', () => { + beforeEach(() => { + mountComponent({ error: { status: 'resolved' } }); + }); + + it('renders the correct action button to undo unresolve', () => { + expect(findButtons().exists()).toBe(true); + + return wrapper.vm.$nextTick().then(() => { + expect( + findButtons() + .at(1) + .attributes('title'), + ).toBe('Unresolve'); + }); + }); + }); +}); 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 cd6dd5c7519..3bea1d343be 100644 --- a/spec/frontend/error_tracking/components/error_tracking_list_spec.js +++ b/spec/frontend/error_tracking/components/error_tracking_list_spec.js @@ -3,6 +3,7 @@ import Vuex from 'vuex'; import { GlEmptyState, GlLoadingIcon, GlFormInput, GlPagination, GlDropdown } from '@gitlab/ui'; import stubChildren from 'helpers/stub_children'; import ErrorTrackingList from '~/error_tracking/components/error_tracking_list.vue'; +import ErrorTrackingActions from '~/error_tracking/components/error_tracking_actions.vue'; import errorsList from './list_mock.json'; const localVue = createLocalVue(); @@ -30,6 +31,7 @@ describe('ErrorTrackingList', () => { .find(GlDropdown); const findLoadingIcon = () => wrapper.find(GlLoadingIcon); const findPagination = () => wrapper.find(GlPagination); + const findErrorActions = () => wrapper.find(ErrorTrackingActions); function mountComponent({ errorTrackingEnabled = true, @@ -151,15 +153,9 @@ describe('ErrorTrackingList', () => { }); }); - it('each error in the list should have an ignore button', () => { + it('each error in the list should have an action button set', () => { findErrorListRows().wrappers.forEach(row => { - expect(row.contains('glicon-stub[name="eye-slash"]')).toBe(true); - }); - }); - - it('each error in the list should have a resolve button', () => { - findErrorListRows().wrappers.forEach(row => { - expect(row.contains('glicon-stub[name="check-circle"]')).toBe(true); + expect(row.contains(ErrorTrackingActions)).toBe(true); }); }); @@ -237,8 +233,6 @@ 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; @@ -253,7 +247,10 @@ describe('ErrorTrackingList', () => { }); it('sends the "ignored" status and error ID', () => { - ignoreErrorButton().trigger('click'); + findErrorActions().vm.$emit('update-issue-status', { + errorId: errorsList[0].id, + status: 'ignored', + }); expect(actions.updateStatus).toHaveBeenCalledWith( expect.anything(), { @@ -265,7 +262,7 @@ describe('ErrorTrackingList', () => { }); it('calls an action to remove the item from the list', () => { - ignoreErrorButton().trigger('click'); + findErrorActions().vm.$emit('update-issue-status', { errorId: '1', status: undefined }); expect(actions.removeIgnoredResolvedErrors).toHaveBeenCalledWith( expect.anything(), '1', @@ -275,8 +272,6 @@ describe('ErrorTrackingList', () => { }); 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; @@ -291,7 +286,10 @@ describe('ErrorTrackingList', () => { }); it('sends "resolved" status and error ID', () => { - resolveErrorButton().trigger('click'); + findErrorActions().vm.$emit('update-issue-status', { + errorId: errorsList[0].id, + status: 'resolved', + }); expect(actions.updateStatus).toHaveBeenCalledWith( expect.anything(), { @@ -303,7 +301,7 @@ describe('ErrorTrackingList', () => { }); it('calls an action to remove the item from the list', () => { - resolveErrorButton().trigger('click'); + findErrorActions().vm.$emit('update-issue-status', { errorId: '1', status: undefined }); expect(actions.removeIgnoredResolvedErrors).toHaveBeenCalledWith( expect.anything(), '1', diff --git a/spec/frontend/error_tracking/components/list_mock.json b/spec/frontend/error_tracking/components/list_mock.json index a6e94c1a026..54ae0a4c7cf 100644 --- a/spec/frontend/error_tracking/components/list_mock.json +++ b/spec/frontend/error_tracking/components/list_mock.json @@ -6,7 +6,8 @@ "userCount": 0, "count": "52", "firstSeen": "2019-05-30T07:21:46Z", - "lastSeen": "2019-11-06T03:21:39Z" + "lastSeen": "2019-11-06T03:21:39Z", + "status": "unresolved" }, { "id": "2", @@ -15,7 +16,8 @@ "userCount": 0, "count": "12", "firstSeen": "2019-10-19T03:53:56Z", - "lastSeen": "2019-11-05T03:51:54Z" + "lastSeen": "2019-11-05T03:51:54Z", + "status": "unresolved" }, { "id": "3", @@ -24,6 +26,7 @@ "userCount": 0, "count": "275", "firstSeen": "2019-02-12T07:22:36Z", - "lastSeen": "2019-10-22T03:20:48Z" + "lastSeen": "2019-10-22T03:20:48Z", + "status": "unresolved" } ] \ No newline at end of file -- cgit v1.2.1