Skip to content

Commit

Permalink
[Comment Editor publiclab#8775] System Test: Synchronous Comment from…
Browse files Browse the repository at this point in the history
… Question Page via JS + URL (publiclab#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
  • Loading branch information
noi5e authored and manchere committed Feb 13, 2021
1 parent 30f35a0 commit 4d08100
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 2 deletions.
7 changes: 7 additions & 0 deletions test/fixtures/node_tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
14 changes: 13 additions & 1 deletion test/fixtures/nodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -444,4 +444,16 @@ sun_question:
status: 1
type: "note"
cached_likes: 0
slug: "note-tagged-with-question-sun"
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
8 changes: 8 additions & 0 deletions test/fixtures/revisions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions test/fixtures/tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions test/system/comment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

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 @@ -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

Expand Down

0 comments on commit 4d08100

Please sign in to comment.