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

Update Capybara #68

Merged
merged 4 commits into from
Jan 2, 2024
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
2 changes: 2 additions & 0 deletions config/initializers/omniauth.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
OmniAuth.config.logger = Rails.logger

# Implementation inspired by register-trainee-teachers repo
case ENV.fetch("SIGN_IN_METHOD")
when "persona"
Expand Down
24 changes: 10 additions & 14 deletions spec/support/capybara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,22 @@

Capybara.always_include_port = true

Capybara.register_driver :chrome_headless do |app|
options = Selenium::WebDriver::Chrome::Options.new

options.add_argument("--headless") unless ENV["HEADLESS"] == "false"
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-gpu")
options.add_argument("--window-size=1400,1400")
Capybara.register_driver :selenium_chrome_headless do |app|
options = Selenium::WebDriver::Chrome::Options.new.tap do |opts|
opts.add_argument("--headless=new")
opts.add_argument("--no-sandbox")
opts.add_argument("--disable-dev-shm-usage")
opts.add_argument("--disable-gpu")
opts.add_argument("--window-size=1400,1400")
end

Capybara::Selenium::Driver.new(app, browser: :chrome, options:)
end

Capybara.javascript_driver = :chrome_headless
Capybara.javascript_driver = :selenium_chrome_headless

RSpec.configure do |config|
config.before(:each, type: :system) do
if self.class.metadata[:js] == true
driven_by(:chrome_headless)
else
driven_by(:rack_test)
end
driven_by Capybara.current_driver
end
end
2 changes: 1 addition & 1 deletion spec/system/claims/view_organisations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

RSpec.describe "View organisations", type: :system do
around do |example|
Capybara.app_host = "https://#{ENV["CLAIMS_HOST"]}"
Capybara.app_host = "http://#{ENV["CLAIMS_HOST"]}"
example.run
Capybara.app_host = nil
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require "rails_helper"

# Changing type from feature => system stops the javascript working.
# Will attempt to resolve in another PR.
RSpec.describe "Placements / Providers / Support User adds a Provider",
type: :feature do
RSpec.describe "Placements / Providers / Support User adds a Provider", type: :system, js: true do
before do
next_year = Time.current.next_year.year

Expand Down
2 changes: 1 addition & 1 deletion spec/system/placements/view_organisations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

RSpec.describe "View organisations", type: :system do
around do |example|
Capybara.app_host = "https://#{ENV["PLACEMENTS_HOST"]}"
Capybara.app_host = "http://#{ENV["PLACEMENTS_HOST"]}"
example.run
Capybara.app_host = nil
end
Expand Down