Add two new mock users and fix tests

This commit is contained in:
Angelina Filippova 2020-10-24 00:31:38 +03:00
parent 697138d38b
commit cceed3045d
3 changed files with 32 additions and 30 deletions

View file

@ -2,9 +2,11 @@ import userChats from './chat'
export let users = [
{ active: true, approval_pending: false, deactivated: false, id: '2', nickname: 'allis', local: true, external: false, roles: { admin: true, moderator: false }, tags: [], actor_type: 'Person' },
{ active: true, approval_pending: false, deactivated: false, id: '10', nickname: 'bob', local: false, external: true, roles: { admin: false, moderator: false }, tags: ['mrf_tag:sandbox'], actor_type: 'Person' },
{ active: true, approval_pending: false, deactivated: false, id: '10', nickname: 'bob', local: true, external: false, roles: { admin: false, moderator: false }, tags: ['mrf_tag:sandbox'], actor_type: 'Person' },
{ active: true, approval_pending: true, deactivated: false, id: '567', nickname: 'ded', local: false, external: true, roles: { admin: false, moderator: false }, tags: [], actor_type: 'Person' },
{ active: false, approval_pending: false, deactivated: true, id: 'abc', nickname: 'john', local: true, external: false, roles: { admin: false, moderator: false }, tags: ['mrf_tag:media-strip'], actor_type: 'Person' },
{ active: true, approval_pending: true, deactivated: false, id: '100', nickname: 'sally', local: true, external: false, roles: { admin: false, moderator: false }, tags: [], actor_type: 'Service' }
{ active: true, approval_pending: true, deactivated: false, id: '100', nickname: 'sally', local: true, external: false, roles: { admin: false, moderator: false }, tags: [], actor_type: 'Service' },
{ active: true, approval_pending: true, deactivated: false, id: '123', nickname: 'bot', local: true, external: false, roles: { admin: false, moderator: false }, tags: [], actor_type: 'Application' }
]
const userProfile = { avatar: 'avatar.jpg', nickname: 'allis', id: '2', tags: [], roles: { admin: true, moderator: false }, local: true, external: false }

View file

