decidim-dev 0.26.10 → 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
@@ -1,3 +1,4 @@
1
+ ---
1
2
  sv:
2
3
  activemodel:
3
4
  attributes:
@@ -14,8 +15,6 @@ sv:
14
15
  dummy:
15
16
  settings:
16
17
  global:
17
- guided: Guidad ingång
18
- guided_help: Hjälptext
19
18
  readonly_attribute: Skrivskyddat attribut
20
19
  test: Ett test
21
20
  test_choices:
@@ -1 +1,2 @@
1
+ ---
1
2
  sw:
@@ -1 +1,2 @@
1
+ ---
1
2
  ti:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  tr:
2
3
  activemodel:
3
4
  attributes:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  uk:
2
3
  activemodel:
3
4
  attributes:
@@ -1 +1,2 @@
1
+ ---
1
2
  val:
@@ -1 +1,2 @@
1
+ ---
1
2
  vi:
@@ -1,3 +1,4 @@
1
+ ---
1
2
  zh-CN:
2
3
  activemodel:
3
4
  attributes:
@@ -1,64 +1,2 @@
1
+ ---
1
2
  zh-TW:
2
- activemodel:
3
- attributes:
4
- dummy_resource:
5
- created_at: 建立於
6
- decidim_scope_id: 範圍
7
- field: 我的欄位
8
- start_date: 開始日期
9
- title: 標題
10
- translatable_text: 可翻譯的文字
11
- updated_at: 更新於
12
- decidim:
13
- components:
14
- dummy:
15
- settings:
16
- global:
17
- guided: 導引輸入
18
- guided_help: 說明文字
19
- guided_readonly: 禁用輸入
20
- guided_rich: 導引豐富輸入
21
- guided_rich_help_html: HTML <strong>說明</strong> 文字
22
- guided_rich_readonly_html: 禁用輸入 HTML <strong>說明</strong> 文字
23
- readonly_attribute: 唯讀屬性
24
- test: A 測試
25
- test_choices:
26
- a: A選項
27
- b: B選項
28
- c: C選項
29
- test_options:
30
- bar: Bar
31
- baz: Baz
32
- foo: Foo
33
- step:
34
- endorsements_blocked: 封鎖支持
35
- endorsements_enabled: 啟用支持
36
- readonly_step_attribute: 唯讀步驟屬性
37
- test_options:
38
- bar: Bar
39
- baz: Baz
40
- foo: Foo
41
- dummy:
42
- admin:
43
- exports:
44
- dummies: 測試帳戶
45
- gamification:
46
- badges:
47
- test:
48
- conditions:
49
- - 在Decidim中使用測試環境。
50
- description: 參與者通過建立測試可獲得此徽章。
51
- description_another: 此參與者已建立了 %{score} 個測試。
52
- description_own: 您已建立了 %{score} 個測試。
53
- name: 測試
54
- next_level_in: 再建立 %{score} 個測試即可達到下一個等級!
55
- unearned_another: 這個參與者尚未創建任何測試。
56
- unearned_own: 您尚未建立任何測試。
57
- resource_links:
58
- test_link:
59
- dummy_resource_dummy: 相關的測試帳戶
60
- statistics:
61
- bar: Bar
62
- dummies_count_high: 高級測試帳戶
63
- dummies_count_medium: 中級測試帳戶
64
- foo: Foo
@@ -512,17 +512,7 @@
512
512
  },
513
513
  "weight": 0,
514
514
  "permissions": null,
515
- "published_at": "2020-01-22 07:55:04 UTC",
516
- "specific_data": {
517
- "body": {
518
- "en": "English content",
519
- "ca": "Catalan content",
520
- "es": "Spanish content",
521
- "machine_translations": {
522
- "es": "Machine translation spanish content"
523
- }
524
- }
525
- }
515
+ "published_at": "2020-01-22 07:55:04 UTC"
526
516
  },
