From a7791635aa98f012d35f97c3c5288494bbb28e38 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Wed, 13 Mar 2024 18:03:43 +0100 Subject: Initial commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- test/application_system_test_case.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/application_system_test_case.rb (limited to 'test/application_system_test_case.rb') diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb new file mode 100644 index 0000000..eaa28b0 --- /dev/null +++ b/test/application_system_test_case.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require 'test_helper' + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400] + + # Sign in with the default user. + def sign_in! + visit new_sessions_url + + fill_in I18n.t('activerecord.attributes.user.username'), with: users(:user).username + fill_in I18n.t('activerecord.attributes.user.password'), with: '12341234' + click_on I18n.t('sessions.sign-in') + + assert_text I18n.t('searches.home') + end + + # Sign out the current user if it's already signed in, otherwise do nothing. + def sign_out_maybe! + click_on I18n.t('sessions.sign-out') + assert_text I18n.t('sessions.title') + rescue Capybara::ElementNotFound + # We were not logged in, do nothing. + end +end -- cgit v1.2.3