From 08359a8ebcb7fc2c0f996b43186e826ddbec9554 Mon Sep 17 00:00:00 2001 From: Samantha Ming Date: Fri, 21 Jun 2019 10:10:05 +0000 Subject: Add back trimChar method to remove trailing +/- Add test for checking output --- app/assets/javascripts/notes/components/diff_with_note.vue | 7 ++++++- changelogs/unreleased/59028-fix-extra-plus-in-diffs.yml | 5 +++++ spec/javascripts/notes/components/diff_with_note_spec.js | 13 +++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/59028-fix-extra-plus-in-diffs.yml diff --git a/app/assets/javascripts/notes/components/diff_with_note.vue b/app/assets/javascripts/notes/components/diff_with_note.vue index b95835ed10a..54c242b2fda 100644 --- a/app/assets/javascripts/notes/components/diff_with_note.vue +++ b/app/assets/javascripts/notes/components/diff_with_note.vue @@ -7,6 +7,8 @@ import { GlSkeletonLoading } from '@gitlab/ui'; import { getDiffMode } from '~/diffs/store/utils'; import { diffViewerModes } from '~/ide/constants'; +const FIRST_CHAR_REGEX = /^(\+|-| )/; + export default { components: { DiffFileHeader, @@ -59,6 +61,9 @@ export default { this.error = true; }); }, + trimChar(line) { + return line.replace(FIRST_CHAR_REGEX, ''); + }, }, userColorSchemeClass: window.gon.user_color_scheme, }; @@ -83,7 +88,7 @@ export default { > {{ line.old_line }} {{ line.new_line }} - + diff --git a/changelogs/unreleased/59028-fix-extra-plus-in-diffs.yml b/changelogs/unreleased/59028-fix-extra-plus-in-diffs.yml new file mode 100644 index 00000000000..0786f4dbc10 --- /dev/null +++ b/changelogs/unreleased/59028-fix-extra-plus-in-diffs.yml @@ -0,0 +1,5 @@ +--- +title: Remove duplicate trailing +/- char in merge request discussions +merge_request: 29518 +author: +type: fixed diff --git a/spec/javascripts/notes/components/diff_with_note_spec.js b/spec/javascripts/notes/components/diff_with_note_spec.js index 0752bd05904..f849fe9d8bb 100644 --- a/spec/javascripts/notes/components/diff_with_note_spec.js +++ b/spec/javascripts/notes/components/diff_with_note_spec.js @@ -47,6 +47,19 @@ describe('diff_with_note', () => { vm = mountComponentWithStore(Component, { props, store }); }); + it('removes trailing "+" char', () => { + const richText = vm.$el.querySelectorAll('.line_holder')[4].querySelector('.line_content') + .textContent[0]; + + expect(richText).not.toEqual('+'); + }); + + it('removes trailing "-" char', () => { + const richText = vm.$el.querySelector('#LC13').parentNode.textContent[0]; + + expect(richText).not.toEqual('-'); + }); + it('shows text diff', () => { expect(selectors.container).toHaveClass('text-file'); expect(selectors.diffTable).toExist(); -- cgit v1.2.1