From e7e5e7efaf6ba14f6b40495e6f181b056fa2ef55 Mon Sep 17 00:00:00 2001 From: Will Gutierrez Date: Sun, 6 Jun 2021 20:51:46 -0700 Subject: [PATCH 1/5] prune comment system tests #9069 --- test/system/comment_test.rb | 471 ++++++++++++++++++------------------ 1 file changed, 236 insertions(+), 235 deletions(-) diff --git a/test/system/comment_test.rb b/test/system/comment_test.rb index dea8157019..f6e9b9246a 100644 --- a/test/system/comment_test.rb +++ b/test/system/comment_test.rb @@ -477,52 +477,72 @@ def get_path(page_type, path) 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 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 @@ -637,65 +657,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 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 @@ -707,38 +716,38 @@ def get_path(page_type, path) # there are many variations of this bug. this particular test involves: # DRAG & DROP upload into MAIN comment form # DRAG & DROP into EDIT comment form (.dropzone button) - test "#{page_type_string}: image DRAG & DROP into EDIT form isn't cross-wired with MAIN form" do - # setup page with editable comment - nodes(node_name).add_comment({ - uid: 2, - body: comment_text - }) - visit get_path(page_type, nodes(node_name).path) - # .dropzone is hidden, so reveal it for Capybara's finders: - Capybara.ignore_hidden_elements = false - # drag & drop the image. drop_in_dropzone simulates 'drop' event, see application_system_test_case.rb - drop_in_dropzone("#{Rails.root.to_s}/public/images/pl.png", '#comments-list + div .dropzone-large') # this CSS selects .dropzones that belong to sibling element immediately following #comments-list. technically, there are two .dropzones in the main comment form. - Capybara.ignore_hidden_elements = true - wait_for_ajax - # we need the ID of parent div that contains

comment_text

: - comment_id = page.find('p', text: comment_text).find(:xpath, '..')[:id] - # regex to strip the ID number out of string. ID format is comment-body-4231 - comment_id_num = /comment-body-(\d+)/.match(comment_id)[1] - comment_dropzone_selector = '#comment-form-body-edit-' + comment_id_num - # open the edit comment form - page.find(".edit-comment-btn").click - # drop into the edit comment form - Capybara.ignore_hidden_elements = false - drop_in_dropzone("#{Rails.root.to_s}/public/images/pl.png", comment_dropzone_selector) - Capybara.ignore_hidden_elements = true - wait_for_ajax - # open the preview for the main comment form - page.find('#toggle-preview-button-main').click - # once preview is open, the images are embedded in the page. - # there should only be 1 image in the main comment form! - preview_imgs = page.all('#comment-preview-main img').size - assert_equal(1, preview_imgs) - end + # test "#{page_type_string}: image DRAG & DROP into EDIT form isn't cross-wired with MAIN form" do + # # setup page with editable comment + # nodes(node_name).add_comment({ + # uid: 2, + # body: comment_text + # }) + # visit get_path(page_type, nodes(node_name).path) + # # .dropzone is hidden, so reveal it for Capybara's finders: + # Capybara.ignore_hidden_elements = false + # # drag & drop the image. drop_in_dropzone simulates 'drop' event, see application_system_test_case.rb + # drop_in_dropzone("#{Rails.root.to_s}/public/images/pl.png", '#comments-list + div .dropzone-large') # this CSS selects .dropzones that belong to sibling element immediately following #comments-list. technically, there are two .dropzones in the main comment form. + # Capybara.ignore_hidden_elements = true + # wait_for_ajax + # # we need the ID of parent div that contains

comment_text

