diff --git a/webapp/components/FilterPosts/FilterPosts.spec.js b/webapp/components/FilterPosts/FilterPosts.spec.js index c0ad56843..0cbd3e962 100644 --- a/webapp/components/FilterPosts/FilterPosts.spec.js +++ b/webapp/components/FilterPosts/FilterPosts.spec.js @@ -19,6 +19,7 @@ describe('FilterPosts.vue', () => { let allCategoriesButton let environmentAndNatureButton let democracyAndPoliticsButton + let happyEmotionButton beforeEach(() => { mocks = { @@ -52,6 +53,7 @@ describe('FilterPosts.vue', () => { 'postsFilter/TOGGLE_FILTER_BY_FOLLOWED': jest.fn(), 'postsFilter/RESET_CATEGORIES': jest.fn(), 'postsFilter/TOGGLE_CATEGORY': jest.fn(), + 'postsFilter/TOGGLE_EMOTION': jest.fn(), } getters = { 'postsFilter/isActive': () => false, @@ -121,5 +123,22 @@ describe('FilterPosts.vue', () => { expect(mutations['postsFilter/TOGGLE_FILTER_BY_FOLLOWED']).toHaveBeenCalledWith({}, 'u34') }) }) + + describe('click on an "emotions-buttons" button', () => { + it('calls TOGGLE_EMOTION when clicked', () => { + const wrapper = openFilterPosts() + happyEmotionButton = wrapper.findAll('button.emotions-buttons').at(1) + happyEmotionButton.trigger('click') + expect(mutations['postsFilter/TOGGLE_EMOTION']).toHaveBeenCalledWith({}, 'happy') + }) + + it('sets the attribute `src` to colorized image', () => { + getters['postsFilter/filteredByEmotions'] = jest.fn(() => ['happy']) + const wrapper = openFilterPosts() + happyEmotionButton = wrapper.findAll('button.emotions-buttons').at(1) + const happyEmotionButtonImage = happyEmotionButton.find('img') + expect(happyEmotionButtonImage.attributes().src).toEqual('/img/svg/emoji/happy_color.svg') + }) + }) }) }) diff --git a/webapp/components/FilterPosts/GeneralFilterMenuItems.vue b/webapp/components/FilterPosts/GeneralFilterMenuItems.vue index 4dd79591a..183f2b250 100644 --- a/webapp/components/FilterPosts/GeneralFilterMenuItems.vue +++ b/webapp/components/FilterPosts/GeneralFilterMenuItems.vue @@ -72,7 +72,7 @@ export default { methods: { ...mapMutations({ toggleFilteredByFollowed: 'postsFilter/TOGGLE_FILTER_BY_FOLLOWED', - toogleFilteredByEmotions: 'postsFilter/TOGGLE_FILTER_BY_EMOTIONS', + toogleFilteredByEmotions: 'postsFilter/TOGGLE_EMOTION', }), iconPath(emotion) { if (this.filteredByEmotions.includes(emotion)) { diff --git a/webapp/graphql/ModerationListQuery.js b/webapp/graphql/ModerationListQuery.js index 940ada6f6..221ec6177 100644 --- a/webapp/graphql/ModerationListQuery.js +++ b/webapp/graphql/ModerationListQuery.js @@ -1,7 +1,7 @@ import gql from 'graphql-tag' export default app => { - return gql(` + return gql` query { Report(first: 20, orderBy: createdAt_desc) { id @@ -30,6 +30,7 @@ export default app => { } } comment { + id contentExcerpt author { id @@ -76,5 +77,5 @@ export default app => { } } } - `) + ` } diff --git a/webapp/pages/moderation/index.vue b/webapp/pages/moderation/index.vue index e6b8532fc..9988ebc7a 100644 --- a/webapp/pages/moderation/index.vue +++ b/webapp/pages/moderation/index.vue @@ -1,8 +1,6 @@