From 352f1ba900e6a563b829d4464372cbafe0c1d8a9 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Sun, 6 Jul 2025 18:45:48 +0100 Subject: [PATCH 1/2] Adds a DOCKER env variable, to disable sandbox mode for system tests Fixes rubocop offense - || instead of or Comments out the DOCKER variable Corrects the syntax for Markdown inline code --- .env.test | 3 +++ docker/README.md | 2 ++ spec/system/support/cuprite_setup.rb | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.env.test b/.env.test index 0833c82074..5abea97a14 100644 --- a/.env.test +++ b/.env.test @@ -35,3 +35,6 @@ OPENID_REFRESH_TOKEN="dummy-refresh-token" ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY="test_primary_key" ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY="test_deterministic_key" ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT="test_derivation_salt" + +# Let the tests know if they are run within a Docker container: +# DOCKER="true" diff --git a/docker/README.md b/docker/README.md index 9b6ff65e40..be161f6518 100644 --- a/docker/README.md +++ b/docker/README.md @@ -5,6 +5,8 @@ Docker is intended to provide a common virtual environment available to all deve ## Limitations 1. The docker environment can't directly control your host system browser, which means that browser specs (under `/spec/system/`) and email previews will not work. You may be able to find a solution with [this article](https://evilmartians.com/chronicles/system-of-a-test-setting-up-end-to-end-rails-testing). If so, please contribute! +2. You can try circumventing this by setting the option `DOCKER=true` on the `.env.test file`, which will disable the `sandbox` mode for Chrome, used for system tests. + ## Installing Docker ### Requirements * You should have at least 2 GB free on your local machine to download Docker images and create Docker containers for this app. diff --git a/spec/system/support/cuprite_setup.rb b/spec/system/support/cuprite_setup.rb index 8d20148feb..431d4d546d 100644 --- a/spec/system/support/cuprite_setup.rb +++ b/spec/system/support/cuprite_setup.rb @@ -5,7 +5,7 @@ require "capybara/cuprite" headless = ActiveModel::Type::Boolean.new.cast(ENV.fetch("HEADLESS", true)) browser_options = {} -browser_options["no-sandbox"] = nil if ENV['CI'] +browser_options["no-sandbox"] = nil if ENV['CI'] || ENV['DOCKER'] Capybara.register_driver(:cuprite_ofn) do |app| Capybara::Cuprite::Driver.new( From 38388be4da427a56c0564b2f39f55df51a0fbd76 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Thu, 10 Jul 2025 11:07:26 +0100 Subject: [PATCH 2/2] Only the .env.test.local file (not tracked) should be changed This prevents contributors from inadvertently committing changes on the .env.test file (which is tracked) Reverts changes to .env.test and changes README.md accordingly --- .env.test | 3 --- docker/README.md | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.env.test b/.env.test index 5abea97a14..0833c82074 100644 --- a/.env.test +++ b/.env.test @@ -35,6 +35,3 @@ OPENID_REFRESH_TOKEN="dummy-refresh-token" ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY="test_primary_key" ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY="test_deterministic_key" ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT="test_derivation_salt" - -# Let the tests know if they are run within a Docker container: -# DOCKER="true" diff --git a/docker/README.md b/docker/README.md index be161f6518..6a621eba2f 100644 --- a/docker/README.md +++ b/docker/README.md @@ -5,7 +5,7 @@ Docker is intended to provide a common virtual environment available to all deve ## Limitations 1. The docker environment can't directly control your host system browser, which means that browser specs (under `/spec/system/`) and email previews will not work. You may be able to find a solution with [this article](https://evilmartians.com/chronicles/system-of-a-test-setting-up-end-to-end-rails-testing). If so, please contribute! -2. You can try circumventing this by setting the option `DOCKER=true` on the `.env.test file`, which will disable the `sandbox` mode for Chrome, used for system tests. +2. You can try circumventing this by setting the option `DOCKER=true` on the `.env.test.local` file, which will disable the `sandbox` mode for Chrome, used for system tests. ## Installing Docker ### Requirements