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
174efc30
Commit
174efc30
authored
5 years ago
by
Angelina Filippova
Browse files
Options
Downloads
Patches
Plain Diff
First green test for users filters
parent
977e49f5
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
+1
-1
1 addition, 1 deletion
src/api/__mocks__/users.js
test/views/users/usersFilters.test.js
+92
-0
92 additions, 0 deletions
test/views/users/usersFilters.test.js
with
93 additions
and
1 deletion
src/api/__mocks__/users.js
+
1
−
1
View file @
174efc30
...
...
@@ -9,7 +9,7 @@ const filterUsers = (str) => {
if
(
filters
.
length
===
0
)
{
return
users
}
return
filters
.
reduce
((
filter
,
acc
)
=>
{
return
filters
.
reduce
((
acc
,
filter
)
=>
{
const
filteredUsers
=
users
.
filter
(
user
=>
user
[
filter
])
return
[...
acc
,
...
filteredUsers
]
},
[])
...
...
This diff is collapsed.
Click to expand it.
test/views/users/usersFilters.test.js
0 → 100644
+
92
−
0
View file @
174efc30
import
Vuex
from
'
vuex
'
import
{
mount
,
createLocalVue
,
config
}
from
'
@vue/test-utils
'
import
Element
from
'
element-ui
'
import
Filters
from
'
@/views/users/components/UsersFilter
'
import
storeConfig
from
'
./store.conf
'
import
{
cloneDeep
}
from
'
lodash
'
import
flushPromises
from
'
flush-promises
'
config
.
mocks
[
"
$t
"
]
=
()
=>
{}
const
localVue
=
createLocalVue
()
localVue
.
use
(
Vuex
)
localVue
.
use
(
Element
)
jest
.
mock
(
'
@/api/users
'
)
describe
(
'
Filters users
'
,
()
=>
{
let
store
beforeEach
(
async
()
=>
{
store
=
new
Vuex
.
Store
(
cloneDeep
(
storeConfig
))
store
.
dispatch
(
'
FetchUsers
'
,
{
page
:
1
})
await
flushPromises
()
})
it
(
'
shows local users on "Local" filter click
'
,
async
(
done
)
=>
{
const
wrapper
=
mount
(
Filters
,
{
store
,
localVue
,
stubs
:
{
transition
:
false
}
})
let
usersLength
=
store
.
state
.
users
.
totalUsersCount
expect
(
usersLength
).
toEqual
(
3
)
const
filter
=
wrapper
.
find
(
`li.el-select-dropdown__item:nth-child(
${
1
}
)`
)
filter
.
trigger
(
'
click
'
)
await
wrapper
.
vm
.
$nextTick
()
usersLength
=
store
.
state
.
users
.
totalUsersCount
expect
(
usersLength
).
toEqual
(
2
)
filter
.
trigger
(
'
click
'
)
await
wrapper
.
vm
.
$nextTick
()
usersLength
=
store
.
state
.
users
.
totalUsersCount
expect
(
usersLength
).
toEqual
(
2
)
done
()
})
// it('shows local users with search query', async (done) => {
// const wrapper = mount(Users, {
// store,
// localVue,
// stubs: ['users-filter']
// })
// wrapper.vm.handleDebounceSearchInput = (query) => {
// store.dispatch('SearchUsers', { query, page: 1 })
// }
// await wrapper.vm.$nextTick()
// expect(wrapper.vm.usersCount).toEqual(3)
// const checkboxInput = wrapper.find('input.el-checkbox__original')
// checkboxInput.trigger('click')
// await wrapper.vm.$nextTick()
// const searchInput = wrapper.find('input.el-input__inner')
// searchInput.element.value = 'bob'
// searchInput.trigger('input')
// await wrapper.vm.$nextTick()
// expect(wrapper.vm.usersCount).toEqual(0)
// searchInput.element.value = 'allis'
// searchInput.trigger('input')
// await wrapper.vm.$nextTick()
// expect(wrapper.vm.usersCount).toEqual(1)
// searchInput.element.value = ''
// searchInput.trigger('input')
// await wrapper.vm.$nextTick()
// expect(wrapper.vm.usersCount).toEqual(2)
// checkboxInput.trigger('click')
// await wrapper.vm.$nextTick()
// expect(wrapper.vm.usersCount).toEqual(3)
// done()
// })
})
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