forked from AkkomaGang/admin-fe
Merge branch 'fix/delete-user' into 'master'
Remove deleted users See merge request pleroma/admin-fe!26
This commit is contained in:
commit
af610f4669
3 changed files with 9 additions and 25 deletions
|
@ -68,17 +68,15 @@ const users = {
|
|||
await createNewAccount(nickname, email, password, getters.authHost, getters.token)
|
||||
dispatch('FetchUsers', { page: state.currentPage })
|
||||
},
|
||||
async DeleteUser({ commit, getters }, user) {
|
||||
await deleteUser(user.nickname, getters.authHost, getters.token)
|
||||
const updatedUser = { ...user, deactivated: true }
|
||||
commit('SWAP_USER', updatedUser)
|
||||
async DeleteUser({ commit, dispatch, getters, state }, user) {
|
||||
const { nickname } = await deleteUser(user.nickname, getters.authHost, getters.token)
|
||||
const users = state.fetchedUsers.filter(user => user.nickname !== nickname)
|
||||
commit('SET_USERS', users)
|
||||
},
|
||||
async FetchUsers({ commit, state, getters }, { page }) {
|
||||
commit('SET_LOADING', true)
|
||||
|
||||
const filters = Object.keys(state.filters).filter(filter => state.filters[filter]).join()
|
||||
const response = await fetchUsers(filters, getters.authHost, getters.token, page)
|
||||
|
||||
loadUsers(commit, page, response.data)
|
||||
},
|
||||
async RemoveTag({ commit, getters }, { users, tag }) {
|
||||
|
|
|
@ -129,22 +129,18 @@ describe('Users actions', () => {
|
|||
done()
|
||||
})
|
||||
|
||||
it('deactivates user when Delete action is called', async (done) => {
|
||||
it('deletes user', async (done) => {
|
||||
const wrapper = mount(Users, {
|
||||
store,
|
||||
localVue,
|
||||
sync: false
|
||||
})
|
||||
await flushPromises()
|
||||
|
||||
const user = store.state.users.fetchedUsers[1]
|
||||
expect(user.deactivated).toBe(false)
|
||||
expect(store.state.users.fetchedUsers.length).toEqual(3)
|
||||
|
||||
wrapper.find(htmlElement(2, 2)).trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
const updatedUser = store.state.users.fetchedUsers[1]
|
||||
expect(updatedUser.deactivated).toBe(true)
|
||||
expect(store.state.users.fetchedUsers.length).toEqual(2)
|
||||
done()
|
||||
})
|
||||
|
||||
|
|
|
@ -229,21 +229,11 @@ describe('Apply users actions to multiple users', () => {
|
|||
expect(wrapper.vm.deleteMultipleUsers).toHaveBeenCalled()
|
||||
|
||||
const remove = wrapper.vm.mappers().remove
|
||||
const user1 = store.state.users.fetchedUsers[0]
|
||||
const user2 = store.state.users.fetchedUsers[1]
|
||||
const user3 = store.state.users.fetchedUsers[2]
|
||||
expect(user1.deactivated).toBe(false)
|
||||
expect(user2.deactivated).toBe(false)
|
||||
expect(user3.deactivated).toBe(true)
|
||||
expect(store.state.users.fetchedUsers.length).toEqual(3)
|
||||
remove()
|
||||
await flushPromises()
|
||||
|
||||
const updatedUser1 = store.state.users.fetchedUsers[0]
|
||||
const updatedUser2 = store.state.users.fetchedUsers[1]
|
||||
const updatedUser3 = store.state.users.fetchedUsers[2]
|
||||
expect(updatedUser1.deactivated).toBe(true)
|
||||
expect(updatedUser2.deactivated).toBe(true)
|
||||
expect(updatedUser3.deactivated).toBe(true)
|
||||
expect(store.state.users.fetchedUsers.length).toEqual(0)
|
||||
done()
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue