decidim-dev 0.26.2 → 0.27.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/app/commands/decidim/dummy_resources/create_dummy_resource.rb +1 -1
  3. data/app/controllers/concerns/decidim/dev/needs_development_tools.rb +1 -1
  4. data/config/locales/ar.yml +1 -0
  5. data/config/locales/bg.yml +1 -0
  6. data/config/locales/ca.yml +7 -0
  7. data/config/locales/cs.yml +5 -0
  8. data/config/locales/de.yml +1 -0
  9. data/config/locales/el.yml +1 -0
  10. data/config/locales/en.yml +6 -0
  11. data/config/locales/es-MX.yml +7 -0
  12. data/config/locales/es-PY.yml +7 -0
  13. data/config/locales/es.yml +7 -0
  14. data/config/locales/eu.yml +1 -0
  15. data/config/locales/fi-plain.yml +7 -0
  16. data/config/locales/fi.yml +7 -0
  17. data/config/locales/fr-CA.yml +7 -0
  18. data/config/locales/fr.yml +7 -0
  19. data/config/locales/ga-IE.yml +1 -0
  20. data/config/locales/gl.yml +1 -0
  21. data/config/locales/hu.yml +1 -0
  22. data/config/locales/id-ID.yml +1 -0
  23. data/config/locales/is-IS.yml +2 -1
  24. data/config/locales/it.yml +1 -0
  25. data/config/locales/ja.yml +7 -0
  26. data/config/locales/lt.yml +64 -0
  27. data/config/locales/lv.yml +1 -0
  28. data/config/locales/nl.yml +1 -0
  29. data/config/locales/no.yml +1 -0
  30. data/config/locales/pl.yml +1 -0
  31. data/config/locales/pt-BR.yml +1 -0
  32. data/config/locales/pt.yml +1 -0
  33. data/config/locales/ro-RO.yml +1 -0
  34. data/config/locales/ru.yml +1 -0
  35. data/config/locales/sk.yml +1 -0
  36. data/config/locales/sl.yml +1 -0
  37. data/config/locales/sr-CS.yml +1 -0
  38. data/config/locales/sv.yml +1 -0
  39. data/config/locales/tr-TR.yml +1 -0
  40. data/config/locales/uk.yml +1 -0
  41. data/config/locales/zh-CN.yml +1 -0
  42. data/lib/decidim/dev/assets/geocoder_result_here.json +46 -67
  43. data/lib/decidim/dev/assets/import_voting_census_only_headers.csv +1 -0
  44. data/lib/decidim/dev/assets/logo.png +0 -0
  45. data/lib/decidim/dev/assets/ssl-cert.pem +22 -0
  46. data/lib/decidim/dev/assets/ssl-key.pem +28 -0
  47. data/lib/decidim/dev/common_rake.rb +1 -0
  48. data/lib/decidim/dev/railtie.rb +1 -1
  49. data/lib/decidim/dev/test/base_spec_helper.rb +2 -1
  50. data/lib/decidim/dev/test/rspec_support/attachment_helpers.rb +30 -0
  51. data/lib/decidim/dev/test/rspec_support/autocomplete_select.rb +23 -0
  52. data/lib/decidim/dev/test/rspec_support/capybara.rb +77 -9
  53. data/lib/decidim/dev/test/rspec_support/comments.rb +1 -1
  54. data/lib/decidim/dev/test/rspec_support/component.rb +5 -5
  55. data/lib/decidim/dev/test/rspec_support/controller_example_group.rb +27 -0
  56. data/lib/decidim/dev/test/rspec_support/data_consent.rb +41 -0
  57. data/lib/decidim/dev/test/rspec_support/dynamic_attach.rb +31 -0
  58. data/lib/decidim/dev/test/rspec_support/frontend.rb +1 -1
  59. data/lib/decidim/dev/test/rspec_support/geocoder.rb +6 -2
  60. data/lib/decidim/dev/test/rspec_support/helpers.rb +12 -0
  61. data/lib/decidim/dev/test/rspec_support/html_matchers.rb +11 -0
  62. data/lib/decidim/dev/test/rspec_support/imports_controller_shared_examples.rb +3 -8
  63. data/lib/decidim/dev/test/rspec_support/network_conditions_helpers.rb +18 -0
  64. data/lib/decidim/dev/test/rspec_support/rake_tasks.rb +0 -2
  65. data/lib/decidim/dev/test/rspec_support/screenshot_helper.rb +41 -0
  66. data/lib/decidim/dev/test/rspec_support/warden.rb +5 -0
  67. data/lib/decidim/dev/test/rspec_support/wicked_pdf_assets_mock.rb +4 -0
  68. data/lib/decidim/dev/test/spec_helper.rb +2 -4
  69. data/lib/decidim/dev/test/w3c_rspec_validators_overrides.rb +0 -2
  70. data/lib/decidim/dev/version.rb +1 -1
  71. data/lib/decidim-dev.rb +1 -1
  72. data/lib/tasks/generators.rake +7 -2
  73. data/lib/tasks/lighthouse_report.rake +29 -0
  74. data/lib/tasks/locale_checker.rake +1 -1
  75. metadata +51 -41
  76. data/lib/decidim/dev/test/rspec_support/react_select.rb +0 -29
