From 1afa0a1ac8a3ada1f7ac726f202a5fe84a5f9505 Mon Sep 17 00:00:00 2001 From: noi5e Date: Mon, 14 Dec 2020 14:03:57 -0800 Subject: [PATCH] [Outreachy Comment Editor] New Test: Respond to Question Comment (#8845) * create new question fixture * new fixtures to tag node as question * new comment fixture to test comment replies * add new test: respond to question comment --- test/fixtures/comments.yml | 9 ++++++++- test/system/comment_test.rb | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/test/fixtures/comments.yml b/test/fixtures/comments.yml index 300529af0d..26eaeb4587 100644 --- a/test/fixtures/comments.yml +++ b/test/fixtures/comments.yml @@ -160,4 +160,11 @@ comment_by_first_time_user: status: 1 comment: This is comment is replied to first timestamp: <%= Time.now.to_i + 10 %> - thread: /01 \ No newline at end of file + thread: /01 + +reply_to_this_comment: + uid: 1 + nid: 37 + status: 1 + comment: Uhh... + timestamp: <%= Time.now.to_i + 10 %> \ No newline at end of file diff --git a/test/system/comment_test.rb b/test/system/comment_test.rb index 89fea8532e..616c5e7c4d 100644 --- a/test/system/comment_test.rb +++ b/test/system/comment_test.rb @@ -82,6 +82,20 @@ def setup page.evaluate_script("addComment('yes you can', '/comment/create/37')") assert_selector('#comments-list .comment-body p', text: 'yes you can') end + + test 'question page: respond to existing comment with addComment' do + visit "/questions/jeff/12-07-2020/can-i-post-comments-here" + + # find comment ID of the first comment on page + parent_id = "#" + page.find('#comments-list').first('.comment')[:id] + parent_id_num = /c(\d+)/.match(parent_id)[1] # eg. comment ID format is id="c9834" + + # addComment(comment text, submitURL, comment's parent ID) + page.evaluate_script("addComment(\"no you can't\", '/comment/create/37', #{parent_id_num})") + + # check for comment text + assert_selector("#{parent_id} .comment .comment-body p", text: 'no you can\'t') + end test 'comment preview button' do visit "/wiki/wiki-page-path/comments"