From c3b9ed747e1c1374e05bd29e63a7631d2ec93053 Mon Sep 17 00:00:00 2001 From: noi5e Date: Mon, 14 Dec 2020 14:33:21 -0800 Subject: [PATCH] [Outreachy Comment Editor] New Test: Respond to Note Comment (#8844) * add note fixture 4 testing comments * add comment 4 testing comment replies * add new test: respond to note comments * changed test name: 'respond to existing comment' --- test/fixtures/comments.yml | 7 +++++++ test/system/comment_test.rb | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/test/fixtures/comments.yml b/test/fixtures/comments.yml index 26eaeb4587..1c80c7918d 100644 --- a/test/fixtures/comments.yml +++ b/test/fixtures/comments.yml @@ -167,4 +167,11 @@ reply_to_this_comment: nid: 37 status: 1 comment: Uhh... + timestamp: <%= Time.now.to_i + 10 %> + +note_comment_for_responses: + uid: 1 + nid: 38 + status: 1 + comment: I do what I want! 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 616c5e7c4d..6ca3569039 100644 --- a/test/system/comment_test.rb +++ b/test/system/comment_test.rb @@ -52,6 +52,19 @@ def setup page.evaluate_script("addComment('hahaha', '/comment/create/38')") assert_selector('#comments-list .comment-body p', text: 'hahaha') end + + test 'note: respond to existing comment' do + visit nodes(:comment_note).path + # find comment ID of the first comment on page + parent_id = "#" + page.find('#comments-list').first('.comment')[:id] + # comment ID format is id="c9834" + # regex to find everything after the "c" + parent_id_num = /c(\d+)/.match(parent_id)[1] + # parameters for addComment: addComment(comment text, submitURL, comment's parent ID) + page.evaluate_script("addComment(\"I admire you\", '/comment/create/#{nodes(:comment_note).nid}', #{parent_id_num})") + # check for comment text + assert_selector("#{parent_id} .comment .comment-body p", text: 'I admire you') + end test "note: comment manually" do visit nodes(:one).path