Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e18c629a
Commit
e18c629a
authored
May 03, 2021
by
Jiaan Louw
Committed by
Nicolò Maria Mezzopera
May 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert admin/users view - update specs for feature flag rollout
parent
668fc6a8
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
531 additions
and
484 deletions
+531
-484
app/assets/javascripts/admin/users/components/actions/unblock.vue
...ts/javascripts/admin/users/components/actions/unblock.vue
+1
-3
app/assets/javascripts/admin/users/components/user_actions.vue
...ssets/javascripts/admin/users/components/user_actions.vue
+2
-2
app/assets/javascripts/admin/users/components/users_table.vue
...assets/javascripts/admin/users/components/users_table.vue
+4
-0
app/views/admin/users/_user.html.haml
app/views/admin/users/_user.html.haml
+4
-4
ee/spec/features/admin/admin_users_spec.rb
ee/spec/features/admin/admin_users_spec.rb
+127
-120
spec/features/admin/users/user_spec.rb
spec/features/admin/users/user_spec.rb
+94
-83
spec/features/admin/users/users_spec.rb
spec/features/admin/users/users_spec.rb
+292
-267
spec/frontend/admin/users/components/user_actions_spec.js
spec/frontend/admin/users/components/user_actions_spec.js
+7
-5
No files found.
app/assets/javascripts/admin/users/components/actions/unblock.vue
View file @
e18c629a
...
...
@@ -23,9 +23,7 @@ export default {
'
data-method
'
:
'
put
'
,
'
data-modal-attributes
'
:
JSON
.
stringify
({
title
:
sprintf
(
s__
(
'
AdminUsers|Unblock user %{username}?
'
),
{
username
:
this
.
username
}),
message
:
s__
(
'
AdminUsers|You can always unblock their account, their data will remain intact.
'
,
),
message
:
s__
(
'
AdminUsers|You can always block their account again if needed.
'
),
okVariant
:
'
confirm
'
,
okTitle
:
s__
(
'
AdminUsers|Unblock
'
),
}),
...
...
app/assets/javascripts/admin/users/components/user_actions.vue
View file @
e18c629a
...
...
@@ -70,14 +70,14 @@ export default {
</
script
>
<
template
>
<div
class=
"gl-display-flex gl-justify-content-end"
>
<div
class=
"gl-display-flex gl-justify-content-end"
:data-testid=
"`user-actions-$
{user.id}`"
>
<gl-button
v-if=
"hasEditAction"
data-testid=
"edit"
:href=
"userPaths.edit"
>
{{
$options
.
i18n
.
edit
}}
</gl-button>
<gl-dropdown
v-if=
"hasDropdownActions"
data-testid=
"
actions
"
data-testid=
"
dropdown-toggle
"
right
class=
"gl-ml-2"
icon=
"settings"
...
...
app/assets/javascripts/admin/users/components/users_table.vue
View file @
e18c629a
...
...
@@ -77,6 +77,10 @@ export default {
<user-date
:date=
"lastActivityOn"
show-never
/>
</
template
>
<
template
#cell(projectsCount)=
"{ item: { id, projectsCount } }"
>
<div
:data-testid=
"`user-project-count-$
{id}`">
{{
projectsCount
}}
</div>
</
template
>
<
template
#cell(settings)=
"{ item: user }"
>
<user-actions
:user=
"user"
:paths=
"paths"
/>
</
template
>
...
...
app/views/admin/users/_user.html.haml
View file @
e18c629a
...
...
@@ -21,13 +21,13 @@
=
user
.
last_activity_on
.
nil?
?
_
(
'Never'
)
:
l
(
user
.
last_activity_on
,
format: :admin
)
-
unless
user
.
internal?
.table-section.section-20.table-button-footer
.table-action-buttons
=
link_to
_
(
'Edit'
),
edit_admin_user_path
(
user
),
id:
"edit_
#{
dom_id
(
user
)
}
"
,
class:
'btn gl-button btn-default'
.table-action-buttons
{
data:
{
testid:
"user-actions-#{user.id}"
}
}
=
link_to
_
(
'Edit'
),
edit_admin_user_path
(
user
),
class:
'btn gl-button btn-default'
-
unless
user
==
current_user
%button
.dropdown-new.btn.gl-button.btn-default
{
type:
'button'
,
data:
{
testid:
"
user-action-button-#{user.id}
"
,
toggle:
'dropdown'
}
}
%button
.dropdown-new.btn.gl-button.btn-default
{
type:
'button'
,
data:
{
testid:
"
dropdown-toggle
"
,
toggle:
'dropdown'
}
}
=
sprite_icon
(
'settings'
)
=
sprite_icon
(
'chevron-down'
)
%ul
.dropdown-menu.dropdown-menu-right
{
data:
{
testid:
"user-action-dropdown-#{user.id}"
}
}
%ul
.dropdown-menu.dropdown-menu-right
%li
.dropdown-header
=
_
(
'Settings'
)
%li
...
...
ee/spec/features/admin/admin_users_spec.rb
View file @
e18c629a
...
...
@@ -3,20 +3,20 @@
require
'spec_helper'
RSpec
.
describe
"Admin::Users"
do
include
Spec
::
Support
::
Helpers
::
Features
::
ResponsiveTableHelpers
let!
(
:user
)
do
create
(
:omniauth_user
,
provider:
'twitter'
,
extern_uid:
'123456'
)
end
let!
(
:current_user
)
{
create
(
:admin
,
last_activity_on:
5
.
days
.
ago
)
}
let_it_be
(
:user
)
{
create
(
:omniauth_user
,
provider:
'twitter'
,
extern_uid:
'123456'
)
}
let_it_be
(
:current_user
)
{
create
(
:admin
)
}
before
do
stub_feature_flags
(
vue_admin_users:
false
)
sign_in
(
current_user
)
gitlab_enable_admin_mode_sign_in
(
current_user
)
end
[
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
describe
'GET /admin/users'
do
describe
'send emails to users'
do
context
'when `send_emails_from_admin_area` feature is enabled'
do
...
...
@@ -108,13 +108,10 @@ RSpec.describe "Admin::Users" do
end
describe
"GET /admin/users/:id/edit"
do
before
do
visit
admin_users_path
click_link
"edit_user_
#{
user
.
id
}
"
end
describe
"Update user account type"
do
before
do
visit_edit_user
(
user
.
id
)
allow_any_instance_of
(
AuditorUserHelper
).
to
receive
(
:license_allows_auditor_user?
).
and_return
(
true
)
choose
"user_access_level_auditor"
click_button
"Save changes"
...
...
@@ -129,25 +126,33 @@ RSpec.describe "Admin::Users" do
end
describe
'Update shared runners quota'
do
let!
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
,
shared_runners_enabled:
true
)
}
let_it_be
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
,
shared_runners_enabled:
true
)
}
before
do
it
"shows page with new data"
do
visit_edit_user
(
user
.
id
)
fill_in
"user_namespace_attributes_shared_runners_minutes_limit"
,
with:
"500"
click_button
"Save changes"
end
it
"shows page with new data"
do
expect
(
page
).
to
have_content
(
'Pipeline minutes quota: 0 / 500'
)
end
end
def
visit_edit_user
(
user_id
)
visit
admin_users_path
page
.
within
(
"[data-testid='user-actions-
#{
user_id
}
']"
)
do
click_link
'Edit'
end
end
end
describe
'show user keys for SSH and LDAP'
do
let!
(
:key1
)
do
let_it_be
(
:key1
)
do
create
(
:ldap_key
,
user:
user
,
title:
"LDAP Key1"
)
end
let!
(
:key2
)
do
let_it_be
(
:key2
)
do
create
(
:key
,
user:
user
,
title:
"ssh-rsa Key2"
,
key:
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4FIEBXGi4bPU8kzxMefudPIJ08/gNprdNTaO9BR/ndy3+58s2HCTw2xCHcsuBmq+TsAqgEidVq4skpqoTMB+Uot5Uzp9z4764rc48dZiI661izoREoKnuRQSsRqUTHg5wrLzwxlQbl1MVfRWQpqiz/5KjBC7yLEb9AbusjnWBk8wvC1bQPQ1uLAauEA7d836tgaIsym9BrLsMVnR4P1boWD3Xp1B1T/ImJwAGHvRmP/ycIqmKdSpMdJXwxcb40efWVj0Ibbe7ii9eeoLdHACqevUZi6fwfbymdow+FeqlkPoHyGg3Cu4vD/D8+8cRc7mE/zGCWcQ15Var83Tczour Key2"
)
end
...
...
@@ -172,4 +177,6 @@ RSpec.describe "Admin::Users" do
end
end
end
end
end
end
spec/features/admin/users/user_spec.rb
View file @
e18c629a
...
...
@@ -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,21 +263,37 @@ RSpec.describe 'Admin::Users::User' do
expect
(
page
).
to
have_content
(
"
#{
secondary_email
.
email
}
Verified"
)
end
end
describe
'show user identities'
do
it
'shows user identities'
,
:aggregate_failures
do
visit
admin_user_identities_path
(
user
)
expect
(
page
).
to
have_content
(
user
.
name
)
expect
(
page
).
to
have_content
(
'twitter'
)
end
end
describe
'update user identities'
do
before
do
allow
(
Gitlab
::
Auth
::
OAuth
::
Provider
).
to
receive
(
:providers
).
and_return
([
:twitter
,
:twitter_updated
])
end
describe
'show user attributes'
do
it
'has expected attributes'
,
:aggregate_failures
do
visit
admin_users_path
it
'modifies twitter identity'
,
:aggregate_failures
do
visit
admin_user_identities_path
(
user
)
click_link
user
.
name
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
'Account'
expect
(
page
).
to
have_content
'Personal projects limit'
expect
(
page
).
to
have_content
(
user
.
name
)
expect
(
page
).
to
have_content
(
'twitter_updated'
)
expect
(
page
).
to
have_content
(
'654321'
)
end
end
describe
'remove users secondary email'
,
:js
do
let!
(
:secondary_email
)
do
let_it_be
(
:secondary_email
)
do
create
:email
,
email:
'secondary@example.com'
,
user:
user
end
...
...
@@ -303,14 +308,24 @@ RSpec.describe 'Admin::Users::User' do
end
end
describe
'remove user with identities'
do
it
'removes user with twitter identity'
,
:aggregate_failures
do
visit
admin_user_identities_path
(
user
)
click_link
'Delete'
expect
(
page
).
to
have_content
(
user
.
name
)
expect
(
page
).
not_to
have_content
(
'twitter'
)
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'
)
visit
admin_users_path
visit
admin_user_path
(
user
)
click_link
user
.
name
click_link
'SSH keys'
expect
(
page
).
to
have_content
(
key1
.
title
)
...
...
@@ -331,42 +346,38 @@ RSpec.describe 'Admin::Users::User' do
end
end
describe
'show user identiti
es'
do
it
'shows user identiti
es'
,
:aggregate_failures
do
visit
admin_user_identities
_path
(
user
)
describe
'show user attribut
es'
do
it
'has expected attribut
es'
,
:aggregate_failures
do
visit
admin_user
_path
(
user
)
expect
(
page
).
to
have_content
(
user
.
name
)
expect
(
page
).
to
have_content
(
'twitter'
)
expect
(
page
).
to
have_content
'Account'
expect
(
page
).
to
have_content
'Personal projects limit'
end
end
end
describe
'update user identities'
do
[
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
allow
(
Gitlab
::
Auth
::
OAuth
::
Provider
).
to
receive
(
:providers
).
and_return
([
:twitter
,
:twitter_updated
]
)
stub_feature_flags
(
vue_admin_users:
vue_admin_users
)
end
it
'modifies twitter identity'
,
:aggregate_failures
do
visit
admin_user_identities_path
(
user
)
describe
'GET /admin/users'
do
context
'user pending approval'
do
it
'shows user info'
,
:aggregate_failures
do
user
=
create
(
:user
,
:blocked_pending_approval
)
find
(
'.table'
).
find
(
:link
,
'Edit'
).
click
fill_in
'identity_extern_uid'
,
with:
'654321'
select
'twitter_updated'
,
from:
'identity_provider'
click_button
'Save changes'
visit
admin_users_path
click_link
'Pending approval'
click_link
user
.
name
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
(
'Pending approval'
)
expect
(
page
).
to
have_link
(
'Approve user'
)
expect
(
page
).
to
have_link
(
'Reject request'
)
end
end
end
describe
'remove user with identities'
do
it
'removes user with twitter identity'
,
:aggregate_failures
do
visit
admin_user_identities_path
(
user
)
click_link
'Delete'
expect
(
page
).
to
have_content
(
user
.
name
)
expect
(
page
).
not_to
have_content
(
'twitter'
)
end
end
end
spec/features/admin/users/users_spec.rb
View file @
e18c629a
...
...
@@ -3,19 +3,22 @@
require
'spec_helper'
RSpec
.
describe
'Admin::Users'
do
include
Spec
::
Support
::
Helpers
::
Features
::
ResponsiveTableHelpers
let_it_be
(
:user
,
reload:
true
)
{
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
)
end
[
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
describe
'GET /admin/users'
do
before
do
stub_feature_flags
(
vue_admin_users:
false
)
visit
admin_users_path
end
...
...
@@ -24,19 +27,32 @@ RSpec.describe 'Admin::Users' do
end
it
"has users list"
do
current_user
.
reload
expect
(
page
).
to
have_content
(
current_user
.
email
)
expect
(
page
).
to
have_content
(
current_user
.
name
)
expect
(
page
).
to
have_content
(
current_user
.
created_at
.
strftime
(
'%e %b, %Y'
))
expect
(
page
).
to
have_content
(
current_user
.
last_activity_on
.
strftime
(
'%e %b, %Y'
))
expect
(
page
).
to
have_content
(
user
.
email
)
expect
(
page
).
to
have_content
(
user
.
name
)
expect
(
page
).
to
have_content
(
'Projects'
)
click_user_dropdown_toggle
(
user
.
id
)
expect
(
page
).
to
have_button
(
'Block'
)
expect
(
page
).
to
have_button
(
'Deactivate'
)
expect
(
page
).
to
have_button
(
'Delete user'
)
expect
(
page
).
to
have_button
(
'Delete user and contributions'
)
end
it
'clicking edit user takes us to edit page'
,
:aggregate_failures
do
page
.
within
(
"[data-testid='user-actions-
#{
user
.
id
}
']"
)
do
click_link
'Edit'
end
expect
(
page
).
to
have_content
(
'Name'
)
expect
(
page
).
to
have_content
(
'Password'
)
end
describe
'view extra user information'
do
it
'shows the user popover on hover'
,
:js
,
quarantine:
'https://gitlab.com/gitlab-org/gitlab/-/issues/11290'
do
expect
(
page
).
not_to
have_selector
(
'#__BV_popover_1__'
)
...
...
@@ -112,7 +128,6 @@ RSpec.describe 'Admin::Users' do
visit
admin_users_path
(
search_query:
'Foo'
)
sort_by
(
'Name'
)
expect
(
page
).
not_to
have_content
(
'Dmitriy'
)
expect
(
first_row
.
text
).
to
include
(
'Foo Bar'
)
expect
(
second_row
.
text
).
to
include
(
'Foo Baz'
)
...
...
@@ -281,20 +296,12 @@ RSpec.describe 'Admin::Users' do
expect
(
page
).
not_to
have_content
(
user
.
email
)
end
end
def
click_action_in_user_dropdown
(
user_id
,
action
)
find
(
"[data-testid='user-action-button-
#{
user_id
}
']"
).
click
within
find
(
"[data-testid='user-action-dropdown-
#{
user_id
}
']"
)
do
find
(
'li button'
,
text:
action
).
click
end
wait_for_requests
end
end
describe
'GET /admin/users/new'
do
let
(
:user_username
)
{
'bang'
}
let
_it_be
(
:user_username
)
{
'bang'
}
before
do
visit
new_admin_user_path
...
...
@@ -344,7 +351,7 @@ RSpec.describe 'Admin::Users' do
end
context
'username contains spaces'
do
let
(
:user_username
)
{
'Bing bang'
}
let
_it_be
(
:user_username
)
{
'Bing bang'
}
it
"doesn't create the user and shows an error message"
do
expect
{
click_button
'Create user'
}.
to
change
{
User
.
count
}.
by
(
0
)
...
...
@@ -363,22 +370,6 @@ RSpec.describe 'Admin::Users' do
visit
new_admin_user_path
end
def
expects_external_to_be_checked
expect
(
find
(
'#user_external'
)).
to
be_checked
end
def
expects_external_to_be_unchecked
expect
(
find
(
'#user_external'
)).
not_to
be_checked
end
def
expects_warning_to_be_hidden
expect
(
find
(
'#warning_external_automatically_set'
,
visible: :all
)[
:class
]).
to
include
'hidden'
end
def
expects_warning_to_be_shown
expect
(
find
(
'#warning_external_automatically_set'
)[
:class
]).
not_to
include
'hidden'
end
it
'automatically unchecks external for matching email'
do
expects_external_to_be_checked
expects_warning_to_be_hidden
...
...
@@ -413,55 +404,22 @@ RSpec.describe 'Admin::Users' do
expect
(
new_user
.
external
).
to
be_falsy
end
end
end
end
describe
'GET /admin/users/:id/edit'
do
before
do
stub_feature_flags
(
vue_admin_users:
false
)
visit
admin_users_path
click_link
"edit_user_
#{
user
.
id
}
"
end
it
'has user edit page'
do
expect
(
page
).
to
have_content
(
'Name'
)
expect
(
page
).
to
have_content
(
'Password'
)
end
describe
'Update user'
do
before
do
fill_in
'user_name'
,
with:
'Big Bang'
fill_in
'user_email'
,
with:
'bigbang@mail.com'
fill_in
'user_password'
,
with:
'AValidPassword1'
fill_in
'user_password_confirmation'
,
with:
'AValidPassword1'
choose
'user_access_level_admin'
click_button
'Save changes'
def
expects_external_to_be_checked
expect
(
find
(
'#user_external'
)).
to
be_checked
end
it
'shows page with new data'
do
expect
(
page
).
to
have_content
(
'bigbang@mail.com'
)
expect
(
page
).
to
have_content
(
'Big Bang'
)
def
expects_external_to_be_unchecked
expect
(
find
(
'#user_external'
)).
not_to
be_checked
end
it
'changes user entry'
do
user
.
reload
expect
(
user
.
name
).
to
eq
(
'Big Bang'
)
expect
(
user
.
admin?
).
to
be_truthy
expect
(
user
.
password_expires_at
).
to
be
<=
Time
.
now
end
def
expects_warning_to_be_hidden
expect
(
find
(
'#warning_external_automatically_set'
,
visible: :all
)[
:class
]).
to
include
'hidden'
end
describe
'update username to non ascii char'
do
it
do
fill_in
'user_username'
,
with:
'\u3042\u3044'
click_button
(
'Save'
)
page
.
within
'#error_explanation'
do
expect
(
page
).
to
have_content
(
'Username'
)
def
expects_warning_to_be_shown
expect
(
find
(
'#warning_external_automatically_set'
)[
:class
]).
not_to
include
'hidden'
end
expect
(
page
).
to
have_selector
(
%(form[action="/admin/users/#{user.username}"])
)
end
end
end
...
...
@@ -541,15 +499,82 @@ RSpec.describe 'Admin::Users' do
check_breadcrumb
(
'Edit Identity'
)
end
end
def
check_breadcrumb
(
content
)
expect
(
find
(
'.breadcrumbs-sub-title'
)).
to
have_content
(
content
)
end
end
describe
'GET /admin/users/:id/edit'
do
before
do
visit
edit_admin_user_path
(
user
)
end
describe
'Update user'
do
before
do
fill_in
'user_name'
,
with:
'Big Bang'
fill_in
'user_email'
,
with:
'bigbang@mail.com'
fill_in
'user_password'
,
with:
'AValidPassword1'
fill_in
'user_password_confirmation'
,
with:
'AValidPassword1'
choose
'user_access_level_admin'
click_button
'Save changes'
end
it
'shows page with new data'
do
expect
(
page
).
to
have_content
(
'bigbang@mail.com'
)
expect
(
page
).
to
have_content
(
'Big Bang'
)
end
it
'changes user entry'
do
user
.
reload
expect
(
user
.
name
).
to
eq
(
'Big Bang'
)
expect
(
user
.
admin?
).
to
be_truthy
expect
(
user
.
password_expires_at
).
to
be
<=
Time
.
now
end
end
describe
'update username to non ascii char'
do
it
do
fill_in
'user_username'
,
with:
'\u3042\u3044'
click_button
(
'Save'
)
page
.
within
'#error_explanation'
do
expect
(
page
).
to
have_content
(
'Username'
)
end
def
sort_by
(
text
)
page
.
within
(
'.user-sort-dropdown'
)
do
click_link
text
expect
(
page
).
to
have_selector
(
%(form[action="/admin/users/#{user.username}"])
)
end
end
end
def
click_user_dropdown_toggle
(
user_id
)
page
.
within
(
"[data-testid='user-actions-
#{
user_id
}
']"
)
do
find
(
"[data-testid='dropdown-toggle']"
).
click
end
end
def
first_row
page
.
all
(
'[role="row"]'
)[
1
]
end
def
second_row
page
.
all
(
'[role="row"]'
)[
2
]
end
def
sort_by
(
option
)
page
.
within
(
'.filtered-search-block'
)
do
find
(
'.dropdown-menu-toggle'
).
click
click_link
option
end
end
def
click_action_in_user_dropdown
(
user_id
,
action
)
click_user_dropdown_toggle
(
user_id
)
within
find
(
"[data-testid='user-actions-
#{
user_id
}
']"
)
do
find
(
'li button'
,
text:
action
).
click
end
wait_for_requests
end
end
spec/frontend/admin/users/components/user_actions_spec.js
View file @
e18c629a
import
{
GlDropdownDivider
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
Extended
}
from
'
helpers/vue_test_utils_helper
'
;
import
Actions
from
'
~/admin/users/components/actions
'
;
import
AdminUserActions
from
'
~/admin/users/components/user_actions.vue
'
;
import
{
I18N_USER_ACTIONS
}
from
'
~/admin/users/constants
'
;
...
...
@@ -14,12 +14,14 @@ describe('AdminUserActions component', () => {
const
user
=
users
[
0
];
const
userPaths
=
generateUserPaths
(
paths
,
user
.
username
);
const
findEditButton
=
()
=>
wrapper
.
find
(
'
[data-testid="edit"]
'
);
const
findActionsDropdown
=
()
=>
wrapper
.
find
(
'
[data-testid="actions"
'
);
const
findDropdownDivider
=
()
=>
wrapper
.
find
(
GlDropdownDivider
);
const
findUserActions
=
(
id
)
=>
wrapper
.
findByTestId
(
`user-actions-
${
id
}
`
);
const
findEditButton
=
(
id
=
user
.
id
)
=>
findUserActions
(
id
).
find
(
'
[data-testid="edit"]
'
);
const
findActionsDropdown
=
(
id
=
user
.
id
)
=>
findUserActions
(
id
).
find
(
'
[data-testid="dropdown-toggle"]
'
);
const
findDropdownDivider
=
()
=>
wrapper
.
findComponent
(
GlDropdownDivider
);
const
initComponent
=
({
actions
=
[]
}
=
{})
=>
{
wrapper
=
shallowMount
(
AdminUserActions
,
{
wrapper
=
shallowMount
Extended
(
AdminUserActions
,
{
propsData
:
{
user
:
{
...
user
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment