diff options
Diffstat (limited to 'spec/frontend/sentry/init_sentry_spec.js')
-rw-r--r-- | spec/frontend/sentry/init_sentry_spec.js | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/spec/frontend/sentry/init_sentry_spec.js b/spec/frontend/sentry/init_sentry_spec.js index e31068b935b..fb0dba35759 100644 --- a/spec/frontend/sentry/init_sentry_spec.js +++ b/spec/frontend/sentry/init_sentry_spec.js @@ -3,11 +3,10 @@ import { defaultStackParser, makeFetchTransport, defaultIntegrations, + BrowserTracing, // exports captureException, - captureMessage, - withScope, SDK_VERSION, } from 'sentrybrowser'; import * as Sentry from 'sentrybrowser'; @@ -96,11 +95,17 @@ describe('SentryConfig', () => { transport: makeFetchTransport, stackParser: defaultStackParser, - integrations: defaultIntegrations, + integrations: [...defaultIntegrations, expect.any(BrowserTracing)], }), ); }); + it('Uses data-page to set BrowserTracing transaction name', () => { + const context = BrowserTracing.mock.calls[0][0].beforeNavigate(); + + expect(context).toMatchObject({ name: mockPage }); + }); + it('binds the BrowserClient to the hub', () => { expect(mockBindClient).toHaveBeenCalledTimes(1); expect(mockBindClient).toHaveBeenCalledWith(expect.any(BrowserClient)); @@ -126,8 +131,6 @@ describe('SentryConfig', () => { // eslint-disable-next-line no-underscore-dangle expect(window._Sentry).toEqual({ captureException, - captureMessage, - withScope, SDK_VERSION, }); }); @@ -173,5 +176,27 @@ describe('SentryConfig', () => { expect(window._Sentry).toBe(undefined); }); }); + + describe('when data-page is not defined in the body', () => { + beforeEach(() => { + delete document.body.dataset.page; + initSentry(); + }); + + it('calls Sentry.setTags with gon values', () => { + expect(mockSetTags).toHaveBeenCalledTimes(1); + expect(mockSetTags).toHaveBeenCalledWith( + expect.objectContaining({ + page: undefined, + }), + ); + }); + + it('Uses location.path to set BrowserTracing transaction name', () => { + const context = BrowserTracing.mock.calls[0][0].beforeNavigate({ op: 'pageload' }); + + expect(context).toEqual({ op: 'pageload', name: window.location.pathname }); + }); + }); }); }); |