From 1ca274fad43147410a3fb1e5f663623849b75742 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 31 May 2023 11:01:28 +0200 Subject: [PATCH 01/39] Add creatEvent to the update post so the form has event specific fields. Co-authored-by: elweyn Co-authored-by: maeckes-infinitylabs --- webapp/pages/post/edit/_id.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/pages/post/edit/_id.vue b/webapp/pages/post/edit/_id.vue index d365709be..d05eef449 100644 --- a/webapp/pages/post/edit/_id.vue +++ b/webapp/pages/post/edit/_id.vue @@ -12,6 +12,7 @@   From e18fa0cea03fb817e70235093dda0dd82de7279b Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 31 May 2023 12:32:48 +0200 Subject: [PATCH 02/39] Fix test of post edit. Co-authored-by: maeckes-infinitylabs --- webapp/pages/post/edit/_id.spec.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/webapp/pages/post/edit/_id.spec.js b/webapp/pages/post/edit/_id.spec.js index aa25eb8e8..3bb68b098 100644 --- a/webapp/pages/post/edit/_id.spec.js +++ b/webapp/pages/post/edit/_id.spec.js @@ -29,7 +29,10 @@ describe('post/_id.vue', () => { defaultClient: { query: jest.fn().mockResolvedValue({ data: { - Post: [{ author: { id: authorId } }], + Post: [{ + author: { id: authorId }, + postType: ['Article'], + }], }, }), }, From ef7bb652bc29647094aeac6ae0f467408e6088ea Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 31 May 2023 20:44:44 +0200 Subject: [PATCH 03/39] Fix linting. Co-authored-by: maeckes-infinitylabs --- webapp/pages/post/edit/_id.spec.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/webapp/pages/post/edit/_id.spec.js b/webapp/pages/post/edit/_id.spec.js index 3bb68b098..2773483a4 100644 --- a/webapp/pages/post/edit/_id.spec.js +++ b/webapp/pages/post/edit/_id.spec.js @@ -29,10 +29,12 @@ describe('post/_id.vue', () => { defaultClient: { query: jest.fn().mockResolvedValue({ data: { - Post: [{ - author: { id: authorId }, - postType: ['Article'], - }], + Post: [ + { + author: { id: authorId }, + postType: ['Article'], + }, + ], }, }), }, From 17e0d0a85c92102e99a42cd29d093ccf27745922 Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 1 Jun 2023 13:04:06 +0200 Subject: [PATCH 04/39] Rename creatEvent to createEvent --- .../ContributionForm/ContributionForm.vue | 14 +++++++------- webapp/pages/post/create.vue | 16 ++++++++-------- webapp/pages/post/edit/_id.vue | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index 997a25341..eea00e444 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -54,7 +54,7 @@ -
+

@@ -210,7 +210,7 @@ export default { type: Object, default: () => null, }, - creatEvent: { + createEvent: { type: Boolean, default: false, }, @@ -266,9 +266,9 @@ export default { return [] }, }, - eventStart: { required: !!this.creatEvent }, - eventVenue: { required: !!this.creatEvent, min: 3, max: 100 }, - eventLocationName: { required: !!this.creatEvent, min: 3, max: 100 }, + eventStart: { required: !!this.createEvent }, + eventVenue: { required: !!this.createEvent, min: 3, max: 100 }, + eventLocationName: { required: !!this.createEvent, min: 3, max: 100 }, }, loading: false, users: [], @@ -284,7 +284,7 @@ export default { currentUser: 'auth/user', }), eventInput() { - if (this.creatEvent) { + if (this.createEvent) { return { eventStart: this.formData.eventStart, eventVenue: this.formData.eventVenue, @@ -356,7 +356,7 @@ export default { id: this.contribution.id || null, image, groupId: this.groupId, - postType: !this.creatEvent ? 'Article' : 'Event', + postType: !this.createEvent ? 'Article' : 'Event', eventInput: this.eventInput, }, }) diff --git a/webapp/pages/post/create.vue b/webapp/pages/post/create.vue index 199cc14a4..9da1a85e9 100644 --- a/webapp/pages/post/create.vue +++ b/webapp/pages/post/create.vue @@ -4,10 +4,10 @@ - +
{{ $t('post.createNewPost.title') }} - + {{ $t('post.createNewPost.title') }}
- +
{{ $t('post.createNewEvent.title') }} - + {{ $t('post.createNewEvent.title') }}
@@ -50,7 +50,7 @@ - +   @@ -69,7 +69,7 @@ export default { const { groupId = null } = this.$route.query return { groupId, - creatEvent: false, + createEvent: false, } }, computed: { diff --git a/webapp/pages/post/edit/_id.vue b/webapp/pages/post/edit/_id.vue index d05eef449..649174ca3 100644 --- a/webapp/pages/post/edit/_id.vue +++ b/webapp/pages/post/edit/_id.vue @@ -12,7 +12,7 @@
  From 726640a7593c07f802ccb069118b3072a1f444df Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 1 Jun 2023 13:36:24 +0200 Subject: [PATCH 05/39] Create a function to switch between Article and Event. --- webapp/pages/post/create.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/webapp/pages/post/create.vue b/webapp/pages/post/create.vue index 9da1a85e9..dbe58eaa0 100644 --- a/webapp/pages/post/create.vue +++ b/webapp/pages/post/create.vue @@ -15,7 +15,7 @@ > {{ $t('post.createNewPost.title') }} - + {{ $t('post.createNewPost.title') }}
@@ -34,7 +34,7 @@ > {{ $t('post.createNewEvent.title') }} - + {{ $t('post.createNewEvent.title') }}
@@ -98,6 +98,11 @@ export default { fetchPolicy: 'cache-and-network', }, }, + methods: { + switchPostType() { + this.createEvent = !this.createEvent + }, + }, } From 3d99382df9889b96056f5af83cc80ec6550503da Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 7 Jun 2023 10:18:53 +0200 Subject: [PATCH 18/39] Add change event for checkbox. --- webapp/components/ContributionForm/ContributionForm.vue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index d346cf3a7..b95e977a1 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -134,6 +134,7 @@ v-model="formData.eventIsOnline" name="eventIsOnline" class="event-grid-item-font-helper" + @change="changeEventIsOnline($event)" /> {{ $t('post.viewEvent.eventIsOnline') }} @@ -384,6 +385,9 @@ export default { updateEditorContent(value) { this.$refs.contributionForm.update('content', value) }, + changeEventIsOnline(event) { + this.$refs.contributionForm.update('eventIsOnline', event.target.value) + }, addHeroImage(file) { this.formData.image = null if (file) { From 89503b6b13376fade9a844cf71b1b670938e9d98 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 7 Jun 2023 10:20:28 +0200 Subject: [PATCH 19/39] Add change event for eventEnd. --- webapp/components/ContributionForm/ContributionForm.vue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index b95e977a1..eb630ec46 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -96,6 +96,7 @@ :disabled-date="notBeforeEventDay" :disabled-time="notBeforeEvent" :show-second="false" + @change="changeEventEnd($event)" > @@ -388,6 +389,9 @@ export default { changeEventIsOnline(event) { this.$refs.contributionForm.update('eventIsOnline', event.target.value) }, + changeEventEnd(event) { + this.$refs.contributionForm.update('eventEnd', event.target.value) + }, addHeroImage(file) { this.formData.image = null if (file) { From c0ae044182b479b73297078a5c9853915c865c5b Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 7 Jun 2023 10:31:22 +0200 Subject: [PATCH 20/39] WIP add change event on DatePicker. --- .../ContributionForm/ContributionForm.vue | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index eb630ec46..472d0db54 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -73,6 +73,7 @@ :disabled-date="notBeforeToday" :disabled-time="notBeforeNow" :show-second="false" + @change="changeEventStart($event)" >
@@ -86,6 +87,7 @@ Date: Wed, 7 Jun 2023 10:49:27 +0200 Subject: [PATCH 21/39] Make form interactive.. --- .../ContributionForm/ContributionForm.vue | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index 472d0db54..f4fc9ec46 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -116,7 +116,7 @@
- + Date: Wed, 7 Jun 2023 10:51:35 +0200 Subject: [PATCH 22/39] Remove unused InputCheckbox component. --- .../InputCheckbox/InputCheckbox.spec.js | 1 - .../InputCheckbox/InputCheckbox.vue | 42 ------------------- 2 files changed, 43 deletions(-) delete mode 100644 webapp/components/InputCheckbox/InputCheckbox.spec.js delete mode 100644 webapp/components/InputCheckbox/InputCheckbox.vue diff --git a/webapp/components/InputCheckbox/InputCheckbox.spec.js b/webapp/components/InputCheckbox/InputCheckbox.spec.js deleted file mode 100644 index 8b1378917..000000000 --- a/webapp/components/InputCheckbox/InputCheckbox.spec.js +++ /dev/null @@ -1 +0,0 @@ - diff --git a/webapp/components/InputCheckbox/InputCheckbox.vue b/webapp/components/InputCheckbox/InputCheckbox.vue deleted file mode 100644 index 04177d233..000000000 --- a/webapp/components/InputCheckbox/InputCheckbox.vue +++ /dev/null @@ -1,42 +0,0 @@ - - From 2c31453bb0b08467ccc6ca8fb6a21a25f777271e Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 7 Jun 2023 11:50:46 +0200 Subject: [PATCH 23/39] test event data form --- .../ContributionForm/ContributionForm.spec.js | 89 ++++++++++++++++++- .../ContributionForm/ContributionForm.vue | 4 +- 2 files changed, 90 insertions(+), 3 deletions(-) diff --git a/webapp/components/ContributionForm/ContributionForm.spec.js b/webapp/components/ContributionForm/ContributionForm.spec.js index 6b9db448b..9095665fc 100644 --- a/webapp/components/ContributionForm/ContributionForm.spec.js +++ b/webapp/components/ContributionForm/ContributionForm.spec.js @@ -1,8 +1,8 @@ import { mount } from '@vue/test-utils' import ContributionForm from './ContributionForm.vue' +import PostMutations from '~/graphql/PostMutations.js' import Vuex from 'vuex' -import PostMutations from '~/graphql/PostMutations.js' import ImageUploader from '~/components/Uploader/ImageUploader' import MutationObserver from 'mutation-observer' @@ -108,6 +108,10 @@ describe('ContributionForm.vue', () => { await wrapper.vm.updateEditorContent(postContent) }) + it('has no event data block', () => { + expect(wrapper.find('div.eventDatas').exists()).toBe(false) + }) + it('title cannot be empty', async () => { postTitleInput.setValue('') wrapper.find('form').trigger('submit') @@ -293,5 +297,88 @@ describe('ContributionForm.vue', () => { }) }) }) + + describe('Events', () => { + beforeEach(() => { + propsData.createEvent = true + wrapper = Wrapper() + }) + + it('has event data block', () => { + expect(wrapper.find('div.eventDatas').exists()).toBe(true) + }) + + describe('is online event', () => { + it('has false as default', () => { + expect(wrapper.vm.formData.eventIsOnline).toBe(false) + }) + + it('has input for event location', () => { + expect(wrapper.find('input[name="eventLocationName"]').exists()).toBe(true) + }) + + describe('click is online event', () => { + beforeEach(() => { + wrapper.find('input[name="eventIsOnline"]').setChecked(true) + }) + + it('has no input for event location', () => { + expect(wrapper.find('input[name="eventLocationName"]').exists()).toBe(false) + }) + }) + + describe('invalid form', () => { + beforeEach(() => { + wrapper.find('input[name="title"]').setValue('Illegaler Kindergeburtstag') + wrapper.vm.updateEditorContent('Elli hat Geburtstag!') + }) + + it('has submit button disabled', () => { + expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBe('disabled') + }) + }) + + describe('valid form', () => { + const now = new Date() + + beforeEach(() => { + wrapper.find('input[name="title"]').setValue('Illegaler Kindergeburtstag') + wrapper.vm.updateEditorContent('Elli hat Geburtstag!') + wrapper + .findComponent({ name: 'DatePicker' }) + .vm.$emit('change', new Date(now.getFullYear(), now.getMonth() + 1).toISOString()) + wrapper.find('input[name="eventVenue"]').setValue('Ellis Kinderzimmer') + wrapper.find('input[name="eventLocationName"]').setValue('Deutschland') + }) + + it('has submit button not disabled', () => { + expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBe(undefined) + }) + + describe('submit', () => { + beforeEach(() => { + wrapper.find('form').trigger('submit') + }) + + it('calls create post', () => { + expect(mocks.$apollo.mutate).toHaveBeenCalledWith({ + mutation: PostMutations().CreatePost, + variables: expect.objectContaining({ + title: 'Illegaler Kindergeburtstag', + content: 'Elli hat Geburtstag!', + eventInput: { + eventStart: new Date(now.getFullYear(), now.getMonth() + 1).toISOString(), + eventVenue: 'Ellis Kinderzimmer', + eventLocationName: 'Deutschland', + eventIsOnline: false, + eventEnd: null, + }, + }), + }) + }) + }) + }) + }) + }) }) }) diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index f4fc9ec46..31ff849a3 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -106,7 +106,7 @@
@@ -119,7 +119,7 @@
From de553e1f8262c8a1775e9a60f6d6114740708565 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 7 Jun 2023 12:27:09 +0200 Subject: [PATCH 24/39] Make eventEnd removable. Co-authored-by: maeckes --- backend/src/schema/resolvers/helpers/events.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/src/schema/resolvers/helpers/events.js b/backend/src/schema/resolvers/helpers/events.js index 84e64299d..e97d7aeac 100644 --- a/backend/src/schema/resolvers/helpers/events.js +++ b/backend/src/schema/resolvers/helpers/events.js @@ -5,10 +5,10 @@ export const validateEventParams = (params) => { const { eventInput } = params validateEventDate(eventInput.eventStart) params.eventStart = eventInput.eventStart - if (eventInput.eventEnd) { - validateEventEnd(eventInput.eventStart, eventInput.eventEnd) - params.eventEnd = eventInput.eventEnd - } + + validateEventEnd(eventInput.eventStart, eventInput.eventEnd) + params.eventEnd = eventInput.eventEnd + if (eventInput.eventLocationName && !eventInput.eventVenue) { throw new UserInputError('Event venue must be present if event location is given!') } @@ -38,6 +38,7 @@ const validateEventDate = (dateString) => { } const validateEventEnd = (start, end) => { + if (end === null) return const endDate = new Date(end) if (endDate.toString() === 'Invalid Date') throw new UserInputError('Event end date must be a valid date!') From 3dadfd43299aa54e92dbfed56d158d63d67b2965 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 7 Jun 2023 12:34:09 +0200 Subject: [PATCH 25/39] Add a trim to check if locationName is not empty. --- backend/src/schema/resolvers/helpers/events.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/schema/resolvers/helpers/events.js b/backend/src/schema/resolvers/helpers/events.js index e97d7aeac..41f8b0d74 100644 --- a/backend/src/schema/resolvers/helpers/events.js +++ b/backend/src/schema/resolvers/helpers/events.js @@ -18,7 +18,7 @@ export const validateEventParams = (params) => { } delete params.eventInput let locationName - if (params.eventLocationName) { + if (params.eventLocationName.trim()) { locationName = params.eventLocationName } else { params.eventLocationName = null From 4e43b77da2ea05859c334ab1d24530bfe79f8f91 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 7 Jun 2023 12:55:21 +0200 Subject: [PATCH 26/39] Add custom error messages for events. Co-authored-by: maeckes --- .../ContributionForm/ContributionForm.vue | 23 ++++++++++++++++++- webapp/locales/de.json | 4 ++++ webapp/locales/en.json | 4 ++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index 31ff849a3..ae1a7654b 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -286,11 +286,32 @@ export default { }, }, eventStart: { required: !!this.createEvent }, - eventVenue: { required: !!this.createEvent, min: 3, max: 100 }, + eventVenue: { + required: !!this.createEvent, + min: 3, + max: 100, + validator: (_, value = '') => { + if (!value.trim()) { + return [new Error(this.$t('common.validations.eventVenueNotEmpty'))] + } + if (value.length < 3 || value.length > 100) { + return [new Error(this.$t('common.validations.eventVenueLength', { min: 3, max: 100 }))] + } + return [] + }, }, eventLocationName: { required: !!this.createEvent && !this.formData.eventIsOnline, min: 3, max: 100, + validator: (_, value = '') => { + if (!value.trim()) { + return [new Error(this.$t('common.validations.eventLocationNameNotEmpty'))] + } + if (value.length < 3 || value.length > 100) { + return [new Error(this.$t('common.validations.eventLocationNameLength', { min: 3, max: 100 }))] + } + return [] + }, }, } }, diff --git a/webapp/locales/de.json b/webapp/locales/de.json index 1b57fb0dc..5acab107e 100644 --- a/webapp/locales/de.json +++ b/webapp/locales/de.json @@ -115,6 +115,10 @@ "validations": { "categories": "es müssen eine bis drei Themen ausgewählt werden", "email": "muss eine gültige E-Mail-Adresse sein", + "eventLocationNameLength": "Mindestens {min} Maximal {max}", + "eventLocationNameNotEmpty": "es dürfen nicht nur Freizeichen eingetragen werden", + "eventVenueLength": "Mindestens {min} Maximal {max}", + "eventVenueNotEmpty": "es dürfen nicht nur Freizeichen eingetragen werden", "url": "muss eine gültige URL sein" }, "versus": "Versus" diff --git a/webapp/locales/en.json b/webapp/locales/en.json index 0f0b9c6b4..565f4b80a 100644 --- a/webapp/locales/en.json +++ b/webapp/locales/en.json @@ -115,6 +115,10 @@ "validations": { "categories": "at least one and at most three topics must be selected", "email": "must be a valid e-mail address", + "eventLocationNameLength": "minimal {min} maximal {max}", + "eventLocationNameNotEmpty": "only empty characters are not allowed", + "eventVenueLength": "minimal {min} maximal {max}", + "eventVenueNotEmpty": "only empty characters are not allowed", "url": "must be a valid URL" }, "versus": "Versus" From 387fa9bfcb136cdc2082d075a69c029f384df8cc Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 7 Jun 2023 16:03:30 +0200 Subject: [PATCH 27/39] Fix events helper. --- .../src/schema/resolvers/helpers/events.js | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/backend/src/schema/resolvers/helpers/events.js b/backend/src/schema/resolvers/helpers/events.js index 41f8b0d74..bb573021f 100644 --- a/backend/src/schema/resolvers/helpers/events.js +++ b/backend/src/schema/resolvers/helpers/events.js @@ -1,29 +1,32 @@ import { UserInputError } from 'apollo-server' export const validateEventParams = (params) => { + let locationName = null if (params.postType && params.postType === 'Event') { const { eventInput } = params validateEventDate(eventInput.eventStart) params.eventStart = eventInput.eventStart - validateEventEnd(eventInput.eventStart, eventInput.eventEnd) - params.eventEnd = eventInput.eventEnd + if (eventInput.eventEnd) { + validateEventEnd(eventInput.eventStart, eventInput.eventEnd) + params.eventEnd = eventInput.eventEnd + } else { + params.eventEnd = null + } if (eventInput.eventLocationName && !eventInput.eventVenue) { throw new UserInputError('Event venue must be present if event location is given!') } params.eventVenue = eventInput.eventVenue - params.eventLocationName = eventInput.eventLocationName + params.eventLocationName = eventInput.eventLocationName && eventInput.eventLocationName.trim() + if (params.eventLocationName) { + locationName = params.eventLocationName + } else { + params.eventLocationName = null + } params.eventIsOnline = !!eventInput.eventIsOnline } delete params.eventInput - let locationName - if (params.eventLocationName.trim()) { - locationName = params.eventLocationName - } else { - params.eventLocationName = null - locationName = null - } return locationName } @@ -38,7 +41,6 @@ const validateEventDate = (dateString) => { } const validateEventEnd = (start, end) => { - if (end === null) return const endDate = new Date(end) if (endDate.toString() === 'Invalid Date') throw new UserInputError('Event end date must be a valid date!') From ae2aec0d8a193a18f3d82c77042f474a0a4fd086 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 7 Jun 2023 16:43:38 +0200 Subject: [PATCH 28/39] Fix eventLocationName validator and remove eventLocationName of query parameters if eventIsOnline true. --- webapp/components/ContributionForm/ContributionForm.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index ae1a7654b..c305b1fed 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -304,6 +304,7 @@ export default { min: 3, max: 100, validator: (_, value = '') => { + if (this.formData.eventIsOnline) return [] if (!value.trim()) { return [new Error(this.$t('common.validations.eventLocationNameNotEmpty'))] } @@ -322,7 +323,7 @@ export default { eventVenue: this.formData.eventVenue, eventEnd: this.formData.eventEnd, eventIsOnline: this.formData.eventIsOnline, - eventLocationName: this.formData.eventLocationName, + eventLocationName: !this.formData.eventIsOnline ? this.formData.eventLocationName : null, } } return undefined From 107a9491ca046a38aadb8d7f8f257b14b4fdeb16 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 7 Jun 2023 16:47:30 +0200 Subject: [PATCH 29/39] Correct some locales. --- webapp/locales/de.json | 4 ++-- webapp/locales/en.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/webapp/locales/de.json b/webapp/locales/de.json index 5acab107e..1ce7d2f61 100644 --- a/webapp/locales/de.json +++ b/webapp/locales/de.json @@ -115,9 +115,9 @@ "validations": { "categories": "es müssen eine bis drei Themen ausgewählt werden", "email": "muss eine gültige E-Mail-Adresse sein", - "eventLocationNameLength": "Mindestens {min} Maximal {max}", + "eventLocationNameLength": "Minimum {min}, Maximum {max} Zeichen", "eventLocationNameNotEmpty": "es dürfen nicht nur Freizeichen eingetragen werden", - "eventVenueLength": "Mindestens {min} Maximal {max}", + "eventVenueLength": "Minimum {min}, Maximum {max} Zeichen", "eventVenueNotEmpty": "es dürfen nicht nur Freizeichen eingetragen werden", "url": "muss eine gültige URL sein" }, diff --git a/webapp/locales/en.json b/webapp/locales/en.json index 565f4b80a..f25cc8575 100644 --- a/webapp/locales/en.json +++ b/webapp/locales/en.json @@ -115,9 +115,9 @@ "validations": { "categories": "at least one and at most three topics must be selected", "email": "must be a valid e-mail address", - "eventLocationNameLength": "minimal {min} maximal {max}", + "eventLocationNameLength": "minimum {min} or maximum {max} characters", "eventLocationNameNotEmpty": "only empty characters are not allowed", - "eventVenueLength": "minimal {min} maximal {max}", + "eventVenueLength": "minimum {min} or maximum {max} characters", "eventVenueNotEmpty": "only empty characters are not allowed", "url": "must be a valid URL" }, From 930c1f219b613a60060b0057ba8b52511d6683b4 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 7 Jun 2023 17:08:31 +0200 Subject: [PATCH 30/39] Fix linting of webapp. --- .../ContributionForm/ContributionForm.vue | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index c305b1fed..6db9f7e02 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -286,7 +286,7 @@ export default { }, }, eventStart: { required: !!this.createEvent }, - eventVenue: { + eventVenue: { required: !!this.createEvent, min: 3, max: 100, @@ -295,10 +295,13 @@ export default { return [new Error(this.$t('common.validations.eventVenueNotEmpty'))] } if (value.length < 3 || value.length > 100) { - return [new Error(this.$t('common.validations.eventVenueLength', { min: 3, max: 100 }))] + return [ + new Error(this.$t('common.validations.eventVenueLength', { min: 3, max: 100 })), + ] } return [] - }, }, + }, + }, eventLocationName: { required: !!this.createEvent && !this.formData.eventIsOnline, min: 3, @@ -309,7 +312,11 @@ export default { return [new Error(this.$t('common.validations.eventLocationNameNotEmpty'))] } if (value.length < 3 || value.length > 100) { - return [new Error(this.$t('common.validations.eventLocationNameLength', { min: 3, max: 100 }))] + return [ + new Error( + this.$t('common.validations.eventLocationNameLength', { min: 3, max: 100 }), + ), + ] } return [] }, From e18baf34f3c491fa4cac95c4ed036fc08c79d9db Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 7 Jun 2023 17:09:19 +0200 Subject: [PATCH 31/39] Fix linting of backend. --- backend/src/schema/resolvers/helpers/events.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/schema/resolvers/helpers/events.js b/backend/src/schema/resolvers/helpers/events.js index bb573021f..835088d8c 100644 --- a/backend/src/schema/resolvers/helpers/events.js +++ b/backend/src/schema/resolvers/helpers/events.js @@ -11,7 +11,7 @@ export const validateEventParams = (params) => { validateEventEnd(eventInput.eventStart, eventInput.eventEnd) params.eventEnd = eventInput.eventEnd } else { - params.eventEnd = null + params.eventEnd = null } if (eventInput.eventLocationName && !eventInput.eventVenue) { From a8659e37bd3d06133060018af7e3f8f676a8e563 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 7 Jun 2023 17:46:06 +0200 Subject: [PATCH 32/39] check required in valiator --- .../ContributionForm/#ContributionForm.vue# | 623 ++++++++++++++++++ .../ContributionForm/ContributionForm.vue | 17 +- 2 files changed, 636 insertions(+), 4 deletions(-) create mode 100644 webapp/components/ContributionForm/#ContributionForm.vue# diff --git a/webapp/components/ContributionForm/#ContributionForm.vue# b/webapp/components/ContributionForm/#ContributionForm.vue# new file mode 100644 index 000000000..1d1353b1e --- /dev/null +++ b/webapp/components/ContributionForm/#ContributionForm.vue# @@ -0,0 +1,623 @@ + + + + diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index c305b1fed..47841c717 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -286,30 +286,39 @@ export default { }, }, eventStart: { required: !!this.createEvent }, - eventVenue: { + eventVenue: { required: !!this.createEvent, min: 3, max: 100, validator: (_, value = '') => { + if (!this.createEvent) return [] if (!value.trim()) { return [new Error(this.$t('common.validations.eventVenueNotEmpty'))] } if (value.length < 3 || value.length > 100) { - return [new Error(this.$t('common.validations.eventVenueLength', { min: 3, max: 100 }))] + return [ + new Error(this.$t('common.validations.eventVenueLength', { min: 3, max: 100 })), + ] } return [] - }, }, + }, + }, eventLocationName: { required: !!this.createEvent && !this.formData.eventIsOnline, min: 3, max: 100, validator: (_, value = '') => { + if (!this.createEvent) return [] if (this.formData.eventIsOnline) return [] if (!value.trim()) { return [new Error(this.$t('common.validations.eventLocationNameNotEmpty'))] } if (value.length < 3 || value.length > 100) { - return [new Error(this.$t('common.validations.eventLocationNameLength', { min: 3, max: 100 }))] + return [ + new Error( + this.$t('common.validations.eventLocationNameLength', { min: 3, max: 100 }), + ), + ] } return [] }, From a669f799ae5cea661e3cb2dcc17ac2e3aa483c17 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 7 Jun 2023 17:48:06 +0200 Subject: [PATCH 33/39] remove emacs backup --- .../ContributionForm/#ContributionForm.vue# | 623 ------------------ 1 file changed, 623 deletions(-) delete mode 100644 webapp/components/ContributionForm/#ContributionForm.vue# diff --git a/webapp/components/ContributionForm/#ContributionForm.vue# b/webapp/components/ContributionForm/#ContributionForm.vue# deleted file mode 100644 index 1d1353b1e..000000000 --- a/webapp/components/ContributionForm/#ContributionForm.vue# +++ /dev/null @@ -1,623 +0,0 @@ - - - - From 5b40122b0e805652df02d939edcfeecd6d9ec848 Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 8 Jun 2023 09:44:11 +0200 Subject: [PATCH 34/39] Remove async of cypress command and add contribution default value to post edit _id. --- cypress/support/commands.js | 3 +-- webapp/pages/post/edit/_id.vue | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 88836b4f1..2c3826f78 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -49,9 +49,8 @@ Cypress.Commands.add( 'mutate', { prevSubject: true }, (graphQLClient, mutation, variables, response) => { - return new Cypress.Promise(async (resolve, reject) => { + return new Cypress.Promise((resolve, reject) => { graphQLClient.request(mutation, variables).then(() => resolve(graphQLClient)) - }) }) diff --git a/webapp/pages/post/edit/_id.vue b/webapp/pages/post/edit/_id.vue index 7d17babd1..9bdde55da 100644 --- a/webapp/pages/post/edit/_id.vue +++ b/webapp/pages/post/edit/_id.vue @@ -41,7 +41,11 @@ export default { }), }, data() { - return { contribution: {} } + return { + contribution: { + postType: ['Article'], + } + } }, async asyncData(context) { const { From 866079d307043f21877d9dcf0bd57874f3fdbe6f Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 8 Jun 2023 09:49:42 +0200 Subject: [PATCH 35/39] Fix linting. --- webapp/pages/post/edit/_id.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/pages/post/edit/_id.vue b/webapp/pages/post/edit/_id.vue index 9bdde55da..04d120c50 100644 --- a/webapp/pages/post/edit/_id.vue +++ b/webapp/pages/post/edit/_id.vue @@ -41,10 +41,10 @@ export default { }), }, data() { - return { + return { contribution: { postType: ['Article'], - } + }, } }, async asyncData(context) { From e7cee2808751ee2baa97011ae61cffc301ac4db1 Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 8 Jun 2023 11:19:20 +0200 Subject: [PATCH 36/39] Remove gray box under date-picker. --- webapp/components/ContributionForm/ContributionForm.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index 47841c717..0067dab72 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -76,9 +76,9 @@ @change="changeEventStart($event)" >
-
+
- +
From abc272bfd925a4cc0d6ea6563610032e782ba7bd Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 8 Jun 2023 12:06:40 +0200 Subject: [PATCH 37/39] Set timeout for page load to 180000. --- cypress/cypress.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cypress/cypress.config.js b/cypress/cypress.config.js index 2d2cefc47..db8ea73e2 100644 --- a/cypress/cypress.config.js +++ b/cypress/cypress.config.js @@ -38,6 +38,7 @@ module.exports = defineConfig({ e2e: { projectId: "qa7fe2", defaultCommandTimeout: 10000, + pageLoadTimeout: 180000, chromeWebSecurity: false, baseUrl: "http://localhost:3000", specPattern: "cypress/e2e/**/*.feature", From 02cd897947ce349be7863e8450bbf8c772526805 Mon Sep 17 00:00:00 2001 From: mahula Date: Thu, 8 Jun 2023 13:01:07 +0200 Subject: [PATCH 38/39] set default cypress timeout up and merge get and contain --- cypress/cypress.config.js | 2 +- .../Notification.Mention/mention_{string}_in_the_text.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cypress/cypress.config.js b/cypress/cypress.config.js index db8ea73e2..9885eb7a2 100644 --- a/cypress/cypress.config.js +++ b/cypress/cypress.config.js @@ -37,7 +37,7 @@ const { parsed } = dotenv.config({ path: '../backend/.env' }) module.exports = defineConfig({ e2e: { projectId: "qa7fe2", - defaultCommandTimeout: 10000, + defaultCommandTimeout: 60000, pageLoadTimeout: 180000, chromeWebSecurity: false, baseUrl: "http://localhost:3000", diff --git a/cypress/support/step_definitions/Notification.Mention/mention_{string}_in_the_text.js b/cypress/support/step_definitions/Notification.Mention/mention_{string}_in_the_text.js index e1bd19da0..d404356f9 100644 --- a/cypress/support/step_definitions/Notification.Mention/mention_{string}_in_the_text.js +++ b/cypress/support/step_definitions/Notification.Mention/mention_{string}_in_the_text.js @@ -3,7 +3,6 @@ import { When } from "@badeball/cypress-cucumber-preprocessor"; When("mention {string} in the text", mention => { cy.get(".ProseMirror") .type(" @"); - cy.get(".suggestion-list__item") - .contains(mention) + cy.contains(".suggestion-list__item", mention) .click(); }); From 31e1efd356cb35c03f82c7845e62e6bccf489942 Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 8 Jun 2023 19:45:58 +0200 Subject: [PATCH 39/39] Remove cypress changes. --- cypress/cypress.config.js | 3 +-- cypress/support/commands.js | 3 ++- .../Notification.Mention/mention_{string}_in_the_text.js | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cypress/cypress.config.js b/cypress/cypress.config.js index 9885eb7a2..2d2cefc47 100644 --- a/cypress/cypress.config.js +++ b/cypress/cypress.config.js @@ -37,8 +37,7 @@ const { parsed } = dotenv.config({ path: '../backend/.env' }) module.exports = defineConfig({ e2e: { projectId: "qa7fe2", - defaultCommandTimeout: 60000, - pageLoadTimeout: 180000, + defaultCommandTimeout: 10000, chromeWebSecurity: false, baseUrl: "http://localhost:3000", specPattern: "cypress/e2e/**/*.feature", diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 2c3826f78..88836b4f1 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -49,8 +49,9 @@ Cypress.Commands.add( 'mutate', { prevSubject: true }, (graphQLClient, mutation, variables, response) => { - return new Cypress.Promise((resolve, reject) => { + return new Cypress.Promise(async (resolve, reject) => { graphQLClient.request(mutation, variables).then(() => resolve(graphQLClient)) + }) }) diff --git a/cypress/support/step_definitions/Notification.Mention/mention_{string}_in_the_text.js b/cypress/support/step_definitions/Notification.Mention/mention_{string}_in_the_text.js index d404356f9..e1bd19da0 100644 --- a/cypress/support/step_definitions/Notification.Mention/mention_{string}_in_the_text.js +++ b/cypress/support/step_definitions/Notification.Mention/mention_{string}_in_the_text.js @@ -3,6 +3,7 @@ import { When } from "@badeball/cypress-cucumber-preprocessor"; When("mention {string} in the text", mention => { cy.get(".ProseMirror") .type(" @"); - cy.contains(".suggestion-list__item", mention) + cy.get(".suggestion-list__item") + .contains(mention) .click(); });