decidim-dev 0.26.9 → 0.27.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) 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/assets.rb +1 -2
  5. data/config/locales/am-ET.yml +1 -0
  6. data/config/locales/ar.yml +1 -18
  7. data/config/locales/bg.yml +1 -0
  8. data/config/locales/ca.yml +1 -6
  9. data/config/locales/cs.yml +5 -10
  10. data/config/locales/da.yml +1 -0
  11. data/config/locales/de.yml +2 -9
  12. data/config/locales/el.yml +1 -0
  13. data/config/locales/en.yml +0 -6
  14. data/config/locales/eo.yml +1 -0
  15. data/config/locales/es-MX.yml +1 -6
  16. data/config/locales/es-PY.yml +1 -6
  17. data/config/locales/es.yml +1 -6
  18. data/config/locales/et.yml +1 -0
  19. data/config/locales/eu.yml +9 -14
  20. data/config/locales/fi-plain.yml +1 -6
  21. data/config/locales/fi.yml +1 -6
  22. data/config/locales/fr-CA.yml +1 -6
  23. data/config/locales/fr.yml +1 -6
  24. data/config/locales/ga-IE.yml +1 -0
  25. data/config/locales/gl.yml +1 -0
  26. data/config/locales/hr.yml +1 -0
  27. data/config/locales/hu.yml +1 -0
  28. data/config/locales/id-ID.yml +1 -0
  29. data/config/locales/is-IS.yml +2 -1
  30. data/config/locales/it.yml +1 -0
  31. data/config/locales/ja.yml +1 -6
  32. data/config/locales/ko.yml +1 -0
  33. data/config/locales/lb.yml +1 -0
  34. data/config/locales/lt.yml +1 -63
  35. data/config/locales/lv.yml +1 -0
  36. data/config/locales/mt.yml +1 -0
  37. data/config/locales/nl.yml +1 -0
  38. data/config/locales/no.yml +1 -0
  39. data/config/locales/om-ET.yml +1 -0
  40. data/config/locales/pl.yml +1 -0
  41. data/config/locales/pt-BR.yml +2 -7
  42. data/config/locales/pt.yml +1 -0
  43. data/config/locales/ro-RO.yml +1 -6
  44. data/config/locales/ru.yml +1 -0
  45. data/config/locales/si-LK.yml +1 -0
  46. data/config/locales/sk.yml +1 -0
  47. data/config/locales/sl.yml +1 -0
  48. data/config/locales/so-SO.yml +1 -0
  49. data/config/locales/sr-CS.yml +1 -0
  50. data/config/locales/sv.yml +1 -2
  51. data/config/locales/sw-KE.yml +1 -0
  52. data/config/locales/ti-ER.yml +1 -0
  53. data/config/locales/tr-TR.yml +1 -0
  54. data/config/locales/uk.yml +1 -0
  55. data/config/locales/val-ES.yml +1 -0
  56. data/config/locales/vi.yml +1 -0
  57. data/config/locales/zh-CN.yml +1 -0
  58. data/config/locales/zh-TW.yml +1 -63
  59. data/lib/decidim/dev/assets/assemblies.json +1 -11
  60. data/lib/decidim/dev/assets/geocoder_result_here.json +46 -67
  61. data/lib/decidim/dev/assets/logo.png +0 -0
  62. data/lib/decidim/dev/common_rake.rb +1 -0
  63. data/lib/decidim/dev/railtie.rb +1 -1
  64. data/lib/decidim/dev/test/base_spec_helper.rb +2 -1
  65. data/lib/decidim/dev/test/rspec_support/accessibility_examples.rb +1 -3
  66. data/lib/decidim/dev/test/rspec_support/attachment_helpers.rb +30 -0
  67. data/lib/decidim/dev/test/rspec_support/autocomplete_select.rb +23 -0
  68. data/lib/decidim/dev/test/rspec_support/capybara.rb +43 -5
  69. data/lib/decidim/dev/test/rspec_support/comments.rb +1 -1
  70. data/lib/decidim/dev/test/rspec_support/component.rb +5 -5
  71. data/lib/decidim/dev/test/rspec_support/component_context.rb +0 -20
  72. data/lib/decidim/dev/test/rspec_support/controller_example_group.rb +27 -0
  73. data/lib/decidim/dev/test/rspec_support/cookies.rb +41 -0
  74. data/lib/decidim/dev/test/rspec_support/dynamic_attach.rb +31 -0
  75. data/lib/decidim/dev/test/rspec_support/frontend.rb +1 -1
  76. data/lib/decidim/dev/test/rspec_support/geocoder.rb +10 -6
  77. data/lib/decidim/dev/test/rspec_support/helpers.rb +0 -12
  78. data/lib/decidim/dev/test/rspec_support/html_matchers.rb +11 -0
  79. data/lib/decidim/dev/test/rspec_support/imports_controller_shared_examples.rb +3 -8
  80. data/lib/decidim/dev/test/rspec_support/network_conditions_helpers.rb +18 -0
  81. data/lib/decidim/dev/test/rspec_support/rake_tasks.rb +0 -2
  82. data/lib/decidim/dev/test/rspec_support/screenshot_helper.rb +41 -0
  83. data/lib/decidim/dev/test/rspec_support/warden.rb +5 -0
  84. data/lib/decidim/dev/test/rspec_support/wicked_pdf_assets_mock.rb +4 -0
  85. data/lib/decidim/dev/test/spec_helper.rb +2 -4
  86. data/lib/decidim/dev/test/w3c_rspec_validators_overrides.rb +0 -2
  87. data/lib/decidim/dev/version.rb +1 -1
  88. data/lib/decidim-dev.rb +1 -1
  89. data/lib/tasks/generators.rake +6 -2
  90. data/lib/tasks/lighthouse_report.rake +29 -0
  91. data/lib/tasks/locale_checker.rake +1 -1
  92. metadata +48 -66
  93. data/app/packs/entrypoints/decidim_dev_test_custom_map.js +0 -1
  94. data/app/packs/src/decidim/dev/test/custom_map_factory.js +0 -55
  95. data/config/environment.rb +0 -3
  96. data/config/locales/fa-IR.yml +0 -1
  97. data/config/locales/gn-PY.yml +0 -1
  98. data/config/locales/ka-GE.yml +0 -1
  99. data/config/locales/kaa.yml +0 -1
  100. data/config/locales/lo-LA.yml +0 -1
  101. data/config/locales/oc-FR.yml +0 -1
  102. data/config/locales/sq-AL.yml +0 -1
  103. data/config/locales/th-TH.yml +0 -1
  104. data/lib/decidim/dev/test/rspec_support/react_select.rb +0 -29
