From 0db16fbbcf4e6436f313c532d5f957d4c5027ebf Mon Sep 17 00:00:00 2001 From: Will Gutierrez Date: Sun, 13 Dec 2020 21:03:51 -0800 Subject: [PATCH 1/4] create new question fixture --- test/fixtures/nodes.yml | 14 +++++++++++++- test/fixtures/revisions.yml | 8 ++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/test/fixtures/nodes.yml b/test/fixtures/nodes.yml index e5651f5ec3..6e53ab709c 100644 --- a/test/fixtures/nodes.yml +++ b/test/fixtures/nodes.yml @@ -444,4 +444,16 @@ sun_question: status: 1 type: "note" cached_likes: 0 - slug: "note-tagged-with-question-sun" \ No newline at end of file + slug: "note-tagged-with-question-sun" + +question4: # fresh question fixture for testing comments on question pages + nid: 37 + uid: 2 + title: "Can I post comments here" + path: "/notes/jeff/12-07-2020/can-i-post-comments-here" + created: <%= DateTime.new(2020,12,7).to_i %> + changed: <%= DateTime.new(2020,12,7).to_i %> + status: 1 + type: "note" + cached_likes: 0 + slug: jeff-12-07-2020-can-i-post-comments-here \ No newline at end of file diff --git a/test/fixtures/revisions.yml b/test/fixtures/revisions.yml index 2ce8d95f45..69ae33df44 100644 --- a/test/fixtures/revisions.yml +++ b/test/fixtures/revisions.yml @@ -402,3 +402,11 @@ sun_question: body: "This is the body" timestamp: <%= DateTime.new(2020,2,12).to_i %> status: 1 + +question4: # fresh question fixture for testing comments on question pages + nid: 37 + uid: 2 + title: "Can I post comments here" + body: "I'm gonna do it" + timestamp: <%= DateTime.new(2020,12,7).to_i %> + status: 1 \ No newline at end of file From 381663ab3373d8025ca3b1e356e26b1d6565eac4 Mon Sep 17 00:00:00 2001 From: Will Gutierrez Date: Sun, 13 Dec 2020 21:04:18 -0800 Subject: [PATCH 2/4] new fixtures to tag node as question --- test/fixtures/node_tags.yml | 7 +++++++ test/fixtures/tags.yml | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/test/fixtures/node_tags.yml b/test/fixtures/node_tags.yml index 29e92ae5a8..6442e51202 100644 --- a/test/fixtures/node_tags.yml +++ b/test/fixtures/node_tags.yml @@ -261,3 +261,10 @@ organizers-chapter: nid: 5 date: <%= DateTime.now.to_i %> +# this tags node 37 as a question +# ultimately, this is for testing comments on that node. +question4: + tid: 35 + uid: 2 + nid: 37 + date: <%= DateTime.now.to_i %> \ No newline at end of file diff --git a/test/fixtures/tags.yml b/test/fixtures/tags.yml index 920f9fd9b3..8c35c0ef10 100644 --- a/test/fixtures/tags.yml +++ b/test/fixtures/tags.yml @@ -136,3 +136,9 @@ sunny_day: sun_question: tid: 34 name: question:sun + +# this tags node 37 as a question +# ultimately, this is for testing comments on that node. +question4: + tid: 35 + name: question:general \ No newline at end of file From 926969ae1c38512e474503ceebf3ec981ce29e73 Mon Sep 17 00:00:00 2001 From: Will Gutierrez Date: Sun, 13 Dec 2020 21:04:46 -0800 Subject: [PATCH 3/4] new comment fixture to test comment replies --- test/fixtures/comments.yml | 9 ++++++++- 1 file changed, 8 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 From 5370e677b167feaa859815570b69a2ef44606b1a Mon Sep 17 00:00:00 2001 From: Will Gutierrez Date: Sun, 13 Dec 2020 21:05:07 -0800 Subject: [PATCH 4/4] add new test: respond to question comment --- test/system/comment_test.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/system/comment_test.rb b/test/system/comment_test.rb index bd5c59c78a..ecc631f594 100644 --- a/test/system/comment_test.rb +++ b/test/system/comment_test.rb @@ -71,6 +71,20 @@ def setup find("p", text: "Awesome Reply") 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"