summaryrefslogtreecommitdiff
path: root/spec/features/issues/user_sorts_issue_comments_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/issues/user_sorts_issue_comments_spec.rb')
-rw-r--r--spec/features/issues/user_sorts_issue_comments_spec.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/features/issues/user_sorts_issue_comments_spec.rb b/spec/features/issues/user_sorts_issue_comments_spec.rb
new file mode 100644
index 00000000000..e1c0acc32f1
--- /dev/null
+++ b/spec/features/issues/user_sorts_issue_comments_spec.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe 'Comment sort direction' do
+ let_it_be(:project) { create(:project, :public, :repository) }
+ let_it_be(:issue) { create(:issue, project: project) }
+ let_it_be(:comment_1) { create(:note_on_issue, noteable: issue, project: project, note: 'written first') }
+ let_it_be(:comment_2) { create(:note_on_issue, noteable: issue, project: project, note: 'written second') }
+
+ context 'on issue page', :js do
+ before do
+ visit project_issue_path(project, issue)
+ end
+
+ it 'saves sort order' do
+ # open dropdown, and select 'Newest first'
+ page.within('.issuable-details') do
+ click_button('Oldest first')
+ click_button('Newest first')
+ end
+
+ expect(first_comment).to have_content(comment_2.note)
+ expect(last_comment).to have_content(comment_1.note)
+
+ visit project_issue_path(project, issue)
+ wait_for_requests
+
+ expect(first_comment).to have_content(comment_2.note)
+ expect(last_comment).to have_content(comment_1.note)
+ end
+ end
+
+ def all_comments
+ all('.timeline > .note.timeline-entry')
+ end
+
+ def first_comment
+ all_comments.first
+ end
+
+ def last_comment
+ all_comments.last
+ end
+end