decidim-dev 0.26.5 → 0.27.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/commands/decidim/dummy_resources/create_dummy_resource.rb +1 -1
- data/app/controllers/concerns/decidim/dev/needs_development_tools.rb +1 -1
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/ar.yml +1 -0
- data/config/locales/bg.yml +1 -0
- data/config/locales/ca.yml +1 -6
- data/config/locales/cs.yml +1 -6
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +1 -0
- data/config/locales/el.yml +1 -0
- data/config/locales/en.yml +0 -6
- data/config/locales/eo.yml +1 -0
- data/config/locales/es-MX.yml +1 -6
- data/config/locales/es-PY.yml +1 -6
- data/config/locales/es.yml +1 -6
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +1 -0
- data/config/locales/fi-plain.yml +1 -6
- data/config/locales/fi.yml +1 -6
- data/config/locales/fr-CA.yml +1 -6
- data/config/locales/fr.yml +1 -6
- data/config/locales/ga-IE.yml +1 -0
- data/config/locales/gl.yml +1 -0
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +1 -0
- data/config/locales/id-ID.yml +1 -0
- data/config/locales/is-IS.yml +2 -1
- data/config/locales/it.yml +1 -0
- data/config/locales/ja.yml +1 -6
- data/config/locales/ko.yml +1 -0
- data/config/locales/lb.yml +1 -0
- data/config/locales/lt.yml +1 -63
- data/config/locales/lv.yml +1 -0
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +1 -0
- data/config/locales/no.yml +1 -0
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +1 -0
- data/config/locales/pt-BR.yml +2 -1
- data/config/locales/pt.yml +1 -0
- data/config/locales/ro-RO.yml +1 -1
- data/config/locales/ru.yml +1 -0
- data/config/locales/si-LK.yml +1 -0
- data/config/locales/sk.yml +1 -0
- data/config/locales/sl.yml +1 -0
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +1 -0
- data/config/locales/sv.yml +1 -1
- data/config/locales/sw-KE.yml +1 -0
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +1 -0
- data/config/locales/uk.yml +1 -0
- data/config/locales/val-ES.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +1 -0
- data/config/locales/zh-TW.yml +1 -0
- data/lib/decidim/dev/assets/assemblies.json +1 -11
- data/lib/decidim/dev/assets/geocoder_result_here.json +46 -67
- data/lib/decidim/dev/assets/logo.png +0 -0
- data/lib/decidim/dev/common_rake.rb +1 -0
- data/lib/decidim/dev/railtie.rb +1 -1
- data/lib/decidim/dev/test/base_spec_helper.rb +2 -1
- data/lib/decidim/dev/test/rspec_support/accessibility_examples.rb +1 -3
- data/lib/decidim/dev/test/rspec_support/attachment_helpers.rb +30 -0
- data/lib/decidim/dev/test/rspec_support/autocomplete_select.rb +23 -0
- data/lib/decidim/dev/test/rspec_support/capybara.rb +43 -5
- data/lib/decidim/dev/test/rspec_support/comments.rb +1 -1
- data/lib/decidim/dev/test/rspec_support/component.rb +5 -5
- data/lib/decidim/dev/test/rspec_support/controller_example_group.rb +27 -0
- data/lib/decidim/dev/test/rspec_support/cookies.rb +41 -0
- data/lib/decidim/dev/test/rspec_support/dynamic_attach.rb +31 -0
- data/lib/decidim/dev/test/rspec_support/frontend.rb +1 -1
- data/lib/decidim/dev/test/rspec_support/geocoder.rb +6 -2
- data/lib/decidim/dev/test/rspec_support/helpers.rb +0 -12
- data/lib/decidim/dev/test/rspec_support/html_matchers.rb +11 -0
- data/lib/decidim/dev/test/rspec_support/imports_controller_shared_examples.rb +3 -8
- data/lib/decidim/dev/test/rspec_support/network_conditions_helpers.rb +18 -0
- data/lib/decidim/dev/test/rspec_support/rake_tasks.rb +0 -2
- data/lib/decidim/dev/test/rspec_support/screenshot_helper.rb +41 -0
- data/lib/decidim/dev/test/rspec_support/warden.rb +5 -0
- data/lib/decidim/dev/test/rspec_support/wicked_pdf_assets_mock.rb +4 -0
- data/lib/decidim/dev/test/spec_helper.rb +2 -4
- data/lib/decidim/dev/test/w3c_rspec_validators_overrides.rb +0 -2
- data/lib/decidim/dev/version.rb +1 -1
- data/lib/decidim-dev.rb +1 -1
- data/lib/tasks/generators.rake +6 -2
- data/lib/tasks/lighthouse_report.rake +29 -0
- data/lib/tasks/locale_checker.rake +1 -1
- metadata +48 -45
- data/config/locales/gn-PY.yml +0 -1
- data/config/locales/ka-GE.yml +0 -1
- data/config/locales/lo-LA.yml +0 -1
- data/config/locales/oc-FR.yml +0 -1
- data/lib/decidim/dev/test/rspec_support/react_select.rb +0 -29
@@ -1,72 +1,51 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
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
|
-
"
|
21
|
+
"position": {
|
22
|
+
"lat": 48.86926,
|
23
|
+
"lng": 2.3321
|
24
|
+
},
|
25
|
+
"access": [
|
7
26
|
{
|
8
|
-
"
|
9
|
-
"
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
data/lib/decidim/dev/railtie.rb
CHANGED
@@ -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"].
|
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.
|
@@ -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
|
-
|
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
|
-
|
80
|
+
capabilities: [options]
|
53
81
|
)
|
54
82
|
end
|
55
83
|
|
56
|
-
Capybara.server = :puma, { Silent: true,
|
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.
|
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
|
@@ -89,7 +89,7 @@ module Decidim
|
|
89
89
|
include Followable
|
90
90
|
include Traceable
|
91
91
|
include Publicable
|
92
|
-
include Decidim::
|
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 :
|
240
|
-
settings.attribute :
|
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 :
|
250
|
-
settings.attribute :
|
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 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.
|
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(".
|
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,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
|
-
|
23
|
-
|
24
|
-
|
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
|