@@ -3,6 +3,7 @@
3
3
  require "decidim/dev"
4
4
 
5
5
  ENV["RAILS_ENV"] ||= "test"
6
+ ENV["RAILS_SYSTEM_TESTING_SCREENSHOT_HTML"] ||= "1"
6
7
 
7
8
  engine_spec_dir = File.join(Dir.pwd, "spec")
8
9
 
@@ -18,7 +19,7 @@ require_relative "rspec_support/authorization"
18
19
 
19
20
  require "#{Decidim::Dev.dummy_app_path}/config/environment"
20
21
 
21
- Dir["#{engine_spec_dir}/shared/**/*.rb"].sort.each { |f| require f }
22
+ Dir["#{engine_spec_dir}/shared/**/*.rb"].each { |f| require f }
22
23
 
23
24
  require "paper_trail/frameworks/rspec"
24
25
 
@@ -9,6 +9,36 @@ module AttachmentHelpers
9
9
  def attachment_file_size(attachment)
10
10
  ActiveSupport::NumberHelper.number_to_human_size(attachment.file_size)
11
11
  end
12
+
13
+ # Creates ActiveStorage::Blob object and returns its signed_id
14
+ # Used in non-system tests that need files.
15
+ def upload_test_file(file, options = {})
16
+ filename = options[:filename] || upload_test_file_filename(file)
17
+ content_type = options[:content_type] || upload_test_file_content_type(file)
18
+
19
+ blob = ActiveStorage::Blob.create_and_upload!(
20
+ io: File.open(file),
21
+ filename: filename,
22
+ content_type: content_type
23
+ )
24
+ return blob if options[:return_blob]
25
+
26
+ blob.signed_id
27
+ end
28
+
29
+ private
30
+
31
+ def upload_test_file_filename(file)
32
+ return file.original_filename if file.respond_to? :original_filename
33
+
34
+ file.split("/").last
35
+ end
36
+
37
+ def upload_test_file_content_type(file)
38
+ return file.content_type if file.respond_to? :content_type
39
+
40
+ MIME::Types.type_for(file).first.content_type
41
+ end
12
42
  end
13
43
 
14
44
  RSpec.configure do |config|
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Capybara
4
+ module AutoCompleteJS
5
+ def autocomplete_select(value, from:)
6
+ within("div[data-autocomplete-for='#{from}']") do
7
+ find(".autocomplete-input").click
8
+ find(".autocomplete-input").native.send_keys(value[0..4])
9
+ expect(page).to have_css("#autoComplete_list_1") # select should be open now
10
+
11
+ expect(page).to have_css("#autoComplete_result_0", text: value)
12
+ find("#autoComplete_result_0", text: value).hover
13
+ expect(page).to have_css("#autoComplete_result_0", text: value)
14
+ find("#autoComplete_result_0", text: value).click
15
+ expect(page).to have_css(".autocomplete__selected-item", text: value)
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ RSpec.configure do |config|
22
+ config.include Capybara::AutoCompleteJS, type: :system
23
+ end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "selenium-webdriver"
4
- require "system_test_html_screenshots"
5
4
 
6
5
  module Decidim
7
6
  # Helpers meant to be used only during capybara test runs.
@@ -9,7 +8,7 @@ module Decidim
9
8
  def switch_to_host(host = "lvh.me")
10
9
  raise "Can't switch to a custom host unless it really exists. Use `whatever.lvh.me` as a workaround." unless /lvh\.me$/.match?(host)
11
10
 
12
- app_host = (host ? "http://#{host}" : nil)
11
+ app_host = (host ? "#{protocol}://#{host}" : nil)
13
12
  Capybara.app_host = app_host
