Skip to content
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

Upgrades pt 1: Replace poltergeist with apparition; fix failing tests #859

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ group :development do
end

group :test do
gem "apparition", "~> 0.6"
gem "webmock", "~> 2"
end

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

Expand Down
11 changes: 4 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -524,7 +523,6 @@ DEPENDENCIES
paperclip (~> 5.2)
pg (~> 1.1)
pg_search
poltergeist (~> 1)
premailer-rails (~> 1)
puma (~> 3)
rack-attack (~> 5)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions spec/features/action_pages/tweet_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
58 changes: 28 additions & 30 deletions spec/features/admin/action_creation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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: "[email protected]"
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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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)
Expand Down
40 changes: 0 additions & 40 deletions spec/features/users_spec.rb

This file was deleted.

32 changes: 16 additions & 16 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion spec/support/feature_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down