diff --git a/test/fixtures/nodes.yml b/test/fixtures/nodes.yml index 7c76e1afa8..b32103681d 100644 --- a/test/fixtures/nodes.yml +++ b/test/fixtures/nodes.yml @@ -446,7 +446,7 @@ sun_question: cached_likes: 0 slug: "note-tagged-with-question-sun" -question4: # fresh question fixture for testing comments on question pages +question4: # for testing comments on questions nid: 37 uid: 2 title: "Can I post comments here" @@ -457,3 +457,15 @@ question4: # fresh question fixture for testing comments on question pages type: "note" cached_likes: 0 slug: jeff-12-07-2020-can-i-post-comments-here + +comment_note: # for testing comments on notes + nid: 38 + uid: 2 + title: "Please don't comment here" + path: "/notes/jeff/12-08-2020/please-don-t-comment-here" + created: <%= DateTime.new(2020,12,8).to_i %> + changed: <%= DateTime.new(2020,12,8).to_i %> + status: 1 + type: "note" + cached_likes: 0 + slug: "note-please-don-t-comment-here" diff --git a/test/fixtures/revisions.yml b/test/fixtures/revisions.yml index 69ae33df44..8cedb90ea8 100644 --- a/test/fixtures/revisions.yml +++ b/test/fixtures/revisions.yml @@ -403,10 +403,19 @@ sun_question: timestamp: <%= DateTime.new(2020,2,12).to_i %> status: 1 -question4: # fresh question fixture for testing comments on question pages +question4: # for testing comments on questions 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 + status: 1 + +comment_note: # for testing comments on notes + nid: 38 + uid: 2 + title: "Please don't comment here" + body: "I beg you, please" + timestamp: <%= DateTime.new(2020,12,8).to_i %> + status: 1 + \ No newline at end of file diff --git a/test/functional/notes_controller_test.rb b/test/functional/notes_controller_test.rb index e2dc543706..9655cf1b0d 100644 --- a/test/functional/notes_controller_test.rb +++ b/test/functional/notes_controller_test.rb @@ -368,7 +368,7 @@ def teardown assert_response :success selector = css_select 'div.note' - assert_equal 27, selector.size + assert_equal 28, selector.size assert_select "div p", 'Pending approval by community moderators. Please be patient!' end @@ -397,7 +397,7 @@ def teardown assert_response :success selector = css_select 'div.note' - assert_equal 27, selector.size + assert_equal 28, selector.size assert_select 'a[data-test="spam"]','Spam' end diff --git a/test/system/comment_test.rb b/test/system/comment_test.rb index 43fbb053f1..89fea8532e 100644 --- a/test/system/comment_test.rb +++ b/test/system/comment_test.rb @@ -15,7 +15,7 @@ def setup find(".login-modal-form #login-button").click() end - test 'adding a comment via javascript' do + test 'wiki: comment via JavaScript, with comment body ONLY' do visit "/wiki/wiki-page-path/comments" # run the javascript function @@ -25,7 +25,7 @@ def setup assert_selector('#comments-list .comment-body p', text: 'fantastic four') end - test 'adding a comment via javascript with url only' do + test 'wiki: comment via JavaScript, with comment body + URL' do visit "/wiki/wiki-page-path/comments" # run the javascript function @@ -35,7 +35,7 @@ def setup assert_selector('#comments-list .comment-body p', text: 'superhero') end - test 'adding a reply comment via javascript with url only' do + test 'wiki: reply to comment via JavaScript with comment body + URL' do visit "/wiki/wiki-page-path/comments" # run the javascript function @@ -47,7 +47,13 @@ def setup assert_selector("#{parentid} .comment .comment-body p", text: 'batman') end - test "add a comment manually" do + test 'note: comment via JavaScript, with comment body + URL' do + visit nodes(:comment_note).path + page.evaluate_script("addComment('hahaha', '/comment/create/38')") + assert_selector('#comments-list .comment-body p', text: 'hahaha') + end + + test "note: comment manually" do visit nodes(:one).path fill_in("body", with: "Awesome comment! :)") diff --git a/test/unit/node_test.rb b/test/unit/node_test.rb index 0b3c0946b9..e9e44d550a 100644 --- a/test/unit/node_test.rb +++ b/test/unit/node_test.rb @@ -349,7 +349,7 @@ def setup nodes(:draft), nodes(:post_test1), nodes(:post_test2), nodes(:post_test3), nodes(:post_test4), nodes(:scraped_image), nodes(:search_trawling), nodes(:purple_air_without_hyphen), nodes(:purple_air_with_hyphen), - nodes(:sun_note), nodes(:sunny_day_note)] + nodes(:sun_note), nodes(:sunny_day_note), nodes(:comment_note)] assert_equal expected, notes end