Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Run devcontainer system tests in headless Chrome (#5510)

Artur Kalimullin6fd9063ef426
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 90a80c9853..9d050c339e 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -26,7 +26,7 @@ To get setup for local development, you have two options:
1. [Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers) with VSCode (see the `.devcontainer` folder)
- A `selenium/standalone-chrome` service is included in the Dev Container setup, so **system tests work out of the box** — no local Chrome required.
- Run system tests: `DISABLE_PARALLELIZATION=true bin/rails test:system`
- - Watch the browser live at `http://localhost:7900` or `http://localhost:4444` (password: `secret`)
+ - Watch the browser live by adding `E2E_BROWSER=chrome` and opening `http://localhost:7900` or `http://localhost:4444` (password: `secret`); it runs headless otherwise
2. Local Development
- [Mac Setup Guide](https://github.com/we-promise/sure/wiki/Mac-Dev-Setup-Guide)
- [Linux Setup Guide](https://github.com/we-promise/sure/wiki/Linux-Dev-Setup-Guide)
diff --git a/docs/llm-guides/development.md b/docs/llm-guides/development.md
index 642bb40adb..aac83e2780 100644
--- a/docs/llm-guides/development.md
+++ b/docs/llm-guides/development.md
@@ -63,5 +63,8 @@ GitHub checks and an up-to-date branch before requesting review.
The [devcontainer configuration](../../.devcontainer/docker-compose.yml) includes
Selenium Chromium and sets `SELENIUM_REMOTE_URL`; no local Chrome is needed there.
-Run `DISABLE_PARALLELIZATION=true bin/rails test:system`. Watch the browser at
+Run `DISABLE_PARALLELIZATION=true bin/rails test:system`. The browser runs
+headless, as in CI. To watch it, add `E2E_BROWSER=chrome` and open
`http://localhost:7900` or `http://localhost:4444` (development password: `secret`).
+Keep such a run serial: headed sessions share the node's display, and one session's
+window interrupts hovers in another.
diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb
index e009c91cbd..1c80cf808b 100644
--- a/test/application_system_test_case.rb
+++ b/test/application_system_test_case.rb
@@ -25,6 +25,13 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
Capybara.register_driver :selenium_remote_chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument("--window-size=1400,1400")
+ # Every session on the Selenium node shares one X display. A headed
+ # window there also receives the display's real pointer: when another
+ # session's window opens, resizes or closes over it, Chrome reports the
+ # pointer leaving whatever a test is hovering, and its tooltip closes.
+ # Headless sessions only receive WebDriver input. E2E_BROWSER=chrome
+ # shows the browser on the node's VNC, for watching a serial run.
+ options.add_argument("--headless=new") unless ENV["E2E_BROWSER"] == "chrome"
Capybara::Selenium::Driver.new(
app,