Commit e12c2c77 authored by Phil Hughes's avatar Phil Hughes

Fixed resolved discussions not toggling expanded

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/51370
parent 44931bd2
......@@ -214,12 +214,7 @@ export default {
[types.SET_DISCUSSION_DIFF_LINES](state, { discussionId, diffLines }) {
const discussion = utils.findNoteObjectById(state.discussions, discussionId);
const index = state.discussions.indexOf(discussion);
const discussionWithDiffLines = Object.assign({}, discussion, {
truncated_diff_lines: diffLines,
});
state.discussions.splice(index, 1, discussionWithDiffLines);
discussion.truncated_diff_lines = diffLines;
},
};
---
title: Fixed resolved discussions not toggling expanded state on changes tab
merge_request: 21676
author:
type: fixed
import Vue from 'vue';
import mutations from '~/notes/stores/mutations';
import {
note,
......@@ -333,7 +334,7 @@ describe('Notes Store mutations', () => {
});
});
describe('SET_NOTES_FETCHING_STATE', () => {
describe('SET_NOTES_FETCHED_STATE', () => {
it('should set the given state', () => {
const state = {
isNotesFetched: false,
......@@ -343,4 +344,37 @@ describe('Notes Store mutations', () => {
expect(state.isNotesFetched).toEqual(true);
});
});
describe('SET_DISCUSSION_DIFF_LINES', () => {
it('sets truncated_diff_lines', () => {
const state = {
discussions: [
{
id: 1,
},
],
};
mutations.SET_DISCUSSION_DIFF_LINES(state, { discussionId: 1, diffLines: ['test'] });
expect(state.discussions[0].truncated_diff_lines).toEqual(['test']);
});
it('keeps reactivity of discussion', () => {
const state = {};
Vue.set(state, 'discussions', [
{
id: 1,
expanded: false,
},
]);
const discussion = state.discussions[0];
mutations.SET_DISCUSSION_DIFF_LINES(state, { discussionId: 1, diffLines: ['test'] });
discussion.expanded = true;
expect(state.discussions[0].expanded).toBe(true);
});
});
});
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