# frozen_string_literal: true require "test_helper" class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by(:selenium, using: :headless_chrome, options: { browser: :remote, url: ENV.fetch("SELENIUM_REMOTE_URL", nil) }) setup do Capybara.server_host = "0.0.0.0" # bind to all interfaces Capybara.app_host = "http://#{IPSocket.getaddress(Socket.gethostname)}" if ENV["SELENIUM_REMOTE_URL"].present? end def app_host "http://#{IPSocket.getaddress(Socket.gethostname)}" end def login(email, password) visit "/session/new" assert_selector("h1", text: "Login") fill_in "Login", with: email fill_in "Passwort", with: password click_button "Login" assert_text("Dashboard") save_screenshot "after_login.png" end def logout Session.destroy_all end def login_test user = User.find_or_initialize_by(email_address: "test@example.com") user.update!(password: "password") login(user.email_address, user.password) save_screenshot "login.png" end end