I am currently working on an app that uses ruby on rails on the backend and react.js on the front end.
Since Heroku 18 is ending, I decided to start the upgrade to Heroku 20 which will be available till 2025. Since doing so, I have been banging my head against the wall for 2 days. I have updated my dependancies as I believe fit based on documentation, but now 3 of my tests keep failing (using selenium-webdriver, webdriver, and capybarra). The error thrown shows this:
Failures:
1) Posts create post
Failure/Error: fill_in :user_email, with: user.email
Capybara::ElementNotFound:
Unable to find visible field :user_email that is not disabled
# ./spec/support/auth_helper.rb:5:in `login_as'
# ./spec/features/beneficiary/posts/post_spec.rb:7:in `block (2 levels) in <main>'
# ./spec/rails_helper.rb:46:in `block (3 levels) in <top (required)>'
# ./spec/rails_helper.rb:45:in `block (2 levels) in <top (required)>'
2) donor dashboard should have nav elements
Failure/Error: fill_in :user_email, with: user.email
Capybara::ElementNotFound:
Unable to find visible field :user_email that is not disabled
# ./spec/support/auth_helper.rb:5:in `login_as'
# ./spec/features/donor/dashboard_spec.rb:7:in `block (2 levels) in <main>'
# ./spec/rails_helper.rb:46:in `block (3 levels) in <top (required)>'
# ./spec/rails_helper.rb:45:in `block (2 levels) in <top (required)>'
3) Posts create post
Failure/Error: fill_in :user_email, with: user.email
Capybara::ElementNotFound:
Unable to find visible field :user_email that is not disabled
# ./spec/support/auth_helper.rb:5:in `login_as'
# ./spec/features/donor/posts/post_spec.rb:7:in `block (2 levels) in <main>'
# ./spec/rails_helper.rb:46:in `block (3 levels) in <top (required)>'
# ./spec/rails_helper.rb:45:in `block (2 levels) in <top (required)>'
In the file auth_helper, the format for the fill_in seems to be the issue, but looking at the documentation and confirming the id for user_email to be correct, I don't really understand what is happening at all. I feel like this might be a red herring as it really doesn't seem to be an issue on other tests that use the same method login_as. I tried upping the capybarra timeout time limit as well, and it still seems to fail to the page is certainly loading.
These tests are also passing locally, and only fail when i run them through circleci, which has me baffled and without much understanding of what to try next.
def login_as(user, password: "password")
visit root_path
find('a', text: 'Login').click
fill_in :user_email, with: user.email
fill_in :user_password, with: password
find("input[value='Log in']").click
end
The referenced lines in rails_helper are databaseCleaner and example run lines below:
config.around(:each) do |example|
DatabaseCleaner.cleaning do
example.run
end
end
My config.yml is:
# CircleCI 2.0 configuration file
version: 2.1
orbs:
browser-tools: circleci/[email protected]
jobs:
build:
docker:
# specify the version you desire here
- image: cimg/ruby:3.0.5-browsers # circleci/ruby:2.7.0-node-browsers
environment:
PGHOST: 127.0.0.1
PGUSER: $HEROKU_APP_NAME
RAILS_ENV: test
BUNDLER_VERSION: 2.0.2
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
- image: circleci/postgres:9.5-alpine
environment:
POSTGRES_USER: $HEROKU_APP_NAME
POSTGRES_DB: $HEROKU_APP_NAME_test
POSTGRES_PASSWORD: $HEROKU_APP_NAME
- image: redis:4.0.10
working_directory: ~/repo
steps:
- checkout
- browser-tools/install-browser-tools
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "Gemfile.lock" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: Swap node versions
command: |
set +e
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
nvm install v14
nvm alias default 14.21.1
echo 'export NVM_DIR="$HOME/.nvm"' >> $BASH_ENV
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV
- run:
name: Configure Bundler
command: |
echo 'export BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")' >> $BASH_ENV
source $BASH_ENV
gem install bundler
- run:
name: install dependencies
command: |
bundle config set --local path 'vendor/bundle'
bundle install --jobs=4 --retry=3
# --path vendor/bundle
- save_cache:
paths:
- ./vendor/bundle
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
# Database setup
- run: bundle exec rails db:create
- run: bundle exec rails db:schema:load
# frontend
- restore_cache:
keys:
- sell-more-yarn-cache-{{ .Branch }}-{{ checksum "yarn.lock" }}
- sell-more-yarn-cache-{{ .Branch }}-
- sell-more-yarn-cache-
- run:
name: Yarn Install
command: |
yarn --ignore-engines --cache-folder ~/.cache/yarn
- save_cache:
key: sell-more-yarn-cache-{{ .Branch }}-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
- run:
name: Webpacker Pre-Compile
command: bundle exec rails webpacker:compile
# run tests!
- run:
name: run tests
command: |
bundle exec rspec --profile 10 \
--out test_results/rspec.xml \
--format progress \
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
# collect reports
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
destination: test-results
workflows:
version: 2
build-and-deploy:
jobs:
- build
Versions:
ruby '3.0.5'
gem 'rails', '~> 6.1'
group :test do
gem 'capybara', '~> 3.38'
gem 'database_cleaner'
gem 'factory_bot_rails', '~> 6.2.0'
gem 'rack_session_access'
gem 'rails-controller-testing'
gem 'rspec-rails'
gem 'selenium-webdriver', '~> 4.0'
gem 'shoulda-callback-matchers', '~> 1.1.1'
gem 'shoulda-matchers', '~> 4.4'
gem 'spring-commands-rspec'
gem 'stripe-ruby-mock', github: 'rebelidealist/stripe-ruby-mock'
gem 'timecop'
gem 'webdrivers', '~> 5.2'
gem 'webmock'
end
Anyone have any ideas to help me get past this as I am falling behind on time and could really use a point in the right direction!
Thanks in advance!
I am expecting these tests to pass as they can locally and should be able to on circleci as they were right before the upgrade.