14
13
  end
15
14
 
@@ -18,7 +17,13 @@ module Decidim
18
17
  end
19
18
 
20
19
  def switch_to_secure_context_host
21
- Capybara.app_host = "http://localhost"
20
+ Capybara.app_host = "#{protocol}://localhost"
21
+ end
22
+
23
+ def protocol
24
+ return "https" if ENV["TEST_SSL"]
25
+
26
+ "http"
22
27
  end
23
28
  end
24
29
  end
@@ -32,11 +37,50 @@ Capybara.register_driver :headless_chrome do |app|
32
37
  else
33
38
  "--window-size=1920,1080"
34
39
  end
40
+ options.args << "--ignore-certificate-errors" if ENV["TEST_SSL"]
41
+ Capybara::Selenium::Driver.new(
42
+ app,
43
+ browser: :chrome,
44
+ capabilities: [options]
45
+ )
46
+ end
47
+
48
+ 1.step do
49
+ port = rand(5000..6999)
50
+ begin
51
+ Socket.tcp("127.0.0.1", port, connect_timeout: 5).close
52
+ rescue Errno::ECONNREFUSED
53
+ # When connection is refused, the port is available for use.
54
+ Capybara.server_port = port
55
+ break
56
+ end
57
+ end
58
+
59
+ # In order to work with PWA apps, Chrome can't be run in headless mode, and requires
60
+ # setting up special prefs and flags
61
+ Capybara.register_driver :pwa_chrome do |app|
62
+ options = ::Selenium::WebDriver::Chrome::Options.new
63
+ options.args << "--no-sandbox"
64
+ # Don't limit browser resources
65
+ options.args << "--disable-dev-shm-usage"
66
+ # Add pwa.lvh.me host as a secure origin
67
+ options.args << "--unsafely-treat-insecure-origin-as-secure=http://pwa.lvh.me:#{Capybara.server_port}"
68
+ # User data flag is mandatory when preferences and locale state is set
69
+ options.args << "--user-data-dir=/tmp/decidim_tests_user_data_#{rand(1000)}"
70
+ options.args << if ENV["BIG_SCREEN_SIZE"].present?
71
+ "--window-size=1920,3000"
72
+ else
73
+ "--window-size=1920,1080"
74
+ end
75
+ # Set notifications allowed in http protocol
76
+ options.local_state["browser.enabled_labs_experiments"] = ["enable-system-notifications@1", "unsafely-treat-insecure-origin-as-secure"]
77
+ # Mark notification permission as enabled
78
+ options.prefs["profile.default_content_setting_values.notifications"] = 1
35
79
 
36
80
  Capybara::Selenium::Driver.new(
37
81
  app,
38
82
  browser: :chrome,
39
- options: options
83
+ capabilities: [options]
40
84
  )
41
85
  end
42
86
 
@@ -49,13 +93,22 @@ Capybara.register_driver :iphone do |app|
49
93
  Capybara::Selenium::Driver.new(
50
94
  app,
51
95
  browser: :chrome,
52
- options: options
96
+ capabilities: [options]
53
97
  )
54
98
  end
55
99
 
56
- Capybara.server = :puma, { Silent: true, Threads: "1:1" }
57
-
58
- Capybara.asset_host = "http://localhost:3000"
100
+ server_options = { Silent: true, queue_requests: false }
101
+ if ENV["TEST_SSL"]
102
+ dev_gem = Bundler.load.specs.find { |spec| spec.name == "decidim-dev" }
103
+ cert_dir = "#{dev_gem.full_gem_path}/lib/decidim/dev/assets"
104
+ server_options.merge!(
105
+ Host: "ssl://#{Capybara.server_host}:#{Capybara.server_port}?key=#{cert_dir}/ssl-key.pem&cert=#{cert_dir}/ssl-cert.pem"
106
+ )
107
+ Capybara.asset_host = "https://localhost:3000"
108
+ else
109
+ Capybara.asset_host = "http://localhost:3000"
110
+ end
111
+ Capybara.server = :puma, server_options
59
112
 
60
113
  Capybara.server_errors = [SyntaxError, StandardError]
61
114
 
@@ -65,6 +118,21 @@ RSpec.configure do |config|
65
118
  config.before :each, type: :system do
66
119
  driven_by(:headless_chrome)
67
120
  switch_to_default_host
