diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a26626838..578947491 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: CI +name: Tests on: [push, pull_request] @@ -62,3 +62,5 @@ jobs: run: yarn install --frozen-lockfile --non-interactive - name: Run tests run: bundle exec rails test + - name: Run system tests + run: bundle exec rails test:system diff --git a/Gemfile b/Gemfile index 935e341f0..98b174175 100644 --- a/Gemfile +++ b/Gemfile @@ -91,10 +91,12 @@ group :development do end group :test do + gem 'capybara' gem 'committee' gem 'minitest' gem 'minitest-reporters' gem 'rails-controller-testing' + gem 'selenium-webdriver' gem 'vcr' gem 'webmock' end diff --git a/Gemfile.lock b/Gemfile.lock index 5e606b21f..0f8b3d923 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -111,7 +111,7 @@ GEM activerecord (>= 4.0) autoprefixer-rails (10.4.13.0) execjs (~> 2) - base64 (0.1.2) + base64 (0.3.0) bcp47_spec (0.2.1) bcrypt (3.1.22) benchmark (0.5.0) @@ -135,6 +135,15 @@ GEM railties (>= 3.1) builder (3.3.0) byebug (11.1.3) + capybara (3.40.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) case_transform (0.2) activesupport cgi (0.5.1) @@ -425,7 +434,7 @@ GEM orm_adapter (0.5.0) ostruct (0.6.3) parallel (1.23.0) - parser (3.2.2.3) + parser (3.3.11.1) ast (~> 2.4.1) racc pg (1.5.6) @@ -624,12 +633,11 @@ GEM faraday (>= 0.9, < 3, != 2.0.0) rss (0.3.0) rexml - rubocop (1.56.1) - base64 (~> 0.1.1) + rubocop (1.57.2) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.2.3) + parser (>= 3.2.2.4) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) @@ -643,6 +651,7 @@ GEM faraday (>= 1) faraday-multipart (>= 1) ruby-progressbar (1.13.0) + rubyzip (3.3.0) safely_block (0.4.0) sass (3.7.4) sass-listen (~> 4.0.0) @@ -661,6 +670,12 @@ GEM tilt scanf (1.0.0) securerandom (0.4.1) + selenium-webdriver (4.44.0) + base64 (~> 0.2) + logger (~> 1.4) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 4.0) + websocket (~> 1.0) sentry-rails (5.11.0) railties (>= 5.0) sentry-ruby (~> 5.11.0) @@ -803,6 +818,7 @@ GEM crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) webrick (1.9.2) + websocket (1.2.11) websocket-driver (0.8.0) base64 websocket-extensions (>= 0.1.0) @@ -810,6 +826,8 @@ GEM whenever (1.0.0) chronic (>= 0.6.3) will_paginate (4.0.0) + xpath (3.2.0) + nokogiri (~> 1.8) yaml-ld (0.0.3) json-ld (~> 3.3) psych (>= 3.3) @@ -833,6 +851,7 @@ DEPENDENCIES bootstrap-sass bootstrap-tab-history-rails byebug + capybara committee country_select devise @@ -883,6 +902,7 @@ DEPENDENCIES ruby-openai sass-rails sassc-rails + selenium-webdriver sentry-rails sentry-ruby sentry-sidekiq diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb new file mode 100644 index 000000000..38c58b5fe --- /dev/null +++ b/test/application_system_test_case.rb @@ -0,0 +1,8 @@ +require 'test_helper' + +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase + driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400] do |options| + options.add_argument('--no-sandbox') + options.add_argument('--disable-dev-shm-usage') + end +end diff --git a/test/system/events_calendar_system_test.rb b/test/system/events_calendar_system_test.rb new file mode 100644 index 000000000..34913d8f8 --- /dev/null +++ b/test/system/events_calendar_system_test.rb @@ -0,0 +1,26 @@ +require 'application_system_test_case' + +class EventsCalendarSystemTest < ApplicationSystemTestCase + test 'calendar tab loads and renders events with javascript' do + freeze_time(Time.utc(2026, 5, 20, 12, 0, 0)) do + Event.create!( + title: 'System calendar event', + url: 'http://example.com/system-calendar-event', + user: users(:regular_user), + content_provider: content_providers(:goblet), + timezone: 'UTC', + start: Time.now.beginning_of_month + 10.days, + end: Time.now.beginning_of_month + 10.days + 2.hours, + city: 'Manchester', + country: 'United Kingdom' + ) + + visit events_path + + within('.index-display-options') { click_link 'Calendar' } + + assert_selector('#events_calendar #calendar.simple-calendar') + assert_selector('#events_calendar a.clear-both', text: 'System calendar event') + end + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index 17218b588..8d6583b3f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -35,6 +35,7 @@ VCR.configure do |config| config.cassette_library_dir = 'test/vcr_cassettes' config.hook_into :webmock + config.ignore_localhost = true # config.allow_http_connections_when_no_cassette = true end