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

#3391 Switch to selenium with chrome headless #3394

Merged
merged 4 commits into from
Aug 24, 2018
Merged
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
20 changes: 8 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
language: ruby
dist: trusty
sudo: false
addons:
apt:
packages:
- chromium-chromedriver
cache: bundler
before_install: gem install bundler
bundler_args: --without development
before_script:
- export RETRY_COUNT=3
- export PATH=$PATH:/usr/lib/chromium-browser/
- bin/rake refinery:testing:dummy_app
script:
- bin/rspec $EXTENSION/spec
Expand All @@ -18,21 +25,10 @@ env:
- DB=mysql EXTENSION=resources
notifications:
email: true
irc:
use_notice: true
skip_join: true
channels:
- "irc.freenode.org#refinerycms"
campfire:
on_success: always
on_failure: always
rooms:
- secure: "X5X39BTgXacSdc32F8mIjJKPqm5dZzmgZfJ14qYpJeMETTdA5JfByt2uCfU8\njJkkxT+XGWta0bSSlRIHQJO6pK26U94A95VYDX0jNuneKEnsoAsqJ6U0VY6v\nH5oxXMAZ2perP/FH9ZsPNR+ulyFfbMQCeGPJw5AXKZQqzf6qPOI="
webhooks:
- https://webhooks.gitter.im/e/b5d48907cdc89864b874
rvm:
- 2.5.0
- 2.4.3
- 2.3.6
- 2.2.9
sudo: false
- 2.2.9
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ end

gem 'spring'
gem 'spring-commands-rspec'
gem 'poltergeist', '>= 1.8.1'
gem 'selenium-webdriver', require: false

# Add support for refinerycms-acts-as-indexed
gem 'refinerycms-acts-as-indexed', ['~> 3.0', '>= 3.0.0']
Expand Down
2 changes: 1 addition & 1 deletion core/app/assets/javascripts/refinery/admin.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ var link_dialog = {
}
}

$('.form-actions-dialog #cancel_button').trigger('click');
$('.form-actions-dialog #cancel_button').click;
});
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$(".form-actions.form-actions-dialog .form-actions-left a.close_dialog").click (e) ->
titlebar_close_button = $('.ui-dialog-titlebar-close')
titlebar_close_button = parent.$('.ui-dialog-titlebar-close') if parent
titlebar_close_button.trigger('click')
titlebar_close_button.click
e.preventDefault()

$("a.suppress").on "click", (e) ->
Expand Down
2 changes: 1 addition & 1 deletion images/spec/support/shared_contexts/admin_images_tab.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
shared_context 'admin images tab' do

let(:open_upload_dialog) { find('a', text: ::I18n.t('create_new_image', scope: 'refinery.admin.images.actions')).trigger(:click) }
let(:open_upload_dialog) { find('a', text: ::I18n.t('create_new_image', scope: 'refinery.admin.images.actions')).click }
let(:select_upload) {}
let(:initialize_context) {}
let(:index_in_frame) {false}
Expand Down
39 changes: 22 additions & 17 deletions pages/spec/features/refinery/admin/pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,22 @@ module Admin

it "refreshes the cache if sub_children change" do
expect(page).to have_content(location.title)
location.update(title: 'Las Vegas')
visit refinery.admin_pages_path
expect(page).to have_content(location.title)

find("#page_#{location.id} .edit_icon").click
fill_in "Title", with: 'Las Vegas'
click_button "Save"

expect(page).to have_content('Las Vegas')
end
end
end
end

describe "new/create" do
it "Creates a page", js:true do
it "Creates a page", js: true do
visit refinery.admin_pages_path

find('a', text: 'Add new page').trigger(:click)
find('a', text: 'Add new page').click

fill_in "Title", :with => "My first page"
expect { click_button "Save" }.to change(Refinery::Page, :count).from(0).to(1)
Expand All @@ -173,7 +176,7 @@ module Admin

fill_in "Title", :with => "My first page"

find('#toggle_advanced_options').trigger(:click)
find('#toggle_advanced_options').click

fill_in "Menu title", :with => "The first page"

Expand Down Expand Up @@ -215,7 +218,7 @@ module Admin

context 'when saving and returning to index' do
it "updates page", js: true do
find("a[href$='#{updateable_page.slug}/edit']").trigger(:click)
find("a[href$='#{updateable_page.slug}/edit']").click

fill_in "Title", :with => "Updated"
find("#submit_button").click
Expand Down Expand Up @@ -366,7 +369,7 @@ module Admin

find('a[tooltip^=Edit]').click
fill_in 'Title', :with => 'Searchable'
find('#toggle_advanced_options').trigger(:click)
find('#toggle_advanced_options').click
select 'Searchable', :from => 'View template'
Timeout::timeout(5) do
click_button 'Preview'
Expand All @@ -380,7 +383,7 @@ module Admin
it "will not save when just previewing", js:true do
visit refinery.admin_pages_path

