diff --git a/.travis.yml b/.travis.yml index b4a0ed27c..8ffc83c25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ before_script: - npm install - cp config/database.yml.travis config/database.yml - psql -c 'create database travis_ci_test;' -U postgres - - RAILS_ENV=test bundle exec rails webdrivers:chromedriver:update + - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost & script: - bundle exec rubocop - $(npm bin)/sass-lint -vq diff --git a/Gemfile b/Gemfile index e30d333e3..b18e97543 100644 --- a/Gemfile +++ b/Gemfile @@ -111,6 +111,7 @@ group :development do end group :test do + gem "apparition", "~> 0.6" gem "webmock", "~> 2" end @@ -120,13 +121,11 @@ group :development, :test do gem "cucumber-rails", "1.6.0", require: false gem "database_cleaner", "~> 1" gem "factory_girl_rails", "~> 4" - gem "poltergeist", "~> 1" gem "rails-controller-testing" gem "rspec-core", "~> 3" gem "rspec-rails", "~> 3" gem "rubocop", "0.52.0" gem "rubocop-github", "0.9.0" - gem "selenium-webdriver", "~> 3" gem "webdrivers", "~> 4" end diff --git a/Gemfile.lock b/Gemfile.lock index f70727cfc..17bbf4967 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -69,6 +69,9 @@ GEM safely_block (>= 0.1.1) user_agent_parser uuidtools + apparition (0.6.0) + capybara (~> 3.13, < 4) + websocket-driver (>= 0.6.5) arel (7.1.4) ast (2.4.0) autoprefixer-rails (9.5.1) @@ -122,7 +125,6 @@ GEM rake (< 13.0) chronic (0.10.2) climate_control (0.2.0) - cliver (0.3.2) cocoon (1.2.12) coderay (1.1.2) concurrent-ruby (1.1.5) @@ -275,10 +277,6 @@ GEM pg_search (2.1.7) activerecord (>= 4.2) activesupport (>= 4.2) - poltergeist (1.18.1) - capybara (>= 2.1, < 4) - cliver (~> 0.3.1) - websocket-driver (>= 0.2.0) powerpack (0.1.2) premailer (1.11.1) addressable @@ -484,6 +482,7 @@ DEPENDENCIES activerecord-session_store (~> 1) acts_as_paranoid! ahoy_matey (~> 1.6) + apparition (~> 0.6) aws-sdk (~> 2.3) aws-sdk-rails (~> 1) better_errors (~> 2) @@ -524,7 +523,6 @@ DEPENDENCIES paperclip (~> 5.2) pg (~> 1.1) pg_search - poltergeist (~> 1) premailer-rails (~> 1) puma (~> 3) rack-attack (~> 5) @@ -561,7 +559,6 @@ DEPENDENCIES sass-rails (~> 5.0) sdoc select2-rails - selenium-webdriver (~> 3) sentry-raven (~> 0.15) sprockets-image_compressor (~> 0) uglifier (>= 1.3.0) diff --git a/spec/features/action_pages/tweet_action_spec.rb b/spec/features/action_pages/tweet_action_spec.rb index a61ff43b8..7c504f65a 100644 --- a/spec/features/action_pages/tweet_action_spec.rb +++ b/spec/features/action_pages/tweet_action_spec.rb @@ -26,15 +26,11 @@ it "allows vistors to tweet at representatives" do visit action_page_path(tweet_action) - expect(page).not_to have_content("THANK YOU!") fill_in "street_address", with: "1630 Ravello Drive" fill_in "zipcode", with: "94109" click_on "Look up your reps" - - expect(page).to have_content("Default message") click_on "Tweet @sisko" - expect(page).to have_content("THANK YOU!") end end diff --git a/spec/features/admin/action_creation_spec.rb b/spec/features/admin/action_creation_spec.rb index ec9fc701e..08cb7e5d8 100644 --- a/spec/features/admin/action_creation_spec.rb +++ b/spec/features/admin/action_creation_spec.rb @@ -8,16 +8,16 @@ fill_in_basic_info(title: "Very Important Action", summary: "A summary", description: "A description") - click_on "Next" + next_section select_action_type("tweet") fill_in "Message", with: "A message" - click_on "Next" + next_section + + # skip banner selection + next_section - skip_image_selection fill_in_social_media - # Skip partners - click_on "Next" tempermental { click_button "Save" @@ -30,18 +30,18 @@ fill_in_basic_info(title: "Very Important Action", summary: "A summary", description: "A description") - click_on "Next" + next_section select_action_type("petition") fill_in_editor "#action_page_petition_attributes_description", with: "A petititon letter" fill_in "Goal", with: 1000 - click_on "Next" + next_section + + # skip banner selection + next_section - skip_image_selection fill_in_social_media - # Skip partners - click_on "Next" tempermental { click_button "Save" @@ -54,18 +54,18 @@ fill_in_basic_info(title: "Very Important Action", summary: "A summary", description: "A description") - click_on "Next" + next_section select_action_type("email") fill_in "To", with: "test@gmail.com" fill_in "Subject", with: "Subject" fill_in "Message", with: "An email" - click_on "Next" + next_section + + # skip banner selection + next_section - skip_image_selection fill_in_social_media - # Skip partners - click_on "Next" tempermental { click_button "Save" @@ -78,17 +78,17 @@ fill_in_basic_info(title: "Very Important Action", summary: "A summary", description: "A description") - click_on "Next" + next_section select_action_type("congress_message") fill_in "Subject", with: "Subject" fill_in "Message", with: "A message" - click_on "Next" + next_section + + # skip banner selection + next_section - skip_image_selection fill_in_social_media - # Skip partners - click_on "Next" tempermental { click_button "Save" @@ -101,17 +101,17 @@ fill_in_basic_info(title: "Very Important Action", summary: "A summary", description: "A description") - click_on "Next" + next_section select_action_type "call" fill_in_editor "#action_page_call_campaign_attributes_message", with: "Call script" - click_on "Next" + next_section + + # skip banner selection + next_section - skip_image_selection fill_in_social_media - # Skip partners - click_on "Next" tempermental { click_button "Save" @@ -126,17 +126,15 @@ def fill_in_basic_info(title:, summary:, description:) fill_in_select2 "#action_page_category_id", with: category.title end - def skip_image_selection + def next_section click_on "Next" - sleep 0.1 - click_on "Next" - sleep 0.1 + sleep 0.05 end def fill_in_social_media fill_in "Share Message", with: "Twitter message" fill_in "Title", with: "A social media title" - click_on "Next" + next_section end def select_action_type(type) diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb deleted file mode 100644 index 106598e70..000000000 --- a/spec/features/users_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require "rails_helper" - -RSpec.describe "Tests about users", type: :feature do - before(:each) do - stub_civicrm - @user = FactoryGirl.create(:user) - end - - it "promoted users lose their old password and need a strong one" do - sign_in_user(@user) - - # Test that we can see that we're at the /account page fine - expect(page).to have_content("Personal information") - - # log user out - find("input[value='Logout']", match: :first).click - - #promote user to activist - @user.admin = true - @user.save - - # try to login and see prompt to add password - sign_in_user(@user) - expect(page).not_to have_content("Personal information") - - # try navigating anywhere else to make sure they can't get around it - visit "/admin/action_pages" - expect(page).to have_content("Your account has been flagged for importance") - - # Submit a strong password and move on like an adult - fill_in "Current Password", with: @user.password - fill_in "New Password", with: "P1" + @user.password - fill_in "Confirm New Password", with: "P1" + @user.password - click_button "Submit" - - # check that the password update nag screen is eliminated - visit "/account" - expect(page).to have_content("Personal information") - end -end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 9c8ec65d4..90ba63766 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -5,8 +5,7 @@ abort("The Rails environment is running in production mode!") if Rails.env.production? require "spec_helper" require "rspec/rails" -require "selenium/webdriver" -require "webdrivers" +require "capybara/apparition" # Add additional requires below this line. Rails is not loaded until this point! @@ -30,24 +29,25 @@ ActiveRecord::Migration.maintain_test_schema! -capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( - :loggingPrefs => { - browser: "ALL", - client: "ALL", - driver: "ALL", - server: "ALL" - }, - "chromeOptions" => { +apparition_opts = { + window_size: [1400, 900], + screen_size: [1920, 1090], + browser_options: { "w3c" => false, - "args" => ["headless", "disable-gpu", "--window-size=1400,900"].tap do |a| - a.push("no-sandbox") if ENV["TRAVIS"] - end + "args" => ["headless", "disable-gpu", "--window-size=1400,900"] } -) +} + +if ENV["TRAVIS"] + apparition_opts[:browser_options] = { + "remote-debugging-address" => "127.0.0.1", + "remote-debugging-port" => 9222 + } + apparition_opts[:remote] = true +end Capybara.register_driver :chrome_headless do |app| - Capybara::Selenium::Driver.new(app, browser: :chrome, - desired_capabilities: capabilities) + Capybara::Apparition::Driver.new(app, apparition_opts) end Capybara.server = :puma diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb index 2ae488dcf..4e7c8d7c2 100644 --- a/spec/support/feature_helpers.rb +++ b/spec/support/feature_helpers.rb @@ -7,13 +7,18 @@ def sign_in_user(user) click_button "Sign in" end + def sign_out_user(user) + find("#nav-modal-toggle").click + find("input[value='Logout']", visible: :all, match: :first).click + end + def disable_call_tool allow(CallTool).to receive(:enabled?).and_return(false) end def fill_in_editor(locator, with:) within_frame find(locator, visible: :all).sibling("div").find("iframe") do - within_frame find("iframe") do + within_frame find("#epiceditor-editor-frame") do find("body").set(with) end end