diff --git a/admin/src/components/CreationFormular.spec.js b/admin/src/components/CreationFormular.spec.js index 1d3338d93..9e11048e8 100644 --- a/admin/src/components/CreationFormular.spec.js +++ b/admin/src/components/CreationFormular.spec.js @@ -421,14 +421,13 @@ describe('CreationFormular', () => { expect(stateCommitMock).toBeCalledWith('openCreationsPlus', 0) }) - it('toasts two errors', () => { - expect(toastErrorSpy).toBeCalledWith([ - 'creation_form.creation_failed', - { email: 'bob@baumeister.de' }, - ]) - expect(toastErrorSpy).toBeCalledWith([ - 'creation_form.creation_failed', - { email: 'bibi@bloxberg.de' }, + it('emits remove all bookmarks', () => { + expect(wrapper.emitted('remove-all-bookmark')).toBeTruthy() + }) + + it('emits toast dailed creations with two emails', () => { + expect(wrapper.emitted('toast-failed-creations')).toEqual([ + [['bob@baumeister.de', 'bibi@bloxberg.de']], ]) }) }) diff --git a/admin/src/components/CreationFormular.vue b/admin/src/components/CreationFormular.vue index 57361348d..cd4de5fd6 100644 --- a/admin/src/components/CreationFormular.vue +++ b/admin/src/components/CreationFormular.vue @@ -166,16 +166,18 @@ export default { fetchPolicy: 'no-cache', }) .then((result) => { + const failedCreations = [] this.$store.commit( 'openCreationsPlus', result.data.createPendingCreations.successfulCreation.length, ) if (result.data.createPendingCreations.failedCreation.length > 0) { result.data.createPendingCreations.failedCreation.forEach((email) => { - this.toastError(this.$t('creation_form.creation_failed', { email })) + failedCreations.push(email) }) } this.$emit('remove-all-bookmark') + this.$emit('toast-failed-creations', failedCreations) }) .catch((error) => { this.toastError(error.message) diff --git a/admin/src/pages/Creation.spec.js b/admin/src/pages/Creation.spec.js index 4bbd25e5b..f9a4ed506 100644 --- a/admin/src/pages/Creation.spec.js +++ b/admin/src/pages/Creation.spec.js @@ -33,7 +33,7 @@ const apolloQueryMock = jest.fn().mockResolvedValue({ const storeCommitMock = jest.fn() const mocks = { - $t: jest.fn((t) => t), + $t: jest.fn((t, options) => (options ? [t, options] : t)), $d: jest.fn((d) => d), $apollo: { query: apolloQueryMock, @@ -233,6 +233,25 @@ describe('Creation', () => { }) }) + describe('failed creations', () => { + beforeEach(async () => { + await wrapper + .findComponent({ name: 'CreationFormular' }) + .vm.$emit('toast-failed-creations', ['bibi@bloxberg.de', 'benjamin@bluemchen.de']) + }) + + it('toasts two error messages', () => { + expect(toastErrorSpy).toBeCalledWith([ + 'creation_form.creation_failed', + { email: 'bibi@bloxberg.de' }, + ]) + expect(toastErrorSpy).toBeCalledWith([ + 'creation_form.creation_failed', + { email: 'benjamin@bluemchen.de' }, + ]) + }) + }) + describe('watchers', () => { beforeEach(() => { jest.clearAllMocks() diff --git a/admin/src/pages/Creation.vue b/admin/src/pages/Creation.vue index 10217fae6..a5966ee68 100644 --- a/admin/src/pages/Creation.vue +++ b/admin/src/pages/Creation.vue @@ -56,6 +56,7 @@ :creation="creation" :items="itemsMassCreation" @remove-all-bookmark="removeAllBookmarks" + @toast-failed-creations="toastFailedCreations" /> @@ -144,6 +145,11 @@ export default { this.$store.commit('setUserSelectedInMassCreation', []) this.getUsers() }, + toastFailedCreations(failedCreations) { + failedCreations.forEach((email) => + this.toastError(this.$t('creation_form.creation_failed', { email })), + ) + }, }, computed: { Searchfields() {