Handle transformed notes from polling response
Transforms notes when the note was transformed in some other tab
This commit is contained in:
parent
ab391b779e
commit
d72a61b41d
2 changed files with 17 additions and 0 deletions
|
@ -193,6 +193,10 @@ export default {
|
||||||
const noteObj = utils.findNoteObjectById(state.discussions, note.discussion_id);
|
const noteObj = utils.findNoteObjectById(state.discussions, note.discussion_id);
|
||||||
|
|
||||||
if (noteObj.individual_note) {
|
if (noteObj.individual_note) {
|
||||||
|
if (note.type === constants.DISCUSSION_NOTE) {
|
||||||
|
noteObj.individual_note = false;
|
||||||
|
}
|
||||||
|
|
||||||
noteObj.notes.splice(0, 1, note);
|
noteObj.notes.splice(0, 1, note);
|
||||||
} else {
|
} else {
|
||||||
const comment = utils.findNoteObjectById(noteObj.notes, note.id);
|
const comment = utils.findNoteObjectById(noteObj.notes, note.id);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import mutations from '~/notes/stores/mutations';
|
import mutations from '~/notes/stores/mutations';
|
||||||
|
import { DISCUSSION_NOTE } from '~/notes/constants';
|
||||||
import {
|
import {
|
||||||
note,
|
note,
|
||||||
discussionMock,
|
discussionMock,
|
||||||
|
@ -326,6 +327,18 @@ describe('Notes Store mutations', () => {
|
||||||
|
|
||||||
expect(state.discussions[0].notes[0].note).toEqual('Foo');
|
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', () => {
|
describe('CLOSE_ISSUE', () => {
|
||||||
|
|
Loading…
Reference in a new issue