diff --git a/cypress/integration/common/profile.js b/cypress/integration/common/profile.js index cb5689f63..1df1e2652 100644 --- a/cypress/integration/common/profile.js +++ b/cypress/integration/common/profile.js @@ -12,14 +12,16 @@ Then('I should be able to change my profile picture', () => { cy.fixture(avatarUpload, 'base64').then(fileContent => { cy.get('#customdropzone').upload( { fileContent, fileName: avatarUpload, mimeType: 'image/png' }, - { subjectType: 'drag-n-drop' }, + { subjectType: 'drag-n-drop' } ) }) - cy.get('#customdropzone') - .should('have.attr', 'style') + cy.get('.profile-avatar img') + .should('have.attr', 'src') .and('contains', 'onourjourney') - cy.contains('.iziToast-message', 'Upload successful') - .should('have.length', 1) + cy.contains('.iziToast-message', 'Upload successful').should( + 'have.length', + 1 + ) }) When("I visit another user's profile page", () => { @@ -31,4 +33,4 @@ Then('I cannot upload a picture', () => { .children() .should('not.have.id', 'customdropzone') .should('have.class', 'ds-avatar') -}) \ No newline at end of file +}) diff --git a/webapp/components/Upload/index.vue b/webapp/components/Upload/index.vue index a1ea4ab55..f7f730632 100644 --- a/webapp/components/Upload/index.vue +++ b/webapp/components/Upload/index.vue @@ -4,21 +4,30 @@ id="customdropzone" :key="user.avatar" ref="el" + :use-custom-slot="true" :options="dropzoneOptions" - :include-styling="false" - :style="backgroundImage" - @vdropzone-thumbnail="thumbnail" @vdropzone-error="verror" - /> + > +
+ - diff --git a/webapp/components/Upload/spec.js b/webapp/components/Upload/spec.js index b81babb6e..8ee5f6046 100644 --- a/webapp/components/Upload/spec.js +++ b/webapp/components/Upload/spec.js @@ -35,26 +35,6 @@ describe('Upload', () => { }, } - const fileSuccess = { - filename: 'avatar.jpg', - previewElement: { - classList: { - remove: jest.fn(), - add: jest.fn(), - }, - querySelectorAll: jest.fn().mockReturnValue([ - { - alt: '', - style: { - 'background-image': '/api/generic.jpg', - }, - }, - ]), - }, - } - - const dataUrl = 'avatar.jpg' - beforeEach(() => { jest.useFakeTimers() wrapper = shallowMount(Upload, { localVue, propsData, mocks }) @@ -69,11 +49,6 @@ describe('Upload', () => { expect(mocks.$apollo.mutate).toHaveBeenCalledTimes(1) }) - it('thumbnail', () => { - wrapper.vm.thumbnail(fileSuccess, dataUrl) - expect(fileSuccess.previewElement.classList.add).toHaveBeenCalledTimes(1) - }) - describe('error handling', () => { const message = 'File upload failed' const fileError = { status: 'error' } @@ -93,5 +68,15 @@ describe('Upload', () => { jest.runAllTimers() expect(wrapper.vm.error).toEqual(false) }) + + it('shows an error toaster when the apollo mutation rejects', async () => { + // calls vddrop twice because of how mockResolvedValueOnce works in jest + // the first time the mock function is called it will resolve, calling it a + // second time will cause it to fail(with this implementation) + // https://jestjs.io/docs/en/mock-function-api.html#mockfnmockresolvedvalueoncevalue + await wrapper.vm.vddrop([{ filename: 'avatar.jpg' }]) + await wrapper.vm.vddrop([{ filename: 'avatar.jpg' }]) + expect(mocks.$toast.error).toHaveBeenCalledTimes(1) + }) }) }) diff --git a/webapp/package.json b/webapp/package.json index 512e827e8..379053d08 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -51,7 +51,7 @@ "dependencies": { "@human-connection/styleguide": "0.5.17", "@nuxtjs/apollo": "4.0.0-rc4.2", - "@nuxtjs/axios": "~5.5.3", + "@nuxtjs/axios": "~5.5.4", "@nuxtjs/dotenv": "~1.3.0", "@nuxtjs/style-resources": "~0.1.2", "accounting": "~0.4.1", @@ -75,7 +75,6 @@ "vue-count-to": "~1.0.13", "vue-izitoast": "1.1.2", "vue-sweetalert-icons": "~3.2.0", - "vue2-dropzone": "^3.5.9", "vuex-i18n": "~1.11.0", "zxcvbn": "^4.4.2" }, @@ -107,7 +106,7 @@ "nodemon": "~1.19.1", "prettier": "~1.17.1", "sass-loader": "~7.1.0", - "tippy.js": "^4.3.2", + "tippy.js": "^4.3.3", "vue-jest": "~3.0.4", "vue-svg-loader": "~0.12.0" } diff --git a/webapp/yarn.lock b/webapp/yarn.lock index f08f339ca..56e2e50b3 100644 --- a/webapp/yarn.lock +++ b/webapp/yarn.lock @@ -1141,10 +1141,10 @@ vue-cli-plugin-apollo "^0.20.0" webpack-node-externals "^1.7.2" -"@nuxtjs/axios@~5.5.3": - version "5.5.3" - resolved "https://registry.yarnpkg.com/@nuxtjs/axios/-/axios-5.5.3.tgz#1893609fc4a3e845516a45c1aaf428104cb3d524" - integrity sha512-WEgWcmgJqWLHWw8ZTieQvuV+I6vcaVgdnCmtzrsKliPsCTtbhDu1i7iFkM/dYAqppIxpL2v46lH6sQ4FfOOxTA== +"@nuxtjs/axios@~5.5.4": + version "5.5.4" + resolved "https://registry.yarnpkg.com/@nuxtjs/axios/-/axios-5.5.4.tgz#c4aee2322901b19d4072670c03144662a73ea6f4" + integrity sha512-/Ljsyh5VIc9paXGrQue7RQ+PpBNES1oit0g4l+ya1tfyKnZMpHSbghuLcv0xq+BpXlSEr690uemHbz54/N6U5w== dependencies: "@nuxtjs/proxy" "^1.3.3" axios "^0.19.0" @@ -10561,10 +10561,10 @@ timsort@^0.3.0: resolved "https://registry.yarnpkg.com/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4" integrity sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q= -tippy.js@^4.3.2: - version "4.3.2" - resolved "https://registry.yarnpkg.com/tippy.js/-/tippy.js-4.3.2.tgz#f785d96fd03d890aa118646e1a873f851bd1c8b4" - integrity sha512-vSdVU8zkhsdCFegwtKq7WJfF29xo4Qiq5GWPZEjKbW4knogI43HJHPAOCUkxbi28gKTTgiWF+GveZgTqhS9QOw== +tippy.js@^4.3.3: + version "4.3.3" + resolved "https://registry.yarnpkg.com/tippy.js/-/tippy.js-4.3.3.tgz#396304bea577bbff03f2700a1761329e8c1fce86" + integrity sha512-2fPMlquzVQxpLoOd0eJA1sPZ86/R6zD/9985wV0d2zhhX52DiO3aeg7TTS/mBrUjgFwVZh19YLb4l2c8bJkQPw== dependencies: popper.js "^1.14.7" @@ -11318,13 +11318,6 @@ vue2-dropzone@3.5.8: dependencies: dropzone "^5.5.1" -vue2-dropzone@^3.5.9: - version "3.5.9" - resolved "https://registry.yarnpkg.com/vue2-dropzone/-/vue2-dropzone-3.5.9.tgz#a63999a45a7aad24d4c21e3d35be409b4e6bdce8" - integrity sha512-nJz6teulVKlZIAeKgvPU7wBI/gzfIgqDOrEp1okSkQIkdprDVCoM0U7XWM0NOM4AAVX+4XGRtMoocYWdTYb3bQ== - dependencies: - dropzone "^5.5.1" - vue@^2.6.10, vue@^2.6.6: version "2.6.10" resolved "https://registry.yarnpkg.com/vue/-/vue-2.6.10.tgz#a72b1a42a4d82a721ea438d1b6bf55e66195c637"