: + # comment_id = page.find('p', text: comment_text).find(:xpath, '..')[:id] + # # regex to strip the ID number out of string. ID format is comment-body-4231 + # comment_id_num = /comment-body-(\d+)/.match(comment_id)[1] + # comment_dropzone_selector = '#comment-form-body-edit-' + comment_id_num + # # open the edit comment form + # page.find(".edit-comment-btn").click + # # drop into the edit comment form + # Capybara.ignore_hidden_elements = false + # drop_in_dropzone("#{Rails.root.to_s}/public/images/pl.png", comment_dropzone_selector) + # Capybara.ignore_hidden_elements = true + # wait_for_ajax + # # open the preview for the main comment form + # page.find('#toggle-preview-button-main').click + # # once preview is open, the images are embedded in the page. + # # there should only be 1 image in the main comment form! + # preview_imgs = page.all('#comment-preview-main img').size + # assert_equal(1, preview_imgs) + # end # cross-wiring test: # SELECT image upload in both: @@ -747,111 +756,103 @@ def get_path(page_type, path) # NOTE: this is also a test for: # IMMEDIATE image SELECT upload into MAIN comment form - test "#{page_type_string}: image SELECT upload into EDIT form isn't CROSS-WIRED with MAIN 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) - # open the edit comment form: - find(".edit-comment-btn").click - # find the parent of edit comment's fileinput: - comment_fileinput_parent_id = page.find('[id^=dropzone-small-edit-]')[:id] # 'begins with' CSS selector - comment_id_num = /dropzone-small-edit-(\d+)/.match(comment_fileinput_parent_id)[1] - # upload images - # the that take image uploads are hidden, so reveal them: - Capybara.ignore_hidden_elements = false - # upload an image in the main comment form - page.find('#fileinput-button-main').set("#{Rails.root.to_s}/public/images/pl.png") - wait_for_ajax - # find edit comment's fileinput: - page.find('#fileinput-button-edit-' + comment_id_num).set("#{Rails.root.to_s}/public/images/pl.png") - wait_for_ajax - Capybara.ignore_hidden_elements = true - # click preview buttons in main and edit form - page.find('h4', text: /Post comment|Post Comment/) # title text on wikis is 'Post comment' - .find(:xpath, '..') - .find('a', text: 'Preview').click - page.find('#comment-form-edit-' + comment_id_num + ' a', text: 'Preview').click - # once preview is open, the images are embedded in the page. - # there should be 1 image in main, and 1 image in edit - assert_selector('#comment-preview-edit-' + comment_id_num + ' img', count: 1) - assert_selector('#comment-preview-main img', count: 1) - end + # test "#{page_type_string}: image SELECT upload into EDIT form isn't CROSS-WIRED with MAIN 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) + # # open the edit comment form: + # find(".edit-comment-btn").click + # # find the parent of edit comment's fileinput: + # comment_fileinput_parent_id = page.find('[id^=dropzone-small-edit-]')[:id] # 'begins with' CSS selector + # comment_id_num = /dropzone-small-edit-(\d+)/.match(comment_fileinput_parent_id)[1] + # # upload images + # # the that take image uploads are hidden, so reveal them: + # Capybara.ignore_hidden_elements = false + # # upload an image in the main comment form + # page.find('#fileinput-button-main').set("#{Rails.root.to_s}/public/images/pl.png") + # wait_for_ajax + # # find edit comment's fileinput: + # page.find('#fileinput-button-edit-' + comment_id_num).set("#{Rails.root.to_s}/public/images/pl.png") + # wait_for_ajax + # Capybara.ignore_hidden_elements = true + # # click preview buttons in main and edit form + # page.find('h4', text: /Post comment|Post Comment/) # title text on wikis is 'Post comment' + # .find(:xpath, '..') + # .find('a', text: 'Preview').click + # page.find('#comment-form-edit-' + comment_id_num + ' a', text: 'Preview').click + # # once preview is open, the images are embedded in the page. + # # there should be 1 image in main, and 1 image in edit + # assert_selector('#comment-preview-edit-' + comment_id_num + ' img', count: 1) + # assert_selector('#comment-preview-main img', count: 1) + # end # cross-wiring test # SELECT image upload in both: # EDIT FORM # REPLY form - test "#{page_type_string}: image SELECT upload into EDIT form isn't CROSS-WIRED with REPLY form" do - nodes(node_name).add_comment({ - uid: 2, - body: comment_text - }) - visit get_path(page_type, nodes(node_name).path) - # find the EDIT id - # open up the edit comment form - page.find(".edit-comment-btn").click - edit_comment_form_id = page.find('h4', text: 'Edit comment').find(:xpath, '..')[:id] - # regex to strip the ID number out of string. ID format is #c1234edit - edit_id_num = /comment-form-edit-(\d+)/.match(edit_comment_form_id)[1] - # open the edit comment form - edit_preview_id = '#comment-preview-edit-' + edit_id_num - # find the REPLY id - page.all('p', text: 'Reply to this comment...')[0].click - reply_dropzone_id = page.find('[id^=dropzone-small-reply-]')[:id] - # ID begins with... - reply_id_num = /dropzone-small-reply-(\d+)/.match(reply_dropzone_id)[1] - # upload images - # the 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-' + reply_id_num).set("#{Rails.root.to_s}/public/images/pl.png") - wait_for_ajax - # upload an image in the edit comment form - page.find('#fileinput-button-edit-' + edit_id_num).set("#{Rails.root.to_s}/public/images/pl.png") - Capybara.ignore_hidden_elements = true - wait_for_ajax - # click preview buttons in reply and edit form - page.find('#comment-form-edit-' + edit_id_num + ' a', text: 'Preview').click - page.first('a', text: 'Preview').click - assert_selector('#comment-preview-edit-' + edit_id_num + ' img', count: 1) - 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, - body: comment_text - }) - nodes(node_name).add_comment({ - uid: 2, - body: comment_text - }) - visit get_path(page_type, nodes(node_name).path) - # open up the edit comment form - page.find(".edit-comment-btn").click - # find the EDIT id - edit_comment_form_id = page.find('h4', text: 'Edit comment').find(:xpath, '..')[:id] - # open up the reply comment form - page.all('p', text: 'Reply to this comment...')[1].click - page.all("[data-original-title='Bold']")[0].click - reply_input_value = page.find('[id^=text-input-reply-]').value - edit_input_value = page.find('#' + edit_comment_form_id + ' textarea').value - assert_equal(comment_text, edit_input_value) - assert_equal('****', reply_input_value) - end + # test "#{page_type_string}: image SELECT upload into EDIT form isn't CROSS-WIRED with REPLY form" do + # nodes(node_name).add_comment({ + # uid: 2, + # body: comment_text + # }) + # visit get_path(page_type, nodes(node_name).path) + # # find the EDIT id + # # open up the edit comment form + # page.find(".edit-comment-btn").click + # edit_comment_form_id = page.find('h4', text: 'Edit comment').find(:xpath, '..')[:id] + # # regex to strip the ID number out of string. ID format is #c1234edit + # edit_id_num = /comment-form-edit-(\d+)/.match(edit_comment_form_id)[1] + # # open the edit comment form + # edit_preview_id = '#comment-preview-edit-' + edit_id_num + # # find the REPLY id + # page.all('p', text: 'Reply to this comment...')[0].click + # reply_dropzone_id = page.find('[id^=dropzone-small-reply-]')[:id] + # # ID begins with... + # reply_id_num = /dropzone-small-reply-(\d+)/.match(reply_dropzone_id)[1] + # # upload images + # # the 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-' + reply_id_num).set("#{Rails.root.to_s}/public/images/pl.png") + # wait_for_ajax + # # upload an image in the edit comment form + # page.find('#fileinput-button-edit-' + edit_id_num).set("#{Rails.root.to_s}/public/images/pl.png") + # Capybara.ignore_hidden_elements = true + # wait_for_ajax + # # click preview buttons in reply and edit form + # page.find('#comment-form-edit-' + edit_id_num + ' a', text: 'Preview').click + # page.first('a', text: 'Preview').click + # assert_selector('#comment-preview-edit-' + edit_id_num + ' img', count: 1) + # assert_selector('#comment-preview-reply-' + reply_id_num, count: 1) + # 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, + # body: comment_text + # }) + # nodes(node_name).add_comment({ + # uid: 2, + # body: comment_text + # }) + # visit get_path(page_type, nodes(node_name).path) + # # open up the edit comment form + # page.find(".edit-comment-btn").click + # # find the EDIT id + # edit_comment_form_id = page.find('h4', text: 'Edit comment').find(:xpath, '..')[:id] + # # open up the reply comment form + # page.all('p', text: 'Reply to this comment...')[1].click + # page.all("[data-original-title='Bold']")[0].click + # reply_input_value = page.find('[id^=text-input-reply-]').value + # edit_input_value = page.find('#' + edit_comment_form_id + ' textarea').value + # assert_equal(comment_text, edit_input_value) + # assert_equal('****', reply_input_value) + # end end end From a5a9d304269446530775b644c244b8d618372eb7 Mon Sep 17 00:00:00 2001 From: Will Gutierrez Date: Mon, 26 Jul 2021 14:03:08 -0700 Subject: [PATCH 2/5] break comment system tests out to separate workflow #9069 --- .github/workflows/tests.yml | 47 ++++ .../comment_test.rb | 250 +++++++++--------- 2 files changed, 172 insertions(+), 125 deletions(-) rename test/{system => comment_system_tests}/comment_test.rb (82%) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1f3972482a..2109cb3795 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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: "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: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] diff --git a/test/system/comment_test.rb b/test/comment_system_tests/comment_test.rb similarity index 82% rename from test/system/comment_test.rb rename to test/comment_system_tests/comment_test.rb index f6e9b9246a..99619ac926 100644 --- a/test/system/comment_test.rb +++ b/test/comment_system_tests/comment_test.rb @@ -716,38 +716,38 @@ def get_path(page_type, path) # there are many variations of this bug. this particular test involves: # DRAG & DROP upload into MAIN comment form # DRAG & DROP into EDIT comment form (.dropzone button) - # test "#{page_type_string}: image DRAG & DROP into EDIT form isn't cross-wired with MAIN form" do - # # setup page with editable comment - # nodes(node_name).add_comment({ - # uid: 2, - # body: comment_text - # }) - # visit get_path(page_type, nodes(node_name).path) - # # .dropzone is hidden, so reveal it for Capybara's finders: - # Capybara.ignore_hidden_elements = false - # # drag & drop the image. drop_in_dropzone simulates 'drop' event, see application_system_test_case.rb - # drop_in_dropzone("#{Rails.root.to_s}/public/images/pl.png", '#comments-list + div .dropzone-large') # this CSS selects .dropzones that belong to sibling element immediately following #comments-list. technically, there are two .dropzones in the main comment form. - # Capybara.ignore_hidden_elements = true - # wait_for_ajax - # # we need the ID of parent div that contains

