summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Zallmann <tzallmann@gitlab.com>2018-09-05 19:10:30 +0200
committerTim Zallmann <tzallmann@gitlab.com>2018-09-07 12:25:50 +0200
commit89c796db5c67d1d6698c46f75670f197e2647a8f (patch)
tree968087462a456f2c561de29443a429691896886a
parenta0dc392362d880fe80853258929678e75f9cc345 (diff)
downloadgitlab-ce-89c796db5c67d1d6698c46f75670f197e2647a8f.tar.gz
Fixed another rspec about collapsing notes after adding them
-rw-r--r--app/assets/javascripts/notes/stores/actions.js6
-rw-r--r--app/assets/javascripts/notes/stores/mutations.js9
-rw-r--r--spec/features/merge_request/user_posts_diff_notes_spec.rb2
3 files changed, 9 insertions, 8 deletions
diff --git a/app/assets/javascripts/notes/stores/actions.js b/app/assets/javascripts/notes/stores/actions.js
index 44f1c0f63fd..351d4e25a52 100644
--- a/app/assets/javascripts/notes/stores/actions.js
+++ b/app/assets/javascripts/notes/stores/actions.js
@@ -43,7 +43,7 @@ export const fetchDiscussions = ({ commit }, path) =>
commit(types.SET_INITIAL_DISCUSSIONS, discussions);
});
-export const refetchDiscussionById = ({ commit }, { path, discussionId }) =>
+export const refetchDiscussionById = ({ commit, state }, { path, discussionId }) =>
new Promise(resolve => {
service
.fetchDiscussions(path)
@@ -52,7 +52,9 @@ export const refetchDiscussionById = ({ commit }, { path, discussionId }) =>
const selectedDiscussion = discussions.find(discussion => discussion.id === discussionId);
if (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(() => {});
diff --git a/app/assets/javascripts/notes/stores/mutations.js b/app/assets/javascripts/notes/stores/mutations.js
index b6fd19dedf9..8e1da818e3b 100644
--- a/app/assets/javascripts/notes/stores/mutations.js
+++ b/app/assets/javascripts/notes/stores/mutations.js
@@ -54,13 +54,12 @@ export default {
[types.EXPAND_DISCUSSION](state, { discussionId }) {
const discussion = utils.findNoteObjectById(state.discussions, discussionId);
-
- discussion.expanded = true;
+ Object.assign(discussion, { expanded: true });
},
[types.COLLAPSE_DISCUSSION](state, { discussionId }) {
const discussion = utils.findNoteObjectById(state.discussions, discussionId);
- discussion.expanded = false;
+ Object.assign(discussion, { expanded: false });
},
[types.REMOVE_PLACEHOLDER_NOTES](state) {
@@ -95,6 +94,7 @@ export default {
[types.SET_USER_DATA](state, data) {
Object.assign(state, { userData: data });
},
+
[types.SET_INITIAL_DISCUSSIONS](state, discussionsData) {
const discussions = [];
@@ -168,8 +168,7 @@ export default {
[types.TOGGLE_DISCUSSION](state, { discussionId }) {
const discussion = utils.findNoteObjectById(state.discussions, discussionId);
-
- discussion.expanded = !discussion.expanded;
+ Object.assign(discussion, { expanded: !discussion.expanded });
},
[types.UPDATE_NOTE](state, note) {
diff --git a/spec/features/merge_request/user_posts_diff_notes_spec.rb b/spec/features/merge_request/user_posts_diff_notes_spec.rb
index e753e4fea9c..b6ed3686de2 100644
--- a/spec/features/merge_request/user_posts_diff_notes_spec.rb
+++ b/spec/features/merge_request/user_posts_diff_notes_spec.rb
@@ -7,7 +7,7 @@ describe 'Merge request > User posts diff notes', :js do
let(:project) { merge_request.source_project }
let(:user) { project.creator }
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(:test_note_comment) { 'this is a test note!' }