From 0e4f9d18d45e7c11e7645e0a17105e9ae688b4bf Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Tue, 2 Mar 2021 14:55:42 +0100 Subject: [PATCH] Fix browser's download path configuration The CI build can't find the downloaded file and fails like: ``` 2) enterprise fee summaries csv downloads smoke test for generation of report based on permissions when logged in as enterprise user generates file with data for the enterprise Failure/Error: sleep 0.1 until downloaded? Timeout::Error: execution expired # ./spec/support/downloads_helper.rb:34:in `sleep' # ./spec/support/downloads_helper.rb:34:in `block in wait_for_download' # ./spec/support/downloads_helper.rb:33:in `wait_for_download' # ./spec/support/downloads_helper.rb:11:in `downloaded_filename' # ./engines/order_management/spec/features/order_management/reports/enterprise_fee_summaries_spec.rb:119:in `block (5 levels) in ' # ./engines/order_management/spec/features/order_management/reports/enterprise_fee_summaries_spec.rb:80:in `block (4 levels) in ' # ./spec/support/downloads_helper.rb:22:in `with_empty_downloads_folder' # ./engines/order_management/spec/features/order_management/reports/enterprise_fee_summaries_spec.rb:80:in `block (3 levels) in ' ``` --- .github/workflows/build.yml | 45 +++++++++++++++++++++++++++++++++++-- spec/spec_helper.rb | 4 +++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 91113b686f..bbfa5b97a8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ env: DISABLE_KNAPSACK: true jobs: - test-models: + test-non-spree-models: runs-on: ubuntu-18.04 services: postgres: @@ -47,7 +47,48 @@ jobs: bundle exec rake db:schema:load RAILS_ENV=test - name: Run tests - run: bundle exec rspec spec/models + run: bundle exec rspec spec/models --exclude-pattern "spec/models/spree/*" + + test-spree-models: + runs-on: ubuntu-18.04 + services: + postgres: + image: postgres:10 + ports: ["5432:5432"] + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + POSTGRES_DB: open_food_network_test + POSTGRES_USER: ofn + POSTGRES_PASSWORD: f00d + steps: + - uses: actions/checkout@v2 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + + - uses: actions/setup-node@v2 + with: + node-version: '14.15.5' + + - name: Install JS dependencies + run: yarn install --frozen-lockfile + + - name: Set up application.yml + run: cp config/application.yml.example config/application.yml + + - name: Set up database + run: | + bundle exec rake db:create RAILS_ENV=test + bundle exec rake db:schema:load RAILS_ENV=test + + - name: Run tests + run: bundle exec rspec spec/models/spree test-admin-features: runs-on: ubuntu-18.04 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 56e6253921..406ea10cd4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -59,9 +59,11 @@ Capybara.register_driver :chrome do |app| options = Selenium::WebDriver::Chrome::Options.new( args: %w[headless disable-gpu no-sandbox window-size=1280,768] ) + options.add_preference(:download, default_directory: Rails.root.join("tmp", "downloads").to_s) + Capybara::Selenium::Driver .new(app, browser: :chrome, options: options) - .tap { |driver| driver.browser.download_path = DownloadsHelper.path.to_s } + .tap { |driver| driver.browser.download_path = Rails.root.join("tmp", "downloads").to_s } end Capybara.default_max_wait_time = 30