diff --git a/admin/src/components/DeletedUserFormular.spec.js b/admin/src/components/DeletedUserFormular.spec.js index 78ed5e43f..5c41831e5 100644 --- a/admin/src/components/DeletedUserFormular.spec.js +++ b/admin/src/components/DeletedUserFormular.spec.js @@ -2,7 +2,7 @@ import { mount } from '@vue/test-utils' import DeletedUserFormular from './DeletedUserFormular.vue' import { deleteUser } from '../graphql/deleteUser' import { unDeleteUser } from '../graphql/unDeleteUser' -import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup' +import { toastErrorSpy } from '../../test/testSetup' const localVue = global.localVue @@ -112,10 +112,6 @@ describe('DeletedUserFormular', () => { ) }) - it('toasts a success message', () => { - expect(toastSuccessSpy).toBeCalledWith('user_deleted') - }) - it('emits update deleted At', () => { expect(wrapper.emitted('updateDeletedAt')).toEqual( expect.arrayContaining([ @@ -209,10 +205,6 @@ describe('DeletedUserFormular', () => { ) }) - it('toasts a success message', () => { - expect(toastSuccessSpy).toBeCalledWith('user_recovered') - }) - it('emits update deleted At', () => { expect(wrapper.emitted('updateDeletedAt')).toEqual( expect.arrayContaining([ diff --git a/admin/src/components/DeletedUserFormular.vue b/admin/src/components/DeletedUserFormular.vue index be9f280d9..03359d9f9 100644 --- a/admin/src/components/DeletedUserFormular.vue +++ b/admin/src/components/DeletedUserFormular.vue @@ -45,7 +45,6 @@ export default { }, }) .then((result) => { - this.toastSuccess(this.$t('user_deleted')) this.$emit('updateDeletedAt', { userId: this.item.userId, deletedAt: result.data.deleteUser, diff --git a/admin/src/pages/UserSearch.spec.js b/admin/src/pages/UserSearch.spec.js index 5f91f679a..bd18965ac 100644 --- a/admin/src/pages/UserSearch.spec.js +++ b/admin/src/pages/UserSearch.spec.js @@ -1,6 +1,6 @@ import { mount } from '@vue/test-utils' import UserSearch from './UserSearch.vue' -import { toastErrorSpy } from '../../test/testSetup' +import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup' const localVue = global.localVue @@ -16,6 +16,7 @@ const apolloQueryMock = jest.fn().mockResolvedValue({ email: 'bibi@bloxberg.de', creation: [200, 400, 600], emailChecked: true, + deletedAt: null, }, { userId: 2, @@ -24,6 +25,7 @@ const apolloQueryMock = jest.fn().mockResolvedValue({ email: 'benjamin@bluemchen.de', creation: [1000, 1000, 1000], emailChecked: true, + deletedAt: null, }, { userId: 3, @@ -32,6 +34,7 @@ const apolloQueryMock = jest.fn().mockResolvedValue({ email: 'peter@lustig.de', creation: [0, 0, 0], emailChecked: true, + deletedAt: null, }, { userId: 4, @@ -40,6 +43,7 @@ const apolloQueryMock = jest.fn().mockResolvedValue({ email: 'new@user.ch', creation: [1000, 1000, 1000], emailChecked: false, + deletedAt: null, }, ], }, @@ -183,6 +187,21 @@ describe('UserSearch', () => { }) }) + describe('delete user', () => { + const now = new Date() + beforeEach(async () => { + wrapper.findComponent({ name: 'SearchUserTable' }).vm.$emit('updateDeletedAt', 4, now) + }) + + it('marks the user as deleted', () => { + expect(wrapper.vm.searchResult.find((obj) => obj.userId === 4).deletedAt).toEqual(now) + }) + + it('toasts a success message', () => { + expect(toastSuccessSpy).toBeCalledWith('user_deleted') + }) + }) + describe('apollo returns error', () => { beforeEach(() => { apolloQueryMock.mockRejectedValue({ diff --git a/admin/src/pages/UserSearch.vue b/admin/src/pages/UserSearch.vue index a24a47c26..ea49bf805 100644 --- a/admin/src/pages/UserSearch.vue +++ b/admin/src/pages/UserSearch.vue @@ -99,6 +99,7 @@ export default { }, updateDeletedAt(userId, deletedAt) { this.searchResult.find((obj) => obj.userId === userId).deletedAt = deletedAt + this.toastSuccess(this.$t('user_deleted')) }, }, watch: {