2019-12-26 22:10:19 +05:30
|
|
|
import index from '~/sentry/index';
|
2023-03-04 22:38:38 +05:30
|
|
|
|
|
|
|
import LegacySentryConfig from '~/sentry/legacy_sentry_config';
|
2021-03-11 19:13:27 +05:30
|
|
|
import SentryConfig from '~/sentry/sentry_config';
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
describe('Sentry init', () => {
|
2019-12-26 22:10:19 +05:30
|
|
|
const dsn = 'https://123@sentry.gitlab.test/123';
|
2019-07-31 22:56:46 +05:30
|
|
|
const environment = 'test';
|
2023-03-04 22:38:38 +05:30
|
|
|
const currentUserId = '1';
|
|
|
|
const gitlabUrl = 'gitlabUrl';
|
2017-08-17 22:00:37 +05:30
|
|
|
const revision = 'revision';
|
2021-09-30 23:02:18 +05:30
|
|
|
const featureCategory = 'my_feature_category';
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
window.gon = {
|
2019-12-26 22:10:19 +05:30
|
|
|
sentry_dsn: dsn,
|
2019-07-31 22:56:46 +05:30
|
|
|
sentry_environment: environment,
|
2017-08-17 22:00:37 +05:30
|
|
|
current_user_id: currentUserId,
|
|
|
|
gitlab_url: gitlabUrl,
|
|
|
|
revision,
|
2021-09-30 23:02:18 +05:30
|
|
|
feature_category: featureCategory,
|
2017-08-17 22:00:37 +05:30
|
|
|
};
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
jest.spyOn(LegacySentryConfig, 'init').mockImplementation();
|
2019-12-26 22:10:19 +05:30
|
|
|
jest.spyOn(SentryConfig, 'init').mockImplementation();
|
2023-03-04 22:38:38 +05:30
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
it('exports new version of Sentry in the global object', () => {
|
|
|
|
// eslint-disable-next-line no-underscore-dangle
|
|
|
|
expect(window._Sentry.SDK_VERSION).not.toMatch(/^5\./);
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
describe('when called', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
index();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('configures sentry', () => {
|
|
|
|
expect(SentryConfig.init).toHaveBeenCalledTimes(1);
|
|
|
|
expect(SentryConfig.init).toHaveBeenCalledWith({
|
|
|
|
dsn,
|
|
|
|
currentUserId,
|
|
|
|
allowUrls: [gitlabUrl, 'webpack-internal://'],
|
|
|
|
environment,
|
|
|
|
release: revision,
|
|
|
|
tags: {
|
|
|
|
revision,
|
|
|
|
feature_category: featureCategory,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not configure legacy sentry', () => {
|
|
|
|
expect(LegacySentryConfig.init).not.toHaveBeenCalled();
|
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|