In the user management, the account you are currently logged in as could be selected and included in a delete action, even though the backend always rejects self-deletion. Deleting a selection that included your own account produced a "Failed to delete 1 user" error and made your own row temporarily disappear from the list until the page was refreshed. The delete action now excludes the current user from the request, so all other selected users are deleted while your own account is left untouched. When your own account is part of the selection, the delete confirmation dialog shows a hint that it will not be deleted.
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import DeleteUserModal from '../../../../src/components/Users/DeleteUserModal.vue'
|
|
import { defaultComponentMocks, defaultPlugins, shallowMount } from '@ownclouders/web-test-helpers'
|
|
import { mock } from 'vitest-mock-extended'
|
|
import { User } from '@ownclouders/web-client/graph/generated'
|
|
import { Modal } from '@ownclouders/web-pkg'
|
|
|
|
describe('DeleteUserModal', () => {
|
|
it('shows a hint when the current user is part of the selection', () => {
|
|
// the default mocked user store uses id '1'
|
|
const { wrapper } = getWrapper([mock<User>({ id: '1' }), mock<User>({ id: '2' })])
|
|
expect(wrapper.find('.delete-user-own-account-hint').exists()).toBe(true)
|
|
})
|
|
it('does not show a hint when the current user is not part of the selection', () => {
|
|
const { wrapper } = getWrapper([mock<User>({ id: '2' })])
|
|
expect(wrapper.find('.delete-user-own-account-hint').exists()).toBe(false)
|
|
})
|
|
})
|
|
|
|
function getWrapper(users = [mock<User>()]) {
|
|
const mocks = defaultComponentMocks()
|
|
|
|
return {
|
|
mocks,
|
|
wrapper: shallowMount(DeleteUserModal, {
|
|
props: {
|
|
modal: mock<Modal>(),
|
|
users
|
|
},
|
|
global: {
|
|
provide: mocks,
|
|
plugins: [...defaultPlugins()]
|
|
}
|
|
})
|
|
}
|
|
}
|