hitobito / development

Setup your local machine for hitobito development
GNU Affero General Public License v3.0
19 stars 15 forks source link

Executing feature specs non-headless #8

Open hupf opened 4 years ago

hupf commented 4 years ago

To debug or write feature specs, it is absolutely necessary to execute them in a non-headless browser. Generally, to do this, the HEADLESS=false environment variable can be set. With the current container setup it is not possible to execute the features specs in this mode – a solution has to be engineered and documented.

Work around:

RAILS_HOST_NAME=localhost:3000 RAILS_DB_ADAPTER=mysql2 RAILS_DB_HOST=127.0.0.1 RAILS_DB_PORT=33066 RAILS_DB_USERNAME=root RAILS_DB_PASSWORD=hitobito RAILS_DB_NAME=hitobito_test HEADLESS=false bundle exec rspec --tag type:feature spec/features/

See also #7

carlobeltrame commented 4 years ago

I have previously had success with sharing the X socket with a container, such that the container can open windows on the host. On Linux and Mac OS, this can be done as follows:

  1. If you are on Mac, install the XQuartz X11 server (brew cask install xquartz) and restart your machine
  2. Run xhost local:root in order to allow the root user from the Docker container to send messages to the X server
  3. Configure the service that should open the windows as follows in docker-compose.yml:
    environment:
      - DISPLAY
    volumes:
      - /tmp/.X11-unix:/tmp/.X11-unix:rw
  4. docker-compose up

I have not tested this with the hitobito development repo yet, so far this is just for later reference when we take a look at solving this issue.

mtnstar commented 4 years ago

I added the DISPLAY var and the volume from @carlobeltrame post. chromium now starts, but the opened window is just blank and I can't see any content. also the specs are failing when running with HEADLESS=false

further engineering is required ...