]> git.openstreetmap.org Git - rails.git/blob - test/application_system_test_case.rb
Merge pull request #6394 from openstreetmap/dependabot/github_actions/ruby/setup...
[rails.git] / test / application_system_test_case.rb
1 # frozen_string_literal: true
2
3 require "test_helper"
4
5 ENV.delete("http_proxy")
6
7 ActiveSupport.on_load(:action_dispatch_system_test_case) do
8   ActionDispatch::SystemTesting::Server.silence_puma = true
9 end
10
11 class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
12   include ActionMailer::TestCase::ClearTestDeliveries
13
14   Capybara.configure do |config|
15     config.enable_aria_label = true
16   end
17
18   driven_by :selenium, :using => Settings.system_test_headless ? :headless_firefox : :firefox do |options|
19     options.add_preference("intl.accept_languages", "en")
20     options.binary = Settings.system_test_firefox_binary if Settings.system_test_firefox_binary
21   end
22
23   def before_setup
24     super
25     osm_website_app = create(:oauth_application, :name => "OpenStreetMap Web Site", :scopes => "write_api write_notes")
26     Settings.oauth_application = osm_website_app.uid
27   end
28
29   def after_teardown
30     Settings.reload!
31     super
32   end
33
34   private
35
36   def sign_in_as(user)
37     visit login_path
38     within "form", :text => "Email Address or Username" do
39       fill_in "username", :with => user.email
40       fill_in "password", :with => "test"
41       click_on "Log in"
42     end
43   end
44
45   def sign_out
46     visit logout_path
47     click_on "Logout", :match => :first
48   end
49
50   def within_sidebar(&)
51     within("#sidebar_content", &)
52   end
53
54   def within_content_body(&)
55     within("#content > .content-body", &)
56   end
57
58   def within_content_heading(&)
59     within("#content > .content-heading", &)
60   end
61 end