2021-01-27 10:09:15 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe "Admin::Users" do
|
|
|
|
let(:current_user) { create(:admin) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(current_user)
|
|
|
|
gitlab_enable_admin_mode_sign_in(current_user)
|
|
|
|
end
|
|
|
|
|
2021-04-23 08:09:52 -04:00
|
|
|
describe 'Tabs' do
|
2021-01-27 10:09:15 -05:00
|
|
|
let(:tabs_selector) { '.js-users-tabs' }
|
|
|
|
let(:active_tab_selector) { '.nav-link.active' }
|
|
|
|
|
2021-04-23 08:09:52 -04:00
|
|
|
it 'links to the Users tab' do
|
2021-06-16 11:10:08 -04:00
|
|
|
visit admin_cohorts_path
|
2021-01-27 10:09:15 -05:00
|
|
|
|
|
|
|
within tabs_selector do
|
|
|
|
click_link 'Users'
|
2021-04-23 08:09:52 -04:00
|
|
|
|
|
|
|
expect(page).to have_selector active_tab_selector, text: 'Users'
|
2021-01-27 10:09:15 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_current_path(admin_users_path)
|
|
|
|
end
|
|
|
|
|
2021-04-23 08:09:52 -04:00
|
|
|
it 'links to the Cohorts tab' do
|
2021-01-27 10:09:15 -05:00
|
|
|
visit admin_users_path
|
|
|
|
|
|
|
|
within tabs_selector do
|
|
|
|
click_link 'Cohorts'
|
2021-04-23 08:09:52 -04:00
|
|
|
|
|
|
|
expect(page).to have_selector active_tab_selector, text: 'Cohorts'
|
2021-01-27 10:09:15 -05:00
|
|
|
end
|
|
|
|
|
2021-06-16 11:10:08 -04:00
|
|
|
expect(page).to have_current_path(admin_cohorts_path)
|
2021-04-23 08:09:52 -04:00
|
|
|
expect(page).to have_selector active_tab_selector, text: 'Cohorts'
|
2021-01-27 10:09:15 -05:00
|
|
|
end
|
|
|
|
|
2021-04-23 08:09:52 -04:00
|
|
|
it 'redirects legacy route' do
|
2021-01-27 10:09:15 -05:00
|
|
|
visit admin_users_path(tab: 'cohorts')
|
|
|
|
|
2021-06-16 11:10:08 -04:00
|
|
|
expect(page).to have_current_path(admin_cohorts_path)
|
2021-01-27 10:09:15 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'Cohorts tab content' do
|
2021-04-20 17:09:07 -04:00
|
|
|
it 'shows users count per month' do
|
|
|
|
stub_application_setting(usage_ping_enabled: false)
|
2021-01-27 10:09:15 -05:00
|
|
|
|
2021-04-20 17:09:07 -04:00
|
|
|
create_list(:user, 2)
|
2021-01-27 10:09:15 -05:00
|
|
|
|
2021-04-20 17:09:07 -04:00
|
|
|
visit admin_users_path(tab: 'cohorts')
|
2021-01-27 10:09:15 -05:00
|
|
|
|
2022-02-22 13:17:57 -05:00
|
|
|
expect(page).to have_content("#{Time.zone.now.strftime('%b %Y')} 3 0")
|
2021-01-27 10:09:15 -05:00
|
|
|
end
|
|
|
|
end
|
2022-01-06 07:14:04 -05:00
|
|
|
|
|
|
|
describe 'prompt user about registration features' do
|
|
|
|
let(:message) { s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: s_('RegistrationFeatures|send emails to users') } }
|
|
|
|
|
|
|
|
it 'does not render registration features CTA when service ping is enabled' do
|
|
|
|
stub_application_setting(usage_ping_enabled: true)
|
|
|
|
|
|
|
|
visit admin_users_path
|
|
|
|
|
|
|
|
expect(page).not_to have_content(message)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with no license and service ping disabled' do
|
|
|
|
before do
|
|
|
|
stub_application_setting(usage_ping_enabled: false)
|
|
|
|
|
|
|
|
if Gitlab.ee?
|
|
|
|
allow(License).to receive(:current).and_return(nil)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders registration features CTA' do
|
|
|
|
visit admin_users_path
|
|
|
|
|
|
|
|
expect(page).to have_content(message)
|
|
|
|
expect(page).to have_link(s_('RegistrationFeatures|Registration Features Program'))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-01-27 10:09:15 -05:00
|
|
|
end
|