Added tests for hidden jump to button

This commit is contained in:
Phil Hughes 2016-07-29 15:50:58 +01:00
parent d147894b84
commit 03ea267f67
4 changed files with 34 additions and 10 deletions

View File

@ -17,7 +17,7 @@
return Object.keys(this.discussions).length;
},
showButton: function () {
return this.discussionsCount > 1 || !this.discussionId;
return this.discussionsCount > 0 && (this.discussionsCount > 1 || !this.discussionId);
}
},
methods: {

View File

@ -71,6 +71,8 @@
CommentsStore.update(this.discussionId, this.noteId, !this.isResolved, user);
ResolveService.updateUpdatedHtml(this.discussionId, data);
} else {
new Flash('An error occurred when trying to resolve a comment. Please try again.', 'alert');
}
this.$nextTick(this.updateTooltip);

View File

@ -45,12 +45,16 @@
mergeRequestId,
discussionId
}, {}).then((response) => {
const data = response.data;
const user = data ? data.resolved_by : null;
discussion.resolveAllNotes(user);
discussion.loading = false;
if (response.status === 200) {
const data = response.data;
const user = data ? data.resolved_by : null;
discussion.resolveAllNotes(user);
discussion.loading = false;
this.updateUpdatedHtml(discussionId, data);
this.updateUpdatedHtml(discussionId, data);
} else {
new Flash('An error occurred when trying to resolve a discussion. Please try again.', 'alert');
}
});
}
@ -66,11 +70,15 @@
mergeRequestId,
discussionId
}, {}).then((response) => {
const data = response.data;
discussion.unResolveAllNotes();
discussion.loading = false;
if (response.status === 200) {
const data = response.data;
discussion.unResolveAllNotes();
discussion.loading = false;
this.updateUpdatedHtml(discussionId, data);
this.updateUpdatedHtml(discussionId, data);
} else {
new Flash('An error occurred when trying to unresolve a discussion. Please try again.', 'alert');
}
});
}

View File

@ -16,6 +16,20 @@ feature 'Diff notes resolve', feature: true, js: true do
)
end
context 'no discussions' do
before do
project.team << [user, :master]
login_as user
note.destroy
visit_merge_request
end
it 'displays no discussion resolved data' do
expect(page).not_to have_content('discussion resolved')
expect(page).not_to have_selector('.discussion-next-btn')
end
end
context 'as authorized user' do
before do
project.team << [user, :master]