@ -38,7 +38,7 @@ describe('Search and filter users', () => {
})
await flushPromises()
expect(wrapper.vm.usersCount).toEqual(4)
expect(wrapper.vm.usersCount).toEqual(6)
done()
})
@ -57,7 +57,7 @@ describe('Search and filter users', () => {
}
await flushPromises()
expect(wrapper.vm.usersCount).toEqual(4)
expect(wrapper.vm.usersCount).toEqual(6)
const input = wrapper.find('.search input.el-input__inner')
input.element.value = 'bob'
input.trigger('input')
@ -67,7 +67,7 @@ describe('Search and filter users', () => {
input.element.value = ''
input.trigger('input')
await flushPromises()
expect(wrapper.vm.usersCount).toEqual(4)
expect(wrapper.vm.usersCount).toEqual(6)
done()
})
@ -93,12 +93,12 @@ describe('Users actions', () => {
})
await flushPromises()
const user = store.state.users.fetchedUsers[2]
const user = store.state.users.fetchedUsers[1]
expect(user.roles.admin).toBe(false)
expect(user.roles.moderator).toBe(false)
wrapper.find(htmlElement(3, 2)).trigger('click')
wrapper.find(htmlElement(2, 2)).trigger('click')
const updatedUser = store.state.users.fetchedUsers[2]
const updatedUser = store.state.users.fetchedUsers[1]
expect(updatedUser.roles.admin).toBe(true)
done()
})
@ -114,12 +114,12 @@ describe('Users actions', () => {
})
await flushPromises()
const user = store.state.users.fetchedUsers[2]
expect(user.roles.admin).toBe(false)
const user = store.state.users.fetchedUsers[0]
expect(user.roles.admin).toBe(true)
expect(user.roles.moderator).toBe(false)
wrapper.find(htmlElement(3, 3)).trigger('click')
wrapper.find(htmlElement(1, 3)).trigger('click')
const updatedUser = store.state.users.fetchedUsers[2]
const updatedUser = store.state.users.fetchedUsers[0]
expect(updatedUser.roles.moderator).toBe(true)
done()
})
@ -136,7 +136,7 @@ describe('Users actions', () => {
await flushPromises()
const dropdownMenuItems = wrapper.findAll(
`.el-table__fixed-body-wrapper table tr:nth-child(2) ul.el-dropdown-menu > li`
`.el-table__fixed-body-wrapper table tr:nth-child(3) ul.el-dropdown-menu > li`
)
expect(dropdownMenuItems.length).toBe(3)
done()
@ -155,7 +155,7 @@ describe('Users actions', () => {
const user = store.state.users.fetchedUsers[1]
expect(user.deactivated).toBe(false)
wrapper.find(htmlElement(2, 2)).trigger('click')
wrapper.find(htmlElement(2, 4)).trigger('click')
const updatedUser = store.state.users.fetchedUsers[1]
expect(updatedUser.deactivated).toBe(true)
@ -174,7 +174,7 @@ describe('Users actions', () => {
await flushPromises()
expect(store.state.users.fetchedUsers[1].deactivated).toBe(false)
wrapper.find(htmlElement(2, 3)).trigger('click')
wrapper.find(htmlElement(2, 5)).trigger('click')
store.dispatch('DeleteUsers', { users: [{ active: true, deactivated: false, id: '10', nickname: 'bob', local: false, external: true, roles: { admin: false, moderator: false }, tags: ['mrf_tag:sandbox'] }] })
await flushPromises()
@ -221,7 +221,7 @@ describe('Users actions', () => {
const user = store.state.users.fetchedUsers[1]
expect(user.tags.length).toBe(1)
wrapper.find(htmlElement(2, 7)).trigger('click')
wrapper.find(htmlElement(2, 9)).trigger('click')
const updatedUser = store.state.users.fetchedUsers[1]
expect(updatedUser.tags.length).toBe(0)
@ -332,7 +332,7 @@ describe('Creates new account', () => {
}
})
await flushPromises()
expect(wrapper.vm.usersCount).toEqual(4)
expect(wrapper.vm.usersCount).toEqual(6)
const openDialogButton = wrapper.find('button.actions-button')
openDialogButton.trigger('click')
@ -354,7 +354,7 @@ describe('Creates new account', () => {
createButton.trigger('click')
await flushPromises()
expect(wrapper.vm.usersCount).toEqual(5)
expect(wrapper.vm.usersCount).toEqual(7)
done()
})

View file

@ -33,18 +33,18 @@ describe('Filters users', () => {
localVue
})
expect(store.state.users.totalUsersCount).toEqual(4)
expect(store.state.users.totalUsersCount).toEqual(6)
const filter = wrapper.find(`li.el-select-dropdown__item:nth-child(${1})`)
filter.trigger('click')
await flushPromises()
expect(store.state.users.totalUsersCount).toEqual(3)
expect(store.state.users.totalUsersCount).toEqual(5)
done()
})
it('shows users with applied filter and search query', async (done) => {
expect(store.state.users.totalUsersCount).toEqual(4)
expect(store.state.users.totalUsersCount).toEqual(6)
store.dispatch('ToggleUsersFilter', { active: true })
await flushPromises()
@ -58,17 +58,17 @@ describe('Filters users', () => {
store.dispatch('SearchUsers', { query: '', page: 1 })
await flushPromises()
expect(store.state.users.totalUsersCount).toEqual(3)
expect(store.state.users.totalUsersCount).toEqual(5)
done()
})
it('applies two filters', async (done) => {
expect(store.state.users.totalUsersCount).toEqual(4)
expect(store.state.users.totalUsersCount).toEqual(6)
store.dispatch('ToggleUsersFilter', { active: true, local: true })
await flushPromises()
expect(store.state.users.totalUsersCount).toEqual(2)
expect(store.state.users.totalUsersCount).toEqual(4)
expect(store.state.users.fetchedUsers[0].nickname).toEqual('allis')
store.dispatch('ToggleUsersFilter', { deactivated: true, external: true })
@ -79,7 +79,7 @@ describe('Filters users', () => {
})
it('shows all users after removing filters', async (done) => {
expect(store.state.users.totalUsersCount).toEqual(4)
expect(store.state.users.totalUsersCount).toEqual(6)
store.dispatch('ToggleUsersFilter', { deactivated: true })
await flushPromises()
@ -87,17 +87,17 @@ describe('Filters users', () => {
store.dispatch('ToggleUsersFilter', {})
await flushPromises()
expect(store.state.users.totalUsersCount).toEqual(4)
expect(store.state.users.totalUsersCount).toEqual(6)
done()
})
it('applies actor types filters', async (done) => {
expect(store.state.users.totalUsersCount).toEqual(4)
expect(store.state.users.totalUsersCount).toEqual(6)
store.dispatch('ToggleActorTypeFilter', ["Person"])
await flushPromises()
expect(store.state.users.totalUsersCount).toEqual(3)
expect(store.state.users.totalUsersCount).toEqual(4)
expect(store.state.users.fetchedUsers[0].nickname).toEqual('allis')
store.dispatch('ToggleActorTypeFilter', ["Service"])
@ -107,11 +107,11 @@ describe('Filters users', () => {
store.dispatch('ToggleActorTypeFilter', ["Person", "Service"])
await flushPromises()
expect(store.state.users.totalUsersCount).toEqual(4)
expect(store.state.users.totalUsersCount).toEqual(5)
store.dispatch('ToggleActorTypeFilter', ["Application"])
await flushPromises()
expect(store.state.users.totalUsersCount).toEqual(0)
expect(store.state.users.totalUsersCount).toEqual(1)
done()
})