Commit 89c796db authored by Tim Zallmann's avatar Tim Zallmann

Fixed another rspec about collapsing notes after adding them

parent a0dc3923
...@@ -43,7 +43,7 @@ export const fetchDiscussions = ({ commit }, path) => ...@@ -43,7 +43,7 @@ export const fetchDiscussions = ({ commit }, path) =>
commit(types.SET_INITIAL_DISCUSSIONS, discussions); commit(types.SET_INITIAL_DISCUSSIONS, discussions);
}); });
export const refetchDiscussionById = ({ commit }, { path, discussionId }) => export const refetchDiscussionById = ({ commit, state }, { path, discussionId }) =>
new Promise(resolve => { new Promise(resolve => {
service service
.fetchDiscussions(path) .fetchDiscussions(path)
...@@ -52,7 +52,9 @@ export const refetchDiscussionById = ({ commit }, { path, discussionId }) => ...@@ -52,7 +52,9 @@ export const refetchDiscussionById = ({ commit }, { path, discussionId }) =>
const selectedDiscussion = discussions.find(discussion => discussion.id === discussionId); const selectedDiscussion = discussions.find(discussion => discussion.id === discussionId);
if (selectedDiscussion) { if (selectedDiscussion) {
commit(types.UPDATE_DISCUSSION, selectedDiscussion); commit(types.UPDATE_DISCUSSION, selectedDiscussion);
resolve(selectedDiscussion); // We need to refetch as it is now the transformed one in state
const discussion = utils.findNoteObjectById(state.discussions, discussionId);
resolve(discussion);
} }
}) })
.catch(() => {}); .catch(() => {});
......
...@@ -54,13 +54,12 @@ export default { ...@@ -54,13 +54,12 @@ export default {
[types.EXPAND_DISCUSSION](state, { discussionId }) { [types.EXPAND_DISCUSSION](state, { discussionId }) {
const discussion = utils.findNoteObjectById(state.discussions, discussionId); const discussion = utils.findNoteObjectById(state.discussions, discussionId);
Object.assign(discussion, { expanded: true });
discussion.expanded = true;
}, },
[types.COLLAPSE_DISCUSSION](state, { discussionId }) { [types.COLLAPSE_DISCUSSION](state, { discussionId }) {
const discussion = utils.findNoteObjectById(state.discussions, discussionId); const discussion = utils.findNoteObjectById(state.discussions, discussionId);
discussion.expanded = false; Object.assign(discussion, { expanded: false });
}, },
[types.REMOVE_PLACEHOLDER_NOTES](state) { [types.REMOVE_PLACEHOLDER_NOTES](state) {
...@@ -95,6 +94,7 @@ export default { ...@@ -95,6 +94,7 @@ export default {
[types.SET_USER_DATA](state, data) { [types.SET_USER_DATA](state, data) {
Object.assign(state, { userData: data }); Object.assign(state, { userData: data });
}, },
[types.SET_INITIAL_DISCUSSIONS](state, discussionsData) { [types.SET_INITIAL_DISCUSSIONS](state, discussionsData) {
const discussions = []; const discussions = [];
...@@ -168,8 +168,7 @@ export default { ...@@ -168,8 +168,7 @@ export default {
[types.TOGGLE_DISCUSSION](state, { discussionId }) { [types.TOGGLE_DISCUSSION](state, { discussionId }) {
const discussion = utils.findNoteObjectById(state.discussions, discussionId); const discussion = utils.findNoteObjectById(state.discussions, discussionId);
Object.assign(discussion, { expanded: !discussion.expanded });
discussion.expanded = !discussion.expanded;
}, },
[types.UPDATE_NOTE](state, note) { [types.UPDATE_NOTE](state, note) {
......
...@@ -7,7 +7,7 @@ describe 'Merge request > User posts diff notes', :js do ...@@ -7,7 +7,7 @@ describe 'Merge request > User posts diff notes', :js do
let(:project) { merge_request.source_project } let(:project) { merge_request.source_project }
let(:user) { project.creator } let(:user) { project.creator }
let(:comment_button_class) { '.add-diff-note' } let(:comment_button_class) { '.add-diff-note' }
let(:notes_holder_input_class) { 'note-edit-form' } let(:notes_holder_input_class) { 'js-temp-notes-holder' }
let(:notes_holder_input_xpath) { './following-sibling::*[contains(concat(" ", @class, " "), " notes_holder ")]' } let(:notes_holder_input_xpath) { './following-sibling::*[contains(concat(" ", @class, " "), " notes_holder ")]' }
let(:test_note_comment) { 'this is a test note!' } let(:test_note_comment) { 'this is a test note!' }
......
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