121
+ domain = (try(:organization) || try(:current_organization))&.host
122
+ if domain
123
+ # Javascript sets the cookie also for all subdomains but localhost is a
124
+ # special case.
125
+ domain = ".#{domain}" unless domain == "localhost"
126
+ page.driver.browser.execute_cdp(
127
+ "Network.setCookie",
128
+ domain: domain,
129
+ name: Decidim.consent_cookie_name,
130
+ value: { essential: true }.to_json,
131
+ path: "/",
132
+ expires: 1.day.from_now.to_i,
133
+ same_site: "Lax"
134
+ )
135
+ end
68
136
  end
69
137
 
70
138
  config.before :each, driver: :rack_test do
@@ -80,7 +148,7 @@ RSpec.configure do |config|
80
148
  end
81
149
 
82
150
  config.after(type: :system) do |example|
83
- warn page.driver.browser.manage.logs.get(:browser) unless example.metadata[:driver].eql?(:rack_test)
151
+ warn page.driver.browser.logs.get(:browser) unless example.metadata[:driver].eql?(:rack_test)
84
152
  end
85
153
 
86
154
  config.include Decidim::CapybaraTestHelpers, type: :system
@@ -3,7 +3,7 @@
3
3
  module CommentsHelpers
4
4
  def have_comment_from(user, text, opts = {})
5
5
  within "#comments" do
6
- have_content(user.name, opts) && have_content(text, opts)
6
+ have_content(user.name, **opts) && have_content(text, **opts)
7
7
  end
8
8
  end
9
9
 
@@ -89,7 +89,7 @@ module Decidim
89
89
  include Followable
90
90
  include Traceable
91
91
  include Publicable
92
- include Decidim::DataPortability
92
+ include Decidim::DownloadYourData
93
93
  include Searchable
94
94
  include Paddable
95
95
  include Amendable
@@ -236,8 +236,8 @@ Decidim.register_component(:dummy) do |component|
236
236
  settings.attribute :comments_enabled, type: :boolean, default: true
237
237
  settings.attribute :comments_max_length, type: :integer, required: false
238
238
  settings.attribute :resources_permissions_enabled, type: :boolean, default: true
239
- settings.attribute :dummy_global_attribute_1, type: :boolean
240
- settings.attribute :dummy_global_attribute_2, type: :boolean, readonly: ->(_context) { false }
239
+ settings.attribute :dummy_global_attribute1, type: :boolean
240
+ settings.attribute :dummy_global_attribute2, type: :boolean, readonly: ->(_context) { false }
241
241
  settings.attribute :readonly_attribute, type: :boolean, default: true, readonly: ->(_context) { true }
242
242
  settings.attribute :enable_pads_creation, type: :boolean, default: false
243
243
  settings.attribute :amendments_enabled, type: :boolean, default: false
@@ -246,8 +246,8 @@ Decidim.register_component(:dummy) do |component|
246
246
 
247
247
  component.settings(:step) do |settings|
248
248
  settings.attribute :comments_blocked, type: :boolean, default: false
249
- settings.attribute :dummy_step_attribute_1, type: :boolean
250
- settings.attribute :dummy_step_attribute_2, type: :boolean, readonly: ->(_context) { false }
249
+ settings.attribute :dummy_step_attribute1, type: :boolean
250
+ settings.attribute :dummy_step_attribute2, type: :boolean, readonly: ->(_context) { false }
251
251
  settings.attribute :dummy_step_translatable_text, type: :text, translated: true, editor: true, required: true
252
252
  settings.attribute :readonly_step_attribute, type: :boolean, default: true, readonly: ->(_context) { true }
