From 1b1c384e24f17c432b4049cfa9b08303bb1e2e92 Mon Sep 17 00:00:00 2001 From: delasthanos Date: Wed, 28 Aug 2024 19:55:33 +0300 Subject: [PATCH] Environment variable for different hosts and headless options --- .github/workflows/cucumber-tests.yml | 3 +-- env.rb | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cucumber-tests.yml b/.github/workflows/cucumber-tests.yml index 0b8b2e82..9dc3b693 100644 --- a/.github/workflows/cucumber-tests.yml +++ b/.github/workflows/cucumber-tests.yml @@ -25,5 +25,4 @@ jobs: bundle config path vendor/bundle bundle install --jobs 4 --retry 3 - name: Run tests - run: bundle exec cucumber - + run: bundle exec cucumber HEADLESS=true diff --git a/env.rb b/env.rb index 337df2f0..75f81d40 100644 --- a/env.rb +++ b/env.rb @@ -4,13 +4,27 @@ require 'capybara/cucumber' require 'selenium-webdriver' -BASE_URL = 'https://e2e.archivesspace.org' -PUBLIC_URL = BASE_URL.freeze -STAFF_URL = "#{BASE_URL}/staff".freeze +case ENV['HOST'] +when 'localhost', 'http://localhost:8080' + BASE_URL = 'http://localhost:8080' + PUBLIC_URL = 'http://localhost:8081' + STAFF_URL = "#{BASE_URL}".freeze +else + BASE_URL = 'https://e2e.archivesspace.org' + PUBLIC_URL = BASE_URL.freeze + STAFF_URL = "#{BASE_URL}/staff".freeze +end + +case ENV['HEADLESS'] +when 'true' + HEADLESS = '--headless' +else + HEADLESS = '' +end Capybara.register_driver :firefox do |app| options = Selenium::WebDriver::Firefox::Options.new - options.add_argument("--headless") + options.add_argument(HEADLESS) Capybara::Selenium::Driver.new(app, browser: :firefox, options:) end