Commit b5fffb14 authored by Justin Boyson's avatar Justin Boyson Committed by Miguel Rincon

Fix incorrect hiding of inline comment cells

Add tests for parallel and inline comment cell rendering
parent 3f739faf
...@@ -51,6 +51,14 @@ export default { ...@@ -51,6 +51,14 @@ export default {
); );
}, },
}, },
methods: {
showCommentLeft(line) {
return !this.inline || line.left;
},
showCommentRight(line) {
return !this.inline || (line.right && !line.left);
},
},
userColorScheme: window.gon.user_color_scheme, userColorScheme: window.gon.user_color_scheme,
}; };
</script> </script>
...@@ -93,10 +101,7 @@ export default { ...@@ -93,10 +101,7 @@ export default {
:class="line.commentRowClasses" :class="line.commentRowClasses"
class="diff-grid-comments diff-tr notes_holder" class="diff-grid-comments diff-tr notes_holder"
> >
<div <div v-if="showCommentLeft(line)" class="diff-td notes-content parallel old">
v-if="!inline || (line.left && line.left.discussions.length)"
class="diff-td notes-content parallel old"
>
<diff-comment-cell <diff-comment-cell
v-if="line.left" v-if="line.left"
:line="line.left" :line="line.left"
...@@ -106,10 +111,7 @@ export default { ...@@ -106,10 +111,7 @@ export default {
line-position="left" line-position="left"
/> />
</div> </div>
<div <div v-if="showCommentRight(line)" class="diff-td notes-content parallel new">
v-if="!inline || (line.right && line.right.discussions.length)"
class="diff-td notes-content parallel new"
>
<diff-comment-cell <diff-comment-cell
v-if="line.right" v-if="line.right"
:line="line.right" :line="line.right"
......
---
title: Fix comment cells not rendering in unified component inline view
merge_request: 47693
author:
type: fixed
...@@ -49,12 +49,29 @@ describe('DiffView', () => { ...@@ -49,12 +49,29 @@ describe('DiffView', () => {
expect(wrapper.find(DiffExpansionCell).exists()).toBe(true); expect(wrapper.find(DiffExpansionCell).exists()).toBe(true);
}); });
it('renders a comment row', () => { it.each`
type | side | container | sides | total
${'parallel'} | ${'left'} | ${'.old'} | ${{ left: { lineDraft: {} }, right: { lineDraft: {} } }} | ${2}
${'parallel'} | ${'right'} | ${'.new'} | ${{ left: { lineDraft: {} }, right: { lineDraft: {} } }} | ${2}
${'inline'} | ${'left'} | ${'.old'} | ${{ left: { lineDraft: {} } }} | ${1}
${'inline'} | ${'right'} | ${'.new'} | ${{ right: { lineDraft: {} } }} | ${1}
${'inline'} | ${'left'} | ${'.old'} | ${{ left: { lineDraft: {} }, right: { lineDraft: {} } }} | ${1}
`(
'renders a $type comment row with comment cell on $side',
({ type, container, sides, total }) => {
const wrapper = createWrapper({ const wrapper = createWrapper({
diffLines: [{ renderCommentRow: true, left: { lineDraft: {} } }], diffLines: [{ renderCommentRow: true, ...sides }],
}); inline: type === 'inline',
expect(wrapper.find(DiffCommentCell).exists()).toBe(true);
}); });
expect(wrapper.findAll(DiffCommentCell).length).toBe(total);
expect(
wrapper
.find(container)
.find(DiffCommentCell)
.exists(),
).toBe(true);
},
);
it('renders a draft row', () => { it('renders a draft row', () => {
const wrapper = createWrapper({ const wrapper = createWrapper({
......
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