mirror of https://github.com/mastodon/mastodon
Use `fullstack` tag to run full stack system specs
This commit is contained in:
parent
d5a0b141fa
commit
c41340c19d
|
@ -186,6 +186,8 @@ jobs:
|
||||||
DISABLE_SIMPLECOV: true
|
DISABLE_SIMPLECOV: true
|
||||||
RAILS_ENV: test
|
RAILS_ENV: test
|
||||||
BUNDLE_WITH: test
|
BUNDLE_WITH: test
|
||||||
|
LOCAL_DOMAIN: localhost:3000
|
||||||
|
LOCAL_HTTPS: false
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
@ -215,7 +217,7 @@ jobs:
|
||||||
- name: Load database schema
|
- name: Load database schema
|
||||||
run: './bin/rails db:create db:schema:load db:seed'
|
run: './bin/rails db:create db:schema:load db:seed'
|
||||||
|
|
||||||
- run: bundle exec rake spec:system
|
- run: bin/rspec spec/system --tag fullstack
|
||||||
|
|
||||||
- name: Archive logs
|
- name: Archive logs
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
|
|
@ -70,7 +70,7 @@ Style/FetchEnvVar:
|
||||||
- 'config/initializers/vapid.rb'
|
- 'config/initializers/vapid.rb'
|
||||||
- 'lib/mastodon/redis_config.rb'
|
- 'lib/mastodon/redis_config.rb'
|
||||||
- 'lib/tasks/repo.rake'
|
- 'lib/tasks/repo.rake'
|
||||||
- 'spec/features/profile_spec.rb'
|
- 'spec/system/profile_spec.rb'
|
||||||
|
|
||||||
# This cop supports safe autocorrection (--autocorrect).
|
# This cop supports safe autocorrection (--autocorrect).
|
||||||
# Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns.
|
# Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns.
|
||||||
|
|
|
@ -2,13 +2,9 @@
|
||||||
|
|
||||||
ENV['RAILS_ENV'] ||= 'test'
|
ENV['RAILS_ENV'] ||= 'test'
|
||||||
|
|
||||||
# This needs to be defined before Rails is initialized
|
# This needs to be defined before Rails is initialized (used by full stack system specs)
|
||||||
RUN_SYSTEM_SPECS = ENV.fetch('RUN_SYSTEM_SPECS', false)
|
STREAMING_PORT = ENV.fetch('TEST_STREAMING_PORT', '4020')
|
||||||
|
ENV['STREAMING_API_BASE_URL'] = "http://localhost:#{STREAMING_PORT}"
|
||||||
if RUN_SYSTEM_SPECS
|
|
||||||
STREAMING_PORT = ENV.fetch('TEST_STREAMING_PORT', '4020')
|
|
||||||
ENV['STREAMING_API_BASE_URL'] = "http://localhost:#{STREAMING_PORT}"
|
|
||||||
end
|
|
||||||
|
|
||||||
require File.expand_path('../config/environment', __dir__)
|
require File.expand_path('../config/environment', __dir__)
|
||||||
|
|
||||||
|
@ -26,7 +22,7 @@ require 'test_prof/recipes/rspec/before_all'
|
||||||
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
|
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
|
||||||
|
|
||||||
ActiveRecord::Migration.maintain_test_schema!
|
ActiveRecord::Migration.maintain_test_schema!
|
||||||
WebMock.disable_net_connect!(allow: Chewy.settings[:host], allow_localhost: RUN_SYSTEM_SPECS)
|
WebMock.disable_net_connect!(allow: Chewy.settings[:host], allow_localhost: true)
|
||||||
Sidekiq.logger = nil
|
Sidekiq.logger = nil
|
||||||
|
|
||||||
# System tests config
|
# System tests config
|
||||||
|
@ -49,13 +45,9 @@ Devise::Test::ControllerHelpers.module_eval do
|
||||||
end
|
end
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
# This is set before running spec:system, see lib/tasks/tests.rake
|
# By default, skip "full stack" specs with higher startup cost (streaming
|
||||||
config.filter_run_excluding type: lambda { |type|
|
# server spin up) and slower execution (full JS browser). Run from CI only.
|
||||||
case type
|
config.filter_run_excluding fullstack: true
|
||||||
when :system
|
|
||||||
!RUN_SYSTEM_SPECS
|
|
||||||
end
|
|
||||||
}
|
|
||||||
|
|
||||||
# By default, skip the elastic search integration specs
|
# By default, skip the elastic search integration specs
|
||||||
config.filter_run_excluding search: true
|
config.filter_run_excluding search: true
|
||||||
|
@ -78,10 +70,15 @@ RSpec.configure do |config|
|
||||||
metadata[:search] = true
|
metadata[:search] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Set `fullstack` metadata true for all specs in spec/system/fullstack/
|
||||||
|
config.define_derived_metadata(file_path: Regexp.new('spec/system/fullstack/*')) do |metadata|
|
||||||
|
metadata[:fullstack] = true
|
||||||
|
end
|
||||||
|
|
||||||
config.include Devise::Test::ControllerHelpers, type: :controller
|
config.include Devise::Test::ControllerHelpers, type: :controller
|
||||||
config.include Devise::Test::ControllerHelpers, type: :helper
|
config.include Devise::Test::ControllerHelpers, type: :helper
|
||||||
config.include Devise::Test::ControllerHelpers, type: :view
|
config.include Devise::Test::ControllerHelpers, type: :view
|
||||||
config.include Devise::Test::IntegrationHelpers, type: :feature
|
config.include Devise::Test::IntegrationHelpers, type: :system
|
||||||
config.include Devise::Test::IntegrationHelpers, type: :request
|
config.include Devise::Test::IntegrationHelpers, type: :request
|
||||||
config.include ActionMailer::TestHelper
|
config.include ActionMailer::TestHelper
|
||||||
config.include Paperclip::Shoulda::Matchers
|
config.include Paperclip::Shoulda::Matchers
|
||||||
|
@ -111,10 +108,6 @@ RSpec.configure do |config|
|
||||||
stub_reset_connection_pools
|
stub_reset_connection_pools
|
||||||
end
|
end
|
||||||
|
|
||||||
config.before :each, type: :feature do
|
|
||||||
Capybara.current_driver = :rack_test
|
|
||||||
end
|
|
||||||
|
|
||||||
config.before do |example|
|
config.before do |example|
|
||||||
allow(Resolv::DNS).to receive(:open).and_raise('Real DNS queries are disabled, stub Resolv::DNS as needed') unless example.metadata[:type] == :system
|
allow(Resolv::DNS).to receive(:open).and_raise('Real DNS queries are disabled, stub Resolv::DNS as needed') unless example.metadata[:type] == :system
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,6 +26,10 @@ Capybara.javascript_driver = :headless_chrome
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.before(:each, type: :system) do
|
config.before(:each, type: :system) do
|
||||||
|
driven_by :rack_test
|
||||||
|
end
|
||||||
|
|
||||||
|
config.before(:each, :fullstack, type: :system) do
|
||||||
driven_by Capybara.javascript_driver
|
driven_by Capybara.javascript_driver
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.after(:each, type: :system) do
|
config.after(:each, :fullstack, type: :system) do
|
||||||
errors = page.driver.browser.logs.get(:browser)
|
errors = page.driver.browser.logs.get(:browser)
|
||||||
if errors.present?
|
if errors.present?
|
||||||
aggregate_failures 'javascript errrors' do
|
aggregate_failures 'javascript errrors' do
|
||||||
|
|
|
@ -125,6 +125,6 @@ RSpec.configure do |config|
|
||||||
end
|
end
|
||||||
|
|
||||||
def streaming_examples_present?
|
def streaming_examples_present?
|
||||||
RUN_SYSTEM_SPECS
|
RSpec.world.filtered_examples.values.flatten.any? { |example| example.metadata[:fullstack] == true }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue