Handle transformed notes from polling response

Transforms notes when the note was transformed in some other tab
This commit is contained in:
Heinrich Lee Yu 2019-03-06 14:39:53 +08:00
parent ab391b779e
commit d72a61b41d
2 changed files with 17 additions and 0 deletions

View File

@ -193,6 +193,10 @@ export default {
const noteObj = utils.findNoteObjectById(state.discussions, note.discussion_id);
if (noteObj.individual_note) {
if (note.type === constants.DISCUSSION_NOTE) {
noteObj.individual_note = false;
}
noteObj.notes.splice(0, 1, note);
} else {
const comment = utils.findNoteObjectById(noteObj.notes, note.id);

View File

@ -1,5 +1,6 @@
import Vue from 'vue';
import mutations from '~/notes/stores/mutations';
import { DISCUSSION_NOTE } from '~/notes/constants';
import {
note,
discussionMock,
@ -326,6 +327,18 @@ describe('Notes Store mutations', () => {
expect(state.discussions[0].notes[0].note).toEqual('Foo');
});
it('transforms an individual note to discussion', () => {
const state = {
discussions: [individualNote],
};
const transformedNote = { ...individualNote.notes[0], type: DISCUSSION_NOTE };
mutations.UPDATE_NOTE(state, transformedNote);
expect(state.discussions[0].individual_note).toEqual(false);
});
});
describe('CLOSE_ISSUE', () => {