diff --git a/backend/package.json b/backend/package.json index b73efd2c7..be5fb086d 100644 --- a/backend/package.json +++ b/backend/package.json @@ -52,7 +52,7 @@ "cheerio": "~1.0.0-rc.3", "cors": "~2.8.5", "cross-env": "~5.2.0", - "date-fns": "2.0.0-alpha.27", + "date-fns": "2.0.0-alpha.29", "debug": "~4.1.1", "dotenv": "~8.0.0", "express": "~4.17.1", diff --git a/backend/yarn.lock b/backend/yarn.lock index 93192e865..9c8fdc3c5 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -2579,10 +2579,10 @@ data-urls@^1.0.0: whatwg-mimetype "^2.2.0" whatwg-url "^7.0.0" -date-fns@2.0.0-alpha.27: - version "2.0.0-alpha.27" - resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.0.0-alpha.27.tgz#5ecd4204ef0e7064264039570f6e8afbc014481c" - integrity sha512-cqfVLS+346P/Mpj2RpDrBv0P4p2zZhWWvfY5fuWrXNR/K38HaAGEkeOwb47hIpQP9Jr/TIxjZ2/sNMQwdXuGMg== +date-fns@2.0.0-alpha.29: + version "2.0.0-alpha.29" + resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.0.0-alpha.29.tgz#9d4a36e3ebba63d009e957fea8fdfef7921bc6cb" + integrity sha512-AIFZ0hG/1fdb7HZHTDyiEJdNiaFyZxXcx/kF8z3I9wxbhkN678KrrLSneKcsb0Xy5KqCA4wCIxmGpdVWSNZnpA== debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3, debug@^2.6.8, debug@^2.6.9: version "2.6.9" 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/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index 387f33ac0..8f5bcc8ea 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -230,7 +230,7 @@ When('I type in the following text:', text => { Then('the post shows up on the landing page at position {int}', index => { cy.openPage('landing') - const selector = `:nth-child(${index}) > .ds-card > .ds-card-content` + const selector = `.post-card:nth-child(${index}) > .ds-card-content` cy.get(selector).should('contain', lastPost.title) cy.get(selector).should('contain', lastPost.content) }) diff --git a/webapp/components/FilterMenu/FilterMenu.spec.js b/webapp/components/FilterMenu/FilterMenu.spec.js new file mode 100644 index 000000000..c312a401b --- /dev/null +++ b/webapp/components/FilterMenu/FilterMenu.spec.js @@ -0,0 +1,54 @@ +import { mount, createLocalVue } from '@vue/test-utils' +import FilterMenu from './FilterMenu.vue' +import Styleguide from '@human-connection/styleguide' + +const localVue = createLocalVue() + +localVue.use(Styleguide) + +describe('FilterMenu.vue', () => { + let wrapper + let mocks + + const createWrapper = mountMethod => { + return mountMethod(FilterMenu, { + mocks, + localVue, + }) + } + + beforeEach(() => { + mocks = { $t: () => {} } + }) + + describe('mount', () => { + beforeEach(() => { + wrapper = createWrapper(mount) + }) + + it('renders a card', () => { + expect(wrapper.is('.ds-card')).toBe(true) + }) + + describe('click "filter-by-followed-authors-only" button', () => { + it('emits filterBubble object', () => { + wrapper.find({ name: 'filter-by-followed-authors-only' }).trigger('click') + expect(wrapper.emitted('changeFilterBubble')).toBeTruthy() + }) + + it('toggles filterBubble.author property', () => { + wrapper.find({ name: 'filter-by-followed-authors-only' }).trigger('click') + expect(wrapper.emitted('changeFilterBubble')[0]).toEqual([{ author: 'following' }]) + wrapper.find({ name: 'filter-by-followed-authors-only' }).trigger('click') + expect(wrapper.emitted('changeFilterBubble')[1]).toEqual([{ author: 'all' }]) + }) + + it('makes button primary', () => { + wrapper.find({ name: 'filter-by-followed-authors-only' }).trigger('click') + expect( + wrapper.find({ name: 'filter-by-followed-authors-only' }).classes('ds-button-primary'), + ).toBe(true) + }) + }) + }) +}) diff --git a/webapp/components/FilterMenu/FilterMenu.vue b/webapp/components/FilterMenu/FilterMenu.vue new file mode 100644 index 000000000..a2195a5fd --- /dev/null +++ b/webapp/components/FilterMenu/FilterMenu.vue @@ -0,0 +1,57 @@ + + + + + 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/locales/de.json b/webapp/locales/de.json index 909659366..a790e6461 100644 --- a/webapp/locales/de.json +++ b/webapp/locales/de.json @@ -1,4 +1,7 @@ { + "filter-menu": { + "title": "Deine Filterblase" + }, "login": { "copy": "Wenn Du bereits ein Konto bei Human Connection hast, melde Dich bitte hier an.", "login": "Einloggen", diff --git a/webapp/locales/en.json b/webapp/locales/en.json index bd517a7ce..289928f92 100644 --- a/webapp/locales/en.json +++ b/webapp/locales/en.json @@ -1,4 +1,7 @@ { + "filter-menu": { + "title": "Your filter bubble" + }, "login": { "copy": "If you already have a human-connection account, login here.", "login": "Login", diff --git a/webapp/package.json b/webapp/package.json index e230839f5..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", @@ -59,7 +59,7 @@ "apollo-client": "~2.6.1", "cookie-universal-nuxt": "~2.0.14", "cross-env": "~5.2.0", - "date-fns": "2.0.0-alpha.27", + "date-fns": "2.0.0-alpha.29", "express": "~4.17.1", "graphql": "~14.3.1", "jsonwebtoken": "~8.5.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/pages/index.vue b/webapp/pages/index.vue index a45a99656..d8becf206 100644 --- a/webapp/pages/index.vue +++ b/webapp/pages/index.vue @@ -1,6 +1,9 @@