Commit 195d5c3e authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'ag-291060-feature-flag-rollout-of-saas_add_seats_button' into 'master'

Remove `saas_add_seats_button` FF [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!55964
parents 9c380a9e 9c764c7f
---
name: saas_add_seats_button
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/49242
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/291060
milestone: '13.7'
type: development
group: group::purchase
default_enabled: false
......@@ -4,7 +4,6 @@ import { escape } from 'lodash';
import { mapActions, mapState, mapGetters } from 'vuex';
import { TABLE_TYPE_DEFAULT, TABLE_TYPE_FREE, TABLE_TYPE_TRIAL } from 'ee/billings/constants';
import { s__ } from '~/locale';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import SubscriptionTableRow from './subscription_table_row.vue';
const createButtonProps = (text, href, testId) => ({ text, href, testId });
......@@ -16,7 +15,6 @@ export default {
GlLoadingIcon,
SubscriptionTableRow,
},
mixins: [glFeatureFlagsMixin()],
inject: {
planUpgradeHref: {
default: '',
......@@ -43,26 +41,23 @@ export default {
computed: {
...mapState(['isLoadingSubscription', 'hasErrorSubscription', 'plan', 'tables', 'endpoint']),
...mapGetters(['isFreePlan']),
isSubscription() {
return !this.isFreePlan;
},
subscriptionHeader() {
const planName = this.isFreePlan ? s__('SubscriptionTable|Free') : escape(this.planName);
const suffix = !this.isFreePlan && this.plan.trial ? s__('SubscriptionTable|Trial') : '';
const suffix = this.isSubscription && this.plan.trial ? s__('SubscriptionTable|Trial') : '';
return `${this.namespaceName}: ${planName} ${suffix}`;
},
canAddSeats() {
return this.glFeatures.saasAddSeatsButton && !this.isFreePlan;
},
canRenew() {
return !this.isFreePlan;
},
canUpgrade() {
return this.isFreePlan || this.plan.upgradable;
},
canUpgradeEEPlan() {
return !this.isFreePlan && this.planUpgradeHref;
return this.isSubscription && this.planUpgradeHref;
},
addSeatsButton() {
return this.canAddSeats
return this.isSubscription
? createButtonProps(
s__('SubscriptionTable|Add seats'),
this.addSeatsHref,
......@@ -83,12 +78,12 @@ export default {
return this.canUpgradeEEPlan ? this.planUpgradeHref : this.customerPortalUrl;
},
renewButton() {
return this.canRenew
return this.isSubscription
? createButtonProps(s__('SubscriptionTable|Renew'), this.planRenewHref, 'renew-button')
: null;
},
manageButton() {
return !this.isFreePlan
return this.isSubscription
? createButtonProps(
s__('SubscriptionTable|Manage'),
this.customerPortalUrl,
......
......@@ -4,10 +4,6 @@ class Groups::BillingsController < Groups::ApplicationController
before_action :authorize_admin_group!
before_action :verify_namespace_plan_check_enabled
before_action only: [:index] do
push_frontend_feature_flag(:saas_add_seats_button)
end
layout 'group_settings'
feature_category :purchase
......
---
title: Show 'Add Seats' Button on Billing Page
merge_request: 55964
author:
type: added
......@@ -75,19 +75,6 @@ RSpec.describe 'Groups > Billing', :js do
expect(page).to have_link("See usage", href: group_seat_usage_path(group))
end
end
context 'with disabled feature flags' do
before do
stub_feature_flags(saas_add_seats_button: false)
visit group_billings_path(group)
end
it 'does not show "Add Seats" button' do
within subscription_table do
expect(page).not_to have_link("Add seats")
end
end
end
end
context 'with a legacy paid plan' do
......@@ -107,32 +94,4 @@ RSpec.describe 'Groups > Billing', :js do
end
end
end
context 'with feature flags' do
where(:saas_add_seats_button) do
[
true, false
]
end
let(:plan) { 'bronze' }
let_it_be(:subscription) do
create(:gitlab_subscription, namespace: group, hosted_plan: bronze_plan, seats: 15)
end
with_them do
before do
stub_feature_flags(saas_add_seats_button: saas_add_seats_button)
end
it 'pushes the correct feature flags' do
visit group_billings_path(group)
expect(page).to have_pushed_frontend_feature_flags(
saasAddSeatsButton: saas_add_seats_button
)
end
end
end
end
......@@ -19,19 +19,12 @@ describe('SubscriptionTable component', () => {
let store;
let wrapper;
const defaultFlags = { saasAddSeatsButton: false };
const findAddSeatsButton = () => wrapper.findByTestId('add-seats-button');
const findManageButton = () => wrapper.findByTestId('manage-button');
const findRenewButton = () => wrapper.findByTestId('renew-button');
const findUpgradeButton = () => wrapper.findByTestId('upgrade-button');
const createComponentWithStore = ({
props = {},
featureFlags = {},
provide = {},
state = {},
} = {}) => {
const createComponentWithStore = ({ props = {}, provide = {}, state = {} } = {}) => {
store = new Vuex.Store(initialStore());
jest.spyOn(store, 'dispatch').mockImplementation();
......@@ -44,10 +37,6 @@ describe('SubscriptionTable component', () => {
namespaceName,
planName,
...provide,
glFeatures: {
defaultFlags,
...featureFlags,
},
},
propsData: props,
}),
......@@ -120,7 +109,7 @@ describe('SubscriptionTable component', () => {
${null} | ${false} | ${'does not render the button'}
${'free'} | ${false} | ${'does not render the button'}
`(
'given a plan with state: planCode = $planCode and saasAddSeatsButton = $featureFlag',
'given a plan with state: planCode = $planCode',
({ planCode, upgradable, expected, testDescription }) => {
beforeEach(() => {
createComponentWithStore({
......@@ -170,19 +159,15 @@ describe('SubscriptionTable component', () => {
describe('Add seats button', () => {
describe.each`
planCode | featureFlag | expected | testDescription
${'silver'} | ${true} | ${true} | ${'renders the button'}
${'silver'} | ${false} | ${false} | ${'does not render the button'}
${null} | ${true} | ${false} | ${'does not render the button'}
${null} | ${false} | ${false} | ${'does not render the button'}
${'free'} | ${true} | ${false} | ${'does not render the button'}
${'free'} | ${false} | ${false} | ${'does not render the button'}
planCode | expected | testDescription
${'silver'} | ${true} | ${'renders the button'}
${null} | ${false} | ${'does not render the button'}
${'free'} | ${false} | ${'does not render the button'}
`(
'given a plan with state: planCode = $planCode and saasAddSeatsButton = $featureFlag',
({ planCode, featureFlag, expected, testDescription }) => {
'given a plan with state: planCode = $planCode',
({ planCode, expected, testDescription }) => {
beforeEach(() => {
createComponentWithStore({
featureFlags: { saasAddSeatsButton: featureFlag },
state: {
isLoadingSubscription: false,
plan: {
......
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