Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
admin-fe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pleroma
admin-fe
Commits
9c8dd067
Commit
9c8dd067
authored
5 years ago
by
Angelina Filippova
Browse files
Options
Downloads
Patches
Plain Diff
Fix fetching and searching tests for users
parent
46f53b24
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!11
Add ability to read reports
,
!10
Add more users filters
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/api/__mocks__/users.js
+18
-7
18 additions, 7 deletions
src/api/__mocks__/users.js
test/views/users/index.test.js
+52
-13
52 additions, 13 deletions
test/views/users/index.test.js
with
70 additions
and
20 deletions
src/api/__mocks__/users.js
+
18
−
7
View file @
9c8dd067
const
users
=
[
{
deactivated
:
false
,
id
:
'
2
'
,
nickname
:
'
allis
'
,
local
:
true
,
roles
:
{
admin
:
true
,
moderator
:
false
},
tags
:
[]
},
{
deactivated
:
false
,
id
:
'
10
'
,
nickname
:
'
bob
'
,
local
:
false
,
roles
:
{
admin
:
false
,
moderator
:
true
},
tags
:
[
'
sandbox
'
]
},
{
deactivated
:
true
,
id
:
'
abc
'
,
nickname
:
'
john
'
,
local
:
true
,
roles
:
{
admin
:
false
,
moderator
:
false
},
tags
:
[
'
strip_media
'
]
}
{
active
:
true
,
deactivated
:
false
,
id
:
'
2
'
,
nickname
:
'
allis
'
,
local
:
true
,
external
:
false
,
roles
:
{
admin
:
true
,
moderator
:
false
},
tags
:
[]
},
{
active
:
true
,
deactivated
:
false
,
id
:
'
10
'
,
nickname
:
'
bob
'
,
local
:
false
,
external
:
true
,
roles
:
{
admin
:
false
,
moderator
:
true
},
tags
:
[
'
sandbox
'
]
},
{
active
:
false
,
deactivated
:
true
,
id
:
'
abc
'
,
nickname
:
'
john
'
,
local
:
true
,
external
:
false
,
roles
:
{
admin
:
false
,
moderator
:
false
},
tags
:
[
'
strip_media
'
]
}
]
export
async
function
fetchUsers
(
showLocalUsersOnly
,
authHost
,
token
,
page
=
1
)
{
const
filteredUsers
=
showLocalUsersOnly
?
users
.
filter
(
user
=>
user
.
local
)
:
users
const
filterUsers
=
(
str
)
=>
{
const
filters
=
str
.
split
(
'
,
'
).
filter
(
item
=>
item
.
length
>
0
)
if
(
filters
.
length
===
0
)
{
return
users
}
return
filters
.
reduce
((
filter
,
acc
)
=>
{
const
filteredUsers
=
users
.
filter
(
user
=>
user
[
filter
])
return
[...
acc
,
...
filteredUsers
]
},
[])
}
export
async
function
fetchUsers
(
filters
,
authHost
,
token
,
page
=
1
)
{
const
filteredUsers
=
filterUsers
(
filters
)
return
Promise
.
resolve
({
data
:
{
users
:
filteredUsers
,
count
:
filteredUsers
.
length
,
...
...
@@ -18,8 +29,8 @@ export async function toggleUserActivation(nickname, authHost, token) {
return
Promise
.
resolve
({
data
:
{
...
response
,
deactivated
:
!
response
.
deactivated
}})
}
export
async
function
searchUsers
(
query
,
showLocalUsersOnly
,
authHost
,
token
,
page
=
1
)
{
const
filteredUsers
=
showLocalUsersOnly
?
u
sers
.
filter
(
user
=>
user
.
local
)
:
user
s
export
async
function
searchUsers
(
query
,
filters
,
authHost
,
token
,
page
=
1
)
{
const
filteredUsers
=
filterU
sers
(
filters
)
const
response
=
filteredUsers
.
filter
(
user
=>
user
.
nickname
===
query
)
return
Promise
.
resolve
({
data
:
{
users
:
response
,
...
...
This diff is collapsed.
Click to expand it.
test/views/users/index.test.js
+
52
−
13
View file @
9c8dd067
...
...
@@ -6,6 +6,9 @@ import storeConfig from './store.conf'
import
{
cloneDeep
}
from
'
lodash
'
config
.
mocks
[
"
$t
"
]
=
()
=>
{}
config
.
mocks
[
"
$i18n
"
]
=
{
t
:
()
=>
{}
}
const
localVue
=
createLocalVue
()
localVue
.
use
(
Vuex
)
...
...
@@ -23,7 +26,10 @@ describe('Search and filter users', () => {
it
(
'
fetches initial list of users
'
,
async
(
done
)
=>
{
const
wrapper
=
mount
(
Users
,
{
store
,
localVue
localVue
,
stubs
:
{
transition
:
false
}
})
await
wrapper
.
vm
.
$nextTick
()
...
...
@@ -34,7 +40,10 @@ describe('Search and filter users', () => {
it
(
'
starts a search on input change
'
,
async
(
done
)
=>
{
const
wrapper
=
mount
(
Users
,
{
store
,
localVue
localVue
,
stubs
:
{
transition
:
false
}
})
wrapper
.
vm
.
handleDebounceSearchInput
=
(
query
)
=>
{
...
...
@@ -44,7 +53,7 @@ describe('Search and filter users', () => {
await
wrapper
.
vm
.
$nextTick
()
expect
(
wrapper
.
vm
.
usersCount
).
toEqual
(
3
)
const
input
=
wrapper
.
find
(
'
input.el-input__inner
'
)
const
input
=
wrapper
.
find
(
'
.search
input.el-input__inner
'
)
input
.
element
.
value
=
'
bob
'
input
.
trigger
(
'
input
'
)
await
wrapper
.
vm
.
$nextTick
()
...
...
@@ -61,7 +70,10 @@ describe('Search and filter users', () => {
it
(
'
shows local users on checkbox click
'
,
async
(
done
)
=>
{
const
wrapper
=
mount
(
Users
,
{
store
,
localVue
localVue
,
stubs
:
{
transition
:
false
}
})
await
wrapper
.
vm
.
$nextTick
()
...
...
@@ -82,7 +94,10 @@ describe('Search and filter users', () => {
it
(
'
shows local users with search query
'
,
async
(
done
)
=>
{
const
wrapper
=
mount
(
Users
,
{
store
,
localVue
localVue
,
stubs
:
{
transition
:
false
}
})
wrapper
.
vm
.
handleDebounceSearchInput
=
(
query
)
=>
{
...
...
@@ -131,7 +146,10 @@ describe('Users actions', () => {
it
(
'
grants admin and moderator rights to a local user
'
,
async
(
done
)
=>
{
const
wrapper
=
mount
(
Users
,
{
store
,
localVue
localVue
,
stubs
:
{
transition
:
false
}
})
await
wrapper
.
vm
.
$nextTick
()
...
...
@@ -153,7 +171,10 @@ describe('Users actions', () => {
it
(
'
does not show actions that grant admin and moderator rights to external users
'
,
async
(
done
)
=>
{
const
wrapper
=
mount
(
Users
,
{
store
,
localVue
localVue
,
stubs
:
{
transition
:
false
}
})
await
wrapper
.
vm
.
$nextTick
()
...
...
@@ -167,7 +188,10 @@ describe('Users actions', () => {
it
(
'
toggles activation status
'
,
async
(
done
)
=>
{
const
wrapper
=
mount
(
Users
,
{
store
,
localVue
localVue
,
stubs
:
{
transition
:
false
}
})
await
wrapper
.
vm
.
$nextTick
()
...
...
@@ -185,7 +209,10 @@ describe('Users actions', () => {
it
(
'
deactivates user when Delete action is called
'
,
async
(
done
)
=>
{
const
wrapper
=
mount
(
Users
,
{
store
,
localVue
localVue
,
stubs
:
{
transition
:
false
}
})
await
wrapper
.
vm
.
$nextTick
()
...
...
@@ -203,7 +230,10 @@ describe('Users actions', () => {
it
(
'
adds tags
'
,
async
(
done
)
=>
{
const
wrapper
=
mount
(
Users
,
{
store
,
localVue
localVue
,
stubs
:
{
transition
:
false
}
})
await
wrapper
.
vm
.
$nextTick
()
...
...
@@ -227,7 +257,10 @@ describe('Users actions', () => {
it
(
'
deletes tags
'
,
async
(
done
)
=>
{
const
wrapper
=
mount
(
Users
,
{
store
,
localVue
localVue
,
stubs
:
{
transition
:
false
}
})
await
wrapper
.
vm
.
$nextTick
()
...
...
@@ -245,7 +278,10 @@ describe('Users actions', () => {
it
(
'
shows check icon when tag is added
'
,
async
(
done
)
=>
{
const
wrapper
=
mount
(
Users
,
{
store
,
localVue
localVue
,
stubs
:
{
transition
:
false
}
})
await
wrapper
.
vm
.
$nextTick
()
...
...
@@ -261,7 +297,10 @@ describe('Users actions', () => {
it
(
'
does not change user index in array when tag is added
'
,
async
(
done
)
=>
{
const
wrapper
=
mount
(
Users
,
{
store
,
localVue
localVue
,
stubs
:
{
transition
:
false
}
})
await
wrapper
.
vm
.
$nextTick
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment