diff --git a/backend/yarn.lock b/backend/yarn.lock index 5749c5639..8ccca9a63 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -1137,7 +1137,7 @@ url-regex "~4.1.1" video-extensions "~1.1.0" -"@metascraper/helpers@^5.10.3", "@metascraper/helpers@^5.10.5": +"@metascraper/helpers@^5.10.5": version "5.10.5" resolved "https://registry.yarnpkg.com/@metascraper/helpers/-/helpers-5.10.5.tgz#c3558533f30144bacecf9599fd02ac88d839a0cc" integrity sha512-noTBDk3cF3UzKoPrC9/Sye1f9945PVEDju6br7S19YWyUpceEXoDrPF1YaqN37ku62f1s7bul11+Lv/xAYuEVQ== @@ -3872,7 +3872,6 @@ extsprintf@^1.2.0: faker@Marak/faker.js#master: version "4.1.0" - uid "3b2fa4aebccee52ae1bafc15d575061fb30c3cf1" resolved "https://codeload.github.com/Marak/faker.js/tar.gz/3b2fa4aebccee52ae1bafc15d575061fb30c3cf1" fast-deep-equal@^2.0.1: @@ -7730,6 +7729,11 @@ serve-static@1.14.1: version "1.14.1" resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.14.1.tgz#666e636dc4f010f7ef29970a88a674320898b2f9" integrity sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg== + dependencies: + encodeurl "~1.0.2" + escape-html "~1.0.3" + parseurl "~1.3.3" + send "0.17.1" set-blocking@^2.0.0, set-blocking@~2.0.0: version "2.0.0" diff --git a/webapp/components/Comment/Comment.spec.js b/webapp/components/Comment/Comment.spec.js index b307700d9..14b0dd7ec 100644 --- a/webapp/components/Comment/Comment.spec.js +++ b/webapp/components/Comment/Comment.spec.js @@ -14,7 +14,13 @@ describe('Comment.vue', () => { let Wrapper beforeEach(() => { - propsData = {} + propsData = { + comment: { + id: 'comment007', + author: { id: 'some-user' }, + }, + postId: 'post42', + } mocks = { $t: jest.fn(), $toast: { @@ -28,6 +34,7 @@ describe('Comment.vue', () => { truncate: a => a, removeHtml: a => a, }, + $route: { hash: '' }, $scrollTo: jest.fn(), $apollo: { mutate: jest.fn().mockResolvedValue({ @@ -68,6 +75,7 @@ describe('Comment.vue', () => { id: '2', contentExcerpt: 'Hello I am a comment content', content: 'Hello I am comment content', + author: { id: 'some-user' }, } }) diff --git a/webapp/components/Comment/Comment.vue b/webapp/components/Comment/Comment.vue index b413e03f6..df1320837 100644 --- a/webapp/components/Comment/Comment.vue +++ b/webapp/components/Comment/Comment.vue @@ -1,61 +1,45 @@ - diff --git a/webapp/components/CommentForm/CommentForm.spec.js b/webapp/components/CommentForm/CommentForm.spec.js index 420ab26fb..b940c561d 100644 --- a/webapp/components/CommentForm/CommentForm.spec.js +++ b/webapp/components/CommentForm/CommentForm.spec.js @@ -153,10 +153,10 @@ describe('CommentForm.vue', () => { expect(closeMethodSpy).toHaveBeenCalledTimes(1) }) - it('emits `showEditCommentMenu` event', async () => { + it('emits `finishEditing` event', async () => { wrapper.vm.updateEditorContent('ok') await wrapper.find('form').trigger('submit') - expect(wrapper.emitted('showEditCommentMenu')).toEqual([[false]]) + expect(wrapper.emitted('finishEditing')).toBeTruthy() }) }) @@ -167,10 +167,10 @@ describe('CommentForm.vue', () => { expect(closeMethodSpy).toHaveBeenCalledTimes(1) }) - it('emits `showEditCommentMenu` event', async () => { + it('emits `finishEditing` event', async () => { wrapper.vm.updateEditorContent('ok') await wrapper.find('[data-test="cancel-button"]').trigger('submit') - expect(wrapper.emitted('showEditCommentMenu')).toEqual([[false]]) + expect(wrapper.emitted('finishEditing')).toBeTruthy() }) }) diff --git a/webapp/components/CommentForm/CommentForm.vue b/webapp/components/CommentForm/CommentForm.vue index 063a3d599..4952f99cf 100644 --- a/webapp/components/CommentForm/CommentForm.vue +++ b/webapp/components/CommentForm/CommentForm.vue @@ -69,7 +69,7 @@ export default { this.$refs.editor.clear() }, closeEditWindow() { - this.$emit('showEditCommentMenu', false) + this.$emit('finishEditing') }, handleCancel() { if (!this.update) { diff --git a/webapp/components/CommentList/CommentList.spec.js b/webapp/components/CommentList/CommentList.spec.js index 064b8f136..38f39adca 100644 --- a/webapp/components/CommentList/CommentList.spec.js +++ b/webapp/components/CommentList/CommentList.spec.js @@ -17,9 +17,14 @@ describe('CommentList.vue', () => { beforeEach(() => { propsData = { post: { - id: 1, + id: 'post42', comments: [ - { id: 'comment134', contentExcerpt: 'this is a comment', content: 'this is a comment' }, + { + id: 'comment134', + contentExcerpt: 'this is a comment', + content: 'this is a comment', + author: { id: 'some-user' }, + }, ], }, } @@ -38,6 +43,7 @@ describe('CommentList.vue', () => { removeHtml: a => a, }, $scrollTo: jest.fn(), + $route: { hash: '' }, $apollo: { queries: { Post: { @@ -70,12 +76,6 @@ describe('CommentList.vue', () => { beforeEach(jest.useFakeTimers) describe('$route.hash !== `#comments`', () => { - beforeEach(() => { - mocks.$route = { - hash: '', - } - }) - it('skips $scrollTo', () => { wrapper = Wrapper() jest.runAllTimers() diff --git a/webapp/components/CommentList/CommentList.vue b/webapp/components/CommentList/CommentList.vue index 96edf9bc3..1654e31da 100644 --- a/webapp/components/CommentList/CommentList.vue +++ b/webapp/components/CommentList/CommentList.vue @@ -4,14 +4,12 @@ {{ $t('common.comment', null, 0) }} -
'' }, - post: { type: Object, default: () => {} }, + post: { + type: Object, + required: true, + }, }, methods: { checkAnchor(anchor) { diff --git a/webapp/components/ContentMenu/ContentMenu.spec.js b/webapp/components/ContentMenu/ContentMenu.spec.js index f079f6240..bbb0c0941 100644 --- a/webapp/components/ContentMenu/ContentMenu.spec.js +++ b/webapp/components/ContentMenu/ContentMenu.spec.js @@ -154,7 +154,7 @@ describe('ContentMenu.vue', () => { .filter(item => item.text() === 'comment.menu.edit') .at(0) .trigger('click') - expect(wrapper.emitted('showEditCommentMenu')).toEqual([[true]]) + expect(wrapper.emitted('editComment')).toBeTruthy() }) it('delete the comment', () => { wrapper diff --git a/webapp/components/ContentMenu/ContentMenu.vue b/webapp/components/ContentMenu/ContentMenu.vue index a22bc3267..a4c931470 100644 --- a/webapp/components/ContentMenu/ContentMenu.vue +++ b/webapp/components/ContentMenu/ContentMenu.vue @@ -104,7 +104,7 @@ export default { routes.push({ label: this.$t(`comment.menu.edit`), callback: () => { - this.$emit('showEditCommentMenu', true) + this.$emit('editComment') }, icon: 'edit', }) diff --git a/webapp/components/_new/generic/BaseCard/BaseCard.vue b/webapp/components/_new/generic/BaseCard/BaseCard.vue index b76af1c78..6a97c47f1 100644 --- a/webapp/components/_new/generic/BaseCard/BaseCard.vue +++ b/webapp/components/_new/generic/BaseCard/BaseCard.vue @@ -5,9 +5,7 @@