find('a', text: 'Add new page').trigger(:click)
find('a', text: 'Add new page').click
fill_in "Title", :with => "My first page"
window = window_opened_by do
click_button "Preview"
Expand Down Expand Up @@ -421,7 +424,9 @@ module Admin
it "will show delete button" do
visit refinery.admin_pages_path

find('a[tooltip="Remove this page forever"]').trigger(:click)
find('a[tooltip="Remove this page forever"]').click

page.accept_alert

expect(page).to have_content("'Delete me' was successfully removed.")

Expand Down Expand Up @@ -474,7 +479,7 @@ module Admin
describe "add a page with title for default locale", js:true do
before do
visit refinery.admin_pages_path
find('a', text: "Add new page").trigger(:click)
find('a', text: "Add new page").click
fill_in "Title", :with => "News"
click_button "Save"
end
Expand Down Expand Up @@ -622,7 +627,7 @@ module Admin

it "lets you add a Russian title without an English title" do
ru_page.destroy!
find('a', text: 'Add new page').trigger(:click)
find('a', text: 'Add new page').click
switch_page_form_locale "RU"

fill_in "Title", :with => ru_page_title
Expand Down Expand Up @@ -684,7 +689,7 @@ module Admin
expect(sub_page.parent).to eq(parent_page)
visit refinery.admin_pages_path
within "#page_#{sub_page.id}" do
find("a.edit_icon").trigger(:click)
find("a.edit_icon").click
end
fill_in "Title", :with => ru_page_title
click_button "Save"
Expand All @@ -701,7 +706,7 @@ module Admin

it "adds new page part", js: true do
visit refinery.new_admin_page_path
find("#add_page_part").trigger(:click)
find("#add_page_part").click

within "#new_page_part_dialog" do
fill_in "new_page_part_title", :with => "testy"
Expand Down Expand Up @@ -735,7 +740,7 @@ module Admin
end

2.times do
find("#delete_page_part").trigger(:click)
find("#delete_page_part").click
# Poltergeist automatically accepts dialogues.
if Capybara.javascript_driver != :poltergeist
page.driver.browser.switch_to.alert.accept
Expand Down Expand Up @@ -776,7 +781,7 @@ module Admin
specify 'sub page should inherit them', js: true do
visit refinery.edit_admin_page_path(@page.id)

find('#toggle_advanced_options').trigger(:click)
find('#toggle_advanced_options').click

within '#page_layout_template' do
expect(page.find('option[value=refinery]')).to be_selected
Expand Down Expand Up @@ -806,7 +811,7 @@ module Admin

specify "should retain the html", js:true do
visit refinery.admin_pages_path
find('a[tooltip="Edit this page"]').trigger(:click)
find('a[tooltip="Edit this page"]').click
Capybara.ignore_hidden_elements = false
expect(page).to have_content("header class='regression'")
Capybara.ignore_hidden_elements = true
Expand Down
2 changes: 1 addition & 1 deletion resources/spec/features/refinery/admin/resources_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module Admin
context "new/create" do
it "uploads file", :js => true do
visit refinery.admin_resources_path
find('a', text: 'Upload new file').trigger(:click)
find('a', text: 'Upload new file').click

expect(page).to have_selector 'iframe#dialog_iframe'

Expand Down
15 changes: 10 additions & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,15 @@
require support_file
end

Capybara.register_driver :poltergeist_debug do |app|
Capybara::Poltergeist::Driver.new(app, debug: false, js_errors: true, inspector: :open)
require "selenium/webdriver"

Capybara.register_driver :selenium_chrome_headless do |app|
browser_options = ::Selenium::WebDriver::Chrome::Options.new
browser_options.args << '--headless'
browser_options.args << '--no-sandbox'
browser_options.args << '--disable-gpu'
browser_options.args << '--window-size=1440,1080'
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
end

require 'capybara/poltergeist'
Capybara.javascript_driver = :poltergeist
Capybara.always_include_port = true
Capybara.javascript_driver = (ENV['CAPYBARA_DRIVER'] || :selenium_chrome_headless).to_sym
2 changes: 1 addition & 1 deletion testing/refinerycms-testing.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |s|
s.add_dependency 'database_cleaner', '~> 1.6'
s.add_dependency 'factory_bot_rails', '~> 4.8'
s.add_dependency 'rspec-rails', '~> 3.5'
s.add_dependency 'capybara', '~> 2.7'
s.add_dependency 'capybara', '~> 2.18'
s.add_dependency 'rails-controller-testing', '~> 0.1.1'

s.required_ruby_version = Refinery::Version.required_ruby_version
Expand Down