253
253
  settings.attribute :amendment_creation_enabled, type: :boolean, default: true
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ControllerExampleGroup
5
+ extend ActiveSupport::Concern
6
+
7
+ class_methods do
8
+ def routes
9
+ before do
10
+ routes = yield
11
+ @orig_default_url_options = routes.default_url_options.dup
12
+ routes.default_url_options[:script_name] = ""
13
+
14
+ self.routes = routes
15
+ end
16
+
17
+ after do
18
+ routes.default_url_options = @orig_default_url_options
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ RSpec.configure do |config|
26
+ config.include Decidim::ControllerExampleGroup, type: :controller
27
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Capybara
4
+ module DataConsent
5
+ # Update data consent
6
+ def data_consent(categories = "all", options = {})
7
+ visit decidim.root_path if options[:visit_root]
8
+
9
+ dialog_present = begin
10
+ find("#dc-dialog-wrapper")
11
+ rescue Capybara::ElementNotFound => _e
12
+ false
13
+ end
14
+
15
+ if dialog_present
16
+ click_button "Settings"
17
+ else
18
+ within ".footer" do
19
+ click_link "Cookie settings"
20
+ end
21
+ end
22
+
23
+ if [true, "all"].include?(categories)
24
+ click_button "Accept all"
25
+ elsif categories.is_a?(Array)
26
+ categories.each do |category|
27
+ within "[data-id='#{category}']" do
28
+ find(".switch-paddle").click
29
+ end
30
+ end
31
+ click_button "Save settings"
32
+ elsif [false, "essential"].include?(categories)
33
+ click_button "Accept only essential"
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ RSpec.configure do |config|
40
+ config.include Capybara::DataConsent, type: :system
41
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Adapted from https://github.com/JedWatson/react-select/issues/832#issuecomment-276441836
4
+
5
+ module Capybara
6
+ module UploadModal
7
+ # Replaces attach_file.
8
+ # Beware that modal does not open within form!
9
+ def dynamically_attach_file(name, file_location, options = {})
10
+ find("##{name}_button").click
11
+ filename = options[:filename] || file_location.to_s.split("/").last
12
+
13
+ yield if block_given?
14
+
15
+ within ".upload-modal" do
16
+ find(".remove-upload-item").click if options[:remove_before]
17
+ input_element = find("input[type='file']", visible: :all)
18
+ input_element.attach_file(file_location)
19
+ within "[data-filename='#{filename}']" do
20
+ expect(page).to have_css("div.progress-bar.filled", wait: 5)
21
+ end
22
+ all("input.attachment-title").last.set(options[:title]) if options.has_key?(:title)
23
+ click_button "Save" unless options[:keep_modal_open]
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ RSpec.configure do |config|
30
+ config.include Capybara::UploadModal, type: :system
31
+ end
@@ -4,7 +4,7 @@ module FrontendHelpers
4
4
  # Thanks to:
5
5
  # https://medium.com/@coorasse/catch-javascript-errors-in-your-system-tests-89c2fe6773b1
6
6
  def expect_no_js_errors
7
- errors = page.driver.browser.manage.logs.get(:browser)
7
+ errors = page.driver.browser.logs.get(:browser)
8
8
  return if errors.blank?
9
9
 
10
10
  aggregate_failures "javascript errors" do
@@ -17,8 +17,9 @@ module GeocoderHelpers
17
17
  # Waits for the front-end geocoding request to finish in order to ensure there
18
18
  # are no pending requests when proceeding.
19
19
  def fill_in_geocoding(attribute, options = {})
20
- fill_in attribute, options
21
- expect(page).to have_selector(".tribute-container ul#results", count: 1)
20
+ fill_in attribute, **options
21
+ expect(page).to have_selector(".autoComplete_wrapper ul#autoComplete_list_1", count: 1)
22
+ find("li#autoComplete_result_0").click
22
23
  end
23
24
 
24
25
  module_function
@@ -38,6 +39,7 @@ module Decidim::Map::Provider
38
39
  module Geocoding
39
40
  class Test < ::Decidim::Map::Geocoding; end
40
41
  end
42
+
41
43
  module Autocomplete
42
44
  class Test < ::Decidim::Map::Autocomplete
43
45
  def self.stubs
@@ -66,9 +68,11 @@ module Decidim::Map::Provider
66
68
  end
67
69
  end
68
70
  end
71
+
69
72
  module DynamicMap
70
73
  class Test < ::Decidim::Map::DynamicMap; end
71
74
  end
75
+
72
76
  module StaticMap
73
77
  class Test < ::Decidim::Map::StaticMap; end
74
78
  end
@@ -39,6 +39,18 @@ module Decidim::ComponentTestHelpers
39
39
  def have_admin_callout(text)
40
40
  have_selector(".callout--full", text: text)
41
41
  end
42
+
43
+ def stub_get_request_with_format(rq_url, rs_format)
44
+ stub_request(:get, rq_url)
45
+ .with(
46
+ headers: {
47
+ "Accept" => "*/*",
48
+ "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
49
+ "User-Agent" => "Ruby"
50
+ }
51
+ )
52
+ .to_return(status: 200, body: "", headers: { content_type: rs_format })
53
+ end
42
54
  end
