2024-07-15 14:31:54 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2024-09-05 22:54:38 +02:00
|
|
|
require "test_helper"
|
2024-07-15 02:19:27 +02:00
|
|
|
|
|
|
|
|
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
2024-07-23 01:06:45 +02:00
|
|
|
driven_by(:selenium, using: :headless_chrome,
|
2024-09-05 22:54:38 +02:00
|
|
|
options: { browser: :remote,
|
|
|
|
|
url: ENV.fetch("SELENIUM_REMOTE_URL", nil) })
|
2024-07-23 01:06:45 +02:00
|
|
|
|
2024-09-22 22:49:53 +02:00
|
|
|
setup do
|
2024-09-05 22:54:38 +02:00
|
|
|
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?
|
2024-09-22 22:49:53 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def app_host
|
|
|
|
|
"http://#{IPSocket.getaddress(Socket.gethostname)}"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def login(email, password)
|
2024-11-08 22:05:31 +01:00
|
|
|
visit "/session/new"
|
|
|
|
|
assert_selector("h1", text: "Login")
|
2024-09-22 22:49:53 +02:00
|
|
|
fill_in "Login", with: email
|
2024-11-08 22:05:31 +01:00
|
|
|
fill_in "Passwort", with: password
|
2024-09-22 22:49:53 +02:00
|
|
|
click_button "Login"
|
2024-11-08 22:05:31 +01:00
|
|
|
assert_text("Dashboard")
|
|
|
|
|
save_screenshot "after_login.png"
|
2024-09-22 22:49:53 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def logout
|
2024-11-08 22:05:31 +01:00
|
|
|
Session.destroy_all
|
2024-09-22 22:49:53 +02:00
|
|
|
end
|
2024-07-23 01:06:45 +02:00
|
|
|
|
2024-09-22 22:49:53 +02:00
|
|
|
def login_test
|
2024-11-08 22:05:31 +01:00
|
|
|
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"
|
2024-07-23 01:06:45 +02:00
|
|
|
end
|
2024-07-15 02:19:27 +02:00
|
|
|
end
|