Commit e3b96ad7 authored by Fatih Acet's avatar Fatih Acet

Fix placeholder note rendering

parent 70f4a26b
......@@ -191,6 +191,7 @@ export default {
if (note.placeholderType === SYSTEM_NOTE) {
return placeholderSystemNote;
}
return placeholderNote;
}
......@@ -201,7 +202,7 @@ export default {
return noteableNote;
},
componentData(note) {
return note.isPlaceholderNote ? this.discussion.notes[0] : note;
return note.isPlaceholderNote ? note.notes[0] : note;
},
toggleDiscussionHandler() {
this.toggleDiscussion({ discussionId: this.discussion.id });
......
---
title: Fix rendering placeholder notes
merge_request: 22078
author:
type: fixed
......@@ -133,4 +133,29 @@ describe('noteable_discussion component', () => {
});
});
});
describe('componentData', () => {
it('should return first note object for placeholder note', () => {
const data = {
isPlaceholderNote: true,
notes: [
{ body: 'hello world!' },
],
};
const note = vm.componentData(data);
expect(note).toEqual(data.notes[0]);
});
it('should return given note for nonplaceholder notes', () => {
const data = {
notes: [
{ id: 12 },
],
};
const note = vm.componentData(data);
expect(note).toEqual(data);
});
});
});
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