From 58006286962937da15150f71029af66cd678e58e Mon Sep 17 00:00:00 2001 From: noi5e Date: Mon, 14 Dec 2020 11:59:30 -0800 Subject: [PATCH] [Comment Editor #8775] System Test: Synchronous Comment from Question Page via JS + URL (#8801) * add test for synchronous comments on question pages via JS & URL * changed test so it visits /questions, not /wiki/wiki-page-path * create new question fixture for testing complete with tags, node_tags, and revisions * Update "Find all questions" node unit test --- test/fixtures/node_tags.yml | 7 +++++++ test/fixtures/nodes.yml | 14 +++++++++++++- test/fixtures/revisions.yml | 8 ++++++++ test/fixtures/tags.yml | 6 ++++++ test/system/comment_test.rb | 6 ++++++ test/unit/node_test.rb | 2 +- 6 files changed, 41 insertions(+), 2 deletions(-) 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/nodes.yml b/test/fixtures/nodes.yml index e5651f5ec3..7c76e1afa8 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 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 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 diff --git a/test/system/comment_test.rb b/test/system/comment_test.rb index bd5c59c78a..43fbb053f1 100644 --- a/test/system/comment_test.rb +++ b/test/system/comment_test.rb @@ -71,6 +71,12 @@ def setup find("p", text: "Awesome Reply") end + test 'question page: add synchronous comment via javascript with URL only' do + visit "/questions/jeff/12-07-2020/can-i-post-comments-here" + page.evaluate_script("addComment('yes you can', '/comment/create/37')") + assert_selector('#comments-list .comment-body p', text: 'yes you can') + end + test 'comment preview button' do visit "/wiki/wiki-page-path/comments" diff --git a/test/unit/node_test.rb b/test/unit/node_test.rb index 17552dfbba..0b3c0946b9 100644 --- a/test/unit/node_test.rb +++ b/test/unit/node_test.rb @@ -359,7 +359,7 @@ def setup test 'should find all questions' do questions = Node.questions - expected = [nodes(:question), nodes(:question2), nodes(:first_timer_question), nodes(:question3), nodes(:sun_question)] + expected = [nodes(:question), nodes(:question2), nodes(:first_timer_question), nodes(:question3), nodes(:sun_question), nodes(:question4)] assert_equal expected, questions end