-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Tests for React Post Comment, Post Reply #9665
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,16 +20,68 @@ def get_path(page_type, path) | |
page_type == :wiki ? path + '/comments' : path | ||
end | ||
|
||
# weird syntax, i know. | ||
# most comment tests we can simply test on Research Note pages. | ||
# that's what this block is for. | ||
comment_text = 'woot woot' | ||
comment_response_text = 'wooly woot' | ||
|
||
# comment system tests are divided into 3 parts: | ||
# 1. basic CRUD in both React and Rails research notes | ||
# 2. tests for research notes | ||
# 3. tests for research notes, wikis, and questions | ||
|
||
# PART 1: TESTS FOR BASIC CRUD (REACT & RAILS NOTES) | ||
# system tests for BASIC commenting CRUD functionality: | ||
# create (posting comments & replies) | ||
# update (editing comments) | ||
# delete | ||
[true, false].each do |is_testing_react| | ||
page_type_string = is_testing_react ? 'react note' : 'rails note' | ||
test_path = is_testing_react ? '?react=true' : '' | ||
|
||
test "#{page_type_string}: post comment" do | ||
visit nodes(:comment_note).path + test_path | ||
main_comment_form = page.find('#comment-form-main') | ||
# fill in comment text | ||
main_comment_form | ||
.find('#text-input-main') | ||
.click | ||
.fill_in with: comment_text | ||
# click publish button | ||
main_comment_form | ||
.find('button', text: 'Publish') | ||
.click | ||
# wait for notyNotification to appear | ||
find(".noty_body", text: "Comment Added!") | ||
# assert that comment has appeared | ||
assert_selector('#comments-list .comment-body p', text: comment_text) | ||
end | ||
|
||
test "#{page_type_string}: post REPLY to comment" do | ||
visit nodes(:comment_note).path + test_path | ||
# find the first comment | ||
first_comment = page.first('.comment') | ||
# click on the reply form toggle | ||
first_comment | ||
.find('p', text: 'Reply to this comment...') | ||
.click | ||
# enter text in reply form | ||
first_comment.find('[id^=text-input-reply-]') | ||
.click | ||
.fill_in with: comment_response_text | ||
# click publish button | ||
first_comment | ||
.find('button', text: 'Publish') | ||
.click | ||
# wait for notyNotification to appear | ||
page.find(".noty_body", text: "Comment Added!") | ||
assert_selector('.comment .comment .comment-body p', text: comment_response_text) | ||
end | ||
end | ||
|
||
# other comment tests can ALSO be tested on Wikis and Questions. | ||
# scroll past this block for those tests. | ||
# PART 2: TESTS FOR RESEARCH NOTES ONLY | ||
# public lab has 3 different page types: research notes, wikis, and questions | ||
# to save testing resources, we can run most tests on just research notes | ||
{ :note => :comment_note }.each do |page_type, node_name| | ||
page_type_string = 'note' | ||
comment_text = 'woot woot' | ||
comment_response_text = 'wooly woot' | ||
|
||
test "#{page_type_string}: addComment(comment_text)" do | ||
visit get_path(page_type, nodes(node_name).path) | ||
|
@@ -60,26 +112,6 @@ def get_path(page_type, path) | |
assert_selector("#{'#c' + parent_id_num + 'show'} div div div p", text: comment_response_text) | ||
end | ||
|
||
test "#{page_type_string}: manual comment and reply to comment" do | ||
visit get_path(page_type, nodes(node_name).path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deleted this test. |
||
fill_in("body", with: comment_text) | ||
# preview comment | ||
find("#toggle-preview-button-main").click | ||
find("p", text: comment_text) | ||
# publish comment | ||
click_on "Publish" | ||
find(".noty_body", text: "Comment Added!") | ||
find("p", text: comment_text) | ||
# replying to the comment | ||
first("p", text: "Reply to this comment...").click() | ||
page.find('[id^=text-input-reply-]') | ||
.click | ||
.fill_in with: comment_response_text | ||
# preview reply | ||
first(".preview-btn").click | ||
find("p", text: comment_response_text) | ||
end | ||
|
||
test "#{page_type_string}: toggle preview buttons work" do | ||
nodes(node_name).add_comment({ | ||
uid: 2, | ||
|
@@ -425,14 +457,12 @@ def get_path(page_type, path) | |
end | ||
end | ||
|
||
# TESTS for ALL PAGE TYPES! | ||
# PART 3: TESTS for ALL PAGE TYPES! | ||
# | ||
# the page_types are: Wikis, Research Notes, and Questions | ||
# defined in test/test_helper.rb | ||
page_types.each do |page_type, node_name| | ||
page_type_string = page_type.to_s | ||
comment_text = 'woot woot' | ||
comment_response_text = 'wooly woot' | ||
|
||
test "post #{page_type_string}, then comment on FRESH #{page_type_string}" do | ||
title_text, body_text = String.new, String.new | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice code syntax!!