43
55
 
44
56
  RSpec.configure do |config|
@@ -2,6 +2,16 @@
2
2
 
3
3
  require "rspec-html-matchers"
4
4
 
5
+ module EscapeHtmlHelpers
6
+ def escaped_html(string)
7
+ CGI.escapeHTML(string)
8
+ end
9
+
10
+ def have_escaped_html(string)
11
+ include(escaped_html(string))
12
+ end
13
+ end
14
+
5
15
  RSpec::Matchers.define(:have_equivalent_markup_to) do |expected|
6
16
  cleaner = ->(str) { str.gsub(/>[[:space:]]*/, ">").gsub(/[[:space:]]*</, "<").strip }
7
17
 
@@ -14,4 +24,5 @@ end
14
24
 
15
25
  RSpec.configure do |config|
16
26
  config.include RSpecHtmlMatchers
27
+ config.include EscapeHtmlHelpers
17
28
  end
@@ -19,14 +19,9 @@ shared_examples "admin imports controller" do
19
19
  end
20
20
 
21
21
  describe "POST create" do
22
- let(:file) do
23
- # The file does not really matter for the dummies creator because it
24
- # will always create a record for each data row regardless of the data.
25
- Rack::Test::UploadedFile.new(
26
- Decidim::Dev.test_file("import_proposals.csv", "text/csv"),
27
- "text/csv"
28
- )
29
- end
22
+ # The file does not really matter for the dummies creator because it
23
+ # will always create a record for each data row regardless of the data.
24
+ let(:file) { upload_test_file(Decidim::Dev.test_file("import_proposals.csv", "text/csv")) }
30
25
  let(:params) do
31
26
  default_params.merge(extra_params).merge(file: file)
32
27
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NetworkConditionsHelpers
4
+ def with_browser_in_offline_mode
5
+ page.driver.browser.network_conditions = { offline: true }
6
+
7
+ # Wait for the browser to be offline
8
+ sleep 1
9
+
10
+ yield
11
+
12
+ page.driver.browser.network_conditions = { offline: false }
13
+ end
14
+ end
15
+
16
+ RSpec.configure do |config|
17
+ config.include NetworkConditionsHelpers, type: :system
18
+ end
@@ -32,7 +32,6 @@ module RakeTaskOutputHelpers
32
32
  included do
33
33
  let!(:original_stdout) { $stdout }
34
34
 
35
- # rubocop:disable RSpec/ExpectOutput
36
35
  before do
37
36
  $stdout = StringIO.new
38
37
  end
@@ -40,7 +39,6 @@ module RakeTaskOutputHelpers
40
39
  after do
41
40
  $stdout = original_stdout
42
41
  end
43
- # rubocop:enable RSpec/ExpectOutput
44
42
  end
45
43
 
46
44
  def check_no_errors_have_been_printed
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "action_dispatch/system_testing/test_helpers/screenshot_helper"
4
+
5
+ module ActionDispatch
6
+ module SystemTesting
7
+ module TestHelpers
8
+ module ScreenshotHelper
9
+ private
10
+
11
+ # Customize the screenshot helper to fix the file paths for examples that have
12
+ # unallowed characters in them. Otherwise the artefacts creation and upload
13
+ # fails at GitHub actions. See the list of unallowed characters from:
14
+ # https://github.com/actions/toolkit/blob/main/packages/artifact/docs/additional-information.md#non-supported-characters
15
+ def image_name
16
+ # By default, this only cleans up the forward and backward slash characters.
17
+ sanitized_method_name = method_name.tr("/\\()\":<>|*?", "-----------")
18
+ name = "#{unique}_#{sanitized_method_name}"
19
+ name[0...225]
20
+ end
21
+
22
+ # Add the file URI scheme so terminal emulators can open one click
23
+ def display_image
24
+ message = +"[Screenshot Image]: file://#{image_path}\n"
25
+ message << +"[Screenshot HTML]: file://#{html_path}\n" if save_html?
26
+
27
+ case output_type
28
+ when "artifact"
29
+ message << "\e]1338;url=artifact://#{absolute_image_path}\a\n"
30
+ when "inline"
31
+ name = inline_base64(File.basename(absolute_image_path))
32
+ image = inline_base64(File.read(absolute_image_path))
33
+ message << "\e]1337;File=name=#{name};height=400px;inline=1:#{image}\a\n"
34
+ end
35
+
36
+ message
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -18,6 +18,7 @@ end
18
18
 
