Fix tests

This commit is contained in:
Angelina Filippova 2020-08-23 19:37:40 +03:00
parent d8b3e9e9df
commit 2a42c5ed6b

View file

@ -70,7 +70,7 @@ describe('Search and filter users', () => {
describe('Users actions', () => {
let store
const htmlElement = (trChild, liChild) =>
`.el-table__fixed-body-wrapper table tr:nth-child(${trChild}) ul.el-dropdown-menu li:nth-child(${liChild})`
`.el-table__fixed-body-wrapper table tr:nth-child(${trChild}) ul.el-dropdown-menu > li:nth-child(${liChild})`
beforeEach(() => {
store = new Vuex.Store(cloneDeep(storeConfig))
@ -88,7 +88,7 @@ describe('Users actions', () => {
const user = store.state.users.fetchedUsers[2]
expect(user.roles.admin).toBe(false)
expect(user.roles.moderator).toBe(false)
wrapper.find(htmlElement(3, 1)).trigger('click')
wrapper.find(htmlElement(3, 2)).trigger('click')
const updatedUser = store.state.users.fetchedUsers[2]
expect(updatedUser.roles.admin).toBe(true)
@ -107,7 +107,7 @@ describe('Users actions', () => {
const user = store.state.users.fetchedUsers[2]
expect(user.roles.admin).toBe(false)
expect(user.roles.moderator).toBe(false)
wrapper.find(htmlElement(3, 2)).trigger('click')
wrapper.find(htmlElement(3, 3)).trigger('click')
const updatedUser = store.state.users.fetchedUsers[2]
expect(updatedUser.roles.moderator).toBe(true)
@ -124,9 +124,9 @@ 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(2) ul.el-dropdown-menu > li`
)
expect(dropdownMenuItems.length).toBe(6)
expect(dropdownMenuItems.length).toBe(7)
done()
})
@ -141,7 +141,7 @@ describe('Users actions', () => {
const user = store.state.users.fetchedUsers[1]
expect(user.deactivated).toBe(false)
wrapper.find(htmlElement(2, 1)).trigger('click')
wrapper.find(htmlElement(2, 2)).trigger('click')
const updatedUser = store.state.users.fetchedUsers[1]
expect(updatedUser.deactivated).toBe(true)
@ -158,7 +158,7 @@ describe('Users actions', () => {
await flushPromises()
expect(store.state.users.fetchedUsers[1].deactivated).toBe(false)
wrapper.find(htmlElement(2, 2)).trigger('click')
wrapper.find(htmlElement(2, 3)).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()
@ -180,8 +180,8 @@ describe('Users actions', () => {
expect(user1.tags.length).toBe(0)
expect(user2.tags.length).toBe(1)
wrapper.find(htmlElement(1, 5)).trigger('click')
wrapper.find(htmlElement(2, 5)).trigger('click')
wrapper.find(htmlElement(1, 6)).trigger('click')
wrapper.find(htmlElement(2, 6)).trigger('click')
const updatedUser1 = store.state.users.fetchedUsers[0]
const updatedUser2 = store.state.users.fetchedUsers[1]
@ -201,7 +201,7 @@ describe('Users actions', () => {
const user = store.state.users.fetchedUsers[1]
expect(user.tags.length).toBe(1)
wrapper.find(htmlElement(2, 6)).trigger('click')
wrapper.find(htmlElement(2, 7)).trigger('click')
const updatedUser = store.state.users.fetchedUsers[1]
expect(updatedUser.tags.length).toBe(0)
@ -247,7 +247,7 @@ describe('Users actions', () => {
expect(wrapper.vm.resetPasswordDialogOpen).toBe(false)
expect(store.state.users.passwordResetToken.token).toBe('')
wrapper.find(htmlElement(1, 11)).trigger('click')
wrapper.find(htmlElement(1, 12)).trigger('click')
await flushPromises()
expect(wrapper.vm.resetPasswordDialogOpen).toBe(true)