diff --git a/webapp/components/ContributionForm/ContributionForm.spec.js b/webapp/components/ContributionForm/ContributionForm.spec.js
index 26d045523..1bb8d2e1a 100644
--- a/webapp/components/ContributionForm/ContributionForm.spec.js
+++ b/webapp/components/ContributionForm/ContributionForm.spec.js
@@ -9,6 +9,10 @@ import MutationObserver from 'mutation-observer'
global.MutationObserver = MutationObserver
+jest.mock('image-resize-compress', () => ({
+ fromURL: jest.fn((url) => new Blob([url], { type: 'image/jpeg' })),
+}))
+
const localVue = global.localVue
const stubs = {
@@ -150,6 +154,7 @@ describe('ContributionForm.vue', () => {
image: null,
groupId: null,
postType: 'Article',
+ files: [],
},
}
postTitleInput = wrapper.find('.ds-input')
@@ -189,6 +194,17 @@ describe('ContributionForm.vue', () => {
expect(mocks.$apollo.mutate).toHaveBeenCalledTimes(1)
})
+ it('can add an image to the content', async () => {
+ const content = '
'
+ await wrapper.vm.updateEditorContent(content)
+ expect(wrapper.vm.filesToUpload).toHaveLength(1)
+ await wrapper.find('form').trigger('submit')
+ expectedParams.variables.content = content
+ expectedParams.variables.files = [{ name: 'test image', type: 'image/jpeg', upload: {} }]
+ expectedParams.variables.eventInput = undefined
+ expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expect.objectContaining(expectedParams))
+ })
+
it("pushes the user to the post's page", async () => {
wrapper.find('form').trigger('submit')
await mocks.$apollo.mutate
@@ -277,12 +293,13 @@ describe('ContributionForm.vue', () => {
sensitive: false,
},
postType: 'Article',
+ files: [],
},
}
})
it('calls the UpdatePost apollo mutation', async () => {
- expectedParams.variables.content = postContent
+ expectedParams.variables.content = 'auf Deutsch geschrieben'
wrapper.vm.updateEditorContent(postContent)
await wrapper.find('form').trigger('submit')
expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expect.objectContaining(expectedParams))
diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue
index 4b92cdf47..dc4f438ff 100644
--- a/webapp/components/ContributionForm/ContributionForm.vue
+++ b/webapp/components/ContributionForm/ContributionForm.vue
@@ -189,7 +189,7 @@