diff options
Diffstat (limited to 'spec/features/admin/users/user_spec.rb')
-rw-r--r-- | spec/features/admin/users/user_spec.rb | 177 |
1 files changed, 94 insertions, 83 deletions
diff --git a/spec/features/admin/users/user_spec.rb b/spec/features/admin/users/user_spec.rb index befa7bd338b..01341398135 100644 --- a/spec/features/admin/users/user_spec.rb +++ b/spec/features/admin/users/user_spec.rb @@ -4,18 +4,16 @@ require 'spec_helper' RSpec.describe 'Admin::Users::User' do let_it_be(:user) { create(:omniauth_user, provider: 'twitter', extern_uid: '123456') } - let_it_be(:current_user) { create(:admin, last_activity_on: 5.days.ago) } + let_it_be(:current_user) { create(:admin) } before do sign_in(current_user) gitlab_enable_admin_mode_sign_in(current_user) - stub_feature_flags(vue_admin_users: false) end describe 'GET /admin/users/:id' do it 'has user info', :aggregate_failures do - visit admin_users_path - click_link user.name + visit admin_user_path(user) expect(page).to have_content(user.email) expect(page).to have_content(user.name) @@ -27,21 +25,6 @@ RSpec.describe 'Admin::Users::User' do expect(page).to have_button('Delete user and contributions') end - context 'user pending approval' do - it 'shows user info', :aggregate_failures do - user = create(:user, :blocked_pending_approval) - - visit admin_users_path - click_link 'Pending approval' - click_link user.name - - expect(page).to have_content(user.name) - expect(page).to have_content('Pending approval') - expect(page).to have_link('Approve user') - expect(page).to have_link('Reject request') - end - end - context 'when blocking/unblocking the user' do it 'shows confirmation and allows blocking and unblocking', :js do visit admin_user_path(user) @@ -171,6 +154,8 @@ RSpec.describe 'Admin::Users::User' do it 'logs in as the user when impersonate is clicked' do subject + find('[data-qa-selector="user_menu"]').click + expect(page.find(:css, '[data-testid="user-profile-link"]')['data-user']).to eql(another_user.username) end @@ -205,6 +190,8 @@ RSpec.describe 'Admin::Users::User' do it 'logs out of impersonated user back to original user' do subject + find('[data-qa-selector="user_menu"]').click + expect(page.find(:css, '[data-testid="user-profile-link"]')['data-user']).to eq(current_user.username) end @@ -238,6 +225,8 @@ RSpec.describe 'Admin::Users::User' do end it 'shows when disabled' do + user.update!(otp_required_for_login: false) + visit admin_user_path(user) expect_two_factor_status('Disabled') @@ -251,7 +240,7 @@ RSpec.describe 'Admin::Users::User' do end describe 'Email verification status' do - let!(:secondary_email) do + let_it_be(:secondary_email) do create :email, email: 'secondary@example.com', user: user end @@ -274,99 +263,121 @@ RSpec.describe 'Admin::Users::User' do expect(page).to have_content("#{secondary_email.email} Verified") end end - end - - describe 'show user attributes' do - it 'has expected attributes', :aggregate_failures do - visit admin_users_path - click_link user.name + describe 'show user identities' do + it 'shows user identities', :aggregate_failures do + visit admin_user_identities_path(user) - expect(page).to have_content 'Account' - expect(page).to have_content 'Personal projects limit' + expect(page).to have_content(user.name) + expect(page).to have_content('twitter') + end end - end - describe 'remove users secondary email', :js do - let!(:secondary_email) do - create :email, email: 'secondary@example.com', user: user + describe 'update user identities' do + before do + allow(Gitlab::Auth::OAuth::Provider).to receive(:providers).and_return([:twitter, :twitter_updated]) + end + + it 'modifies twitter identity', :aggregate_failures do + visit admin_user_identities_path(user) + + find('.table').find(:link, 'Edit').click + fill_in 'identity_extern_uid', with: '654321' + select 'twitter_updated', from: 'identity_provider' + click_button 'Save changes' + + expect(page).to have_content(user.name) + expect(page).to have_content('twitter_updated') + expect(page).to have_content('654321') + end end - it do - visit admin_user_path(user.username) + describe 'remove users secondary email', :js do + let_it_be(:secondary_email) do + create :email, email: 'secondary@example.com', user: user + end + + it do + visit admin_user_path(user.username) - expect(page).to have_content("Secondary email: #{secondary_email.email}") + expect(page).to have_content("Secondary email: #{secondary_email.email}") - accept_confirm { find("#remove_email_#{secondary_email.id}").click } + accept_confirm { find("#remove_email_#{secondary_email.id}").click } - expect(page).not_to have_content(secondary_email.email) + expect(page).not_to have_content(secondary_email.email) + end end - end - describe 'show user keys', :js do - it do - key1 = create(:key, user: user, title: 'ssh-rsa Key1', key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4FIEBXGi4bPU8kzxMefudPIJ08/gNprdNTaO9BR/ndy3+58s2HCTw2xCHcsuBmq+TsAqgEidVq4skpqoTMB+Uot5Uzp9z4764rc48dZiI661izoREoKnuRQSsRqUTHg5wrLzwxlQbl1MVfRWQpqiz/5KjBC7yLEb9AbusjnWBk8wvC1bQPQ1uLAauEA7d836tgaIsym9BrLsMVnR4P1boWD3Xp1B1T/ImJwAGHvRmP/ycIqmKdSpMdJXwxcb40efWVj0Ibbe7ii9eeoLdHACqevUZi6fwfbymdow+FeqlkPoHyGg3Cu4vD/D8+8cRc7mE/zGCWcQ15Var83Tczour Key1') - key2 = create(:key, user: user, title: 'ssh-rsa Key2', key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQSTWXhJAX/He+nG78MiRRRn7m0Pb0XbcgTxE0etArgoFoh9WtvDf36HG6tOSg/0UUNcp0dICsNAmhBKdncp6cIyPaXJTURPRAGvhI0/VDk4bi27bRnccGbJ/hDaUxZMLhhrzY0r22mjVf8PF6dvv5QUIQVm1/LeaWYsHHvLgiIjwrXirUZPnFrZw6VLREoBKG8uWvfSXw1L5eapmstqfsME8099oi+vWLR8MgEysZQmD28M73fgW4zek6LDQzKQyJx9nB+hJkKUDvcuziZjGmRFlNgSA2mguERwL1OXonD8WYUrBDGKroIvBT39zS5d9tQDnidEJZ9Y8gv5ViYP7x Key2') + describe 'remove user with identities' do + it 'removes user with twitter identity', :aggregate_failures do + visit admin_user_identities_path(user) - visit admin_users_path + click_link 'Delete' - click_link user.name - click_link 'SSH keys' + expect(page).to have_content(user.name) + expect(page).not_to have_content('twitter') + end + end - expect(page).to have_content(key1.title) - expect(page).to have_content(key2.title) + describe 'show user keys', :js do + it do + key1 = create(:key, user: user, title: 'ssh-rsa Key1', key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4FIEBXGi4bPU8kzxMefudPIJ08/gNprdNTaO9BR/ndy3+58s2HCTw2xCHcsuBmq+TsAqgEidVq4skpqoTMB+Uot5Uzp9z4764rc48dZiI661izoREoKnuRQSsRqUTHg5wrLzwxlQbl1MVfRWQpqiz/5KjBC7yLEb9AbusjnWBk8wvC1bQPQ1uLAauEA7d836tgaIsym9BrLsMVnR4P1boWD3Xp1B1T/ImJwAGHvRmP/ycIqmKdSpMdJXwxcb40efWVj0Ibbe7ii9eeoLdHACqevUZi6fwfbymdow+FeqlkPoHyGg3Cu4vD/D8+8cRc7mE/zGCWcQ15Var83Tczour Key1') + key2 = create(:key, user: user, title: 'ssh-rsa Key2', key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQSTWXhJAX/He+nG78MiRRRn7m0Pb0XbcgTxE0etArgoFoh9WtvDf36HG6tOSg/0UUNcp0dICsNAmhBKdncp6cIyPaXJTURPRAGvhI0/VDk4bi27bRnccGbJ/hDaUxZMLhhrzY0r22mjVf8PF6dvv5QUIQVm1/LeaWYsHHvLgiIjwrXirUZPnFrZw6VLREoBKG8uWvfSXw1L5eapmstqfsME8099oi+vWLR8MgEysZQmD28M73fgW4zek6LDQzKQyJx9nB+hJkKUDvcuziZjGmRFlNgSA2mguERwL1OXonD8WYUrBDGKroIvBT39zS5d9tQDnidEJZ9Y8gv5ViYP7x Key2') - click_link key2.title + visit admin_user_path(user) - expect(page).to have_content(key2.title) - expect(page).to have_content(key2.key) + click_link 'SSH keys' - click_button 'Delete' + expect(page).to have_content(key1.title) + expect(page).to have_content(key2.title) - page.within('.modal') do - page.click_button('Delete') - end + click_link key2.title - expect(page).not_to have_content(key2.title) - end - end + expect(page).to have_content(key2.title) + expect(page).to have_content(key2.key) - describe 'show user identities' do - it 'shows user identities', :aggregate_failures do - visit admin_user_identities_path(user) + click_button 'Delete' - expect(page).to have_content(user.name) - expect(page).to have_content('twitter') - end - end + page.within('.modal') do + page.click_button('Delete') + end - describe 'update user identities' do - before do - allow(Gitlab::Auth::OAuth::Provider).to receive(:providers).and_return([:twitter, :twitter_updated]) + expect(page).not_to have_content(key2.title) + end end - it 'modifies twitter identity', :aggregate_failures do - visit admin_user_identities_path(user) - - find('.table').find(:link, 'Edit').click - fill_in 'identity_extern_uid', with: '654321' - select 'twitter_updated', from: 'identity_provider' - click_button 'Save changes' + describe 'show user attributes' do + it 'has expected attributes', :aggregate_failures do + visit admin_user_path(user) - expect(page).to have_content(user.name) - expect(page).to have_content('twitter_updated') - expect(page).to have_content('654321') + expect(page).to have_content 'Account' + expect(page).to have_content 'Personal projects limit' + end end end - describe 'remove user with identities' do - it 'removes user with twitter identity', :aggregate_failures do - visit admin_user_identities_path(user) + [true, false].each do |vue_admin_users| + context "with vue_admin_users feature flag set to #{vue_admin_users}", js: vue_admin_users do + before do + stub_feature_flags(vue_admin_users: vue_admin_users) + end - click_link 'Delete' + describe 'GET /admin/users' do + context 'user pending approval' do + it 'shows user info', :aggregate_failures do + user = create(:user, :blocked_pending_approval) - expect(page).to have_content(user.name) - expect(page).not_to have_content('twitter') + visit admin_users_path + click_link 'Pending approval' + click_link user.name + + expect(page).to have_content(user.name) + expect(page).to have_content('Pending approval') + expect(page).to have_link('Approve user') + expect(page).to have_link('Reject request') + end + end + end end end end |