From 0851a7bc359d2f5a6a57d57e4102ff653b424354 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 22 Dec 2021 11:57:04 +0100 Subject: [PATCH 1/3] Fix Test Confirm Register Email --- .../ConfirmRegisterMailFormular.spec.js | 26 ++++++++++++++++--- .../ConfirmRegisterMailFormular.vue | 8 +++--- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/admin/src/components/ConfirmRegisterMailFormular.spec.js b/admin/src/components/ConfirmRegisterMailFormular.spec.js index 7fd71a37d..834721fba 100644 --- a/admin/src/components/ConfirmRegisterMailFormular.spec.js +++ b/admin/src/components/ConfirmRegisterMailFormular.spec.js @@ -4,6 +4,8 @@ import ConfirmRegisterMailFormular from './ConfirmRegisterMailFormular.vue' const localVue = global.localVue const apolloMutateMock = jest.fn().mockResolvedValue() +const toastSuccessMock = jest.fn() +const toastErrorMock = jest.fn() const mocks = { $moment: jest.fn(() => { @@ -19,6 +21,10 @@ const mocks = { $apollo: { mutate: apolloMutateMock, }, + $toasted: { + success: toastSuccessMock, + error: toastErrorMock, + }, } const propsData = { @@ -47,8 +53,18 @@ describe('ConfirmRegisterMailFormular', () => { wrapper.find('button.test-button').trigger('click') }) - it('calls the API', () => { - expect(apolloMutateMock).toBeCalled() + it('calls the API with email', () => { + expect(apolloMutateMock).toBeCalledWith( + expect.objectContaining({ + variables: { email: 'bob@baumeister.de' }, + }), + ) + }) + + it('toasts a success message', () => { + expect(toastSuccessMock).toBeCalledWith( + 'Erfolgreich senden der Confirmation Link an die E-Mail des Users! bob@baumeister.de', + ) }) }) @@ -59,8 +75,10 @@ describe('ConfirmRegisterMailFormular', () => { wrapper.find('button.test-button').trigger('click') }) - it('calls the API', () => { - expect(apolloMutateMock).toBeCalled() + it('toasts an error message', () => { + expect(toastErrorMock).toBeCalledWith( + 'Fehler beim senden des confirmation link an den Benutzer: OUCH!', + ) }) }) }) diff --git a/admin/src/components/ConfirmRegisterMailFormular.vue b/admin/src/components/ConfirmRegisterMailFormular.vue index 2f2c3a21f..866e8a487 100644 --- a/admin/src/components/ConfirmRegisterMailFormular.vue +++ b/admin/src/components/ConfirmRegisterMailFormular.vue @@ -42,13 +42,13 @@ export default { }, }) .then(() => { - this.$toasted.global.success( - 'Erfolgreich senden der Confirmation Link an die E-Mail des Users!' + this.email, + this.$toasted.success( + 'Erfolgreich senden der Confirmation Link an die E-Mail des Users! ' + this.email, ) }) .catch((error) => { - this.$toasted.global.error( - 'Fehler beim senden des confirmation link an den Benutzer' + error, + this.$toasted.error( + 'Fehler beim senden des confirmation link an den Benutzer: ' + error.message, ) }) }, From 3e2f93b32d2bd9fc9a5a018be3358d8d174161fc Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 22 Dec 2021 11:59:12 +0100 Subject: [PATCH 2/3] remove moment from test --- .../src/components/ConfirmRegisterMailFormular.spec.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/admin/src/components/ConfirmRegisterMailFormular.spec.js b/admin/src/components/ConfirmRegisterMailFormular.spec.js index 834721fba..8872128e9 100644 --- a/admin/src/components/ConfirmRegisterMailFormular.spec.js +++ b/admin/src/components/ConfirmRegisterMailFormular.spec.js @@ -8,16 +8,6 @@ const toastSuccessMock = jest.fn() const toastErrorMock = jest.fn() const mocks = { - $moment: jest.fn(() => { - return { - format: jest.fn((m) => m), - subtract: jest.fn(() => { - return { - format: jest.fn((m) => m), - } - }), - } - }), $apollo: { mutate: apolloMutateMock, }, From d1b97c4227eb29105a9cb94094e60eb1ee5f43cd Mon Sep 17 00:00:00 2001 From: Hannes Heine Date: Wed, 22 Dec 2021 12:12:44 +0100 Subject: [PATCH 3/3] Update backend/src/config/index.ts Co-authored-by: Moriz Wahl --- backend/src/config/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 4adc21b41..eeca1d80e 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -52,7 +52,7 @@ const email = { EMAIL_LINK_VERIFICATION: process.env.EMAIL_LINK_VERIFICATION || 'http://localhost/vue/checkEmail/$1', EMAIL_LINK_SETPASSWORD: process.env.EMAIL_LINK_SETPASSWORD || 'http://localhost/vue/reset/$1', - RESEND_TIME: process.env.RESEND_TIME || 10, + RESEND_TIME: isNaN(parseInt(process.env.RESEND_TIME)) ? 10 : parseInt(process.env.RESEND_TIME), } const webhook = {