Commit 53475509 authored by Constance Okoghenun's avatar Constance Okoghenun Committed by Clement Ho

Refactored implentation of reply button tracker

Removed check for composed path in the event listner
parent fde2a61c
...@@ -19,7 +19,7 @@ export default { ...@@ -19,7 +19,7 @@ export default {
<gl-button <gl-button
ref="button" ref="button"
v-gl-tooltip v-gl-tooltip
class="note-action-button" class="note-action-button js-note-action-reply"
variant="transparent" variant="transparent"
:title="__('Reply to comment')" :title="__('Reply to comment')"
@click="$emit('startReplying')" @click="$emit('startReplying')"
......
...@@ -2,8 +2,8 @@ import Stats from 'ee/stats'; ...@@ -2,8 +2,8 @@ import Stats from 'ee/stats';
export default () => { export default () => {
document.querySelector('.main-notes-list').addEventListener('click', event => { document.querySelector('.main-notes-list').addEventListener('click', event => {
const isReplyButtonClick = event.path.find( const isReplyButtonClick = event.target.parentElement.classList.contains(
el => el.classList && el.classList.contains('js-reply-button'), 'js-note-action-reply',
); );
if (isReplyButtonClick) { if (isReplyButtonClick) {
......
---
title: Resolve Snowplow tracking for notes does not work in Firefox
merge_request: 12578
author:
type: fixed
import Vue from 'vue';
import Stats from 'ee_else_ce/stats';
import { shallowMount } from '@vue/test-utils';
import initNoteStats from 'ee_else_ce/event_tracking/notes';
describe('initNoteStats', () => {
let wrapper;
const createComponent = template => {
const component = Vue.component('Notes', {
name: 'Notes',
template,
});
return shallowMount(component, { attachToDocument: true });
};
jest.mock('ee_else_ce/stats');
Stats.trackEvent = jest.fn();
Stats.bindTrackableContainer = jest.fn();
afterEach(() => {
Stats.trackEvent.mockClear();
Stats.bindTrackableContainer.mockClear();
wrapper.destroy();
});
describe('is a reply', () => {
beforeEach(() => {
wrapper = createComponent(
"<div class='js-note-action-reply'><button class='main-notes-list'></button></div>",
);
initNoteStats();
});
it('calls bindTrackableContainer', () => {
expect(Stats.bindTrackableContainer).toHaveBeenCalledTimes(1);
});
it('calls trackEvent', () => {
wrapper.find('.main-notes-list').trigger('click');
expect(Stats.trackEvent).toHaveBeenCalledTimes(1);
});
});
describe('is not a reply', () => {
it('does not call trackEvent', () => {
wrapper = createComponent("<div><button class='main-notes-list'></button></div>");
initNoteStats();
wrapper.find('.main-notes-list').trigger('click');
expect(Stats.trackEvent).not.toHaveBeenCalled();
});
});
});
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