Commit 08359a8e authored by Samantha Ming's avatar Samantha Ming Committed by Phil Hughes

Add back trimChar method to remove trailing +/-

Add test for checking output
parent 75b3f26a
......@@ -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 {
>
<td :class="line.type" class="diff-line-num old_line">{{ line.old_line }}</td>
<td :class="line.type" class="diff-line-num new_line">{{ line.new_line }}</td>
<td :class="line.type" class="line_content" v-html="line.rich_text"></td>
<td :class="line.type" class="line_content" v-html="trimChar(line.rich_text)"></td>
</tr>
</template>
<tr v-if="!hasTruncatedDiffLines" class="line_holder line-holder-placeholder">
......
---
title: Remove duplicate trailing +/- char in merge request discussions
merge_request: 29518
author:
type: fixed
......@@ -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();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment