Commit 8b3476f5 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '221063-improve-buy-ci-minutes-link' into 'master'

Rename buy CI minutes link

See merge request gitlab-org/gitlab!34283
parents 0b4196eb cca00b11
...@@ -86,7 +86,7 @@ function trackShowUserDropdownLink(trackEvent, elToTrack, el) { ...@@ -86,7 +86,7 @@ function trackShowUserDropdownLink(trackEvent, elToTrack, el) {
} }
export function initNavUserDropdownTracking() { export function initNavUserDropdownTracking() {
const el = document.querySelector('.js-nav-user-dropdown'); const el = document.querySelector('.js-nav-user-dropdown');
const buyEl = document.querySelector('.js-buy-ci-minutes-link'); const buyEl = document.querySelector('.js-buy-pipeline-minutes-link');
const upgradeEl = document.querySelector('.js-upgrade-plan-link'); const upgradeEl = document.querySelector('.js-upgrade-plan-link');
if (el && buyEl) { if (el && buyEl) {
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
- if current_user_menu?(:settings) - if current_user_menu?(:settings)
%li %li
= link_to s_("CurrentUser|Settings"), profile_path, data: { qa_selector: 'settings_link' } = link_to s_("CurrentUser|Settings"), profile_path, data: { qa_selector: 'settings_link' }
= render_if_exists 'layouts/header/buy_ci_minutes', project: @project, namespace: @group = render_if_exists 'layouts/header/buy_pipeline_minutes', project: @project, namespace: @group
= render_if_exists 'layouts/header/upgrade' = render_if_exists 'layouts/header/upgrade'
- if current_user_menu?(:help) - if current_user_menu?(:help)
......
...@@ -3,22 +3,22 @@ module EE ...@@ -3,22 +3,22 @@ module EE
module RunnersHelper module RunnersHelper
include ::Gitlab::Utils::StrongMemoize include ::Gitlab::Utils::StrongMemoize
def show_buy_ci_minutes?(project, namespace) def show_buy_pipeline_minutes?(project, namespace)
return false unless experiment_enabled?(:ci_notification_dot) || experiment_enabled?(:buy_ci_minutes_version_a) return false unless experiment_enabled?(:ci_notification_dot) || experiment_enabled?(:buy_ci_minutes_version_a)
show_out_of_ci_minutes_notification?(project, namespace) show_out_of_pipeline_minutes_notification?(project, namespace)
end end
def show_ci_minutes_notification_dot?(project, namespace) def show_pipeline_minutes_notification_dot?(project, namespace)
return false unless experiment_enabled?(:ci_notification_dot) return false unless experiment_enabled?(:ci_notification_dot)
show_out_of_ci_minutes_notification?(project, namespace) show_out_of_pipeline_minutes_notification?(project, namespace)
end end
private private
def show_out_of_ci_minutes_notification?(project, namespace) def show_out_of_pipeline_minutes_notification?(project, namespace)
strong_memoize(:show_out_of_ci_minutes_notification) do strong_memoize(:show_out_of_pipeline_minutes_notification) do
next unless project&.persisted? || namespace&.persisted? next unless project&.persisted? || namespace&.persisted?
::Ci::Minutes::Notification.new(project, namespace).show?(current_user) ::Ci::Minutes::Notification.new(project, namespace).show?(current_user)
......
- return unless show_buy_ci_minutes?(project, namespace) - return unless show_buy_pipeline_minutes?(project, namespace)
%li %li
= link_to profile_usage_quotas_path, = link_to profile_usage_quotas_path,
class: 'ci-minutes-emoji js-buy-ci-minutes-link', class: 'ci-minutes-emoji js-buy-pipeline-minutes-link',
data: { 'track-event': 'click_buy_ci_minutes', 'track-label': current_user.namespace.actual_plan_name, 'track-property': 'user_dropdown' } do data: { 'track-event': 'click_buy_ci_minutes', 'track-label': current_user.namespace.actual_plan_name, 'track-property': 'user_dropdown' } do
= s_("CurrentUser|Buy CI minutes") = s_("CurrentUser|Buy Pipeline minutes")
= emoji_icon('clock9', 'aria-hidden': true) = emoji_icon('clock9', 'aria-hidden': true)
- return unless show_ci_minutes_notification_dot?(project, namespace) - return unless show_pipeline_minutes_notification_dot?(project, namespace)
%span.header-user-notification-dot.rounded-circle.position-relative{ data: { track_label: "show_buy_ci_minutes_notification", track_property: current_user.namespace.actual_plan_name, track_event: 'render' } } %span.header-user-notification-dot.rounded-circle.position-relative{ data: { track_label: "show_buy_ci_minutes_notification", track_property: current_user.namespace.actual_plan_name, track_event: 'render' } }
...@@ -49,12 +49,12 @@ RSpec.describe EE::RunnersHelper do ...@@ -49,12 +49,12 @@ RSpec.describe EE::RunnersHelper do
it { is_expected.to be_falsey } it { is_expected.to be_falsey }
context 'when show_ci_minutes_notification_dot? has been called before' do context 'when show_pipeline_minutes_notification_dot? has been called before' do
it 'does not do all the notification and query work again' do it 'does not do all the notification and query work again' do
expect(threshold).not_to receive(:show?) expect(threshold).not_to receive(:show?)
expect(project).to receive(:persisted?).once expect(project).to receive(:persisted?).once
helper.show_ci_minutes_notification_dot?(project, namespace) helper.show_pipeline_minutes_notification_dot?(project, namespace)
expect(subject).to be_falsey expect(subject).to be_falsey
end end
...@@ -67,12 +67,12 @@ RSpec.describe EE::RunnersHelper do ...@@ -67,12 +67,12 @@ RSpec.describe EE::RunnersHelper do
it { is_expected.to be_falsey } it { is_expected.to be_falsey }
end end
context 'when show_ci_minutes_notification_dot? has been called before' do context 'when show_pipeline_minutes_notification_dot? has been called before' do
it 'does not do all the notification and query work again' do it 'does not do all the notification and query work again' do
expect(threshold).to receive(:show?).once expect(threshold).to receive(:show?).once
expect(project).to receive(:persisted?).once expect(project).to receive(:persisted?).once
helper.show_ci_minutes_notification_dot?(project, namespace) helper.show_pipeline_minutes_notification_dot?(project, namespace)
expect(subject).to be_truthy expect(subject).to be_truthy
end end
...@@ -84,8 +84,8 @@ RSpec.describe EE::RunnersHelper do ...@@ -84,8 +84,8 @@ RSpec.describe EE::RunnersHelper do
context 'with notifications' do context 'with notifications' do
let(:experiment_status) { true } let(:experiment_status) { true }
describe '.show_buy_ci_minutes?' do describe '.show_buy_pipeline_minutes?' do
subject { helper.show_buy_ci_minutes?(project, namespace) } subject { helper.show_buy_pipeline_minutes?(project, namespace) }
context 'when experiment is "ci_notification_dot"' do context 'when experiment is "ci_notification_dot"' do
it_behaves_like 'minutes notification' do it_behaves_like 'minutes notification' do
...@@ -106,8 +106,8 @@ RSpec.describe EE::RunnersHelper do ...@@ -106,8 +106,8 @@ RSpec.describe EE::RunnersHelper do
end end
end end
describe '.show_ci_minutes_notification_dot?' do describe '.show_pipeline_minutes_notification_dot?' do
subject { helper.show_ci_minutes_notification_dot?(project, namespace) } subject { helper.show_pipeline_minutes_notification_dot?(project, namespace) }
it_behaves_like 'minutes notification' do it_behaves_like 'minutes notification' do
before do before do
......
...@@ -18,7 +18,7 @@ RSpec.describe 'layouts/application' do ...@@ -18,7 +18,7 @@ RSpec.describe 'layouts/application' do
let(:show_notification_dot) { false } let(:show_notification_dot) { false }
before do before do
allow(view).to receive(:show_ci_minutes_notification_dot?).and_return(show_notification_dot) allow(view).to receive(:show_pipeline_minutes_notification_dot?).and_return(show_notification_dot)
end end
context 'when we show the notification dot' do context 'when we show the notification dot' do
......
...@@ -5,33 +5,33 @@ require 'spec_helper' ...@@ -5,33 +5,33 @@ require 'spec_helper'
RSpec.describe 'layouts/header/_current_user_dropdown' do RSpec.describe 'layouts/header/_current_user_dropdown' do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
describe 'Buy CI Minutes link in user dropdown' do describe 'Buy Pipeline Minutes link in user dropdown' do
let(:need_minutes) { true } let(:need_minutes) { true }
before do before do
allow(view).to receive(:current_user).and_return(user) allow(view).to receive(:current_user).and_return(user)
allow(view).to receive(:show_upgrade_link?).and_return(false) allow(view).to receive(:show_upgrade_link?).and_return(false)
allow(view).to receive(:show_buy_ci_minutes?).and_return(need_minutes) allow(view).to receive(:show_buy_pipeline_minutes?).and_return(need_minutes)
render render
end end
subject { rendered } subject { rendered }
context 'when ci minutes need bought' do context 'when pipeline minutes need bought' do
it 'has "Buy CI minutes" link with correct data properties', :aggregate_failures 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-event="click_buy_ci_minutes"]')
expect(subject).to have_selector("[data-track-label='#{user.namespace.actual_plan_name}']") 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_selector('[data-track-property="user_dropdown"]')
expect(subject).to have_link('Buy CI minutes') expect(subject).to have_link('Buy Pipeline minutes')
end end
end end
context 'when ci minutes do not need bought' do context 'when ci minutes do not need bought' do
let(:need_minutes) { false } let(:need_minutes) { false }
it 'has no "Buy CI minutes" link' do it 'has no "Buy Pipeline minutes" link' do
expect(subject).not_to have_link('Buy CI minutes') expect(subject).not_to have_link('Buy Pipeline minutes')
end end
end end
end end
...@@ -41,7 +41,7 @@ RSpec.describe 'layouts/header/_current_user_dropdown' do ...@@ -41,7 +41,7 @@ RSpec.describe 'layouts/header/_current_user_dropdown' do
before do before do
allow(view).to receive(:current_user).and_return(user) allow(view).to receive(:current_user).and_return(user)
allow(view).to receive(:show_buy_ci_minutes?).and_return(false) allow(view).to receive(:show_buy_pipeline_minutes?).and_return(false)
allow(view).to receive(:show_upgrade_link?).and_return(on_upgradeable_plan) allow(view).to receive(:show_upgrade_link?).and_return(on_upgradeable_plan)
render render
......
...@@ -6723,7 +6723,7 @@ msgstr "" ...@@ -6723,7 +6723,7 @@ msgstr ""
msgid "Current vulnerabilities count" msgid "Current vulnerabilities count"
msgstr "" msgstr ""
msgid "CurrentUser|Buy CI minutes" msgid "CurrentUser|Buy Pipeline minutes"
msgstr "" msgstr ""
msgid "CurrentUser|Profile" msgid "CurrentUser|Profile"
......
...@@ -60,7 +60,7 @@ describe('Header', () => { ...@@ -60,7 +60,7 @@ describe('Header', () => {
beforeEach(() => { beforeEach(() => {
setFixtures(` setFixtures(`
<li class="js-nav-user-dropdown"> <li class="js-nav-user-dropdown">
<a class="js-buy-ci-minutes-link" data-track-event="click_buy_ci_minutes" data-track-label="free" data-track-property="user_dropdown">Buy CI minutes</a> <a class="js-buy-pipeline-minutes-link" data-track-event="click_buy_ci_minutes" data-track-label="free" data-track-property="user_dropdown">Buy Pipeline minutes</a>
<a class="js-upgrade-plan-link" data-track-event="click_upgrade_link" data-track-label="free" data-track-property="user_dropdown">Upgrade</a> <a class="js-upgrade-plan-link" data-track-event="click_upgrade_link" data-track-label="free" data-track-property="user_dropdown">Upgrade</a>
</li>`); </li>`);
...@@ -74,7 +74,7 @@ describe('Header', () => { ...@@ -74,7 +74,7 @@ describe('Header', () => {
unmockTracking(); unmockTracking();
}); });
it('sends a tracking event when the dropdown is opened and contains Buy CI minutes link', () => { it('sends a tracking event when the dropdown is opened and contains Buy Pipeline minutes link', () => {
$('.js-nav-user-dropdown').trigger('shown.bs.dropdown'); $('.js-nav-user-dropdown').trigger('shown.bs.dropdown');
expect(trackingSpy).toHaveBeenCalledWith('some:page', 'show_buy_ci_minutes', { expect(trackingSpy).toHaveBeenCalledWith('some:page', 'show_buy_ci_minutes', {
......
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