Fix placeholder note rendering

This commit is contained in:
Fatih Acet 2018-10-03 12:17:26 +02:00
parent 70f4a26b6e
commit e3b96ad76b
No known key found for this signature in database
GPG key ID: E994FE39E29B7E11
3 changed files with 32 additions and 1 deletions

View file

@ -191,6 +191,7 @@ export default {
if (note.placeholderType === SYSTEM_NOTE) { if (note.placeholderType === SYSTEM_NOTE) {
return placeholderSystemNote; return placeholderSystemNote;
} }
return placeholderNote; return placeholderNote;
} }
@ -201,7 +202,7 @@ export default {
return noteableNote; return noteableNote;
}, },
componentData(note) { componentData(note) {
return note.isPlaceholderNote ? this.discussion.notes[0] : note; return note.isPlaceholderNote ? note.notes[0] : note;
}, },
toggleDiscussionHandler() { toggleDiscussionHandler() {
this.toggleDiscussion({ discussionId: this.discussion.id }); this.toggleDiscussion({ discussionId: this.discussion.id });

View file

@ -0,0 +1,5 @@
---
title: Fix rendering placeholder notes
merge_request: 22078
author:
type: fixed

View file

@ -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);
});
});
}); });