From 6fe0df27226c82ee7ea082320423488aa2af0e56 Mon Sep 17 00:00:00 2001 From: Kohhee Peace Date: Fri, 27 Aug 2021 04:46:25 +0000 Subject: [PATCH] Added config to run selenium and capybara e2e tests in gitpod. --- .gitpod.Dockerfile | 27 +++++++++++++++++++++++++++ test/application_system_test_case.rb | 7 +++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index fa02297..246f05f 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -6,3 +6,30 @@ COPY --chown=gitpod:gitpod .ruby-version /tmp RUN echo "rvm_gems_path=/home/gitpod/.rvm" > ~/.rvmrc RUN bash -lc "rvm reinstall ruby-$(cat /tmp/.ruby-version) && rvm use ruby-$(cat /tmp/.ruby-version) --default && gem install rails" RUN echo "rvm_gems_path=/workspace/.rvm" > ~/.rvmrc + +# Install dependencies +RUN sudo apt-get -q update \ + && sudo apt-get install -y openjdk-8-jre-headless xvfb libxi6 libgconf-2-4 libnss3-dev \ + && sudo rm -rf /var/lib/apt/lists/* + +# Install Chrome +RUN sudo wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - \ + && echo 'deb http://dl.google.com/linux/chrome/deb/ stable main' | sudo tee /etc/apt/sources.list.d/google-chrome.list \ + && sudo apt-get -y update \ + && sudo apt-get -y install google-chrome-stable + +# Install ChromeDriver +RUN CHROME_DRIVER_VERSION=`curl -sS https://chromedriver.storage.googleapis.com/LATEST_RELEASE` \ + && sudo wget -N https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip -P ~/ \ + && unzip ~/chromedriver_linux64.zip -d ~/ \ + && sudo mv -f ~/chromedriver /usr/local/bin/chromedriver \ + && sudo chown root:root /usr/local/bin/chromedriver \ + && sudo chmod 0755 /usr/local/bin/chromedriver + +# Install Selenium +RUN SELENIUM_STANDALONE_VERSION=3.9.1 \ + && SELENIUM_SUBDIR=$(echo "$SELENIUM_STANDALONE_VERSION" | cut -d"." -f-2) \ + && wget -N https://selenium-release.storage.googleapis.com/$SELENIUM_SUBDIR/selenium-server-standalone-$SELENIUM_STANDALONE_VERSION.jar -P ~/ \ + && sudo mv -f ~/selenium-server-standalone-$SELENIUM_STANDALONE_VERSION.jar /usr/local/bin/selenium-server-standalone.jar \ + && sudo chown root:root /usr/local/bin/selenium-server-standalone.jar \ + && sudo chmod 0755 /usr/local/bin/selenium-server-standalone.jar \ No newline at end of file diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index d19212a..5aec6f5 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -1,5 +1,8 @@ -require "test_helper" +require 'test_helper' class ApplicationSystemTestCase < ActionDispatch::SystemTestCase - driven_by :selenium, using: :chrome, screen_size: [1400, 1400] + driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400] end + +# Remove messy "Capybara starting Puma..." test logs +Capybara.server = :puma, { Silent: true } \ No newline at end of file