Commit a79f58bc authored by Michael Lunøe's avatar Michael Lunøe Committed by Dylan Griffith

Fix(EoA Banner): add test coverage + log error

Add test coverage for when user actually dismisses
the banner
parent cffdff1f
......@@ -8,6 +8,7 @@ const PERSISTENT_USER_CALLOUTS = [
'.js-token-expiry-callout',
'.js-registration-enabled-callout',
'.js-new-user-signups-cap-reached',
'.js-eoa-bronze-plan-banner',
];
const initCallouts = () => {
......
......@@ -12,6 +12,7 @@ module EE
NEW_USER_SIGNUPS_CAP_REACHED = 'new_user_signups_cap_reached'
PERSONAL_ACCESS_TOKEN_EXPIRY = 'personal_access_token_expiry'
EOA_BRONZE_PLAN_BANNER = 'eoa_bronze_plan_banner'
EOA_BRONZE_PLAN_END_DATE = '2022-01-26'
def render_enable_hashed_storage_warning
return unless show_enable_hashed_storage_warning?
......@@ -91,7 +92,7 @@ module EE
private
def eoa_bronze_plan_end_date
Date.parse('2022-01-26')
Date.parse(EOA_BRONZE_PLAN_END_DATE)
end
def hashed_storage_enabled?
......
- if show_eoa_bronze_plan_banner?(namespace)
.container-fluid.container-limited.pt-3
.gl-alert.gl-alert-info.gl-mt-5{ role: 'alert', data: { feature_id: ::EE::UserCalloutsHelper::EOA_BRONZE_PLAN_BANNER, dismiss_endpoint: user_callouts_path } }
.gl-alert.gl-alert-info.gl-mt-5.js-eoa-bronze-plan-banner{ role: 'alert', data: { feature_id: ::EE::UserCalloutsHelper::EOA_BRONZE_PLAN_BANNER, dismiss_endpoint: user_callouts_path } }
= sprite_icon('information-o', css_class: 'gl-icon gl-alert-icon gl-alert-icon-no-title')
%button.js-close.gl-alert-dismiss{ type: 'button', 'aria-label' => _('Dismiss') }
= sprite_icon('close', css_class: 'gl-icon')
......
......@@ -19,6 +19,7 @@ RSpec.describe 'Billing plan pages', :feature do
end
before do
stub_feature_flags(show_billing_eoa_banner: true)
stub_feature_flags(hide_deprecated_billing_plans: false)
stub_experiment_for_subject(contact_sales_btn_in_app: true)
stub_full_request("#{EE::SUBSCRIPTIONS_URL}/gitlab_plans?plan=#{plan.name}&namespace_id=#{namespace.id}")
......@@ -35,6 +36,16 @@ RSpec.describe 'Billing plan pages', :feature do
end
end
shared_examples 'does not display EoA banner' do
it 'does not display the banner', :js do
travel_to(Date.parse(EE::UserCalloutsHelper::EOA_BRONZE_PLAN_END_DATE) - 1.day) do
visit page_path
expect(page).not_to have_content("End of availability for the Bronze Plan")
end
end
end
shared_examples 'upgradable plan' do
before do
visit page_path
......@@ -180,6 +191,22 @@ RSpec.describe 'Billing plan pages', :feature do
create(:gitlab_subscription, namespace: namespace, hosted_plan: plan, seats: 15)
end
it 'shows the EoA bronze banner that can be dismissed permanently', :js do
travel_to(Date.parse(EE::UserCalloutsHelper::EOA_BRONZE_PLAN_END_DATE) - 1.day) do
visit page_path
page.within(".js-eoa-bronze-plan-banner") do
expect(page).to have_content("End of availability for the Bronze Plan")
click_button "Dismiss"
end
visit page_path
expect(page).not_to have_content("End of availability for the Bronze Plan")
end
end
it_behaves_like 'plan with header'
it_behaves_like 'downgradable plan'
it_behaves_like 'upgradable plan'
......@@ -199,6 +226,7 @@ RSpec.describe 'Billing plan pages', :feature do
it_behaves_like 'upgradable plan'
it_behaves_like 'can contact sales'
it_behaves_like 'plan with subscription table'
it_behaves_like 'does not display EoA banner'
end
context 'on ultimate plan' do
......@@ -212,6 +240,7 @@ RSpec.describe 'Billing plan pages', :feature do
it_behaves_like 'downgradable plan'
it_behaves_like 'non-upgradable plan'
it_behaves_like 'plan with subscription table'
it_behaves_like 'does not display EoA banner'
end
end
......
......@@ -111,6 +111,10 @@ RSpec.describe 'shared/billings/_eoa_bronze_plan_banner.html.haml' do
it_behaves_like 'with a different plan than Bronze' do
let(:namespace) { group }
end
it_behaves_like 'when user dismissed the banner' do
let(:namespace) { group }
end
end
context 'with personal namespace' do
......@@ -136,5 +140,9 @@ RSpec.describe 'shared/billings/_eoa_bronze_plan_banner.html.haml' do
it_behaves_like 'with a different plan than Bronze' do
let(:namespace) { current_user.namespace }
end
it_behaves_like 'when user dismissed the banner' do
let(:namespace) { current_user.namespace }
end
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