diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-13 09:11:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-13 09:11:33 +0300 |
commit | 56a177ed56309f4742fe9f978adec394636bd7ca (patch) | |
tree | 22020565df5e956e880e1fa67c51bbf72965bf2b /spec/frontend/tracking | |
parent | 4ae83df07e37b502c3b2fdbd352328d72f31d1f5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/tracking')
-rw-r--r-- | spec/frontend/tracking/get_standard_context_spec.js | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/spec/frontend/tracking/get_standard_context_spec.js b/spec/frontend/tracking/get_standard_context_spec.js index b7bdc56b801..ada914b586c 100644 --- a/spec/frontend/tracking/get_standard_context_spec.js +++ b/spec/frontend/tracking/get_standard_context_spec.js @@ -1,5 +1,13 @@ -import { SNOWPLOW_JS_SOURCE } from '~/tracking/constants'; +import { SNOWPLOW_JS_SOURCE, GOOGLE_ANALYTICS_ID_COOKIE_NAME } from '~/tracking/constants'; import getStandardContext from '~/tracking/get_standard_context'; +import { setCookie, removeCookie } from '~/lib/utils/common_utils'; + +const TEST_GA_ID = 'GA1.2.345678901.234567891'; +const TEST_BASE_DATA = { + source: SNOWPLOW_JS_SOURCE, + google_analytics_id: '', + extra: {}, +}; describe('~/tracking/get_standard_context', () => { beforeEach(() => { @@ -10,10 +18,7 @@ describe('~/tracking/get_standard_context', () => { it('returns default object if called without server context', () => { expect(getStandardContext()).toStrictEqual({ schema: undefined, - data: { - source: SNOWPLOW_JS_SOURCE, - extra: {}, - }, + data: TEST_BASE_DATA, }); }); @@ -28,9 +33,8 @@ describe('~/tracking/get_standard_context', () => { expect(getStandardContext()).toStrictEqual({ schema: 'iglu:com.gitlab/gitlab_standard', data: { + ...TEST_BASE_DATA, environment: 'testing', - source: SNOWPLOW_JS_SOURCE, - extra: {}, }, }); }); @@ -50,4 +54,15 @@ describe('~/tracking/get_standard_context', () => { expect(getStandardContext({ extra }).data.extra).toBe(extra); }); + + describe('with Google Analytics cookie present', () => { + afterEach(() => { + removeCookie(GOOGLE_ANALYTICS_ID_COOKIE_NAME); + }); + + it('appends Google Analytics ID', () => { + setCookie(GOOGLE_ANALYTICS_ID_COOKIE_NAME, TEST_GA_ID); + expect(getStandardContext().data.google_analytics_id).toBe(TEST_GA_ID); + }); + }); }); |