comment_text

: - # comment_id = page.find('p', text: comment_text).find(:xpath, '..')[:id] - # # regex to strip the ID number out of string. ID format is comment-body-4231 - # comment_id_num = /comment-body-(\d+)/.match(comment_id)[1] - # comment_dropzone_selector = '#comment-form-body-edit-' + comment_id_num - # # open the edit comment form - # page.find(".edit-comment-btn").click - # # drop into the edit comment form - # Capybara.ignore_hidden_elements = false - # drop_in_dropzone("#{Rails.root.to_s}/public/images/pl.png", comment_dropzone_selector) - # Capybara.ignore_hidden_elements = true - # wait_for_ajax - # # open the preview for the main comment form - # page.find('#toggle-preview-button-main').click - # # once preview is open, the images are embedded in the page. - # # there should only be 1 image in the main comment form! - # preview_imgs = page.all('#comment-preview-main img').size - # assert_equal(1, preview_imgs) - # end + test "#{page_type_string}: image DRAG & DROP into EDIT form isn't cross-wired with MAIN form" do + # setup page with editable comment + nodes(node_name).add_comment({ + uid: 2, + body: comment_text + }) + visit get_path(page_type, nodes(node_name).path) + # .dropzone is hidden, so reveal it for Capybara's finders: + Capybara.ignore_hidden_elements = false + # drag & drop the image. drop_in_dropzone simulates 'drop' event, see application_system_test_case.rb + drop_in_dropzone("#{Rails.root.to_s}/public/images/pl.png", '#comments-list + div .dropzone-large') # this CSS selects .dropzones that belong to sibling element immediately following #comments-list. technically, there are two .dropzones in the main comment form. + Capybara.ignore_hidden_elements = true + wait_for_ajax + # we need the ID of parent div that contains

