Commit 1b76ab40 authored by Mark Florian's avatar Mark Florian

Merge branch...

Merge branch '323986-f-u-f-55810-add-vue-component-specs-for-custom-tracking-behavior' into 'master'

Track opening the trial status popover with the tracking mixin

See merge request gitlab-org/gitlab!56996
parents 3b1e7b04 0a434010
...@@ -19,6 +19,7 @@ export default { ...@@ -19,6 +19,7 @@ export default {
GlPopover, GlPopover,
GlSprintf, GlSprintf,
}, },
mixins: [Tracking.mixin()],
props: { props: {
containerId: { containerId: {
type: [String, null], type: [String, null],
...@@ -85,7 +86,7 @@ export default { ...@@ -85,7 +86,7 @@ export default {
this.updateDisabledState(); this.updateDisabledState();
}, },
onShown() { onShown() {
Tracking.event(undefined, 'popover_shown', { this.track('popover_shown', {
label: 'trial_status_popover', label: 'trial_status_popover',
property: 'experiment:show_trial_status_in_sidebar', property: 'experiment:show_trial_status_in_sidebar',
}); });
......
...@@ -3,9 +3,11 @@ import { GlBreakpointInstance } from '@gitlab/ui/dist/utils'; ...@@ -3,9 +3,11 @@ import { GlBreakpointInstance } from '@gitlab/ui/dist/utils';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import TrialStatusPopover from 'ee/contextual_sidebar/components/trial_status_popover.vue'; import TrialStatusPopover from 'ee/contextual_sidebar/components/trial_status_popover.vue';
import { mockTracking } from 'helpers/tracking_helper';
describe('TrialStatusPopover component', () => { describe('TrialStatusPopover component', () => {
let wrapper; let wrapper;
let trackingSpy;
const getGlButton = (testId) => wrapper.find(`[data-testid="${testId}"]`); const getGlButton = (testId) => wrapper.find(`[data-testid="${testId}"]`);
...@@ -24,6 +26,7 @@ describe('TrialStatusPopover component', () => { ...@@ -24,6 +26,7 @@ describe('TrialStatusPopover component', () => {
beforeEach(() => { beforeEach(() => {
wrapper = createComponent(); wrapper = createComponent();
trackingSpy = mockTracking('_category_', wrapper.element, jest.spyOn);
}); });
afterEach(() => { afterEach(() => {
...@@ -31,6 +34,8 @@ describe('TrialStatusPopover component', () => { ...@@ -31,6 +34,8 @@ describe('TrialStatusPopover component', () => {
wrapper = null; wrapper = null;
}); });
const getGlPopover = () => wrapper.findComponent(GlPopover);
it('matches the snapshot', () => { it('matches the snapshot', () => {
expect(wrapper.element).toMatchSnapshot(); expect(wrapper.element).toMatchSnapshot();
}); });
...@@ -51,8 +56,6 @@ describe('TrialStatusPopover component', () => { ...@@ -51,8 +56,6 @@ describe('TrialStatusPopover component', () => {
describe('methods', () => { describe('methods', () => {
describe('onResize', () => { describe('onResize', () => {
const getGlPopover = () => wrapper.findComponent(GlPopover);
it.each` it.each`
bp | isDisabled bp | isDisabled
${'xs'} | ${'true'} ${'xs'} | ${'true'}
...@@ -72,5 +75,18 @@ describe('TrialStatusPopover component', () => { ...@@ -72,5 +75,18 @@ describe('TrialStatusPopover component', () => {
}, },
); );
}); });
describe('onShown', () => {
beforeEach(() => {
getGlPopover().vm.$emit('shown');
});
it('dispatches tracking event', () => {
expect(trackingSpy).toHaveBeenCalledWith(undefined, 'popover_shown', {
label: 'trial_status_popover',
property: 'experiment:show_trial_status_in_sidebar',
});
});
});
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment