2021-03-11 19:13:27 +05:30
|
|
|
# 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-06-08 01:23:25 +05:30
|
|
|
describe 'Tabs' do
|
2021-03-11 19:13:27 +05:30
|
|
|
let(:tabs_selector) { '.js-users-tabs' }
|
|
|
|
let(:active_tab_selector) { '.nav-link.active' }
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
it 'links to the Users tab' do
|
2021-09-04 01:27:46 +05:30
|
|
|
visit admin_cohorts_path
|
2021-03-11 19:13:27 +05:30
|
|
|
|
|
|
|
within tabs_selector do
|
|
|
|
click_link 'Users'
|
2021-06-08 01:23:25 +05:30
|
|
|
|
|
|
|
expect(page).to have_selector active_tab_selector, text: 'Users'
|
2021-03-11 19:13:27 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_current_path(admin_users_path)
|
|
|
|
end
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
it 'links to the Cohorts tab' do
|
2021-03-11 19:13:27 +05:30
|
|
|
visit admin_users_path
|
|
|
|
|
|
|
|
within tabs_selector do
|
|
|
|
click_link 'Cohorts'
|
2021-06-08 01:23:25 +05:30
|
|
|
|
|
|
|
expect(page).to have_selector active_tab_selector, text: 'Cohorts'
|
2021-03-11 19:13:27 +05:30
|
|
|
end
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
expect(page).to have_current_path(admin_cohorts_path)
|
2021-06-08 01:23:25 +05:30
|
|
|
expect(page).to have_selector active_tab_selector, text: 'Cohorts'
|
2021-03-11 19:13:27 +05:30
|
|
|
end
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
it 'redirects legacy route' do
|
2021-03-11 19:13:27 +05:30
|
|
|
visit admin_users_path(tab: 'cohorts')
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
expect(page).to have_current_path(admin_cohorts_path)
|
2021-03-11 19:13:27 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'Cohorts tab content' do
|
2021-06-08 01:23:25 +05:30
|
|
|
it 'shows users count per month' do
|
|
|
|
stub_application_setting(usage_ping_enabled: false)
|
2021-03-11 19:13:27 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
create_list(:user, 2)
|
2021-03-11 19:13:27 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
visit admin_users_path(tab: 'cohorts')
|
2021-03-11 19:13:27 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
expect(page).to have_content("#{Time.now.strftime('%b %Y')} 3 0")
|
2021-03-11 19:13:27 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|