@@ -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
@@ -47,7 +49,7 @@ module Decidim::Map::Provider
47
49
  def self.add_stub(address, coordinates)
48
50
  stubs.push(
49
51
  properties: address.is_a?(Hash) ? address : { street: address },
50
- geometry: { coordinates: coordinates.reverse }
52
+ geometry: { coordinates: coordinates }
51
53
  )
52
54
  end
53
55
 
@@ -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
@@ -121,7 +125,7 @@ RSpec.configure do |config|
121
125
  country: "Country1"
122
126
  },
123
127
  geometry: {
124
- coordinates: [2.234, 1.123]
128
+ coordinates: [1.123, 2.234]
125
129
  }
126
130
  },
127
131
  {
@@ -132,7 +136,7 @@ RSpec.configure do |config|
132
136
  country: "Country2"
133
137
  },
134
138
  geometry: {
135
- coordinates: [4.456, 3.345]
139
+ coordinates: [3.345, 4.456]
136
140
  }
137
141
  },
138
142
  {
@@ -144,7 +148,7 @@ RSpec.configure do |config|
144
148
  country: "Country3"
145
149
  },
146
150
  geometry: {
147
- coordinates: [6.678, 5.567]
151
+ coordinates: [5.567, 6.678]
148
152
  }
149
153
  }
150
154
  ]
@@ -39,18 +39,6 @@ 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
54
42
  end
55
43
 
56
44
  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.9"
7
+ "0.27.0.rc1"
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,9 @@ namespace :decidim do
48
50
  "--recreate_db",
49
51
  "--seed_db",
50
52
  "--demo",
51
- "--profiling"
53
+ "--profiling",
54
+ "--locales",
55
+ "en,ca,es"
52
56
  )
53
57
  end
54
58
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :decidim do
4
+ namespace :lighthouse do
5
+ desc "Prepares seeds for Lighthouse report"
6
+ task prepare_urls: :environment do
7
+ # Lighhouse report is executed in CI and should check:
8
+ # - homepage
9
+ # - a participatory process page
10
+ # - a meeting page
11
+ # - a proposal page
12
+ #
13
+ # Because seeds make urls dynamic, this task updates the lighthouse configuration
14
+ # to add dynamically the urls to check.
15
+
16
+ host = "http://localhost:3000"
17
+ urls = ["/"]
18
+ urls << ::Decidim::ResourceLocatorPresenter.new(Decidim::ParticipatoryProcess.published.first).path
19
+ urls << ::Decidim::ResourceLocatorPresenter.new(Decidim::Meetings::Meeting.published.first).path
20
+ urls << ::Decidim::ResourceLocatorPresenter.new(Decidim::Proposals::Proposal.published.first).path
21
+
22
+ # Update lighthouse configuration with the urls
23
+ lighthouse_rc_path = Rails.root.join("../.lighthouserc.json")
24
+ lighthouserc = JSON.parse(File.read(lighthouse_rc_path))
25
+ lighthouserc["ci"]["collect"]["url"] = urls.map { |url| "#{host}#{url}" }
26
+ File.write(lighthouse_rc_path, lighthouserc.to_json)
27
+ end
28
+ end
29
+ end
@@ -5,7 +5,7 @@ namespace :decidim do
5
5
  task check_locales: :environment do
6
6
  FileUtils.remove_dir("tmp/decidim_repo", true)
7
7
 
8
- branch = ENV["TARGET_BRANCH"] || "develop"
8
+ branch = ENV.fetch("TARGET_BRANCH", nil) || "develop"
9
9
  status = system("git clone --depth=1 --single-branch --branch #{branch} https://github.com/decidim/decidim tmp/decidim_repo")
10
10
  return unless status
11
11