19
19
  RSpec.configure do |config|
20
20
  config.include Decidim::WardenTestHelpers, type: :system
21
+ config.include Decidim::WardenTestHelpers, type: :request
21
22
  config.include Devise::Test::ControllerHelpers, type: :controller
22
23
 
23
24
  config.before :each, type: :cell do
@@ -30,4 +31,8 @@ RSpec.configure do |config|
30
31
  config.after :each, type: :system do
31
32
  Warden.test_reset!
32
33
  end
34
+
35
+ config.after :each, type: :request do
36
+ Warden.test_reset!
37
+ end
33
38
  end
@@ -8,6 +8,10 @@ class WickedPdf
8
8
  def wicked_pdf_stylesheet_pack_tag(*sources)
9
9
  stylesheet_pack_tag(*sources)
10
10
  end
11
+
12
+ # Disables the images in the PDFs as those requests would be jamming under
13
+ # the test environment
14
+ def wicked_pdf_image_tag(img, options = {}); end
11
15
  end
12
16
  end
13
17
  end
@@ -4,7 +4,6 @@ require "rails-controller-testing"
4
4
  require "rspec/rails"
5
5
  require "rspec/cells"
6
6
  require "byebug"
7
- require "rectify/rspec"
8
7
  require "wisper/rspec/stub_wisper_publisher"
9
8
  require "db-query-matchers"
10
9
  require "action_view/helpers/sanitize_helper"
@@ -14,13 +13,13 @@ require "decidim/dev/test/w3c_rspec_validators_overrides"
14
13
 
15
14
  # Requires supporting files with custom matchers and macros, etc,
16
15
  # in ./rspec_support/ and its subdirectories.
17
- Dir["#{__dir__}/rspec_support/**/*.rb"].sort.each { |f| require f }
16
+ Dir["#{__dir__}/rspec_support/**/*.rb"].each { |f| require f }
18
17
 
19
18
  require_relative "factories"
20
19
 
21
20
  RSpec.configure do |config|
22
21
  config.color = true
23
- config.fail_fast = ENV["FAIL_FAST"] == "true"
22
+ config.fail_fast = ENV.fetch("FAIL_FAST", nil) == "true"
24
23
  config.infer_spec_type_from_file_location!
25
24
  config.mock_with :rspec
26
25
  config.order = :random
@@ -32,7 +31,6 @@ RSpec.configure do |config|
32
31
  # instead of true.
33
32
  config.use_transactional_fixtures = true
34
33
 
35
- config.include Rectify::RSpec::Helpers
36
34
  config.include ActionView::Helpers::SanitizeHelper
37
35
  config.include ERB::Util
38
36
  end
@@ -36,12 +36,10 @@ end
36
36
  # This allows us to dynamically load the validator URL from the ENV.
37
37
  module W3cRspecValidators
38
38
  class Config
39
- # rubocop:disable Naming/MemoizedInstanceVariableName
40
39
  def self.get
41
40
  @config ||= {
42
41
  w3c_service_uri: ENV.fetch("VALIDATOR_HTML_URI", "https://validator.w3.org/nu/")
43
42
  }.stringify_keys
44
43
  end
45
- # rubocop:enable Naming/MemoizedInstanceVariableName
46
44
  end
47
45
  end
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-dev version.
5
5
  module Dev
6
6
  def self.version
7
- "0.26.2"
7
+ "0.27.0.rc2"
8
8
  end
9
9
  end
10
10
  end
data/lib/decidim-dev.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "decidim/dev/engine" if Rails.env.development? || ENV["DECIDIM_DEV_ENGINE"]
3
+ require "decidim/dev/engine" if Rails.env.development? || ENV.fetch("DECIDIM_DEV_ENGINE", nil)
@@ -32,7 +32,9 @@ namespace :decidim do
32
32
  "--skip_spring",
33
33
  "--demo",
34
34
  "--force_ssl",
35
- "false"
35
+ "false",
36
+ "--locales",
37
+ "en,ca,es"
36
38
  )
37
39
  end
38
40
 
@@ -48,7 +50,10 @@ namespace :decidim do
48
50
  "--recreate_db",
49
51
  "--seed_db",
50
52
  "--demo",
51
- "--profiling"
53
+ "--profiling",
54
+ "--locales",
55
+ "en,ca,es",
56
+ "--dev_ssl"
52
57
  )
53
58
  end
54
59
  end