527
517
  {
528
518
  "manifest_name": "proposals",
@@ -1,72 +1,51 @@
1
1
  {
2
- "Response": {
3
- "MetaInfo": {
4
- "Timestamp": "2013-02-08T16:26:39.382+0000"
2
+ "items": [
3
+ {
4
+ "title": "5 Rue Daunou, 75002 Paris, France",
5
+ "id": "here:af:streetsection:bI4Le6cyA.1mlQyLunYpjC:CggIBCCi-9SPARABGgE1KGQ",
6
+ "resultType": "houseNumber",
7
+ "houseNumberType": "PA",
8
+ "address": {
9
+ "label": "5 Rue Daunou, 75002 Paris, France",
10
+ "countryCode": "FRA",
11
+ "countryName": "France",
12
+ "stateCode": "IDF",
13
+ "state": "Île-de-France",
14
+ "county": "Paris",
15
+ "city": "Paris",
16
+ "district": "2e Arrondissement",
17
+ "street": "Rue Daunou",
18
+ "postalCode": "75002",
19
+ "houseNumber": "5"
5
20
  },
6
- "View": [
21
+ "position": {
22
+ "lat": 48.86926,
23
+ "lng": 2.3321
24
+ },
25
+ "access": [
7
26
  {
8
- "_type": "SearchResultsViewType",
9
- "ViewId": 0,
10
- "Result": [
11
- {
12
- "Relevance": 1.0,
13
- "MatchLevel": "houseNumber",
14
- "MatchQuality": {
15
- "State": 1.0,
16
- "City": 1.0,
17
- "Street": [
18
- 1.0
19
- ],
20
- "HouseNumber": 1.0
21
- },
22
- "MatchType": "pointAddress",
23
- "Location": {
24
- "LocationId": "NT_ArsGdYbpo6dqjPQel9gTID_4",
25
- "LocationType": "point",
26
- "DisplayPosition": {
27
- "Latitude": 40.7504692,
28
- "Longitude": -73.9933777
29
- },
30
- "NavigationPosition": [
31
- {
32
- "Latitude": 40.7500305,
33
- "Longitude": -73.9942398
34
- }
35
- ],
36
- "MapView": {
37
- "TopLeft": {
38
- "Latitude": 40.7515934,
39
- "Longitude": -73.9948616
40
- },
41
- "BottomRight": {
42
- "Latitude": 40.7493451,
43
- "Longitude": -73.9918938
44
- }
45
- },
46
- "Address": {
47
- "Label": "4 Penn Plz, New York, NY 10001, United States",
48
- "Country": "USA",
49
- "State": "NY",
50
- "County": "New York",
51
- "City": "New York",
52
- "Street": "Penn Plz",
53
- "HouseNumber": "4",
54
- "PostalCode": "10001",
55
- "AdditionalData": [
56
- {
57
- "value": "United States",
58
- "key": "CountryName"
59
- },
60
- {
61
- "value": "New York",
62
- "key": "StateName"
63
- }
64
- ]
65
- }
66
- }
67
- }
68
- ]
27
+ "lat": 48.86931,
28
+ "lng": 2.33215
29
+ }
30
+ ],
31
+ "mapView": {
32
+ "west": 2.33073,
33
+ "south": 48.86836,
34
+ "east": 2.33347,
35
+ "north": 48.87016
36
+ },
37
+ "scoring": {
38
+ "queryScore": 0.97,
39
+ "fieldScore": {
40
+ "country": 1,
41
+ "city": 1,
42
+ "streets": [
43
+ 1
44
+ ],
45
+ "houseNumber": 1,
46
+ "postalCode": 0.82
69
47
  }
70
- ]
48
+ }
71
49
  }
72
- }
50
+ ]
51
+ }
Binary file
@@ -3,6 +3,7 @@
3
3
  require "bundler/gem_tasks"
4
4
  require "rspec/core/rake_task"
5
5
  require "decidim/dev"
6
+ require "parallel_tests/tasks"
6
7
 
7
8
  RSpec::Core::RakeTask.new(:spec) do |t|
8
9
  t.rspec_opts = "--format progress --format RspecJunitFormatter -o ~/rspec/rspec.xml" if ENV["CI"]
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rails"
3
+ require "decidim/rails"
4
4
 
5
5
  module Decidim
6
6
  module Dev
@@ -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
 
@@ -2,9 +2,7 @@
2
2
 
3
3
  shared_examples_for "accessible page" do
4
4
  it "passes accessibility tests" do
5
- expect(page).to be_axe_clean.excluding(
6
- 'a[title="Find out more about cookies"]'
7
- )
5
+ expect(page).to be_axe_clean
8
6
  end
9
7
 
10
8
  it "passes HTML validation" do
@@ -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.
@@ -32,11 +31,40 @@ Capybara.register_driver :headless_chrome do |app|
32
31
  else
33
32
  "--window-size=1920,1080"
34
33
  end
34
+ Capybara::Selenium::Driver.new(
35
+ app,
36
+ browser: :chrome,
37
+ capabilities: [options]
38
+ )
39
+ end
40
+
41
+ Capybara.server_port = rand(5000..6999)
42
+
43
+ # In order to work with PWA apps, Chrome can't be run in headless mode, and requires
44
+ # setting up special prefs and flags
45
+ Capybara.register_driver :pwa_chrome do |app|
46
+ options = ::Selenium::WebDriver::Chrome::Options.new
47
+ options.args << "--no-sandbox"
48
+ # Don't limit browser resources
49
+ options.args << "--disable-dev-shm-usage"
50
+ # Add pwa.lvh.me host as a secure origin
51
+ options.args << "--unsafely-treat-insecure-origin-as-secure=http://pwa.lvh.me:#{Capybara.server_port}"
52
+ # User data flag is mandatory when preferences and locale state is set
53
+ options.args << "--user-data-dir=/tmp/decidim_tests_user_data_#{rand(1000)}"
54
+ options.args << if ENV["BIG_SCREEN_SIZE"].present?
55
+ "--window-size=1920,3000"
56
+ else
57
+ "--window-size=1920,1080"
58
+ end
59
+ # Set notifications allowed in http protocol
60
+ options.local_state["browser.enabled_labs_experiments"] = ["enable-system-notifications@1", "unsafely-treat-insecure-origin-as-secure"]
61
+ # Mark notification permission as enabled
62
+ options.prefs["profile.default_content_setting_values.notifications"] = 1
35
63
 
36
64
  Capybara::Selenium::Driver.new(
37
65
  app,
38
66
  browser: :chrome,
39
- options: options
67
+ capabilities: [options]
40
68
  )
41
69
  end
42
70
 
@@ -49,11 +77,11 @@ Capybara.register_driver :iphone do |app|
49
77
  Capybara::Selenium::Driver.new(
50
78
  app,
51
79
  browser: :chrome,
52
- options: options
80
+ capabilities: [options]
53
81
  )
54
82
  end
55
83
 
56
- Capybara.server = :puma, { Silent: true, Threads: "1:1" }
84
+ Capybara.server = :puma, { Silent: true, queue_requests: false }
57
85
 
58
86
  Capybara.asset_host = "http://localhost:3000"
59
87
 
@@ -65,6 +93,16 @@ RSpec.configure do |config|
65
93
  config.before :each, type: :system do
66
94
  driven_by(:headless_chrome)
67
95
  switch_to_default_host
96
+ domain = (try(:organization) || try(:current_organization))&.host
97
+ if domain
98
+ page.driver.browser.execute_cdp(
99
+ "Network.setCookie",
100
+ domain: domain,
101
+ name: Decidim.consent_cookie_name,
102
+ value: { essential: true }.to_json,
103
+ path: "/"
104
+ )
105
+ end
68
106
  end
69
107
 
70
108
  config.before :each, driver: :rack_test do
@@ -80,7 +118,7 @@ RSpec.configure do |config|
80
118
  end
81
119
 
82
120
  config.after(type: :system) do |example|
83
- warn page.driver.browser.manage.logs.get(:browser) unless example.metadata[:driver].eql?(:rack_test)
121
+ warn page.driver.browser.logs.get(:browser) unless example.metadata[:driver].eql?(:rack_test)
84
122
  end
85
123
 
86
124
  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
@@ -1,25 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- shared_examples "has mandatory config setting" do |mandatory_field|
4
- let(:edit_component_path) do
5
- Decidim::EngineRouter.admin_proxy(component.participatory_space).edit_component_path(component.id)
6
- end
7
-
8
- before do
9
- visit edit_component_path
10
- component.update(settings: { mandatory_field => "" })
11
- visit edit_component_path
12
- end
13
-
14
- it "does not allow updating the component" do
15
- click_button "Update"
16
-
17
- within ".#{mandatory_field}_container" do
18
- expect(page).to have_content("There's an error in this field")
19
- end
20
- end
21
- end
22
-
23
3
  shared_context "with a component" do
24
4
  let(:manifest) { Decidim.find_component_manifest(manifest_name) }
25
5
  let(:user) { create :user, :confirmed, organization: organization }
@@ -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 Cookies
5
+ # Update cookie consent
6
+ def select_cookies(cookies = "all", options = {})
7
+ visit decidim.root_path if options[:visit_root]
8
+
9
+ dialog_present = begin
10
+ find("#cc-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?(cookies)
24
+ click_button "Accept all"
25
+ elsif cookies.is_a?(Array)
26
+ cookies.each do |cookie|
27
+ within "[data-id='#{cookie}']" do
28
+ find(".switch-paddle").click
29
+ end
30
+ end
31
+ click_button "Save settings"
32
+ elsif [false, "essential"].include?(cookies)
33
+ click_button "Accept only essential"
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ RSpec.configure do |config|
40
+ config.include Capybara::Cookies, 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