Remove need for third party url upload

- we can save the file to a variable, it requires a "url" returned
- we can get by returning an empty string
This commit is contained in:
Matt Rider 2019-06-25 12:09:48 -03:00
parent 145f488556
commit 9f8720df81
3 changed files with 10 additions and 11 deletions

View File

@ -1 +1 @@
scalar Upload
scalar Upload

View File

@ -97,10 +97,9 @@ describe('ContributionForm.vue', () => {
})
describe('valid form submission', () => {
const imageUpload = {
file: { filename: 'avataar.svg', previewElement: '' },
url: 'someUrlToImage',
}
const imageUpload = [
{ file: { filename: 'avataar.svg', previewElement: '' }, url: 'someUrlToImage' },
]
beforeEach(async () => {
expectedParams = {
mutation: PostMutations().CreatePost,
@ -135,8 +134,8 @@ describe('ContributionForm.vue', () => {
})
it('supports adding a teaser image', async () => {
expectedParams.variables.imageUpload = imageUpload
wrapper.vm.vsuccess(imageUpload)
expectedParams.variables.imageUpload = imageUpload[0]
wrapper.vm.addTeaserImage(imageUpload)
await wrapper.find('form').trigger('submit')
expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expect.objectContaining(expectedParams))
})

View File

@ -8,7 +8,6 @@
id="postdropzone"
:use-custom-slot="true"
@vdropzone-thumbnail="thumbnail"
@vdropzone-success="vsuccess"
@vdropzone-error="verror"
>
<div class="dz-message">
@ -108,7 +107,7 @@ export default {
slug: null,
users: [],
dropzoneOptions: {
url: 'https://httpbin.org/post',
url: this.addTeaserImage,
maxFilesize: 5.0,
previewTemplate: this.template(),
},
@ -204,8 +203,9 @@ export default {
this.form.languageOptions.push({ label: locale.name, value: locale.code })
})
},
vsuccess(file, response) {
this.form.teaserImage = file
addTeaserImage(file) {
this.form.teaserImage = file[0]
return ''
},
thumbnail: (file, dataUrl) => {
let thumbnailElement, contributionImage, uploadArea