comment_text

: + comment_id = page.find('p', text: comment_text).find(:xpath, '..')[:id] + # regex to strip the ID number out of string. ID format is comment-body-4231 + comment_id_num = /comment-body-(\d+)/.match(comment_id)[1] + comment_dropzone_selector = '#comment-form-body-edit-' + comment_id_num + # open the edit comment form + page.find(".edit-comment-btn").click + # drop into the edit comment form + Capybara.ignore_hidden_elements = false + drop_in_dropzone("#{Rails.root.to_s}/public/images/pl.png", comment_dropzone_selector) + Capybara.ignore_hidden_elements = true + wait_for_ajax + # open the preview for the main comment form + page.find('#toggle-preview-button-main').click + # once preview is open, the images are embedded in the page. + # there should only be 1 image in the main comment form! + preview_imgs = page.all('#comment-preview-main img').size + assert_equal(1, preview_imgs) + end # cross-wiring test: # SELECT image upload in both: @@ -756,103 +756,103 @@ def get_path(page_type, path) # NOTE: this is also a test for: # IMMEDIATE image SELECT upload into MAIN comment form - # test "#{page_type_string}: image SELECT upload into EDIT form isn't CROSS-WIRED with MAIN 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) - # # open the edit comment form: - # find(".edit-comment-btn").click - # # find the parent of edit comment's fileinput: - # comment_fileinput_parent_id = page.find('[id^=dropzone-small-edit-]')[:id] # 'begins with' CSS selector - # comment_id_num = /dropzone-small-edit-(\d+)/.match(comment_fileinput_parent_id)[1] - # # upload images - # # the that take image uploads are hidden, so reveal them: - # Capybara.ignore_hidden_elements = false - # # upload an image in the main comment form - # page.find('#fileinput-button-main').set("#{Rails.root.to_s}/public/images/pl.png") - # wait_for_ajax - # # find edit comment's fileinput: - # page.find('#fileinput-button-edit-' + comment_id_num).set("#{Rails.root.to_s}/public/images/pl.png") - # wait_for_ajax - # Capybara.ignore_hidden_elements = true - # # click preview buttons in main and edit form - # page.find('h4', text: /Post comment|Post Comment/) # title text on wikis is 'Post comment' - # .find(:xpath, '..') - # .find('a', text: 'Preview').click - # page.find('#comment-form-edit-' + comment_id_num + ' a', text: 'Preview').click - # # once preview is open, the images are embedded in the page. - # # there should be 1 image in main, and 1 image in edit - # assert_selector('#comment-preview-edit-' + comment_id_num + ' img', count: 1) - # assert_selector('#comment-preview-main img', count: 1) - # end + test "#{page_type_string}: image SELECT upload into EDIT form isn't CROSS-WIRED with MAIN 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) + # open the edit comment form: + find(".edit-comment-btn").click + # find the parent of edit comment's fileinput: + comment_fileinput_parent_id = page.find('[id^=dropzone-small-edit-]')[:id] # 'begins with' CSS selector + comment_id_num = /dropzone-small-edit-(\d+)/.match(comment_fileinput_parent_id)[1] + # upload images + # the that take image uploads are hidden, so reveal them: + Capybara.ignore_hidden_elements = false + # upload an image in the main comment form + page.find('#fileinput-button-main').set("#{Rails.root.to_s}/public/images/pl.png") + wait_for_ajax + # find edit comment's fileinput: + page.find('#fileinput-button-edit-' + comment_id_num).set("#{Rails.root.to_s}/public/images/pl.png") + wait_for_ajax + Capybara.ignore_hidden_elements = true + # click preview buttons in main and edit form + page.find('h4', text: /Post comment|Post Comment/) # title text on wikis is 'Post comment' + .find(:xpath, '..') + .find('a', text: 'Preview').click + page.find('#comment-form-edit-' + comment_id_num + ' a', text: 'Preview').click + # once preview is open, the images are embedded in the page. + # there should be 1 image in main, and 1 image in edit + assert_selector('#comment-preview-edit-' + comment_id_num + ' img', count: 1) + assert_selector('#comment-preview-main img', count: 1) + end # cross-wiring test # SELECT image upload in both: # EDIT FORM # REPLY form - # test "#{page_type_string}: image SELECT upload into EDIT form isn't CROSS-WIRED with REPLY form" do - # nodes(node_name).add_comment({ - # uid: 2, - # body: comment_text - # }) - # visit get_path(page_type, nodes(node_name).path) - # # find the EDIT id - # # open up the edit comment form - # page.find(".edit-comment-btn").click - # edit_comment_form_id = page.find('h4', text: 'Edit comment').find(:xpath, '..')[:id] - # # regex to strip the ID number out of string. ID format is #c1234edit - # edit_id_num = /comment-form-edit-(\d+)/.match(edit_comment_form_id)[1] - # # open the edit comment form - # edit_preview_id = '#comment-preview-edit-' + edit_id_num - # # find the REPLY id - # page.all('p', text: 'Reply to this comment...')[0].click - # reply_dropzone_id = page.find('[id^=dropzone-small-reply-]')[:id] - # # ID begins with... - # reply_id_num = /dropzone-small-reply-(\d+)/.match(reply_dropzone_id)[1] - # # upload images - # # the 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-' + reply_id_num).set("#{Rails.root.to_s}/public/images/pl.png") - # wait_for_ajax - # # upload an image in the edit comment form - # page.find('#fileinput-button-edit-' + edit_id_num).set("#{Rails.root.to_s}/public/images/pl.png") - # Capybara.ignore_hidden_elements = true - # wait_for_ajax - # # click preview buttons in reply and edit form - # page.find('#comment-form-edit-' + edit_id_num + ' a', text: 'Preview').click - # page.first('a', text: 'Preview').click - # assert_selector('#comment-preview-edit-' + edit_id_num + ' img', count: 1) - # assert_selector('#comment-preview-reply-' + reply_id_num, count: 1) - # 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, - # body: comment_text - # }) - # nodes(node_name).add_comment({ - # uid: 2, - # body: comment_text - # }) - # visit get_path(page_type, nodes(node_name).path) - # # open up the edit comment form - # page.find(".edit-comment-btn").click - # # find the EDIT id - # edit_comment_form_id = page.find('h4', text: 'Edit comment').find(:xpath, '..')[:id] - # # open up the reply comment form - # page.all('p', text: 'Reply to this comment...')[1].click - # page.all("[data-original-title='Bold']")[0].click - # reply_input_value = page.find('[id^=text-input-reply-]').value - # edit_input_value = page.find('#' + edit_comment_form_id + ' textarea').value - # assert_equal(comment_text, edit_input_value) - # assert_equal('****', reply_input_value) - # end + test "#{page_type_string}: image SELECT upload into EDIT form isn't CROSS-WIRED with REPLY form" do + nodes(node_name).add_comment({ + uid: 2, + body: comment_text + }) + visit get_path(page_type, nodes(node_name).path) + # find the EDIT id + # open up the edit comment form + page.find(".edit-comment-btn").click + edit_comment_form_id = page.find('h4', text: 'Edit comment').find(:xpath, '..')[:id] + # regex to strip the ID number out of string. ID format is #c1234edit + edit_id_num = /comment-form-edit-(\d+)/.match(edit_comment_form_id)[1] + # open the edit comment form + edit_preview_id = '#comment-preview-edit-' + edit_id_num + # find the REPLY id + page.all('p', text: 'Reply to this comment...')[0].click + reply_dropzone_id = page.find('[id^=dropzone-small-reply-]')[:id] + # ID begins with... + reply_id_num = /dropzone-small-reply-(\d+)/.match(reply_dropzone_id)[1] + # upload images + # the 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-' + reply_id_num).set("#{Rails.root.to_s}/public/images/pl.png") + wait_for_ajax + # upload an image in the edit comment form + page.find('#fileinput-button-edit-' + edit_id_num).set("#{Rails.root.to_s}/public/images/pl.png") + Capybara.ignore_hidden_elements = true + wait_for_ajax + # click preview buttons in reply and edit form + page.find('#comment-form-edit-' + edit_id_num + ' a', text: 'Preview').click + page.first('a', text: 'Preview').click + assert_selector('#comment-preview-edit-' + edit_id_num + ' img', count: 1) + assert_selector('#comment-preview-reply-' + reply_id_num, count: 1) + 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, + body: comment_text + }) + nodes(node_name).add_comment({ + uid: 2, + body: comment_text + }) + visit get_path(page_type, nodes(node_name).path) + # open up the edit comment form + page.find(".edit-comment-btn").click + # find the EDIT id + edit_comment_form_id = page.find('h4', text: 'Edit comment').find(:xpath, '..')[:id] + # open up the reply comment form + page.all('p', text: 'Reply to this comment...')[1].click + page.all("[data-original-title='Bold']")[0].click + reply_input_value = page.find('[id^=text-input-reply-]').value + edit_input_value = page.find('#' + edit_comment_form_id + ' textarea').value + assert_equal(comment_text, edit_input_value) + assert_equal('****', reply_input_value) + end end end From c7a7d9d66ac4b20681e84e723ffe4aee26c5628e Mon Sep 17 00:00:00 2001 From: Will Gutierrez Date: Tue, 27 Jul 2021 14:13:58 -0700 Subject: [PATCH 3/5] increase after_n_builds by 1 #9069 --- codecov.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codecov.yml b/codecov.yml index b108ea5fc8..3703effc84 100644 --- a/codecov.yml +++ b/codecov.yml @@ -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] @@ -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 From c9d0f5db19331617afd4587a57f1833e97a0064d Mon Sep 17 00:00:00 2001 From: Will Gutierrez Date: Wed, 28 Jul 2021 10:59:45 -0700 Subject: [PATCH 4/5] change rails test command #9069 --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2109cb3795..308b893ba8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -171,7 +171,7 @@ jobs: 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: "System Tests" + - name: "Comment System Tests" env: RAILS_ENV: test DB_PASSWORD: root @@ -181,7 +181,7 @@ jobs: run: | export DISPLAY=:99 chromedriver --url-base=/wd/hub & - bundle exec rails test:comment_system_tests + bundle exec rails test test/comment_system_tests - name: Archive system test screenshots uses: actions/upload-artifact@v2 with: From 2001d462bdba96154e747130d364efb1b28890e1 Mon Sep 17 00:00:00 2001 From: jywarren Date: Wed, 28 Jul 2021 22:35:49 +0000 Subject: [PATCH 5/5] removed extra "end" --- test/comment_system_tests/comment_test.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/test/comment_system_tests/comment_test.rb b/test/comment_system_tests/comment_test.rb index 99619ac926..3a7f991441 100644 --- a/test/comment_system_tests/comment_test.rb +++ b/test/comment_system_tests/comment_test.rb @@ -475,7 +475,6 @@ 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 test "#{page_type_string}: IMMEDIATE image SELECT upload into REPLY comment form" do nodes(node_name).add_comment({