Skip to content

Commit

Permalink
[Comment Editor] New Test: Comment on Notes with addComment Script (p…
Browse files Browse the repository at this point in the history
…ubliclab#8809)

* add notes comment test & rename tests to distinguish wiki, note, question, etc.

* add new note fixture for testing comments

* update 'find all notes' to include new fixture

* alter expected result of 'all notes' lookup
  • Loading branch information
noi5e authored and lagunasmel committed Mar 2, 2021
1 parent 5800628 commit 0f75e97
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
14 changes: 13 additions & 1 deletion test/fixtures/nodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
13 changes: 11 additions & 2 deletions test/fixtures/revisions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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

4 changes: 2 additions & 2 deletions test/functional/notes_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
14 changes: 10 additions & 4 deletions test/system/comment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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! :)")
Expand Down
2 changes: 1 addition & 1 deletion test/unit/node_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 0f75e97

Please sign in to comment.