diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 11:33:21 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 11:33:21 +0000 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /spec/frontend/projects/pipelines/charts/components/app_spec.js | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) | |
download | gitlab-ce-7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0.tar.gz |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'spec/frontend/projects/pipelines/charts/components/app_spec.js')
-rw-r--r-- | spec/frontend/projects/pipelines/charts/components/app_spec.js | 68 |
1 files changed, 56 insertions, 12 deletions
diff --git a/spec/frontend/projects/pipelines/charts/components/app_spec.js b/spec/frontend/projects/pipelines/charts/components/app_spec.js index e3aaf760d1e..d8876349c5e 100644 --- a/spec/frontend/projects/pipelines/charts/components/app_spec.js +++ b/spec/frontend/projects/pipelines/charts/components/app_spec.js @@ -8,6 +8,12 @@ import { mergeUrlParams, updateHistory, getParameterValues } from '~/lib/utils/u import Component from '~/projects/pipelines/charts/components/app.vue'; import PipelineCharts from '~/projects/pipelines/charts/components/pipeline_charts.vue'; import API from '~/api'; +import { mockTracking } from 'helpers/tracking_helper'; +import { + SNOWPLOW_DATA_SOURCE, + SNOWPLOW_LABEL, + SNOWPLOW_SCHEMA, +} from '~/projects/pipelines/charts/constants'; jest.mock('~/lib/utils/url_utility'); @@ -125,21 +131,59 @@ describe('ProjectsPipelinesChartsApp', () => { }); describe('event tracking', () => { - it.each` - testId | event - ${'pipelines-tab'} | ${'p_analytics_ci_cd_pipelines'} - ${'deployment-frequency-tab'} | ${'p_analytics_ci_cd_deployment_frequency'} - ${'lead-time-tab'} | ${'p_analytics_ci_cd_lead_time'} - ${'time-to-restore-service-tab'} | ${'p_analytics_ci_cd_time_to_restore_service'} - ${'change-failure-rate-tab'} | ${'p_analytics_ci_cd_change_failure_rate'} - `('tracks the $event event when clicked', ({ testId, event }) => { - jest.spyOn(API, 'trackRedisHllUserEvent'); + describe('RedisHLL events', () => { + it.each` + testId | event + ${'pipelines-tab'} | ${'p_analytics_ci_cd_pipelines'} + ${'deployment-frequency-tab'} | ${'p_analytics_ci_cd_deployment_frequency'} + ${'lead-time-tab'} | ${'p_analytics_ci_cd_lead_time'} + ${'time-to-restore-service-tab'} | ${'p_analytics_ci_cd_time_to_restore_service'} + ${'change-failure-rate-tab'} | ${'p_analytics_ci_cd_change_failure_rate'} + `('tracks the $event event when clicked', ({ testId, event }) => { + const trackApiSpy = jest.spyOn(API, 'trackRedisHllUserEvent'); + + expect(trackApiSpy).not.toHaveBeenCalled(); + + wrapper.findByTestId(testId).vm.$emit('click'); + + expect(trackApiSpy).toHaveBeenCalledWith(event); + }); + }); - expect(API.trackRedisHllUserEvent).not.toHaveBeenCalled(); + describe('Snowplow events', () => { + it.each` + testId | event + ${'pipelines-tab'} | ${'p_analytics_ci_cd_pipelines'} + ${'deployment-frequency-tab'} | ${'p_analytics_ci_cd_deployment_frequency'} + ${'lead-time-tab'} | ${'p_analytics_ci_cd_lead_time'} + `('tracks the $event event when clicked', ({ testId, event }) => { + const trackingSpy = mockTracking(undefined, wrapper.element, jest.spyOn); + + wrapper.findByTestId(testId).vm.$emit('click'); + + expect(trackingSpy).toHaveBeenCalledWith(undefined, 'click_tab', { + label: SNOWPLOW_LABEL, + context: { + schema: SNOWPLOW_SCHEMA, + data: { + event_name: event, + data_source: SNOWPLOW_DATA_SOURCE, + }, + }, + }); + }); - wrapper.findByTestId(testId).vm.$emit('click'); + it.each` + tab + ${'time-to-restore-service-tab'} + ${'change-failure-rate-tab'} + `('does not track when tab $tab is clicked', ({ tab }) => { + const trackingSpy = mockTracking(undefined, wrapper.element, jest.spyOn); - expect(API.trackRedisHllUserEvent).toHaveBeenCalledWith(event); + wrapper.findByTestId(tab).vm.$emit('click'); + + expect(trackingSpy).not.toHaveBeenCalled(); + }); }); }); }); |