Commit 825eec24 authored by Axel García's avatar Axel García Committed by Axel Garcia

Use track-action on specs

It also updates some related files, like data
attributes on HAML templates and dataset
auto properties (track-event => trackEvent)
parent bf10fa8d
......@@ -2,10 +2,12 @@ import $ from 'jquery';
import Tracking from '~/tracking';
export default function initTrackInviteMembers(userDropdown) {
const { trackEvent, trackLabel } = userDropdown.querySelector('.js-invite-members-track').dataset;
const { trackAction, trackLabel } = userDropdown.querySelector(
'.js-invite-members-track',
).dataset;
$(userDropdown).on('shown.bs.dropdown', () => {
Tracking.event(undefined, trackEvent, {
Tracking.event(undefined, trackAction, {
label: trackLabel,
});
});
......
%h4.gl-mt-0.gl-mb-3{ data: { testid: 'invite-member-section',
track_label: 'invite_members_empty_project',
track_event: 'render' } }
track_action: 'render' } }
= s_('InviteMember|Invite your team')
%p= s_('InviteMember|Add members to this project and start collaborating with your team.')
.js-invite-members-trigger{ data: { variant: 'confirm',
......
.js-blob-result.gl-mt-3.gl-mb-5{ data: { qa_selector: 'result_item_content' } }
.file-holder.file-holder-top-border
.js-file-title.file-title{ data: { qa_selector: 'file_title_content' } }
= link_to blob_link, data: {track_event: 'click_text', track_label: 'blob_path', track_property: 'search_result'} do
= link_to blob_link, data: {track_action: 'click_text', track_label: 'blob_path', track_property: 'search_result'} do
= sprite_icon('document')
%strong
= search_blob_title(project, path)
......
......@@ -3,7 +3,7 @@
%span.gl-display-flex.gl-align-items-center
%span.badge.badge-pill.gl-badge.sm{ class: "badge-#{issuable_state_to_badge_class(issuable)}" }= issuable_state_text(issuable)
= sprite_icon('eye-slash', css_class: 'gl-text-gray-500 gl-ml-2') if issuable.respond_to?(:confidential?) && issuable.confidential?
= link_to issuable_path(issuable), data: { track_event: 'click_text', track_label: "#{issuable.class.name.downcase}_title", track_property: 'search_result' }, class: 'gl-w-full' do
= link_to issuable_path(issuable), data: { track_action: 'click_text', track_label: "#{issuable.class.name.downcase}_title", track_property: 'search_result' }, class: 'gl-w-full' do
%span.term.str-truncated.gl-font-weight-bold.gl-ml-2= issuable.title
.gl-text-gray-500.gl-my-3
= issuable_project_reference(issuable)
......
.search-result-row
%h4
= link_to project_milestone_path(milestone.project, milestone), data: {track_event: 'click_text', track_label: 'milestone_title', track_property: 'search_result'} do
= link_to project_milestone_path(milestone.project, milestone), data: {track_action: 'click_text', track_label: 'milestone_title', track_property: 'search_result'} do
%span.term.str-truncated= milestone.title
- if milestone.description.present?
......
......@@ -18,7 +18,7 @@
- else
%span #{note.noteable_type.titleize} ##{noteable_identifier}
·
= link_to note.noteable.title, note_url, data: {track_event: 'click_text', track_label: 'noteable_title', track_property: 'search_result'}
= link_to note.noteable.title, note_url, data: {track_action: 'click_text', track_label: 'noteable_title', track_property: 'search_result'}
%span.note-headline-light.note-headline-meta
%span.system-note-separator
......
......@@ -3,7 +3,7 @@
%div{ class: 'search-result-row gl-pb-3! gl-mt-5 gl-mb-0!' }
%span.gl-display-flex.gl-align-items-center
= link_to wiki_blob_link, data: { track_event: 'click_text', track_label: "wiki_title", track_property: 'search_result' }, class: 'gl-w-full' do
= link_to wiki_blob_link, data: { track_action: 'click_text', track_label: "wiki_title", track_property: 'search_result' }, class: 'gl-w-full' do
%span.term.str-truncated.gl-font-weight-bold= ::Gitlab::Git::Wiki::GollumSlug.canonicalize_filename(wiki_blob.path)
.description.term.col-sm-10.gl-px-0
= simple_search_highlight_and_truncate(wiki_blob.data, @search_term)
......@@ -9,7 +9,7 @@
= link_to s_('UsageQuota|Buy additional minutes'),
link_to_buy_additional_minutes_path(namespace),
class: 'gl-button btn btn-confirm float-right',
data: { track_event: 'click_buy_ci_minutes', track_label: namespace.actual_plan_name, track_property: 'pipeline_quota_page' }
data: { track_action: 'click_buy_ci_minutes', track_label: namespace.actual_plan_name, track_property: 'pipeline_quota_page' }
.row
.col-sm-6
......
......@@ -5,7 +5,7 @@
- else
%span.badge.badge-success.badge-pill.gl-badge.sm= _("Open")
= sprite_icon('eye-slash', css_class: 'gl-text-gray-500 gl-ml-2') if epic.confidential?
= link_to group_epic_path(epic.group, epic), data: { track_event: 'click_text', track_label: 'epic_title', track_property: 'search_result' }, class: 'gl-w-full' do
= link_to group_epic_path(epic.group, epic), data: { track_action: 'click_text', track_label: 'epic_title', track_property: 'search_result' }, class: 'gl-w-full' do
%span.term.str-truncated.gl-font-weight-bold.gl-ml-2= epic.title
.gl-text-gray-500.gl-my-3
= sprintf(s_('%{group_name}&%{epic_iid} · created %{epic_created} by %{author}'), { group_name: epic.group.full_name, epic_iid: epic.iid, epic_created: time_ago_with_tooltip(epic.created_at, placement: 'bottom'), author: link_to_member(@project, epic.author, avatar: false) }).html_safe
......
......@@ -157,7 +157,7 @@ RSpec.describe 'Groups > Usage Quotas' do
link = page.find('a', text: 'Buy additional minutes')
expect(link['data-track-event']).to eq('click_buy_ci_minutes')
expect(link['data-track-action']).to eq('click_buy_ci_minutes')
expect(link['data-track-label']).to eq(group.actual_plan_name)
expect(link['data-track-property']).to eq('pipeline_quota_page')
end
......
......@@ -224,7 +224,7 @@ RSpec.describe 'Pipeline', :js do
expect(page).to have_content('Method `new_array` has 12 arguments (exceeds 4 allowed). Consider refactoring.')
expect(find_link('foo.rb:10')[:href]).to end_with(project_blob_path(project, File.join(pipeline.commit.id, 'foo.rb')) + '#L10')
expect(page).to have_selector('[data-track-event="click_button"]')
expect(page).to have_selector('[data-track-action="click_button"]')
expect(page).to have_selector('[data-track-label="get_codequality_report"]')
end
end
......
......@@ -14,7 +14,7 @@ RSpec.describe 'layouts/application' do
end
describe 'layouts/_user_notification_dot' do
let(:track_selector) { '[data-track-event="render"][data-track-label="show_buy_ci_minutes_notification"]' }
let(:track_selector) { '[data-track-action="render"][data-track-label="show_buy_ci_minutes_notification"]' }
let(:show_notification_dot) { false }
before do
......
......@@ -25,7 +25,7 @@ RSpec.describe 'layouts/header/_current_user_dropdown' do
context 'when pipeline minutes need bought without notification dot' do
it 'has "Buy Pipeline minutes" link with correct data properties', :aggregate_failures do
expect(subject).to have_selector('[data-track-event="click_buy_ci_minutes"]')
expect(subject).to have_selector('[data-track-action="click_buy_ci_minutes"]')
expect(subject).to have_selector("[data-track-label='#{user.namespace.actual_plan_name}']")
expect(subject).to have_selector('[data-track-property="user_dropdown"]')
expect(subject).to have_link('Buy Pipeline minutes')
......
......@@ -117,7 +117,7 @@ RSpec.describe 'Issue Sidebar' do
page.within '.dropdown-menu-user' do
expect(page).to have_link('Invite members')
expect(page).to have_selector('[data-track-event="click_invite_members"]')
expect(page).to have_selector('[data-track-action="click_invite_members"]')
expect(page).to have_selector('[data-track-label="edit_assignee"]')
end
......
......@@ -26,7 +26,7 @@ RSpec.describe 'Merge request > User edits reviewers sidebar', :js do
page.within '.dropdown-menu-user' do
expect(page).to have_link('Invite Members')
expect(page).to have_selector('[data-track-event="click_invite_members"]')
expect(page).to have_selector('[data-track-action="click_invite_members"]')
expect(page).to have_selector('[data-track-label="edit_reviewer"]')
end
......
......@@ -78,7 +78,7 @@ describe('RecoveryCodes', () => {
it('fires Snowplow event', () => {
expect(findProceedButton().attributes()).toMatchObject({
'data-track-event': 'click_button',
'data-track-action': 'click_button',
'data-track-label': '2fa_recovery_codes_proceed_button',
});
});
......
......@@ -323,7 +323,7 @@ describe('deprecatedJQueryDropdown', () => {
const li = dropdown.renderItem(item, null, 3);
const link = li.querySelector('a');
expect(link).toHaveAttr('data-track-event', 'click_text');
expect(link).toHaveAttr('data-track-action', 'click_text');
expect(link).toHaveAttr('data-track-label', 'some_value_for_label');
expect(link).toHaveAttr('data-track-value', '3');
expect(link).toHaveAttr('data-track-property', 'suggestion-category');
......
......@@ -15,7 +15,7 @@ RSpec.shared_examples 'issuable invite members' do
page.within '.dropdown-menu-user' do
expect(page).to have_link('Invite Members')
expect(page).to have_selector('[data-track-event="click_invite_members"]')
expect(page).to have_selector('[data-track-action="click_invite_members"]')
expect(page).to have_selector('[data-track-label="edit_assignee"]')
end
......
......@@ -53,7 +53,7 @@ RSpec.describe 'projects/empty' do
it 'shows invite members info', :aggregate_failures do
render
expect(rendered).to have_selector('[data-track-event=render]')
expect(rendered).to have_selector('[data-track-action=render]')
expect(rendered).to have_selector('[data-track-label=invite_members_empty_project]')
expect(rendered).to have_content('Invite your team')
expect(rendered).to have_content('Add members to this project and start collaborating with your team.')
......
......@@ -74,7 +74,7 @@ RSpec.describe 'search/_results' do
it 'renders the click text event tracking attributes' do
render
expect(rendered).to have_selector('[data-track-event=click_text]')
expect(rendered).to have_selector('[data-track-action=click_text]')
expect(rendered).to have_selector('[data-track-property=search_result]')
end
end
......@@ -83,7 +83,7 @@ RSpec.describe 'search/_results' do
it 'does not render the click text event tracking attributes' do
render
expect(rendered).not_to have_selector('[data-track-event=click_text]')
expect(rendered).not_to have_selector('[data-track-action=click_text]')
expect(rendered).not_to have_selector('[data-track-property=search_result]')
end
end
......@@ -105,7 +105,7 @@ RSpec.describe 'search/_results' do
it 'renders the click text event tracking attributes' do
render
expect(rendered).to have_selector('[data-track-event=click_text]')
expect(rendered).to have_selector('[data-track-action=click_text]')
expect(rendered).to have_selector('[data-track-property=search_result]')
end
end
......@@ -114,7 +114,7 @@ RSpec.describe 'search/_results' do
it 'does not render the click text event tracking attributes' do
render
expect(rendered).not_to have_selector('[data-track-event=click_text]')
expect(rendered).not_to have_selector('[data-track-action=click_text]')
expect(rendered).not_to have_selector('[data-track-property=search_result]')
end
end
......
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