diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-15 12:07:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-15 12:07:30 +0300 |
commit | 50e177d19bdeeb0fcc7b129b9c30841454df240b (patch) | |
tree | 11b30123cfec778cfa469bc23e17f40a45d43880 /spec/frontend/ide | |
parent | 9cf113df885ac8959b9fab3aab5e50e2532fef75 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/ide')
-rw-r--r-- | spec/frontend/ide/init_gitlab_web_ide_spec.js | 2 | ||||
-rw-r--r-- | spec/frontend/ide/lib/gitlab_web_ide/handle_tracking_event_spec.js | 32 | ||||
-rw-r--r-- | spec/frontend/ide/remote/index_spec.js | 3 |
3 files changed, 36 insertions, 1 deletions
diff --git a/spec/frontend/ide/init_gitlab_web_ide_spec.js b/spec/frontend/ide/init_gitlab_web_ide_spec.js index b5ad38addbd..bfc87f17092 100644 --- a/spec/frontend/ide/init_gitlab_web_ide_spec.js +++ b/spec/frontend/ide/init_gitlab_web_ide_spec.js @@ -3,6 +3,7 @@ import { GITLAB_WEB_IDE_FEEDBACK_ISSUE } from '~/ide/constants'; import { initGitlabWebIDE } from '~/ide/init_gitlab_web_ide'; import { confirmAction } from '~/lib/utils/confirm_via_gl_modal/confirm_action'; import { createAndSubmitForm } from '~/lib/utils/create_and_submit_form'; +import { handleTracking } from '~/ide/lib/gitlab_web_ide/handle_tracking_event'; import { TEST_HOST } from 'helpers/test_constants'; import setWindowLocation from 'helpers/set_window_location_helper'; import waitForPromises from 'helpers/wait_for_promises'; @@ -115,6 +116,7 @@ describe('ide/init_gitlab_web_ide', () => { format: TEST_EDITOR_FONT_FORMAT, }, handleStartRemote: expect.any(Function), + handleTracking, }); }); diff --git a/spec/frontend/ide/lib/gitlab_web_ide/handle_tracking_event_spec.js b/spec/frontend/ide/lib/gitlab_web_ide/handle_tracking_event_spec.js new file mode 100644 index 00000000000..5dff9b6f118 --- /dev/null +++ b/spec/frontend/ide/lib/gitlab_web_ide/handle_tracking_event_spec.js @@ -0,0 +1,32 @@ +import { snakeCase } from 'lodash'; +import { handleTracking } from '~/ide/lib/gitlab_web_ide/handle_tracking_event'; +import { convertObjectPropsToSnakeCase } from '~/lib/utils/common_utils'; +import { mockTracking } from 'helpers/tracking_helper'; + +describe('ide/handle_tracking_event', () => { + let trackingSpy; + + beforeEach(() => { + trackingSpy = mockTracking(undefined, null, jest.spyOn); + }); + + describe('when the event does not contain data', () => { + it('does not send extra property to snowplow', () => { + const event = { name: 'event-name' }; + + handleTracking(event); + expect(trackingSpy).toHaveBeenCalledWith(undefined, snakeCase(event.name)); + }); + }); + + describe('when the event contains data', () => { + it('sends extra property to snowplow', () => { + const event = { name: 'event-name', data: { 'extra-details': 'details' } }; + + handleTracking(event); + expect(trackingSpy).toHaveBeenCalledWith(undefined, snakeCase(event.name), { + extra: convertObjectPropsToSnakeCase(event.data), + }); + }); + }); +}); diff --git a/spec/frontend/ide/remote/index_spec.js b/spec/frontend/ide/remote/index_spec.js index 0f23b0a4e45..413e7b2e4b7 100644 --- a/spec/frontend/ide/remote/index_spec.js +++ b/spec/frontend/ide/remote/index_spec.js @@ -3,6 +3,7 @@ import { getBaseConfig, setupRootElement } from '~/ide/lib/gitlab_web_ide'; import { mountRemoteIDE } from '~/ide/remote'; import { TEST_HOST } from 'helpers/test_constants'; import { useMockLocationHelper } from 'helpers/mock_window_location_helper'; +import { handleTracking } from '~/ide/lib/gitlab_web_ide/handle_tracking_event'; jest.mock('@gitlab/web-ide'); jest.mock('~/ide/lib/gitlab_web_ide'); @@ -24,7 +25,6 @@ const TEST_RETURN_URL_SAME_ORIGIN = `${TEST_HOST}/foo/example`; describe('~/ide/remote/index', () => { useMockLocationHelper(); const originalHref = window.location.href; - let el; let rootEl; @@ -56,6 +56,7 @@ describe('~/ide/remote/index', () => { hostPath: `/${TEST_DATA.remotePath}`, handleError: expect.any(Function), handleClose: expect.any(Function), + handleTracking, }); }); }); |