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) {
}
export function initNavUserDropdownTracking() {
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');
if (el && buyEl) {
......
......@@ -26,7 +26,7 @@
- if current_user_menu?(:settings)
%li
= 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'
- if current_user_menu?(:help)
......
......@@ -3,22 +3,22 @@ module EE
module RunnersHelper
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)
show_out_of_ci_minutes_notification?(project, namespace)
show_out_of_pipeline_minutes_notification?(project, namespace)
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)
show_out_of_ci_minutes_notification?(project, namespace)
show_out_of_pipeline_minutes_notification?(project, namespace)
end
private
def show_out_of_ci_minutes_notification?(project, namespace)
strong_memoize(:show_out_of_ci_minutes_notification) do
def show_out_of_pipeline_minutes_notification?(project, namespace)
strong_memoize(:show_out_of_pipeline_minutes_notification) do
next unless project&.persisted? || namespace&.persisted?
::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
= 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
= s_("CurrentUser|Buy CI minutes")
= s_("CurrentUser|Buy Pipeline minutes")
= 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' } }
......@@ -49,12 +49,12 @@ RSpec.describe EE::RunnersHelper do
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
expect(threshold).not_to receive(:show?)
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
end
......@@ -67,12 +67,12 @@ RSpec.describe EE::RunnersHelper do
it { is_expected.to be_falsey }
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
expect(threshold).to receive(:show?).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
end
......@@ -84,8 +84,8 @@ RSpec.describe EE::RunnersHelper do
context 'with notifications' do
let(:experiment_status) { true }
describe '.show_buy_ci_minutes?' do
subject { helper.show_buy_ci_minutes?(project, namespace) }
describe '.show_buy_pipeline_minutes?' do
subject { helper.show_buy_pipeline_minutes?(project, namespace) }
context 'when experiment is "ci_notification_dot"' do
it_behaves_like 'minutes notification' do
......@@ -106,8 +106,8 @@ RSpec.describe EE::RunnersHelper do
end
end
describe '.show_ci_minutes_notification_dot?' do
subject { helper.show_ci_minutes_notification_dot?(project, namespace) }
describe '.show_pipeline_minutes_notification_dot?' do
subject { helper.show_pipeline_minutes_notification_dot?(project, namespace) }
it_behaves_like 'minutes notification' do
before do
......
......@@ -18,7 +18,7 @@ RSpec.describe 'layouts/application' do
let(:show_notification_dot) { false }
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
context 'when we show the notification dot' do
......
......@@ -5,33 +5,33 @@ require 'spec_helper'
RSpec.describe 'layouts/header/_current_user_dropdown' do
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 }
before do
allow(view).to receive(:current_user).and_return(user)
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
end
subject { rendered }
context 'when ci minutes need bought' do
it 'has "Buy CI minutes" link with correct data properties', :aggregate_failures do
context 'when pipeline minutes need bought' 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-label='#{user.namespace.actual_plan_name}']")
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
context 'when ci minutes do not need bought' do
let(:need_minutes) { false }
it 'has no "Buy CI minutes" link' do
expect(subject).not_to have_link('Buy CI minutes')
it 'has no "Buy Pipeline minutes" link' do
expect(subject).not_to have_link('Buy Pipeline minutes')
end
end
end
......@@ -41,7 +41,7 @@ RSpec.describe 'layouts/header/_current_user_dropdown' do
before do
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)
render
......
......@@ -6723,7 +6723,7 @@ msgstr ""
msgid "Current vulnerabilities count"
msgstr ""
msgid "CurrentUser|Buy CI minutes"
msgid "CurrentUser|Buy Pipeline minutes"
msgstr ""
msgid "CurrentUser|Profile"
......
......@@ -60,7 +60,7 @@ describe('Header', () => {
beforeEach(() => {
setFixtures(`
<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>
</li>`);
......@@ -74,7 +74,7 @@ describe('Header', () => {
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');
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