Skip to content

Commit

Permalink
Prune Comment System Tests for Faster CI (publiclab#9752)
Browse files Browse the repository at this point in the history
* prune comment system tests publiclab#9069

* break comment system tests out to separate workflow publiclab#9069

* increase after_n_builds by 1 publiclab#9069

* change rails test command publiclab#9069

* removed extra "end"

Co-authored-by: jywarren <jeff@unterbahn.com>
  • Loading branch information
2 people authored and reginaalyssa committed Oct 16, 2021
1 parent 6256f01 commit 02dc6c9
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 113 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,53 @@ jobs:
name: system-test-screenshots
path: tmp/screenshots/*

comment-system-tests:
runs-on: ubuntu-latest
services:
redis:
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps port 6379 on service container to the host
- 6379:6379
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6.6 # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically (not working?)
- uses: nanasess/setup-chromedriver@v1.0.1
- uses: ./.github/actions/setup-test-environment
- name: Install JavaScript dependencies with Yarn
run: yarn check || yarn install --frozen-lockfile;
- name: Run webpacker setup
env:
RAILS_ENV: test
DB_PASSWORD: root
DB_PORT: ${{ job.services.mysql.ports[3306] }}
run: bundle exec rails g webpacker:install && bundle exec rails g webpacker:install:react && bundle exec rails g react:install
- name: "Comment System Tests"
env:
RAILS_ENV: test
DB_PASSWORD: root
DB_PORT: ${{ job.services.mysql.ports[3306] }}
REDIS_HOST: localhost
REDIS_PORT: 6379
run: |
export DISPLAY=:99
chromedriver --url-base=/wd/hub &
bundle exec rails test test/comment_system_tests
- name: Archive system test screenshots
uses: actions/upload-artifact@v2
with:
name: system-test-screenshots
path: tmp/screenshots/*

remove-labels:
runs-on: ubuntu-latest
needs: [add-label, unit-tests, functional-tests, integration-tests, system-tests]
Expand Down
4 changes: 2 additions & 2 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
comment:
layout: "reach, diff, flags, files"
behavior: default
after_n_builds: 4
after_n_builds: 5
require_changes: true # if true: only post the comment if coverage changes
require_base: yes # [yes :: must have a base report to post]
require_head: yes # [yes :: must have a head report to post]
Expand All @@ -27,4 +27,4 @@ codecov:
# https://docs.codecov.io/v4.3.6/docs/comparing-commits
allow_coverage_offsets: true
notify:
after_n_builds: 4
after_n_builds: 5
222 changes: 111 additions & 111 deletions test/system/comment_test.rb → test/comment_system_tests/comment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -475,54 +475,73 @@ def get_path(page_type, path)
# checks for the list of recently active users
assert_selector('#atwho-ground-text-input-main .atwho-view .atwho-view-ul li')
end
end

# 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
test "#{page_type_string}: IMMEDIATE image SELECT upload into REPLY comment form" do
nodes(node_name).add_comment({
uid: 5,
body: comment_text
})
nodes(node_name).add_comment({
uid: 2,
body: comment_text
})
visit get_path(page_type, nodes(node_name).path)
reply_toggles = page.all('p', text: 'Reply to this comment...')
reply_toggles[2].click
reply_dropzone_id = page.find('[id^=dropzone-small-reply-]')[:id] # ID begins with...
comment_id_num = /dropzone-small-reply-(\d+)/.match(reply_dropzone_id)[1]
# upload images
# the <inputs> that take image uploads are hidden, so reveal them:
Capybara.ignore_hidden_elements = false
# upload an image in the reply comment form
page.find('#fileinput-button-reply-' + comment_id_num).set("#{Rails.root.to_s}/public/images/pl.png")
wait_for_ajax
Capybara.ignore_hidden_elements = true
page.all('a', text: 'Preview')[0].click
assert_selector('#comment-' + comment_id_num + '-reply-section img', count: 1)
end

test "post #{page_type_string}, then comment on FRESH #{page_type_string}" do
title_text, body_text = String.new, String.new
case page_type_string
when 'note'
visit '/post'
title_text = 'Ahh, a nice fresh note'
body_text = "Can\'t wait to write in it!"
fill_in('title-input', with: title_text)
find('.wk-wysiwyg').set(body_text)
find('.ple-publish').click()
when 'question'
visit '/questions/new?&tags=question%3Ageneral'
title_text = "Let's talk condiments"
body_text = 'Ketchup or mayo?'
find("input[aria-label='Enter question']", match: :first)
.click()
.fill_in with: title_text
find('.wk-wysiwyg').set(body_text)
find('.ple-publish').click()
when 'wiki'
visit '/wiki/new'
title_text = 'pokemon'
body_text = 'Gotta catch em all!'
fill_in('title', with: title_text)
fill_in('text-input-main', with: body_text)
find('#publish').click()
visit "/wiki/#{title_text}/comments"
end
assert_selector('h1', text: title_text)
page.find("textarea#text-input-main")
.click
.fill_in 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)
test "#{page_type_string}: IMMEDIATE image DRAG & DROP into REPLY comment form" do
Capybara.ignore_hidden_elements = false
visit get_path(page_type, nodes(node_name).path)
find("p", text: "Reply to this comment...").click()
# Upload the image
drop_in_dropzone("#{Rails.root.to_s}/public/images/pl.png", ".dropzone-large")
# Wait for image upload to finish
wait_for_ajax
Capybara.ignore_hidden_elements = true
# Toggle preview
reply_preview_button = page.all('.preview-btn')[0]
reply_preview_button.click()
# Make sure that image has been uploaded
page.assert_selector('.comment-preview img', count: 1)
end

test "#{page_type_string}: IMMEDIATE image CHOOSE ONE upload into REPLY comment form" do
Capybara.ignore_hidden_elements = false
visit get_path(page_type, nodes(node_name).path)
# Open reply comment form
find("p", text: "Reply to this comment...").click()
first("a", text: "choose one").click()
reply_preview_button = page.first('a', text: 'Preview')
Capybara.ignore_hidden_elements = false
# Upload the image
fileinput_element = page.first("[id^=fileinput-button-reply]")
fileinput_element.set("#{Rails.root.to_s}/public/images/pl.png")
Capybara.ignore_hidden_elements = true
wait_for_ajax
# Toggle preview
reply_preview_button.click()
# Make sure that image has been uploaded
page.assert_selector('.comment-preview img', count: 1)
end

test "#{page_type_string}: IMMEDIATE rich-text input works in MAIN form" do
visit get_path(page_type, nodes(node_name).path)
main_comment_form = page.find('h4', text: /Post comment|Post Comment/).find(:xpath, '..') # title text on wikis is 'Post comment'
main_comment_form.find("[data-original-title='Bold']").click
text_input_value = main_comment_form.find('#text-input-main').value
assert_equal(text_input_value, '****')
end

# navigate to page, immediately upload into EDIT form by SELECTing image
Expand Down Expand Up @@ -637,65 +656,54 @@ def get_path(page_type, path)
visit get_path(page_type, nodes(node_name).path)
assert_selector("#c#{comment.id}", count: 0)
end
end

test "#{page_type_string}: IMMEDIATE image SELECT upload into REPLY comment form" do
nodes(node_name).add_comment({
uid: 5,
body: comment_text
})
nodes(node_name).add_comment({
uid: 2,
body: comment_text
})
visit get_path(page_type, nodes(node_name).path)
reply_toggles = page.all('p', text: 'Reply to this comment...')
reply_toggles[2].click
reply_dropzone_id = page.find('[id^=dropzone-small-reply-]')[:id] # ID begins with...
comment_id_num = /dropzone-small-reply-(\d+)/.match(reply_dropzone_id)[1]
# upload images
# the <inputs> that take image uploads are hidden, so reveal them:
Capybara.ignore_hidden_elements = false
# upload an image in the reply comment form
page.find('#fileinput-button-reply-' + comment_id_num).set("#{Rails.root.to_s}/public/images/pl.png")
wait_for_ajax
Capybara.ignore_hidden_elements = true
page.all('a', text: 'Preview')[0].click
assert_selector('#comment-' + comment_id_num + '-reply-section img', count: 1)
end

test "#{page_type_string}: IMMEDIATE image DRAG & DROP into REPLY comment form" do
Capybara.ignore_hidden_elements = false
visit get_path(page_type, nodes(node_name).path)
find("p", text: "Reply to this comment...").click()
# Upload the image
drop_in_dropzone("#{Rails.root.to_s}/public/images/pl.png", ".dropzone-large")
# Wait for image upload to finish
wait_for_ajax
Capybara.ignore_hidden_elements = true
# Toggle preview
reply_preview_button = page.all('.preview-btn')[0]
reply_preview_button.click()
# Make sure that image has been uploaded
page.assert_selector('.comment-preview img', count: 1)
end
# 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

test "#{page_type_string}: IMMEDIATE image CHOOSE ONE upload into REPLY comment form" do
Capybara.ignore_hidden_elements = false
visit get_path(page_type, nodes(node_name).path)
# Open reply comment form
find("p", text: "Reply to this comment...").click()
first("a", text: "choose one").click()
reply_preview_button = page.first('a', text: 'Preview')
Capybara.ignore_hidden_elements = false
# Upload the image
fileinput_element = page.first("[id^=fileinput-button-reply]")
fileinput_element.set("#{Rails.root.to_s}/public/images/pl.png")
Capybara.ignore_hidden_elements = true
wait_for_ajax
# Toggle preview
reply_preview_button.click()
# Make sure that image has been uploaded
page.assert_selector('.comment-preview img', count: 1)
test "post #{page_type_string}, then comment on FRESH #{page_type_string}" do
title_text, body_text = String.new, String.new
case page_type_string
when 'note'
visit '/post'
title_text = 'Ahh, a nice fresh note'
body_text = "Can\'t wait to write in it!"
fill_in('title-input', with: title_text)
find('.wk-wysiwyg').set(body_text)
find('.ple-publish').click()
when 'question'
visit '/questions/new?&tags=question%3Ageneral'
title_text = "Let's talk condiments"
body_text = 'Ketchup or mayo?'
find("input[aria-label='Enter question']", match: :first)
.click()
.fill_in with: title_text
find('.wk-wysiwyg').set(body_text)
find('.ple-publish').click()
when 'wiki'
visit '/wiki/new'
title_text = 'pokemon'
body_text = 'Gotta catch em all!'
fill_in('title', with: title_text)
fill_in('text-input-main', with: body_text)
find('#publish').click()
visit "/wiki/#{title_text}/comments"
end
assert_selector('h1', text: title_text)
page.find("textarea#text-input-main")
.click
.fill_in 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)
end

# Cross-Wiring Bugs
Expand Down Expand Up @@ -823,14 +831,6 @@ def get_path(page_type, path)
assert_selector('#comment-preview-reply-' + reply_id_num, count: 1)
end

test "#{page_type_string}: IMMEDIATE rich-text input works in MAIN form" do
visit get_path(page_type, nodes(node_name).path)
main_comment_form = page.find('h4', text: /Post comment|Post Comment/).find(:xpath, '..') # title text on wikis is 'Post comment'
main_comment_form.find("[data-original-title='Bold']").click
text_input_value = main_comment_form.find('#text-input-main').value
assert_equal(text_input_value, '****')
end

test "#{page_type_string}: rich-text input into REPLY form isn't CROSS-WIRED with EDIT form" do
nodes(node_name).add_comment({
uid: 5,
Expand Down

0 comments on commit 02dc6c9

Please sign in to comment.