diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/frontend/error_tracking/components/error_details_spec.js | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/frontend/error_tracking/components/error_details_spec.js')
-rw-r--r-- | spec/frontend/error_tracking/components/error_details_spec.js | 72 |
1 files changed, 64 insertions, 8 deletions
diff --git a/spec/frontend/error_tracking/components/error_details_spec.js b/spec/frontend/error_tracking/components/error_details_spec.js index adbbc04ce78..fd2164d05fc 100644 --- a/spec/frontend/error_tracking/components/error_details_spec.js +++ b/spec/frontend/error_tracking/components/error_details_spec.js @@ -18,6 +18,12 @@ import { severityLevelVariant, errorStatus, } from '~/error_tracking/components/constants'; +import Tracking from '~/tracking'; +import { + trackClickErrorLinkToSentryOptions, + trackErrorDetailsViewsOptions, + trackErrorStatusUpdateOptions, +} from '~/error_tracking/utils'; jest.mock('~/flash'); @@ -30,12 +36,19 @@ describe('ErrorDetails', () => { let actions; let getters; let mocks; + const externalUrl = 'https://sentry.io/organizations/test-sentry-nk/issues/1/?project=1'; const findInput = name => { const inputs = wrapper.findAll(GlFormInput).filter(c => c.attributes('name') === name); return inputs.length ? inputs.at(0) : inputs; }; + const findUpdateIgnoreStatusButton = () => + wrapper.find('[data-testid="update-ignore-status-btn"]'); + const findUpdateResolveStatusButton = () => + wrapper.find('[data-testid="update-resolve-status-btn"]'); + const findExternalUrl = () => wrapper.find('[data-testid="external-url-link"]'); + function mountComponent() { wrapper = shallowMount(ErrorDetails, { stubs: { GlDeprecatedButton, GlSprintf }, @@ -57,7 +70,7 @@ describe('ErrorDetails', () => { beforeEach(() => { actions = { startPollingStacktrace: () => {}, - updateIgnoreStatus: jest.fn(), + updateIgnoreStatus: jest.fn().mockResolvedValue({}), updateResolveStatus: jest.fn().mockResolvedValue({ closed_issue_iid: 1 }), }; @@ -170,6 +183,9 @@ describe('ErrorDetails', () => { count: 12, userCount: 2, }, + stacktraceData: { + date_received: '2020-05-20', + }, }); }); @@ -235,7 +251,7 @@ describe('ErrorDetails', () => { }, }); return wrapper.vm.$nextTick().then(() => { - expect(wrapper.find(GlBadge).attributes('variant')).toEqual( + expect(wrapper.find(GlBadge).props('variant')).toEqual( severityLevelVariant[severityLevel[level]], ); }); @@ -249,7 +265,7 @@ describe('ErrorDetails', () => { }, }); return wrapper.vm.$nextTick().then(() => { - expect(wrapper.find(GlBadge).attributes('variant')).toEqual( + expect(wrapper.find(GlBadge).props('variant')).toEqual( severityLevelVariant[severityLevel.ERROR], ); }); @@ -302,11 +318,6 @@ 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(); @@ -491,4 +502,49 @@ describe('ErrorDetails', () => { }); }); }); + + describe('Snowplow tracking', () => { + beforeEach(() => { + jest.spyOn(Tracking, 'event'); + mocks.$apollo.queries.error.loading = false; + mountComponent(); + wrapper.setData({ + error: { externalUrl }, + }); + }); + + it('should track detail page views', () => { + const { category, action } = trackErrorDetailsViewsOptions; + expect(Tracking.event).toHaveBeenCalledWith(category, action); + }); + + it('should track IGNORE status update', () => { + Tracking.event.mockClear(); + findUpdateIgnoreStatusButton().vm.$emit('click'); + setImmediate(() => { + const { category, action } = trackErrorStatusUpdateOptions('ignored'); + expect(Tracking.event).toHaveBeenCalledWith(category, action); + }); + }); + + it('should track RESOLVE status update', () => { + Tracking.event.mockClear(); + findUpdateResolveStatusButton().vm.$emit('click'); + setImmediate(() => { + const { category, action } = trackErrorStatusUpdateOptions('resolved'); + expect(Tracking.event).toHaveBeenCalledWith(category, action); + }); + }); + + it('should track external Sentry link views', () => { + Tracking.event.mockClear(); + findExternalUrl().trigger('click'); + setImmediate(() => { + const { category, action, label, property } = trackClickErrorLinkToSentryOptions( + externalUrl, + ); + expect(Tracking.event).toHaveBeenCalledWith(category, action, { label, property }); + }); + }); + }); }); |