Skip to content

Commit

Permalink
Merge pull request #560 from rootstrap/enhancement/add_support_js_sel…
Browse files Browse the repository at this point in the history
…enium_chrome

Enhancement/add support js selenium chrome
  • Loading branch information
frankvielma authored Jan 5, 2024
2 parents 845aa22 + db185f4 commit 01e1311
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
KNAPSACK_CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
KNAPSACK_CI_NODE_INDEX: ${{ matrix.ci_node_index }}
PARALLEL_TESTS_CONCURRENCY: ${{ env.cpu_cores }}
run: bundle exec parallel_rspec -n $PARALLEL_TESTS_CONCURRENCY -e './bin/parallel_tests'
run: HEADLESS=true bundle exec parallel_rspec -n $PARALLEL_TESTS_CONCURRENCY -e './bin/parallel_tests'
- name: Check for missing annotations
run: bundle exec annotate
- name: Check for untracked changes in app and spec directories
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ group :test do
gem 'rspec-openapi', '~> 0.10'
gem 'rspec-rails', '~> 6.1'
gem 'rspec-retry', github: 'rootstrap/rspec-retry', branch: 'add-intermittent-callback'
gem 'selenium-webdriver', '~> 4.16.0'
gem 'shoulda-matchers', '~> 6.0'
gem 'simplecov', '~> 0.22.0', require: false
gem 'webmock', '~> 3.19'
Expand Down
7 changes: 7 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ GEM
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
sanitize (6.1.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand All @@ -509,6 +510,10 @@ GEM
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
selenium-webdriver (4.16.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
sendgrid (1.2.4)
json
sexp_processor (4.17.0)
Expand Down Expand Up @@ -547,6 +552,7 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
websocket (1.2.10)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand Down Expand Up @@ -617,6 +623,7 @@ DEPENDENCIES
rubocop-rake (~> 0.6.0)
rubocop-rspec (~> 2.25)
sass-rails (~> 6.0.0)
selenium-webdriver (~> 4.16.0)
sendgrid (~> 1.2.4)
shoulda-matchers (~> 6.0)
simplecov (~> 0.22.0)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ This template comes with:
1. Install PostgreSQL in case you don't have it
1. Install node and yarn.
1. Run `bootstrap.sh` with the name of your project like `./bootstrap.sh --name=my_awesome_project`
1. `rspec` and make sure all tests pass
1. `rspec` and make sure all tests pass (non-headless mode) or
1. `HEADLESS=true rspec` (headless mode)
1. Run `rails s`.
1. Run `yarn install` and `yarn build --watch`. This bundles the JS assets in the administration site using [esbuild](https://github.com/evanw/esbuild).
1. You can now try your REST services!
Expand Down
Empty file added public/favicon.ico
Empty file.
2 changes: 1 addition & 1 deletion spec/features/admin/sign_in_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

RSpec.describe 'Admin SignIn' do
feature 'Signing in' do
feature 'Signing in', :js do
let(:admin_user) { create(:admin_user) }

scenario 'Admin signs in successfully' do
Expand Down
14 changes: 14 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@

Dir[Rails.root.join('spec/support/**/*.rb')].each { |file| require file }

Capybara.register_driver :chrome do |app|
args = %w[no-sandbox disable-gpu disable-dev-shm-usage]
args << (ENV['HEADLESS'] == 'true' ? 'headless' : 'non-headless')
options = Selenium::WebDriver::Chrome::Options.new(args:)
Capybara::Selenium::Driver.new(app, browser: :chrome, options:)
end

Capybara.configure do |config|
config.javascript_driver = :chrome
config.always_include_port = true
config.default_max_wait_time = 10
config.default_normalize_ws = true
end

RSpec.configure do |config|
config.include Helpers
config.expect_with :rspec do |expectations|
Expand Down

0 comments on commit 01e1311

Please sign in to comment.