From 66a1377db2fcb5f1fcec2b0511bf1784fb93354a Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 20 Jan 2022 13:21:19 +0100 Subject: [PATCH 01/47] fix: Localize Datetime in Admin Interface --- admin/src/components/CreationFormular.vue | 49 ++++++++++++++--------- admin/src/i18n.js | 18 +++++++++ 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/admin/src/components/CreationFormular.vue b/admin/src/components/CreationFormular.vue index 49993d14a..5b6ca7553 100644 --- a/admin/src/components/CreationFormular.vue +++ b/admin/src/components/CreationFormular.vue @@ -15,7 +15,7 @@ @change="updateRadioSelected(beforeLastMonth, 0, creation[0])" > @@ -29,7 +29,7 @@ @change="updateRadioSelected(lastMonth, 1, creation[1])" > @@ -43,7 +43,7 @@ @change="updateRadioSelected(currentMonth, 2, creation[2])" > @@ -169,24 +169,10 @@ export default { value: !this.creationUserData.amount ? 0 : this.creationUserData.amount, rangeMin: 0, rangeMax: 1000, - currentMonth: { - short: this.$moment().format('MMMM'), - long: this.$moment().format('YYYY-MM-DD'), - year: this.$moment().format('YYYY'), - }, - lastMonth: { - short: this.$moment().subtract(1, 'month').format('MMMM'), - long: this.$moment().subtract(1, 'month').format('YYYY-MM') + '-01', - year: this.$moment().subtract(1, 'month').format('YYYY'), - }, - beforeLastMonth: { - short: this.$moment().subtract(2, 'month').format('MMMM'), - long: this.$moment().subtract(2, 'month').format('YYYY-MM') + '-01', - year: this.$moment().subtract(2, 'month').format('YYYY'), - }, submitObj: null, isdisabled: true, createdIndex: null, + now: Date.now(), } }, @@ -298,6 +284,33 @@ export default { }) }, }, + computed: { + currentMonth() { + return { + short: this.$d(this.now, 'month'), + long: this.$d(this.now, 'short'), + year: this.$d(this.now, 'year'), + } + }, + lastMonth() { + const now = new Date(this.now) + const lastMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1) + return { + short: this.$d(lastMonth, 'month'), + long: this.$d(lastMonth, 'short'), + year: this.$d(lastMonth, 'year'), + } + }, + beforeLastMonth() { + const now = new Date(this.now) + const beforeLastMonth = new Date(now.getFullYear(), now.getMonth() - 2, 1) + return { + short: this.$d(beforeLastMonth, 'month'), + long: this.$d(beforeLastMonth, 'short'), + year: this.$d(beforeLastMonth, 'year'), + } + }, + }, created() { this.searchModeratorData() }, diff --git a/admin/src/i18n.js b/admin/src/i18n.js index 14e81543e..6291a9c6c 100644 --- a/admin/src/i18n.js +++ b/admin/src/i18n.js @@ -60,6 +60,15 @@ const dateTimeFormats = { hour: 'numeric', minute: 'numeric', }, + monthShort: { + month: 'short', + }, + month: { + month: 'long', + }, + year: { + year: 'numeric', + }, }, de: { short: { @@ -75,6 +84,15 @@ const dateTimeFormats = { hour: 'numeric', minute: 'numeric', }, + monthShort: { + month: 'short', + }, + month: { + month: 'long', + }, + year: { + year: 'numeric', + }, }, } From af2ea3e809ac8563899bd309822ab12b4befb73b Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 20 Jan 2022 13:26:31 +0100 Subject: [PATCH 02/47] fix tests --- admin/src/components/CreationFormular.spec.js | 11 +---------- admin/src/components/UserTable.spec.js | 1 + 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/admin/src/components/CreationFormular.spec.js b/admin/src/components/CreationFormular.spec.js index 5b0ac09f5..004cf4474 100644 --- a/admin/src/components/CreationFormular.spec.js +++ b/admin/src/components/CreationFormular.spec.js @@ -22,16 +22,7 @@ const toastedSuccessMock = jest.fn() const mocks = { $t: jest.fn((t) => t), - $moment: jest.fn(() => { - return { - format: jest.fn((m) => m), - subtract: jest.fn(() => { - return { - format: jest.fn((m) => m), - } - }), - } - }), + $d: jest.fn((d) => d), $apollo: { query: apolloMock, mutate: apolloMutateMock, diff --git a/admin/src/components/UserTable.spec.js b/admin/src/components/UserTable.spec.js index e26a548cc..01105931c 100644 --- a/admin/src/components/UserTable.spec.js +++ b/admin/src/components/UserTable.spec.js @@ -107,6 +107,7 @@ describe('UserTable', () => { const mocks = { $t: jest.fn((t) => t), + $d: jest.fn((d) => d), $moment: jest.fn(() => { return { format: jest.fn((m) => m), From 5e78e4ad073d9864736ec2f2616a64c4dc5c9d89 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 20 Jan 2022 13:42:25 +0100 Subject: [PATCH 03/47] remove moment. localize date time --- .../components/EditCreationFormular.spec.js | 11 +----- admin/src/components/EditCreationFormular.vue | 37 +++++++++++++------ 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/admin/src/components/EditCreationFormular.spec.js b/admin/src/components/EditCreationFormular.spec.js index ed0f412ba..23b685f39 100644 --- a/admin/src/components/EditCreationFormular.spec.js +++ b/admin/src/components/EditCreationFormular.spec.js @@ -20,16 +20,7 @@ const toastedSuccessMock = jest.fn() const mocks = { $t: jest.fn((t) => t), - $moment: jest.fn(() => { - return { - format: jest.fn((m) => m), - subtract: jest.fn(() => { - return { - format: jest.fn((m) => m), - } - }), - } - }), + $d: jest.fn((d) => d), $apollo: { mutate: apolloMutateMock, }, diff --git a/admin/src/components/EditCreationFormular.vue b/admin/src/components/EditCreationFormular.vue index 172ae5509..34f4d6101 100644 --- a/admin/src/components/EditCreationFormular.vue +++ b/admin/src/components/EditCreationFormular.vue @@ -154,22 +154,11 @@ export default { value: !this.creationUserData.amount ? 0 : this.creationUserData.amount, rangeMin: 0, rangeMax: 1000, - currentMonth: { - short: this.$moment().format('MMMM'), - long: this.$moment().format('YYYY-MM-DD'), - }, - lastMonth: { - short: this.$moment().subtract(1, 'month').format('MMMM'), - long: this.$moment().subtract(1, 'month').format('YYYY-MM') + '-01', - }, - beforeLastMonth: { - short: this.$moment().subtract(2, 'month').format('MMMM'), - long: this.$moment().subtract(2, 'month').format('YYYY-MM') + '-01', - }, submitObj: null, isdisabled: true, createdIndex: null, selectedOpenCreationAmount: {}, + now: Date.now(), } }, @@ -227,6 +216,30 @@ export default { }) }, }, + computed: { + currentMonth() { + return { + short: this.$d(this.now, 'month'), + long: this.$d(this.now, 'short'), + } + }, + lastMonth() { + const now = new Date(this.now) + const lastMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1) + return { + short: this.$d(lastMonth, 'month'), + long: this.$d(lastMonth, 'short'), + } + }, + beforeLastMonth() { + const now = new Date(this.now) + const beforeLastMonth = new Date(now.getFullYear(), now.getMonth() - 2, 1) + return { + short: this.$d(beforeLastMonth, 'month'), + long: this.$d(beforeLastMonth, 'short'), + } + }, + }, created() { if (this.creationUserData.date) { switch (this.$moment(this.creationUserData.date).format('MMMM')) { From 0db297a267ae01a5f133cb2892869e56e187b502 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 20 Jan 2022 14:13:10 +0100 Subject: [PATCH 04/47] fix test --- admin/src/components/EditCreationFormular.spec.js | 13 ++++++++----- admin/src/components/EditCreationFormular.vue | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/admin/src/components/EditCreationFormular.spec.js b/admin/src/components/EditCreationFormular.spec.js index 23b685f39..3915fd828 100644 --- a/admin/src/components/EditCreationFormular.spec.js +++ b/admin/src/components/EditCreationFormular.spec.js @@ -20,7 +20,10 @@ const toastedSuccessMock = jest.fn() const mocks = { $t: jest.fn((t) => t), - $d: jest.fn((d) => d), + $d: jest.fn((d) => { + const date = new Date(d) + return date.toISOString().split('T')[0] + }), $apollo: { mutate: apolloMutateMock, }, @@ -44,7 +47,7 @@ const propsData = { creationUserData: { memo: 'Test schöpfung 1', amount: 100, - date: '2021-12-01', + date: '2022-01-20', }, item: { id: 0, @@ -105,7 +108,7 @@ describe('EditCreationFormular', () => { expect.objectContaining({ variables: { amount: 90, - creationDate: 'YYYY-MM-01', + creationDate: '2021-10-31', email: 'bob@baumeister.de', id: 0, memo: 'Test create coins', @@ -177,7 +180,7 @@ describe('EditCreationFormular', () => { expect.objectContaining({ variables: { amount: 90, - creationDate: 'YYYY-MM-01', + creationDate: '2021-11-30', email: 'bob@baumeister.de', id: 0, memo: 'Test create coins', @@ -233,7 +236,7 @@ describe('EditCreationFormular', () => { expect.objectContaining({ variables: { amount: 90, - creationDate: 'YYYY-MM-DD', + creationDate: '2022-01-20', email: 'bob@baumeister.de', id: 0, memo: 'Test create coins', diff --git a/admin/src/components/EditCreationFormular.vue b/admin/src/components/EditCreationFormular.vue index 34f4d6101..97c503ad5 100644 --- a/admin/src/components/EditCreationFormular.vue +++ b/admin/src/components/EditCreationFormular.vue @@ -242,7 +242,7 @@ export default { }, created() { if (this.creationUserData.date) { - switch (this.$moment(this.creationUserData.date).format('MMMM')) { + switch (this.$d(new Date(this.creationUserData.date), 'month')) { case this.currentMonth.short: this.createdIndex = 2 this.radioSelected = this.currentMonth From 4837aca0bd2b2c8e8709507fd8039b81e3567af4 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 20 Jan 2022 14:37:49 +0100 Subject: [PATCH 05/47] remove moment, localize datetime --- admin/src/pages/Creation.spec.js | 11 +---------- admin/src/pages/Creation.vue | 33 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/admin/src/pages/Creation.spec.js b/admin/src/pages/Creation.spec.js index 01a884f54..3de9ba9e4 100644 --- a/admin/src/pages/Creation.spec.js +++ b/admin/src/pages/Creation.spec.js @@ -32,22 +32,13 @@ const toastErrorMock = jest.fn() const mocks = { $t: jest.fn((t) => t), + $d: jest.fn((d) => d), $apollo: { query: apolloQueryMock, }, $toasted: { error: toastErrorMock, }, - $moment: jest.fn(() => { - return { - format: jest.fn((m) => m), - subtract: jest.fn(() => { - return { - format: jest.fn((m) => m), - } - }), - } - }), } describe('Creation', () => { diff --git a/admin/src/pages/Creation.vue b/admin/src/pages/Creation.vue index 0de804288..20bb586c8 100644 --- a/admin/src/pages/Creation.vue +++ b/admin/src/pages/Creation.vue @@ -71,15 +71,9 @@ export default { { key: 'lastName', label: this.$t('lastname') }, { key: 'creation', - // label: this.$t('open_creation') + 'Jan | Feb | März', - label: - this.$moment().subtract(2, 'month').format('MMM') + - ' | ' + - this.$moment().subtract(1, 'month').format('MMM') + - ' | ' + - this.$moment().format('MMM'), + label: this.creationLabel, formatter: (value, key, item) => { - return String(value[0]) + ` | ` + String(value[1]) + ` | ` + String(value[2]) + return value.join(' | ') }, }, { key: 'email', label: this.$t('e_mail') }, @@ -90,15 +84,9 @@ export default { { key: 'lastName', label: this.$t('lastname') }, { key: 'creation', - // label: this.$t('open_creation') + 'Jan | Feb | März', - label: - this.$moment().subtract(2, 'month').format('MMM') + - ' | ' + - this.$moment().subtract(1, 'month').format('MMM') + - ' | ' + - this.$moment().format('MMM'), + label: this.creationLabel, formatter: (value, key, item) => { - return String(value[0]) + ` | ` + String(value[1]) + ` | ` + String(value[2]) + return value.join(' | ') }, }, { key: 'bookmark', label: this.$t('remove') }, @@ -111,6 +99,7 @@ export default { rows: 0, currentPage: 1, perPage: 25, + now: Date.now(), } }, async created() { @@ -166,6 +155,18 @@ export default { this.itemsMassCreation = [] }, }, + computed: { + creationLabel() { + const now = new Date(this.now) + const lastMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1) + const beforeLastMonth = new Date(now.getFullYear(), now.getMonth() - 2, 1) + return [ + this.$d(beforeLastMonth, 'monthShort'), + this.$d(lastMonth, 'monthShort'), + this.$d(now, 'monthShort'), + ].join(' | ') + }, + }, watch: { currentPage() { this.getUsers() From f9b5df87207cc9f8673a35a95ace7ae95d1fb717 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 20 Jan 2022 14:44:40 +0100 Subject: [PATCH 06/47] remove moment. localize datetime --- admin/src/locales/de.json | 1 + admin/src/locales/en.json | 1 + admin/src/pages/CreationConfirm.spec.js | 6 +----- admin/src/pages/CreationConfirm.vue | 4 ++-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/admin/src/locales/de.json b/admin/src/locales/de.json index d3b87383a..202c5b635 100644 --- a/admin/src/locales/de.json +++ b/admin/src/locales/de.json @@ -2,6 +2,7 @@ "all_emails": "Alle Nutzer", "bookmark": "bookmark", "confirmed": "bestätigt", + "date": "Datum", "creation_form": { "creation_for": "Schöpfung für", "enter_text": "Text eintragen", diff --git a/admin/src/locales/en.json b/admin/src/locales/en.json index 517b69379..e171e7392 100644 --- a/admin/src/locales/en.json +++ b/admin/src/locales/en.json @@ -2,6 +2,7 @@ "all_emails": "All users", "bookmark": "Remember", "confirmed": "confirmed", + "date": "Date", "creation_form": { "creation_for": "Creation for", "enter_text": "Enter text", diff --git a/admin/src/pages/CreationConfirm.spec.js b/admin/src/pages/CreationConfirm.spec.js index 14a71bb78..90e101184 100644 --- a/admin/src/pages/CreationConfirm.spec.js +++ b/admin/src/pages/CreationConfirm.spec.js @@ -38,6 +38,7 @@ const apolloMutateMock = jest.fn().mockResolvedValue({}) const mocks = { $t: jest.fn((t) => t), + $d: jest.fn((d) => d), $store: { commit: storeCommitMock, }, @@ -49,11 +50,6 @@ const mocks = { error: toastedErrorMock, success: toastedSuccessMock, }, - $moment: jest.fn((value) => { - return { - format: jest.fn((format) => value), - } - }), } describe('CreationConfirm', () => { diff --git a/admin/src/pages/CreationConfirm.vue b/admin/src/pages/CreationConfirm.vue index 578c9b23f..829dc8fe4 100644 --- a/admin/src/pages/CreationConfirm.vue +++ b/admin/src/pages/CreationConfirm.vue @@ -37,9 +37,9 @@ export default { { key: 'memo', label: 'Text' }, { key: 'date', - label: 'Datum', + label: this.$t('date'), formatter: (value) => { - return this.$moment(value).format('ll') + return this.$d(new Date(value), 'short') }, }, { key: 'moderator', label: 'Moderator' }, From 4142e6df9f16d26e06ac67e6e8d020f37dbc905a Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 20 Jan 2022 15:57:13 +0100 Subject: [PATCH 07/47] add date, pass date to server --- admin/src/components/CreationFormular.vue | 9 ++- .../components/EditCreationFormular.spec.js | 6 +- admin/src/components/EditCreationFormular.vue | 6 +- admin/src/pages/Creation.vue | 56 +++++++++-------- admin/src/pages/UserSearch.spec.js | 11 +--- admin/src/pages/UserSearch.vue | 60 ++++++++++--------- 6 files changed, 78 insertions(+), 70 deletions(-) diff --git a/admin/src/components/CreationFormular.vue b/admin/src/components/CreationFormular.vue index 5b6ca7553..b2152f917 100644 --- a/admin/src/components/CreationFormular.vue +++ b/admin/src/components/CreationFormular.vue @@ -199,10 +199,11 @@ export default { // eslint-disable-next-line no-console console.log('SUBMIT CREATION => ' + this.type + ' >> für VIELE ' + i + ' Mitglieder') this.submitObj = [] + const date = new Date(this.radioSelected.date) this.items.forEach((item) => { this.submitObj.push({ email: item.email, - creationDate: this.radioSelected.long, + creationDate: date.toISOString(), amount: Number(this.value), memo: this.text, moderator: Number(this.$store.state.moderator.id), @@ -234,9 +235,10 @@ export default { this.$toasted.error(error.message) }) } else if (this.type === 'singleCreation') { + const date = new Date(this.radioSelected.date) this.submitObj = { email: this.item.email, - creationDate: this.radioSelected.long, + creationDate: date.toISOString(), amount: Number(this.value), memo: this.text, moderator: Number(this.$store.state.moderator.id), @@ -290,6 +292,7 @@ export default { short: this.$d(this.now, 'month'), long: this.$d(this.now, 'short'), year: this.$d(this.now, 'year'), + date: this.now, } }, lastMonth() { @@ -299,6 +302,7 @@ export default { short: this.$d(lastMonth, 'month'), long: this.$d(lastMonth, 'short'), year: this.$d(lastMonth, 'year'), + date: lastMonth, } }, beforeLastMonth() { @@ -308,6 +312,7 @@ export default { short: this.$d(beforeLastMonth, 'month'), long: this.$d(beforeLastMonth, 'short'), year: this.$d(beforeLastMonth, 'year'), + date: beforeLastMonth, } }, }, diff --git a/admin/src/components/EditCreationFormular.spec.js b/admin/src/components/EditCreationFormular.spec.js index 3915fd828..4b2244fe5 100644 --- a/admin/src/components/EditCreationFormular.spec.js +++ b/admin/src/components/EditCreationFormular.spec.js @@ -108,7 +108,7 @@ describe('EditCreationFormular', () => { expect.objectContaining({ variables: { amount: 90, - creationDate: '2021-10-31', + creationDate: '2021-10-31T23:00:00.000Z', email: 'bob@baumeister.de', id: 0, memo: 'Test create coins', @@ -180,7 +180,7 @@ describe('EditCreationFormular', () => { expect.objectContaining({ variables: { amount: 90, - creationDate: '2021-11-30', + creationDate: '2021-11-30T23:00:00.000Z', email: 'bob@baumeister.de', id: 0, memo: 'Test create coins', @@ -236,7 +236,7 @@ describe('EditCreationFormular', () => { expect.objectContaining({ variables: { amount: 90, - creationDate: '2022-01-20', + creationDate: expect.stringContaining('2022-01-20T'), email: 'bob@baumeister.de', id: 0, memo: 'Test create coins', diff --git a/admin/src/components/EditCreationFormular.vue b/admin/src/components/EditCreationFormular.vue index 97c503ad5..30424b83f 100644 --- a/admin/src/components/EditCreationFormular.vue +++ b/admin/src/components/EditCreationFormular.vue @@ -169,10 +169,11 @@ export default { this.rangeMax = this.creation[index] }, submitCreation() { + const date = new Date(this.radioSelected.date) this.submitObj = { id: this.item.id, email: this.item.email, - creationDate: this.radioSelected.long, + creationDate: date.toISOString(), amount: Number(this.value), memo: this.text, moderator: Number(this.$store.state.moderator.id), @@ -221,6 +222,7 @@ export default { return { short: this.$d(this.now, 'month'), long: this.$d(this.now, 'short'), + date: this.now, } }, lastMonth() { @@ -229,6 +231,7 @@ export default { return { short: this.$d(lastMonth, 'month'), long: this.$d(lastMonth, 'short'), + date: lastMonth, } }, beforeLastMonth() { @@ -237,6 +240,7 @@ export default { return { short: this.$d(beforeLastMonth, 'month'), long: this.$d(beforeLastMonth, 'short'), + date: beforeLastMonth, } }, }, diff --git a/admin/src/pages/Creation.vue b/admin/src/pages/Creation.vue index 20bb586c8..a3c8b4f73 100644 --- a/admin/src/pages/Creation.vue +++ b/admin/src/pages/Creation.vue @@ -65,32 +65,6 @@ export default { data() { return { showArrays: false, - Searchfields: [ - { key: 'bookmark', label: 'bookmark' }, - { key: 'firstName', label: this.$t('firstname') }, - { key: 'lastName', label: this.$t('lastname') }, - { - key: 'creation', - label: this.creationLabel, - formatter: (value, key, item) => { - return value.join(' | ') - }, - }, - { key: 'email', label: this.$t('e_mail') }, - ], - fields: [ - { key: 'email', label: this.$t('e_mail') }, - { key: 'firstName', label: this.$t('firstname') }, - { key: 'lastName', label: this.$t('lastname') }, - { - key: 'creation', - label: this.creationLabel, - formatter: (value, key, item) => { - return value.join(' | ') - }, - }, - { key: 'bookmark', label: this.$t('remove') }, - ], itemsList: [], itemsMassCreation: [], radioSelectedMass: '', @@ -156,6 +130,36 @@ export default { }, }, computed: { + Searchfields() { + return [ + { key: 'bookmark', label: 'bookmark' }, + { key: 'firstName', label: this.$t('firstname') }, + { key: 'lastName', label: this.$t('lastname') }, + { + key: 'creation', + label: this.creationLabel, + formatter: (value, key, item) => { + return value.join(' | ') + }, + }, + { key: 'email', label: this.$t('e_mail') }, + ] + }, + fields() { + return [ + { key: 'email', label: this.$t('e_mail') }, + { key: 'firstName', label: this.$t('firstname') }, + { key: 'lastName', label: this.$t('lastname') }, + { + key: 'creation', + label: this.creationLabel, + formatter: (value, key, item) => { + return value.join(' | ') + }, + }, + { key: 'bookmark', label: this.$t('remove') }, + ] + }, creationLabel() { const now = new Date(this.now) const lastMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1) diff --git a/admin/src/pages/UserSearch.spec.js b/admin/src/pages/UserSearch.spec.js index 4beda0c49..f7df62730 100644 --- a/admin/src/pages/UserSearch.spec.js +++ b/admin/src/pages/UserSearch.spec.js @@ -24,22 +24,13 @@ const toastErrorMock = jest.fn() const mocks = { $t: jest.fn((t) => t), + $d: jest.fn((d) => d), $apollo: { query: apolloQueryMock, }, $toasted: { error: toastErrorMock, }, - $moment: jest.fn(() => { - return { - format: jest.fn((m) => m), - subtract: jest.fn(() => { - return { - format: jest.fn((m) => m), - } - }), - } - }), } describe('UserSearch', () => { diff --git a/admin/src/pages/UserSearch.vue b/admin/src/pages/UserSearch.vue index 4b9bcae8a..b7c19d03a 100644 --- a/admin/src/pages/UserSearch.vue +++ b/admin/src/pages/UserSearch.vue @@ -44,41 +44,14 @@ export default { data() { return { showArrays: false, - fields: [ - { key: 'email', label: this.$t('e_mail') }, - { key: 'firstName', label: this.$t('firstname') }, - { key: 'lastName', label: this.$t('lastname') }, - { - key: 'creation', - label: [ - this.$moment().subtract(2, 'month').format('MMM'), - this.$moment().subtract(1, 'month').format('MMM'), - this.$moment().format('MMM'), - ].join(' | '), - formatter: (value, key, item) => { - return value.join(' | ') - }, - }, - { key: 'show_details', label: this.$t('details') }, - { key: 'confirm_mail', label: this.$t('confirmed') }, - { key: 'transactions_list', label: this.$t('transaction') }, - ], searchResult: [], massCreation: [], criteria: '', - currentMonth: { - short: this.$moment().format('MMMM'), - }, - lastMonth: { - short: this.$moment().subtract(1, 'month').format('MMMM'), - }, - beforeLastMonth: { - short: this.$moment().subtract(2, 'month').format('MMMM'), - }, filterCheckedEmails: false, rows: 0, currentPage: 1, perPage: 25, + now: Date.now(), } }, methods: { @@ -111,6 +84,37 @@ export default { this.getUsers() }, }, + computed: { + lastMonthDate() { + const now = new Date(this.now) + return new Date(now.getFullYear(), now.getMonth() - 1, 1) + }, + beforeLastMonthDate() { + const now = new Date(this.now) + return new Date(now.getFullYear(), now.getMonth() - 2, 1) + }, + fields() { + return [ + { key: 'email', label: this.$t('e_mail') }, + { key: 'firstName', label: this.$t('firstname') }, + { key: 'lastName', label: this.$t('lastname') }, + { + key: 'creation', + label: [ + this.$d(this.beforeLastMonthDate, 'monthShort'), + this.$d(this.lastMonthDate, 'monthShort'), + this.$d(this.now, 'monthShort'), + ].join(' | '), + formatter: (value, key, item) => { + return value.join(' | ') + }, + }, + { key: 'show_details', label: this.$t('details') }, + { key: 'confirm_mail', label: this.$t('confirmed') }, + { key: 'transactions_list', label: this.$t('transaction') }, + ] + }, + }, created() { this.getUsers() }, From da72a15cf11e11cb9bc80a40d29361609b5a5c07 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 20 Jan 2022 15:59:56 +0100 Subject: [PATCH 08/47] remove moment --- admin/src/components/UserTable.spec.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/admin/src/components/UserTable.spec.js b/admin/src/components/UserTable.spec.js index 01105931c..d90c2929d 100644 --- a/admin/src/components/UserTable.spec.js +++ b/admin/src/components/UserTable.spec.js @@ -108,16 +108,6 @@ describe('UserTable', () => { const mocks = { $t: jest.fn((t) => t), $d: jest.fn((d) => d), - $moment: jest.fn(() => { - return { - format: jest.fn((m) => m), - subtract: jest.fn(() => { - return { - format: jest.fn((m) => m), - } - }), - } - }), $apollo: { query: apolloQueryMock, }, From 105f48084c7288ebe78d04cde128c7cb2955c222 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 20 Jan 2022 16:10:07 +0100 Subject: [PATCH 09/47] remove moment --- admin/src/components/UserTable.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/src/components/UserTable.vue b/admin/src/components/UserTable.vue index 3f8dface3..dec6d88e4 100644 --- a/admin/src/components/UserTable.vue +++ b/admin/src/components/UserTable.vue @@ -110,7 +110,7 @@ diff --git a/admin/src/mixins/creationMonths.js b/admin/src/mixins/creationMonths.js new file mode 100644 index 000000000..56dca5c56 --- /dev/null +++ b/admin/src/mixins/creationMonths.js @@ -0,0 +1,24 @@ +export const creationMonths = { + computed: { + creationDates() { + const now = new Date(Date.now()) + const dates = [now] + for (let i = 1; i < 3; i++) { + dates.push(new Date(now.getFullYear(), now.getMonth() - i, 1)) + } + return dates.reverse() + }, + creationDateObjects() { + const result = [] + this.creationDates.forEach((date) => { + result.push({ + short: this.$d(date, 'month'), + long: this.$d(date, 'short'), + year: this.$d(date, 'year'), + date: this.$d(date, 'short', 'en'), + }) + }) + return result + }, + }, +} From 225b3d4363536ec6a8a31c14a389f573bc01c1cf Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 25 Jan 2022 15:02:37 +0100 Subject: [PATCH 16/47] get tests working, dyncamic dates in EditCreationFormular tests --- admin/src/components/CreationFormular.spec.js | 29 +----------- admin/src/components/CreationFormular.vue | 47 +------------------ .../components/EditCreationFormular.spec.js | 14 ++++-- 3 files changed, 14 insertions(+), 76 deletions(-) diff --git a/admin/src/components/CreationFormular.spec.js b/admin/src/components/CreationFormular.spec.js index 004cf4474..a067961d7 100644 --- a/admin/src/components/CreationFormular.spec.js +++ b/admin/src/components/CreationFormular.spec.js @@ -3,14 +3,6 @@ import CreationFormular from './CreationFormular.vue' const localVue = global.localVue -const apolloMock = jest.fn().mockResolvedValue({ - data: { - verifyLogin: { - name: 'success', - id: 0, - }, - }, -}) const apolloMutateMock = jest.fn().mockResolvedValue({ data: { createPendingCreation: [0, 0, 0], @@ -24,7 +16,6 @@ const mocks = { $t: jest.fn((t) => t), $d: jest.fn((d) => d), $apollo: { - query: apolloMock, mutate: apolloMutateMock, }, $store: { @@ -64,29 +55,12 @@ describe('CreationFormular', () => { expect(wrapper.find('.component-creation-formular').exists()).toBeTruthy() }) - describe('server sends back moderator data', () => { - it('called store commit with mocked data', () => { - expect(stateCommitMock).toBeCalledWith('moderator', { name: 'success', id: 0 }) - }) - }) - - describe('server throws error for moderator data call', () => { - beforeEach(() => { - jest.clearAllMocks() - apolloMock.mockRejectedValueOnce({ message: 'Ouch!' }) - wrapper = Wrapper() - }) - - it('has called store commit with fake data', () => { - expect(stateCommitMock).toBeCalledWith('moderator', { id: 0, name: 'Test Moderator' }) - }) - }) - describe('radio buttons to selcet month', () => { it('has three radio buttons', () => { expect(wrapper.findAll('input[type="radio"]').length).toBe(3) }) + /* describe('with mass creation', () => { beforeEach(async () => { jest.clearAllMocks() @@ -132,6 +106,7 @@ describe('CreationFormular', () => { }) }) }) + */ describe('with single creation', () => { beforeEach(async () => { diff --git a/admin/src/components/CreationFormular.vue b/admin/src/components/CreationFormular.vue index 7cec112da..d01faf6bd 100644 --- a/admin/src/components/CreationFormular.vue +++ b/admin/src/components/CreationFormular.vue @@ -141,17 +141,11 @@ export default { } }, methods: { - // Auswählen eines Zeitraumes updateRadioSelected(name) { this.createdIndex = this.radioOptions.findIndex((obj) => name === obj.item) this.text = this.$t('creation_form.creation_for') + ' ' + name.short + ' ' + name.year - // Wenn Mehrfachschöpfung - if (this.type === 'massCreation') { - // An Creation.vue emitten und radioSelectedMass aktualisieren - this.$emit('update-radio-selected', [name, this.createdIndex]) - } else if (this.type === 'singleCreation') { + if (this.type === 'singleCreation') { this.rangeMin = 0 - // Der maximale offene Betrag an GDD die für ein User noch geschöpft werden kann this.rangeMax = name.creation } }, @@ -166,7 +160,7 @@ export default { this.items.forEach((item) => { this.submitObj.push({ email: item.email, - creationDate: this.radioSelected.date, + creationDate: this.selected.date, amount: Number(this.value), memo: this.text, moderator: Number(this.$store.state.moderator.id), @@ -243,34 +237,6 @@ export default { }, }, computed: { - currentMonth() { - return { - short: this.$d(this.now, 'month'), - long: this.$d(this.now, 'short'), - year: this.$d(this.now, 'year'), - date: this.$d(this.now, 'short', 'en'), - } - }, - lastMonth() { - const now = new Date(this.now) - const lastMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1) - return { - short: this.$d(lastMonth, 'month'), - long: this.$d(lastMonth, 'short'), - year: this.$d(lastMonth, 'year'), - date: this.$d(lastMonth, 'short', 'en'), - } - }, - beforeLastMonth() { - const now = new Date(this.now) - const beforeLastMonth = new Date(now.getFullYear(), now.getMonth() - 2, 1) - return { - short: this.$d(beforeLastMonth, 'month'), - long: this.$d(beforeLastMonth, 'short'), - year: this.$d(beforeLastMonth, 'year'), - date: this.$d(beforeLastMonth, 'short', 'en'), - } - }, radioOptions() { return this.creationDateObjects.map((obj, idx) => { return { @@ -279,15 +245,6 @@ export default { } }) }, - creationObjects() { - return this.creationDateObjects.map((obj, idx) => { - return { - ...obj, - creation: this.creation[idx], - selected: '', - } - }) - }, }, } diff --git a/admin/src/components/EditCreationFormular.spec.js b/admin/src/components/EditCreationFormular.spec.js index 2cbe0451c..0fe83cc9a 100644 --- a/admin/src/components/EditCreationFormular.spec.js +++ b/admin/src/components/EditCreationFormular.spec.js @@ -42,12 +42,18 @@ const mocks = { }, } +const now = new Date(Date.now()) +const getCreationDate = (sub) => { + const date = sub === 0 ? now : new Date(now.getFullYear(), now.getMonth() - sub, 1, 0) + return date.toISOString().split('T')[0] +} + const propsData = { creation: [200, 400, 600], creationUserData: { memo: 'Test schöpfung 1', amount: 100, - date: '2022-01-20', + date: getCreationDate(0), }, item: { id: 0, @@ -108,7 +114,7 @@ describe('EditCreationFormular', () => { expect.objectContaining({ variables: { amount: 90, - creationDate: '2021-11-01', + creationDate: getCreationDate(2), email: 'bob@baumeister.de', id: 0, memo: 'Test create coins', @@ -180,7 +186,7 @@ describe('EditCreationFormular', () => { expect.objectContaining({ variables: { amount: 90, - creationDate: '2021-12-01', + creationDate: getCreationDate(1), email: 'bob@baumeister.de', id: 0, memo: 'Test create coins', @@ -236,7 +242,7 @@ describe('EditCreationFormular', () => { expect.objectContaining({ variables: { amount: 90, - creationDate: '2022-01-20', + creationDate: getCreationDate(0), email: 'bob@baumeister.de', id: 0, memo: 'Test create coins', From 57f4231ec3eb11aa5edef7d81c1ba66fba74cf2c Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 25 Jan 2022 17:03:24 +0100 Subject: [PATCH 17/47] change fetch policy --- admin/src/pages/Creation.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/admin/src/pages/Creation.vue b/admin/src/pages/Creation.vue index a3c8b4f73..db6af503d 100644 --- a/admin/src/pages/Creation.vue +++ b/admin/src/pages/Creation.vue @@ -89,6 +89,7 @@ export default { currentPage: this.currentPage, pageSize: this.perPage, }, + fetchPolicy: 'network-only', }) .then((result) => { this.rows = result.data.searchUsers.userCount From daa8684cc6ca342e253cd7c9ed9b194830f9a996 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 25 Jan 2022 17:15:18 +0100 Subject: [PATCH 18/47] remove unused data --- admin/src/components/CreationFormular.vue | 31 +++++------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/admin/src/components/CreationFormular.vue b/admin/src/components/CreationFormular.vue index d01faf6bd..490996f0c 100644 --- a/admin/src/components/CreationFormular.vue +++ b/admin/src/components/CreationFormular.vue @@ -13,7 +13,7 @@ name="month-selection" > - +
@@ -61,11 +61,10 @@ variant="success" class="test-submit" @click="submitCreation" - :disabled="radioSelected === '' || value <= 0 || text.length < 10" + :disabled="selected === '' || value <= 0 || text.length < 10" > {{ $t('creation_form.update_creation') }} - name === obj.item) this.text = this.$t('creation_form.creation_for') + ' ' + name.short + ' ' + name.year if (this.type === 'singleCreation') { this.rangeMin = 0 @@ -150,15 +143,10 @@ export default { } }, submitCreation() { + let submitObj = [] if (this.type === 'massCreation') { - // Die anzahl der Mitglieder aus der Mehrfachschöpfung - const i = Object.keys(this.items).length - // hinweis das eine Mehrfachschöpfung ausgeführt wird an (Anzahl der MItgleider an die geschöpft wird) - // eslint-disable-next-line no-console - console.log('SUBMIT CREATION => ' + this.type + ' >> für VIELE ' + i + ' Mitglieder') - this.submitObj = [] this.items.forEach((item) => { - this.submitObj.push({ + submitObj.push({ email: item.email, creationDate: this.selected.date, amount: Number(this.value), @@ -166,13 +154,11 @@ export default { moderator: Number(this.$store.state.moderator.id), }) }) - // eslint-disable-next-line no-console - console.log('MehrfachSCHÖPFUNG ABSENDEN FÜR >> ' + i + ' Mitglieder') this.$apollo .mutate({ mutation: createPendingCreations, variables: { - pendingCreations: this.submitObj, + pendingCreations: submitObj, }, fetchPolicy: 'no-cache', }) @@ -192,7 +178,7 @@ export default { this.$toasted.error(error.message) }) } else if (this.type === 'singleCreation') { - this.submitObj = { + submitObj = { email: this.item.email, creationDate: this.selected.date, amount: Number(this.value), @@ -202,7 +188,7 @@ export default { this.$apollo .mutate({ mutation: createPendingCreation, - variables: this.submitObj, + variables: submitObj, }) .then((result) => { this.$emit('update-user-data', this.item, result.data.createPendingCreation) @@ -213,8 +199,6 @@ export default { }), ) this.$store.commit('openCreationsPlus', 1) - this.submitObj = null - this.createdIndex = null // das creation Formular reseten this.$refs.creationForm.reset() // Den geschöpften Wert auf o setzen @@ -222,7 +206,6 @@ export default { }) .catch((error) => { this.$toasted.error(error.message) - this.submitObj = null // das creation Formular reseten this.$refs.creationForm.reset() // Den geschöpften Wert auf o setzen From dd7b95b9afd0912cdd751c66902f482730a0f7c5 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 25 Jan 2022 17:25:58 +0100 Subject: [PATCH 19/47] create radio buttons in mixin --- .github/workflows/test.yml | 2 +- admin/src/components/CreationFormular.vue | 14 -------------- admin/src/mixins/creationMonths.js | 11 +++++++++++ 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d927c64b1..4dc2be992 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -470,7 +470,7 @@ jobs: report_name: Coverage Admin Interface type: lcov result_path: ./coverage/lcov.info - min_coverage: 78 + min_coverage: 79 token: ${{ github.token }} ############################################################################## diff --git a/admin/src/components/CreationFormular.vue b/admin/src/components/CreationFormular.vue index 490996f0c..f939605ad 100644 --- a/admin/src/components/CreationFormular.vue +++ b/admin/src/components/CreationFormular.vue @@ -199,16 +199,12 @@ export default { }), ) this.$store.commit('openCreationsPlus', 1) - // das creation Formular reseten this.$refs.creationForm.reset() - // Den geschöpften Wert auf o setzen this.value = 0 }) .catch((error) => { this.$toasted.error(error.message) - // das creation Formular reseten this.$refs.creationForm.reset() - // Den geschöpften Wert auf o setzen this.value = 0 }) } @@ -219,15 +215,5 @@ export default { this.updateRadioSelected(this.selected) }, }, - computed: { - radioOptions() { - return this.creationDateObjects.map((obj, idx) => { - return { - item: { ...obj, creation: this.creation[idx] }, - name: obj.short + (this.creation[idx] ? ' ' + this.creation[idx] + ' GDD' : ''), - } - }) - }, - }, } diff --git a/admin/src/mixins/creationMonths.js b/admin/src/mixins/creationMonths.js index 56dca5c56..a2bbdcd1a 100644 --- a/admin/src/mixins/creationMonths.js +++ b/admin/src/mixins/creationMonths.js @@ -1,4 +1,7 @@ export const creationMonths = { + props: { + creation: [1000, 1000, 1000], + }, computed: { creationDates() { const now = new Date(Date.now()) @@ -20,5 +23,13 @@ export const creationMonths = { }) return result }, + radioOptions() { + return this.creationDateObjects.map((obj, idx) => { + return { + item: { ...obj, creation: this.creation[idx] }, + name: obj.short + (this.creation[idx] ? ' ' + this.creation[idx] + ' GDD' : ''), + } + }) + }, }, } From 409280316c49f0a4c2dc24091a5472b98c13dfd7 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 26 Jan 2022 18:20:25 +0100 Subject: [PATCH 20/47] refactor edit compoenents form and test it --- .../components/EditCreationFormular.spec.js | 246 +++++------------- admin/src/components/EditCreationFormular.vue | 155 ++--------- 2 files changed, 89 insertions(+), 312 deletions(-) diff --git a/admin/src/components/EditCreationFormular.spec.js b/admin/src/components/EditCreationFormular.spec.js index 0fe83cc9a..84d3e26d3 100644 --- a/admin/src/components/EditCreationFormular.spec.js +++ b/admin/src/components/EditCreationFormular.spec.js @@ -7,8 +7,9 @@ const apolloMutateMock = jest.fn().mockResolvedValue({ data: { updatePendingCreation: { creation: [0, 0, 0], + amount: 500, date: new Date(), - memo: 'qwertzuiopasdfghjkl', + memo: 'Test Schöpfung 2', moderator: 0, }, }, @@ -82,196 +83,79 @@ describe('EditCreationFormular', () => { expect(wrapper.findAll('input[type="radio"]').length).toBe(3) }) - describe('with single creation', () => { + it('has the third radio button checked', () => { + expect(wrapper.findAll('input[type="radio"]').at(0).element.checked).toBeFalsy() + expect(wrapper.findAll('input[type="radio"]').at(1).element.checked).toBeFalsy() + expect(wrapper.findAll('input[type="radio"]').at(2).element.checked).toBeTruthy() + }) + + it('has rangeMax of 700', () => { + expect(wrapper.find('input[type="number"]').attributes('max')).toBe('700') + }) + + describe('change and save memo and value with success', () => { beforeEach(async () => { - jest.clearAllMocks() - await wrapper.setProps({ creation: [200, 400, 600] }) - await wrapper.setData({ rangeMin: 180 }) - await wrapper.setData({ text: 'Test create coins' }) - await wrapper.setData({ value: 90 }) + await wrapper.find('input[type="number"]').setValue(500) + await wrapper.find('textarea').setValue('Test Schöpfung 2') + await wrapper.find('.test-submit').trigger('click') }) - describe('first radio button', () => { - beforeEach(async () => { - await wrapper.findAll('input[type="radio"]').at(0).setChecked() - }) - - it('sets rangeMin to 0', () => { - expect(wrapper.vm.rangeMin).toBe(0) - }) - - it('sets rangeMax to 200', () => { - expect(wrapper.vm.rangeMax).toBe(200) - }) - - describe('sendForm', () => { - beforeEach(async () => { - await wrapper.find('.test-submit').trigger('click') - }) - - it('sends ... to apollo', () => { - expect(apolloMutateMock).toBeCalledWith( - expect.objectContaining({ - variables: { - amount: 90, - creationDate: getCreationDate(2), - email: 'bob@baumeister.de', - id: 0, - memo: 'Test create coins', - moderator: 0, - }, - }), - ) - }) - - it('emits update-user-data', () => { - expect(wrapper.emitted('update-user-data')).toBeTruthy() - expect(wrapper.emitted('update-user-data')).toEqual([ - [ - { - id: 0, - email: 'bob@baumeister.de', - }, - [0, 0, 0], - ], - ]) - }) - - it('toast success message', () => { - expect(toastedSuccessMock).toBeCalledWith('creation_form.toasted_update') - }) - - describe('sendForm with error', () => { - beforeEach(async () => { - jest.clearAllMocks() - apolloMutateMock.mockRejectedValue({ - message: 'Ouch!', - }) - wrapper = Wrapper() - await wrapper.setProps({ type: 'singleCreation', creation: [200, 400, 600] }) - await wrapper.setData({ text: 'Test create coins' }) - await wrapper.setData({ value: 90 }) - await wrapper.findAll('input[type="radio"]').at(0).setChecked() - await wrapper.setData({ rangeMin: 100 }) - await wrapper.find('.test-submit').trigger('click') - }) - - it('toast error message', () => { - expect(toastedErrorMock).toBeCalledWith('Ouch!') - }) - }) - }) + it('calls the API', () => { + expect(apolloMutateMock).toBeCalledWith( + expect.objectContaining({ + variables: { + id: 0, + email: 'bob@baumeister.de', + creationDate: getCreationDate(0), + amount: 500, + memo: 'Test Schöpfung 2', + moderator: 0, + }, + }), + ) }) - describe('second radio button', () => { - beforeEach(async () => { - await wrapper.findAll('input[type="radio"]').at(1).setChecked() - }) - - it('sets rangeMin to 0', () => { - expect(wrapper.vm.rangeMin).toBe(0) - }) - - it('sets rangeMax to 400', () => { - expect(wrapper.vm.rangeMax).toBe(400) - }) - - describe('sendForm', () => { - beforeEach(async () => { - await wrapper.find('.test-submit').trigger('click') - }) - - it('sends ... to apollo', () => { - expect(apolloMutateMock).toBeCalledWith( - expect.objectContaining({ - variables: { - amount: 90, - creationDate: getCreationDate(1), - email: 'bob@baumeister.de', - id: 0, - memo: 'Test create coins', - moderator: 0, - }, - }), - ) - }) - - describe('sendForm with error', () => { - beforeEach(async () => { - jest.clearAllMocks() - apolloMutateMock.mockRejectedValue({ - message: 'Ouch!', - }) - wrapper = Wrapper() - await wrapper.setProps({ creation: [200, 400, 600] }) - await wrapper.setData({ text: 'Test create coins' }) - await wrapper.setData({ value: 100 }) - await wrapper.findAll('input[type="radio"]').at(1).setChecked() - await wrapper.setData({ rangeMin: 180 }) - await wrapper.find('.test-submit').trigger('click') - }) - - it('toast error message', () => { - expect(toastedErrorMock).toBeCalledWith('Ouch!') - }) - }) - }) + it('emits update-user-data', () => { + expect(wrapper.emitted('update-user-data')).toEqual([ + [ + { + id: 0, + email: 'bob@baumeister.de', + }, + [0, 0, 0], + ], + ]) }) - describe('third radio button', () => { - beforeEach(async () => { - await wrapper.setData({ rangeMin: 180 }) - await wrapper.findAll('input[type="radio"]').at(2).setChecked() - }) + it('emits update-creation-data', () => { + expect(wrapper.emitted('update-creation-data')).toEqual([ + [ + { + amount: 500, + date: expect.any(Date), + memo: 'Test Schöpfung 2', + moderator: 0, + row: expect.any(Object), + }, + ], + ]) + }) - it('sets rangeMin to 180', () => { - expect(wrapper.vm.rangeMin).toBe(180) - }) + it('toasts a success message', () => { + expect(toastedSuccessMock).toBeCalledWith('creation_form.toasted_update') + }) + }) - it('sets rangeMax to 700', () => { - expect(wrapper.vm.rangeMax).toBe(700) - }) + describe('change and save memo and value with error', () => { + beforeEach(async () => { + apolloMutateMock.mockRejectedValue({ message: 'Oh no!' }) + await wrapper.find('input[type="number"]').setValue(500) + await wrapper.find('textarea').setValue('Test Schöpfung 2') + await wrapper.find('.test-submit').trigger('click') + }) - describe('sendForm with success', () => { - beforeEach(async () => { - await wrapper.find('.test-submit').trigger('click') - }) - - it('sends ... to apollo', () => { - expect(apolloMutateMock).toBeCalledWith( - expect.objectContaining({ - variables: { - amount: 90, - creationDate: getCreationDate(0), - email: 'bob@baumeister.de', - id: 0, - memo: 'Test create coins', - moderator: 0, - }, - }), - ) - }) - }) - - describe('sendForm with error', () => { - beforeEach(async () => { - jest.clearAllMocks() - apolloMutateMock.mockRejectedValue({ - message: 'Ouch!', - }) - wrapper = Wrapper() - await wrapper.setProps({ creation: [200, 400, 600] }) - await wrapper.setData({ text: 'Test create coins' }) - await wrapper.setData({ value: 90 }) - await wrapper.findAll('input[type="radio"]').at(2).setChecked() - await wrapper.setData({ rangeMin: 180 }) - await wrapper.find('.test-submit').trigger('click') - }) - - it('toast error message', () => { - expect(toastedErrorMock).toBeCalledWith('Ouch!') - }) - }) + it('toasts an error message', () => { + expect(toastedErrorMock).toBeCalledWith('Oh no!') }) }) }) diff --git a/admin/src/components/EditCreationFormular.vue b/admin/src/components/EditCreationFormular.vue index fe174a30a..13caa76d2 100644 --- a/admin/src/components/EditCreationFormular.vue +++ b/admin/src/components/EditCreationFormular.vue @@ -4,65 +4,14 @@ - - - - - - - - - - - - - - - + -
@@ -111,7 +60,7 @@ variant="success" class="test-submit" @click="submitCreation" - :disabled="radioSelected === '' || value <= 0 || text.length < 10" + :disabled="selected === '' || value <= 0 || text.length < 10" > {{ $t('creation_form.update_creation') }} @@ -124,8 +73,11 @@