2019-12-26 22:10:19 +05:30
|
|
|
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
|
|
|
import Vuex from 'vuex';
|
2020-04-08 14:13:33 +05:30
|
|
|
import {
|
2020-07-28 23:09:34 +05:30
|
|
|
GlButton,
|
2020-04-08 14:13:33 +05:30
|
|
|
GlLoadingIcon,
|
|
|
|
GlLink,
|
|
|
|
GlBadge,
|
|
|
|
GlFormInput,
|
|
|
|
GlAlert,
|
|
|
|
GlSprintf,
|
|
|
|
} from '@gitlab/ui';
|
2020-10-24 23:57:45 +05:30
|
|
|
import { __ } from '~/locale';
|
|
|
|
import { deprecatedCreateFlash as createFlash } from '~/flash';
|
2019-12-26 22:10:19 +05:30
|
|
|
import Stacktrace from '~/error_tracking/components/stacktrace.vue';
|
|
|
|
import ErrorDetails from '~/error_tracking/components/error_details.vue';
|
2020-03-13 15:44:24 +05:30
|
|
|
import {
|
|
|
|
severityLevel,
|
|
|
|
severityLevelVariant,
|
|
|
|
errorStatus,
|
|
|
|
} from '~/error_tracking/components/constants';
|
2020-06-23 00:09:42 +05:30
|
|
|
import Tracking from '~/tracking';
|
|
|
|
import {
|
|
|
|
trackClickErrorLinkToSentryOptions,
|
|
|
|
trackErrorDetailsViewsOptions,
|
|
|
|
trackErrorStatusUpdateOptions,
|
|
|
|
} from '~/error_tracking/utils';
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
jest.mock('~/flash');
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
const localVue = createLocalVue();
|
|
|
|
localVue.use(Vuex);
|
|
|
|
|
|
|
|
describe('ErrorDetails', () => {
|
|
|
|
let store;
|
|
|
|
let wrapper;
|
|
|
|
let actions;
|
|
|
|
let getters;
|
2020-03-13 15:44:24 +05:30
|
|
|
let mocks;
|
2020-06-23 00:09:42 +05:30
|
|
|
const externalUrl = 'https://sentry.io/organizations/test-sentry-nk/issues/1/?project=1';
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
const findInput = name => {
|
|
|
|
const inputs = wrapper.findAll(GlFormInput).filter(c => c.attributes('name') === name);
|
|
|
|
return inputs.length ? inputs.at(0) : inputs;
|
|
|
|
};
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
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"]');
|
2020-07-28 23:09:34 +05:30
|
|
|
const findAlert = () => wrapper.find(GlAlert);
|
2020-06-23 00:09:42 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
function mountComponent() {
|
|
|
|
wrapper = shallowMount(ErrorDetails, {
|
2020-07-28 23:09:34 +05:30
|
|
|
stubs: { GlButton, GlSprintf },
|
2019-12-26 22:10:19 +05:30
|
|
|
localVue,
|
|
|
|
store,
|
2020-03-13 15:44:24 +05:30
|
|
|
mocks,
|
2019-12-26 22:10:19 +05:30
|
|
|
propsData: {
|
2020-03-13 15:44:24 +05:30
|
|
|
issueId: '123',
|
|
|
|
projectPath: '/root/gitlab-test',
|
|
|
|
listPath: '/error_tracking',
|
|
|
|
issueUpdatePath: '/123',
|
2019-12-26 22:10:19 +05:30
|
|
|
issueStackTracePath: '/stacktrace',
|
2020-01-01 13:55:28 +05:30
|
|
|
projectIssuesPath: '/test-project/issues/',
|
|
|
|
csrfToken: 'fakeToken',
|
2019-12-26 22:10:19 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
actions = {
|
|
|
|
startPollingStacktrace: () => {},
|
2020-06-23 00:09:42 +05:30
|
|
|
updateIgnoreStatus: jest.fn().mockResolvedValue({}),
|
2020-03-13 15:44:24 +05:30
|
|
|
updateResolveStatus: jest.fn().mockResolvedValue({ closed_issue_iid: 1 }),
|
2019-12-26 22:10:19 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
getters = {
|
|
|
|
sentryUrl: () => 'sentry.io',
|
|
|
|
stacktrace: () => [{ context: [1, 2], lineNo: 53, filename: 'index.js' }],
|
|
|
|
};
|
|
|
|
|
|
|
|
const state = {
|
|
|
|
stacktraceData: {},
|
|
|
|
loadingStacktrace: true,
|
2020-04-08 14:13:33 +05:30
|
|
|
errorStatus: '',
|
2019-12-26 22:10:19 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
store = new Vuex.Store({
|
|
|
|
modules: {
|
|
|
|
details: {
|
|
|
|
namespaced: true,
|
|
|
|
actions,
|
|
|
|
state,
|
|
|
|
getters,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
const query = jest.fn();
|
|
|
|
mocks = {
|
|
|
|
$apollo: {
|
|
|
|
query,
|
|
|
|
queries: {
|
|
|
|
error: {
|
|
|
|
loading: true,
|
|
|
|
stopPolling: jest.fn(),
|
2020-04-08 14:13:33 +05:30
|
|
|
setOptions: jest.fn(),
|
2020-03-13 15:44:24 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2019-12-26 22:10:19 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
if (wrapper) {
|
|
|
|
wrapper.destroy();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('loading', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
mountComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should show spinner while loading', () => {
|
|
|
|
expect(wrapper.find(GlLoadingIcon).exists()).toBe(true);
|
|
|
|
expect(wrapper.find(GlLink).exists()).toBe(false);
|
|
|
|
expect(wrapper.find(Stacktrace).exists()).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
describe('sentry response timeout', () => {
|
|
|
|
const initTime = 300000;
|
|
|
|
const endTime = initTime + 10000;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
mocks.$apollo.queries.error.loading = false;
|
|
|
|
jest.spyOn(Date, 'now').mockReturnValue(initTime);
|
|
|
|
mountComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('when before timeout, still shows loading', () => {
|
|
|
|
Date.now.mockReturnValue(endTime - 1);
|
|
|
|
|
|
|
|
wrapper.vm.onNoApolloResult();
|
|
|
|
|
|
|
|
return wrapper.vm.$nextTick().then(() => {
|
|
|
|
expect(wrapper.find(GlLoadingIcon).exists()).toBe(true);
|
|
|
|
expect(createFlash).not.toHaveBeenCalled();
|
|
|
|
expect(mocks.$apollo.queries.error.stopPolling).not.toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('when timeout is hit and no apollo result, stops loading and shows flash', () => {
|
|
|
|
Date.now.mockReturnValue(endTime + 1);
|
|
|
|
|
|
|
|
wrapper.vm.onNoApolloResult();
|
|
|
|
|
|
|
|
return wrapper.vm.$nextTick().then(() => {
|
|
|
|
expect(wrapper.find(GlLoadingIcon).exists()).toBe(false);
|
|
|
|
expect(wrapper.find(GlLink).exists()).toBe(false);
|
|
|
|
expect(createFlash).toHaveBeenCalledWith(
|
|
|
|
'Could not connect to Sentry. Refresh the page to try again.',
|
|
|
|
'warning',
|
|
|
|
);
|
|
|
|
expect(mocks.$apollo.queries.error.stopPolling).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
describe('Error details', () => {
|
2020-03-13 15:44:24 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
mocks.$apollo.queries.error.loading = false;
|
2019-12-26 22:10:19 +05:30
|
|
|
mountComponent();
|
2020-04-08 14:13:33 +05:30
|
|
|
wrapper.setData({
|
|
|
|
error: {
|
|
|
|
id: 'gid://gitlab/Gitlab::ErrorTracking::DetailedError/129381',
|
|
|
|
sentryId: 129381,
|
|
|
|
title: 'Issue title',
|
|
|
|
externalUrl: 'http://sentry.gitlab.net/gitlab',
|
|
|
|
firstSeen: '2017-05-26T13:32:48Z',
|
|
|
|
lastSeen: '2018-05-26T13:32:48Z',
|
|
|
|
count: 12,
|
|
|
|
userCount: 2,
|
|
|
|
},
|
2020-06-23 00:09:42 +05:30
|
|
|
stacktraceData: {
|
|
|
|
date_received: '2020-05-20',
|
|
|
|
},
|
2020-04-08 14:13:33 +05:30
|
|
|
});
|
2020-03-13 15:44:24 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should show Sentry error details without stacktrace', () => {
|
2019-12-26 22:10:19 +05:30
|
|
|
expect(wrapper.find(GlLink).exists()).toBe(true);
|
|
|
|
expect(wrapper.find(GlLoadingIcon).exists()).toBe(true);
|
|
|
|
expect(wrapper.find(Stacktrace).exists()).toBe(false);
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(wrapper.find(GlBadge).exists()).toBe(false);
|
2020-07-28 23:09:34 +05:30
|
|
|
expect(wrapper.findAll(GlButton)).toHaveLength(3);
|
2020-03-13 15:44:24 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
describe('unsafe chars for culprit field', () => {
|
|
|
|
const findReportedText = () => wrapper.find('[data-qa-selector="reported_text"]');
|
|
|
|
const culprit = '<script>console.log("surprise!")</script>';
|
|
|
|
beforeEach(() => {
|
|
|
|
store.state.details.loadingStacktrace = false;
|
|
|
|
wrapper.setData({
|
|
|
|
error: {
|
|
|
|
culprit,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not convert interpolated text to html entities', () => {
|
|
|
|
expect(findReportedText().findAll('script').length).toEqual(0);
|
|
|
|
expect(findReportedText().findAll('strong').length).toEqual(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render text instead of converting to html entities', () => {
|
|
|
|
expect(findReportedText().text()).toContain(culprit);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Badges', () => {
|
|
|
|
it('should show language and error level badges', () => {
|
|
|
|
wrapper.setData({
|
|
|
|
error: {
|
|
|
|
tags: { level: 'error', logger: 'ruby' },
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return wrapper.vm.$nextTick().then(() => {
|
|
|
|
expect(wrapper.findAll(GlBadge).length).toBe(2);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should NOT show the badge if the tag is not present', () => {
|
|
|
|
wrapper.setData({
|
|
|
|
error: {
|
|
|
|
tags: { level: 'error' },
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return wrapper.vm.$nextTick().then(() => {
|
|
|
|
expect(wrapper.findAll(GlBadge).length).toBe(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it.each(Object.keys(severityLevel))(
|
|
|
|
'should set correct severity level variant for %s badge',
|
|
|
|
level => {
|
|
|
|
wrapper.setData({
|
|
|
|
error: {
|
|
|
|
tags: { level: severityLevel[level] },
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return wrapper.vm.$nextTick().then(() => {
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(wrapper.find(GlBadge).props('variant')).toEqual(
|
2020-03-13 15:44:24 +05:30
|
|
|
severityLevelVariant[severityLevel[level]],
|
|
|
|
);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
it('should fallback for ERROR severityLevelVariant when severityLevel is unknown', () => {
|
|
|
|
wrapper.setData({
|
|
|
|
error: {
|
|
|
|
tags: { level: 'someNewErrorLevel' },
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return wrapper.vm.$nextTick().then(() => {
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(wrapper.find(GlBadge).props('variant')).toEqual(
|
2020-03-13 15:44:24 +05:30
|
|
|
severityLevelVariant[severityLevel.ERROR],
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2019-12-26 22:10:19 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
describe('Stacktrace', () => {
|
|
|
|
it('should show stacktrace', () => {
|
|
|
|
store.state.details.loadingStacktrace = false;
|
2020-03-13 15:44:24 +05:30
|
|
|
return wrapper.vm.$nextTick().then(() => {
|
|
|
|
expect(wrapper.find(GlLoadingIcon).exists()).toBe(false);
|
|
|
|
expect(wrapper.find(Stacktrace).exists()).toBe(true);
|
2020-07-28 23:09:34 +05:30
|
|
|
expect(findAlert().exists()).toBe(false);
|
2020-03-13 15:44:24 +05:30
|
|
|
});
|
2019-12-26 22:10:19 +05:30
|
|
|
});
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
it('should NOT show stacktrace if no entries and show Alert message', () => {
|
2019-12-26 22:10:19 +05:30
|
|
|
store.state.details.loadingStacktrace = false;
|
|
|
|
store.getters = { 'details/sentryUrl': () => 'sentry.io', 'details/stacktrace': () => [] };
|
2020-03-13 15:44:24 +05:30
|
|
|
return wrapper.vm.$nextTick().then(() => {
|
|
|
|
expect(wrapper.find(GlLoadingIcon).exists()).toBe(false);
|
|
|
|
expect(wrapper.find(Stacktrace).exists()).toBe(false);
|
2020-07-28 23:09:34 +05:30
|
|
|
expect(findAlert().text()).toBe('No stack trace for this error');
|
2020-03-13 15:44:24 +05:30
|
|
|
});
|
2019-12-26 22:10:19 +05:30
|
|
|
});
|
|
|
|
});
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
describe('When a user clicks the create issue button', () => {
|
|
|
|
it('should send sentry_issue_identifier', () => {
|
2020-03-13 15:44:24 +05:30
|
|
|
const sentryErrorIdInput = findInput(
|
|
|
|
'issue[sentry_issue_attributes][sentry_issue_identifier]',
|
2020-01-01 13:55:28 +05:30
|
|
|
);
|
|
|
|
expect(sentryErrorIdInput.attributes('value')).toBe('129381');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should set the form values with title and description', () => {
|
2020-03-13 15:44:24 +05:30
|
|
|
const csrfTokenInput = findInput('authenticity_token');
|
|
|
|
const issueTitleInput = findInput('issue[title]');
|
2020-01-01 13:55:28 +05:30
|
|
|
const issueDescriptionInput = wrapper.find('input[name="issue[description]"]');
|
|
|
|
expect(csrfTokenInput.attributes('value')).toBe('fakeToken');
|
|
|
|
expect(issueTitleInput.attributes('value')).toContain(wrapper.vm.issueTitle);
|
|
|
|
expect(issueDescriptionInput.attributes('value')).toContain(wrapper.vm.issueDescription);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should submit the form', () => {
|
|
|
|
window.HTMLFormElement.prototype.submit = () => {};
|
|
|
|
const submitSpy = jest.spyOn(wrapper.vm.$refs.sentryIssueForm, 'submit');
|
2020-04-08 14:13:33 +05:30
|
|
|
wrapper.find('[data-qa-selector="create_issue_button"]').vm.$emit('click');
|
2020-01-01 13:55:28 +05:30
|
|
|
expect(submitSpy).toHaveBeenCalled();
|
|
|
|
submitSpy.mockRestore();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
describe('Status update', () => {
|
|
|
|
afterEach(() => {
|
|
|
|
actions.updateIgnoreStatus.mockClear();
|
|
|
|
actions.updateResolveStatus.mockClear();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when error is unresolved', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
store.state.details.errorStatus = errorStatus.UNRESOLVED;
|
2020-04-08 14:13:33 +05:30
|
|
|
|
|
|
|
return wrapper.vm.$nextTick();
|
2020-03-13 15:44:24 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
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', () => {
|
2020-04-08 14:13:33 +05:30
|
|
|
findUpdateIgnoreStatusButton().vm.$emit('click');
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(actions.updateIgnoreStatus.mock.calls[0][1]).toEqual(
|
|
|
|
expect.objectContaining({ status: errorStatus.IGNORED }),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('marks error as resolved when resolve button is clicked', () => {
|
2020-04-08 14:13:33 +05:30
|
|
|
findUpdateResolveStatusButton().vm.$emit('click');
|
2020-03-13 15:44:24 +05:30
|
|
|
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;
|
2020-04-08 14:13:33 +05:30
|
|
|
|
|
|
|
return wrapper.vm.$nextTick();
|
2020-03-13 15:44:24 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
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', () => {
|
2020-04-08 14:13:33 +05:30
|
|
|
findUpdateIgnoreStatusButton().vm.$emit('click');
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(actions.updateIgnoreStatus.mock.calls[0][1]).toEqual(
|
|
|
|
expect.objectContaining({ status: errorStatus.UNRESOLVED }),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('marks error as resolved when resolve button is clicked', () => {
|
2020-04-08 14:13:33 +05:30
|
|
|
findUpdateResolveStatusButton().vm.$emit('click');
|
2020-03-13 15:44:24 +05:30
|
|
|
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;
|
2020-04-08 14:13:33 +05:30
|
|
|
|
|
|
|
return wrapper.vm.$nextTick();
|
2020-03-13 15:44:24 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
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', () => {
|
2020-04-08 14:13:33 +05:30
|
|
|
findUpdateIgnoreStatusButton().vm.$emit('click');
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(actions.updateIgnoreStatus.mock.calls[0][1]).toEqual(
|
|
|
|
expect.objectContaining({ status: errorStatus.IGNORED }),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('marks error as unresolved when unresolve button is clicked', () => {
|
2020-04-08 14:13:33 +05:30
|
|
|
findUpdateResolveStatusButton().vm.$emit('click');
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(actions.updateResolveStatus.mock.calls[0][1]).toEqual(
|
|
|
|
expect.objectContaining({ status: errorStatus.UNRESOLVED }),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should show alert with closed issueId', () => {
|
|
|
|
const closedIssueId = 123;
|
|
|
|
wrapper.setData({
|
|
|
|
isAlertVisible: true,
|
|
|
|
closedIssueId,
|
|
|
|
});
|
|
|
|
|
|
|
|
return wrapper.vm.$nextTick().then(() => {
|
|
|
|
expect(findAlert().exists()).toBe(true);
|
|
|
|
expect(findAlert().text()).toContain(`#${closedIssueId}`);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
describe('GitLab issue link', () => {
|
2020-03-13 15:44:24 +05:30
|
|
|
const gitlabIssuePath = 'https://gitlab.example.com/issues/1';
|
|
|
|
const findGitLabLink = () => wrapper.find(`[href="${gitlabIssuePath}"]`);
|
2020-01-01 13:55:28 +05:30
|
|
|
const findCreateIssueButton = () => wrapper.find('[data-qa-selector="create_issue_button"]');
|
2020-03-13 15:44:24 +05:30
|
|
|
const findViewIssueButton = () => wrapper.find('[data-qa-selector="view_issue_button"]');
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
describe('is present', () => {
|
|
|
|
beforeEach(() => {
|
2020-03-13 15:44:24 +05:30
|
|
|
wrapper.setData({
|
|
|
|
error: {
|
|
|
|
gitlabIssuePath,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should display the View issue button', () => {
|
|
|
|
expect(findViewIssueButton().exists()).toBe(true);
|
2020-01-01 13:55:28 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should display the issue link', () => {
|
|
|
|
expect(findGitLabLink().exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not display a create issue button', () => {
|
|
|
|
expect(findCreateIssueButton().exists()).toBe(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('is not present', () => {
|
|
|
|
beforeEach(() => {
|
2020-03-13 15:44:24 +05:30
|
|
|
wrapper.setData({
|
|
|
|
error: {
|
|
|
|
gitlabIssuePath: null,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not display the View issue button', () => {
|
|
|
|
expect(findViewIssueButton().exists()).toBe(false);
|
2020-01-01 13:55:28 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should not display an issue link', () => {
|
|
|
|
expect(findGitLabLink().exists()).toBe(false);
|
|
|
|
});
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
it('should display the create issue button', () => {
|
|
|
|
expect(findCreateIssueButton().exists()).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-03-07 23:17:34 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
describe('GitLab commit link', () => {
|
|
|
|
const gitlabCommit = '7975be0116940bf2ad4321f79d02a55c5f7779aa';
|
|
|
|
const gitlabCommitPath =
|
|
|
|
'/gitlab-org/gitlab-test/commit/7975be0116940bf2ad4321f79d02a55c5f7779aa';
|
|
|
|
const findGitLabCommitLink = () => wrapper.find(`[href$="${gitlabCommitPath}"]`);
|
2020-03-07 23:17:34 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
it('should display a link', () => {
|
|
|
|
mocks.$apollo.queries.error.loading = false;
|
|
|
|
wrapper.setData({
|
|
|
|
error: {
|
|
|
|
gitlabCommit,
|
|
|
|
gitlabCommitPath,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return wrapper.vm.$nextTick().then(() => {
|
|
|
|
expect(findGitLabCommitLink().exists()).toBe(true);
|
|
|
|
});
|
2020-03-07 23:17:34 +05:30
|
|
|
});
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
it('should not display a link', () => {
|
|
|
|
mocks.$apollo.queries.error.loading = false;
|
|
|
|
wrapper.setData({
|
|
|
|
error: {
|
|
|
|
gitlabCommit: null,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return wrapper.vm.$nextTick().then(() => {
|
|
|
|
expect(findGitLabCommitLink().exists()).toBe(false);
|
|
|
|
});
|
2020-03-07 23:17:34 +05:30
|
|
|
});
|
|
|
|
});
|
2019-12-26 22:10:19 +05:30
|
|
|
});
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
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 });
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2019-12-26 22:10:19 +05:30
|
|
|
});
|