Commit 0a434010 authored by Axel García's avatar Axel García Committed by Mark Florian

Track trial status popover with Vue mixin

parent f9b157fe
......@@ -19,6 +19,7 @@ export default {
GlPopover,
GlSprintf,
},
mixins: [Tracking.mixin()],
props: {
containerId: {
type: [String, null],
......@@ -85,7 +86,7 @@ export default {
this.updateDisabledState();
},
onShown() {
Tracking.event(undefined, 'popover_shown', {
this.track('popover_shown', {
label: 'trial_status_popover',
property: 'experiment:show_trial_status_in_sidebar',
});
......
......@@ -3,9 +3,11 @@ import { GlBreakpointInstance } from '@gitlab/ui/dist/utils';
import { shallowMount } from '@vue/test-utils';
import TrialStatusPopover from 'ee/contextual_sidebar/components/trial_status_popover.vue';
import { mockTracking } from 'helpers/tracking_helper';
describe('TrialStatusPopover component', () => {
let wrapper;
let trackingSpy;
const getGlButton = (testId) => wrapper.find(`[data-testid="${testId}"]`);
......@@ -24,6 +26,7 @@ describe('TrialStatusPopover component', () => {
beforeEach(() => {
wrapper = createComponent();
trackingSpy = mockTracking('_category_', wrapper.element, jest.spyOn);
});
afterEach(() => {
......@@ -31,6 +34,8 @@ describe('TrialStatusPopover component', () => {
wrapper = null;
});
const getGlPopover = () => wrapper.findComponent(GlPopover);
it('matches the snapshot', () => {
expect(wrapper.element).toMatchSnapshot();
});
......@@ -51,8 +56,6 @@ describe('TrialStatusPopover component', () => {
describe('methods', () => {
describe('onResize', () => {
const getGlPopover = () => wrapper.findComponent(GlPopover);
it.each`
bp | isDisabled
${'xs'} | ${'true'}
......@@ -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