Commit 44ac8a50 authored by jboyson's avatar jboyson

Fix comment button not rendering

parent 2ca11a5f
...@@ -199,10 +199,10 @@ export default { ...@@ -199,10 +199,10 @@ export default {
); );
}, },
hasDiscussionsLeft() { hasDiscussionsLeft() {
return this.line.left.discussions && this.line.left.discussions.length > 0; return this.line.left?.discussions?.length > 0;
}, },
hasDiscussionsRight() { hasDiscussionsRight() {
return this.line.right.discussions && this.line.right.discussions.length > 0; return this.line.right?.discussions?.length > 0;
}, },
lineHrefOld() { lineHrefOld() {
return `#${this.line.left.line_code || ''}`; return `#${this.line.left.line_code || ''}`;
...@@ -217,14 +217,14 @@ export default { ...@@ -217,14 +217,14 @@ export default {
); );
}, },
isMetaLineLeft() { isMetaLineLeft() {
const { type } = this.line.left; const type = this.line.left?.type;
return ( return (
type === OLD_NO_NEW_LINE_TYPE || type === NEW_NO_NEW_LINE_TYPE || type === EMPTY_CELL_TYPE type === OLD_NO_NEW_LINE_TYPE || type === NEW_NO_NEW_LINE_TYPE || type === EMPTY_CELL_TYPE
); );
}, },
isMetaLineRight() { isMetaLineRight() {
const { type } = this.line.right; const type = this.line.right?.type;
return ( return (
type === OLD_NO_NEW_LINE_TYPE || type === NEW_NO_NEW_LINE_TYPE || type === EMPTY_CELL_TYPE type === OLD_NO_NEW_LINE_TYPE || type === NEW_NO_NEW_LINE_TYPE || type === EMPTY_CELL_TYPE
......
...@@ -228,19 +228,20 @@ describe('ParallelDiffTableRow', () => { ...@@ -228,19 +228,20 @@ describe('ParallelDiffTableRow', () => {
const findNoteButton = () => wrapper.find({ ref: 'addDiffNoteButtonLeft' }); const findNoteButton = () => wrapper.find({ ref: 'addDiffNoteButtonLeft' });
it.each` it.each`
hover | userData | query | mergeRefHeadComments | expectation hover | line | userData | query | mergeRefHeadComments | expectation
${true} | ${TEST_USER} | ${'diff_head=false'} | ${false} | ${true} ${true} | ${{}} | ${TEST_USER} | ${'diff_head=false'} | ${false} | ${true}
${true} | ${TEST_USER} | ${'diff_head=true'} | ${true} | ${true} ${true} | ${{ line: { left: null } }} | ${TEST_USER} | ${'diff_head=false'} | ${false} | ${false}
${true} | ${TEST_USER} | ${'diff_head=true'} | ${false} | ${false} ${true} | ${{}} | ${TEST_USER} | ${'diff_head=true'} | ${true} | ${true}
${true} | ${null} | ${''} | ${true} | ${false} ${true} | ${{}} | ${TEST_USER} | ${'diff_head=true'} | ${false} | ${false}
${false} | ${TEST_USER} | ${'diff_head=false'} | ${false} | ${false} ${true} | ${{}} | ${null} | ${''} | ${true} | ${false}
${false} | ${{}} | ${TEST_USER} | ${'diff_head=false'} | ${false} | ${false}
`( `(
'exists is $expectation - with userData ($userData) query ($query)', 'exists is $expectation - with userData ($userData) query ($query)',
async ({ hover, userData, query, mergeRefHeadComments, expectation }) => { async ({ hover, line, userData, query, mergeRefHeadComments, expectation }) => {
store.state.notes.userData = userData; store.state.notes.userData = userData;
gon.features = { mergeRefHeadComments }; gon.features = { mergeRefHeadComments };
setWindowLocation({ href: `${TEST_HOST}?${query}` }); setWindowLocation({ href: `${TEST_HOST}?${query}` });
createComponent({}, store); createComponent(line, store);
if (hover) await wrapper.find('.line_holder').trigger('mouseover'); if (hover) await wrapper.find('.line_holder').trigger('mouseover');
expect(findNoteButton().exists()).toBe(expectation); expect(findNoteButton().exists()).toBe(expectation);
......
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