Skip to content

Commit

Permalink
Ditch poltergeist/phantomjs
Browse files Browse the repository at this point in the history
  • Loading branch information
mlt committed Nov 28, 2019
1 parent 91e77d5 commit 4f44f5c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 33 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ end

group :test do
gem 'simplecov', :require => false
gem 'selenium-webdriver'
gem 'chromedriver-helper' if ENV['CI']
end


Expand All @@ -30,7 +32,6 @@ group :development, :test do
gem 'minitest'
gem 'launchy'
gem 'database_cleaner', '< 1.1.0'
gem 'poltergeist'
gem 'sass-rails', '~> 4.0.0', '>= 4.0.2'
gem 'bootstrap-sass', '~> 3.0.3.0'
end
27 changes: 16 additions & 11 deletions spec/features/tabulatrs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@
Product.create!
end
visit one_item_per_page_with_pagination_products_path
wait_for_ajax
# https://robots.thoughtbot.com/write-reliable-asynchronous-integration-tests-with-capybara#interact-with-all-matching-elements
find('.pagination li a[data-page]', match: :first)
pages = page.all('.pagination li a[data-page]').map{|a| a['data-page'].to_i}
expect(pages).to match_array([1,2,3,10,20])
end
Expand All @@ -133,13 +134,15 @@
visit simple_index_products_path
click_link 'Filter'
fill_in("product_filter[products:title][like]", with: "ore")
find('a.tabulatr-submit-table').click
expect(page).to have_selector('td[data-tabulatr-column-name="products:title"]', text: 'lorem')
expect(page).to have_selector('td[data-tabulatr-column-name="products:title"]', text: 'labore')
expect(page).to have_selector('td[data-tabulatr-column-name="products:title"]', text: 'dolore')

within(".tabulatr_filter_form") do
fill_in("product_filter[products:title][like]", :with => "loreem")
end
find('a.tabulatr-submit-table').click
expect(page).not_to have_selector('td[data-tabulatr-column-name="products:title"]', text: 'lorem')
expect(page).not_to have_selector('td[data-tabulatr-column-name="products:title"]', text: 'labore')
expect(page).not_to have_selector('td[data-tabulatr-column-name="products:title"]', text: 'dolore')
Expand All @@ -151,6 +154,7 @@
visit simple_index_products_path
click_link 'Filter'
find('form.tabulatr_filter_form').fill_in("product_filter[vendor:name]", with: "producer")
find('a.tabulatr-submit-table').click
expect(page).not_to have_selector('td[data-tabulatr-column-name="vendor:name"]', text: @vendor1.name)
expect(page).to have_selector('td[data-tabulatr-column-name="vendor:name"]', text: @vendor2.name)
end
Expand All @@ -168,18 +172,16 @@
click_link 'Filter'
within('.tabulatr_filter_form') do
fill_in("product_filter[products:price][from]", :with => 4)
wait_for_ajax
fill_in("product_filter[products:price][to]", :with => 10)
wait_for_ajax
find('a.tabulatr-submit-table').click
end
expect(page).to have_no_css('.tabulatr-spinner-box')
expect(page).to have_css(".tabulatr_table tbody tr", text: 'foo')
expect(page).to have_no_css(".tabulatr_table tbody tr", text: 'bar')
within('.tabulatr_filter_form') do
fill_in("product_filter[products:price][from]", :with => 12)
wait_for_ajax
fill_in("product_filter[products:price][to]", :with => 19)
wait_for_ajax
find('a.tabulatr-submit-table').click
end
expect(page).to have_no_css('.tabulatr-spinner-box')
expect(page).to have_css(".tabulatr_table tbody tr", text: 'bar')
Expand Down Expand Up @@ -215,6 +217,7 @@
click_link 'Filter'
within(".tabulatr_filter_form") do
fill_in("product_filter[products:title][like]", with: "foo")
find('a.tabulatr-submit-table').click
end
expect(page).not_to have_selector('td[data-tabulatr-column-name="products:title"]', text: 'bar')
expect(page).to have_selector('td[data-tabulatr-column-name="products:title"]', text: 'foo')
Expand All @@ -239,6 +242,7 @@
end
expect(page).to have_css(".tabulatr_table tbody tr", count: 1)
expect(page).to have_css('.tabulatr_table tbody td', text: @vendor1.name)
find('a.tabulatr-reset-table').click
end

scenario 'custom split filters', js: true do
Expand All @@ -256,8 +260,8 @@
within(".tabulatr_filter_form") do
select("Cheap", from: "vendor_filter[product_price_range]")
end
# wait_for_ajax
expect(page).to have_css(".tabulatr_table tbody tr", count: 0, wait: 10)
expect(page).to have_no_css(".tabulatr_table tbody tr")
find('a.tabulatr-reset-table').click
end

scenario 'pre-filter', js: true do
Expand Down Expand Up @@ -338,8 +342,8 @@
product3 = Product.create!(:title => names[2], :active => true, :price => 10.0)
visit with_batch_actions_products_path
expect(page).to have_css(".tabulatr_table tbody tr", count: 3)
find(".tabulatr-checkbox[value='#{product1.id}']").trigger('click')
find(".tabulatr-checkbox[value='#{product3.id}']").trigger('click')
find(".tabulatr-checkbox[value='#{product1.id}']").click
find(".tabulatr-checkbox[value='#{product3.id}']").click
find('.tabulatr-batch-actions-menu-wrapper a').click
within('.dropdown.open') do
click_link 'Delete'
Expand All @@ -356,6 +360,7 @@
within('.dropdown.open') do
click_link 'Delete'
end
page.driver.browser.switch_to.alert.accept
expect(page).to have_css('.tabulatr_table tbody tr', count: 0)
end
end
Expand All @@ -368,8 +373,8 @@
header = find(".tabulatr_table thead th[data-tabulatr-column-name='products:title']")
cell_without_style = find(".tabulatr_table tbody td[data-tabulatr-column-name='products:price']")
header_without_style = find(".tabulatr_table thead th[data-tabulatr-column-name='products:price']")
expect(cell[:style]).to eql 'background-color: green;text-align: left;width: 60px;white-space: nowrap;'
expect(header[:style]).to eql 'color: orange;text-align: left;width: 60px;white-space: nowrap;'
expect(cell).to match_css '[style="background-color: green;text-align: left;width: 60px;white-space: nowrap;"]'
expect(header).to match_css '[style="color: orange;text-align: left;width: 60px;white-space: nowrap;"]'
expect(cell_without_style[:style]).to be_empty
expect(header_without_style[:style]).to be_empty
end
Expand Down
6 changes: 1 addition & 5 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@

require 'rspec/rails'
require 'capybara/rspec'
require 'capybara/poltergeist'
require 'spec_helper'

Capybara.javascript_driver = :poltergeist
Capybara.javascript_driver = :selenium_chrome_headless
Capybara.server = :webrick

Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, {js_errors: true})
end


# Requires supporting ruby files with custom matchers and macros, etc,
Expand Down
16 changes: 0 additions & 16 deletions spec/support/wait_for_ajax.rb

This file was deleted.

0 comments on commit 4f44f5c

Please sign in to comment.