decidim-dev 0.28.6 → 0.29.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/decidim/dev/dummy_resource.rb +2 -2
- data/app/packs/stylesheets/decidim/dev/_accessibility.scss +1 -1
- data/app/packs/stylesheets/decidim/dev/_bullet.scss +4 -0
- data/app/packs/stylesheets/decidim/dev/_rack_profiler.scss +4 -0
- data/app/packs/stylesheets/decidim/dev.scss +2 -0
- data/config/locales/ar.yml +0 -3
- data/config/locales/ca.yml +0 -3
- data/config/locales/cs.yml +0 -3
- data/config/locales/de.yml +0 -3
- data/config/locales/en.yml +0 -3
- data/config/locales/es-MX.yml +0 -3
- data/config/locales/es-PY.yml +0 -3
- data/config/locales/es.yml +0 -3
- data/config/locales/eu.yml +3 -6
- data/config/locales/fi-plain.yml +0 -3
- data/config/locales/fi.yml +0 -3
- data/config/locales/fr-CA.yml +0 -3
- data/config/locales/fr.yml +0 -3
- data/config/locales/ja.yml +0 -3
- data/config/locales/ro-RO.yml +1 -1
- data/config/locales/sv.yml +8 -16
- data/config/rubocop/disabled.yml +60 -0
- data/config/rubocop/performance.yml +154 -0
- data/config/rubocop/rspec.yml +7 -2
- data/config/rubocop/ruby.yml +5 -5
- data/decidim-dev.gemspec +12 -9
- data/lib/decidim/dev/assets/assemblies.json +1 -34
- data/lib/decidim/dev/assets/assemblies_with_null.json +1 -2
- data/lib/decidim/dev/assets/participatory_processes.json +1 -34
- data/lib/decidim/dev/assets/participatory_processes_with_null.json +0 -1
- data/lib/decidim/dev/assets/participatory_text.md +0 -2
- data/lib/decidim/dev/component.rb +2 -3
- data/lib/decidim/dev/dummy_translator.rb +1 -1
- data/lib/decidim/dev/engine.rb +11 -0
- data/lib/decidim/dev/test/map_server.rb +125 -0
- data/lib/decidim/dev/test/rspec_support/attachment_helpers.rb +3 -1
- data/lib/decidim/dev/test/rspec_support/autocomplete_select.rb +2 -2
- data/lib/decidim/dev/test/rspec_support/bullet.rb +4 -0
- data/lib/decidim/dev/test/rspec_support/capybara.rb +18 -8
- data/lib/decidim/dev/test/rspec_support/cell_matchers.rb +1 -1
- data/lib/decidim/dev/test/rspec_support/component_context.rb +1 -1
- data/lib/decidim/dev/test/rspec_support/data_consent.rb +6 -6
- data/lib/decidim/dev/test/rspec_support/datepicker_date_fill.rb +25 -0
- data/lib/decidim/dev/test/rspec_support/datepicker_time_fill.rb +23 -0
- data/lib/decidim/dev/test/rspec_support/dynamic_attach.rb +2 -2
- data/lib/decidim/dev/test/rspec_support/geocoder.rb +8 -85
- data/lib/decidim/dev/test/rspec_support/helpers.rb +4 -4
- data/lib/decidim/dev/test/rspec_support/tom_select.rb +1 -1
- data/lib/decidim/dev/test/rspec_support/translation_helpers.rb +5 -6
- data/lib/decidim/dev/test/rspec_support/warden.rb +0 -1
- data/lib/decidim/dev/test/rspec_support/webmock.rb +7 -1
- data/lib/decidim/dev/test/rspec_support/wicked_pdf_assets_mock.rb +2 -2
- data/lib/decidim/dev/test/spec_helper.rb +2 -8
- data/lib/decidim/dev/version.rb +1 -1
- data/lib/decidim/dev.rb +0 -10
- data/lib/decidim-dev.rb +2 -0
- data/lib/tasks/lighthouse_report.rake +1 -1
- data/rubocop-decidim.yml +6 -0
- metadata +85 -46
- data/app/permissions/decidim/dev/permissions.rb +0 -22
- data/app/presenters/decidim/dev/dummy_resource_presenter.rb +0 -13
- data/config/locales/bn-BD.yml +0 -1
- data/config/locales/bs-BA.yml +0 -9
- data/config/locales/ca-IT.yml +0 -68
- data/lib/decidim/dev/assets/invalid_extension.log +0 -1
- data/lib/decidim/dev/assets/odt_file_reported_as.pdf +0 -0
- data/lib/decidim/dev/auth_engine.rb +0 -33
- data/lib/decidim/dev/test/rspec_support/activestorage_matchers.rb +0 -148
- /data/app/views/decidim/dummy_resource/{_linked_dummys.html.erb → _linked_dummies.html.erb} +0 -0
@@ -48,7 +48,7 @@
|
|
48
48
|
"es": "Incidunt provident doloremque."
|
49
49
|
},
|
50
50
|
"decidim_scope_id": null,
|
51
|
-
"
|
51
|
+
"participatory_scope": {
|
52
52
|
"ca": "Assumenda.",
|
53
53
|
"en": "Quidem.",
|
54
54
|
"es": "Aspernatur."
|
@@ -58,7 +58,6 @@
|
|
58
58
|
"en": "Vel qui.",
|
59
59
|
"es": "Et molestiae."
|
60
60
|
},
|
61
|
-
"show_statistics": false,
|
62
61
|
"scopes_enabled": true,
|
63
62
|
"private_space": false,
|
64
63
|
"reference": "PhD-ASSE-2020-01-1",
|
@@ -91,7 +91,6 @@
|
|
91
91
|
"private_space": false,
|
92
92
|
"promoted": true,
|
93
93
|
"scopes_enabled": true,
|
94
|
-
"show_statistics": true,
|
95
94
|
"participatory_process_steps": [
|
96
95
|
{
|
97
96
|
"id": 1,
|
@@ -340,38 +339,6 @@
|
|
340
339
|
"intro_en": "<p>Voluptatem praesentium maxime vitae.</p>",
|
341
340
|
"intro_ca": "<p>Sapiente animi quo at.</p>",
|
342
341
|
"intro_es": "<p>Illum veritatis porro nulla.</p>",
|
343
|
-
"categories_label": {
|
344
|
-
"ca": "alias",
|
345
|
-
"en": "aut",
|
346
|
-
"es": "omnis"
|
347
|
-
},
|
348
|
-
"categories_label_en": "aut",
|
349
|
-
"categories_label_ca": "alias",
|
350
|
-
"categories_label_es": "omnis",
|
351
|
-
"subcategories_label": {
|
352
|
-
"ca": "rerum",
|
353
|
-
"en": "reprehenderit",
|
354
|
-
"es": "nostrum"
|
355
|
-
},
|
356
|
-
"subcategories_label_en": "reprehenderit",
|
357
|
-
"subcategories_label_ca": "rerum",
|
358
|
-
"subcategories_label_es": "nostrum",
|
359
|
-
"heading_parent_level_results": {
|
360
|
-
"ca": "et",
|
361
|
-
"en": "explicabo",
|
362
|
-
"es": "officiis"
|
363
|
-
},
|
364
|
-
"heading_parent_level_results_en": "explicabo",
|
365
|
-
"heading_parent_level_results_ca": "et",
|
366
|
-
"heading_parent_level_results_es": "officiis",
|
367
|
-
"heading_leaf_level_results": {
|
368
|
-
"ca": "consectetur",
|
369
|
-
"en": "illum",
|
370
|
-
"es": "sunt"
|
371
|
-
},
|
372
|
-
"heading_leaf_level_results_en": "illum",
|
373
|
-
"heading_leaf_level_results_ca": "consectetur",
|
374
|
-
"heading_leaf_level_results_es": "sunt",
|
375
342
|
"display_progress_enabled": true
|
376
343
|
},
|
377
344
|
"weight": 0,
|
@@ -431,4 +398,4 @@
|
|
431
398
|
}
|
432
399
|
]
|
433
400
|
}
|
434
|
-
]
|
401
|
+
]
|
@@ -8,7 +8,6 @@ Decidim.register_component(:dummy) do |component|
|
|
8
8
|
component.actions = %w(foo bar)
|
9
9
|
|
10
10
|
component.newsletter_participant_entities = ["Decidim::Dev::DummyResource"]
|
11
|
-
component.permissions_class_name = "Decidim::Dev::Permissions"
|
12
11
|
|
13
12
|
component.settings(:global) do |settings|
|
14
13
|
settings.attribute :scopes_enabled, type: :boolean, default: false
|
@@ -41,7 +40,7 @@ Decidim.register_component(:dummy) do |component|
|
|
41
40
|
component.register_resource(:dummy_resource) do |resource|
|
42
41
|
resource.name = :dummy
|
43
42
|
resource.model_class_name = "Decidim::Dev::DummyResource"
|
44
|
-
resource.template = "decidim/dummy_resource/
|
43
|
+
resource.template = "decidim/dummy_resource/linked_dummies"
|
45
44
|
resource.actions = %w(foo)
|
46
45
|
resource.searchable = true
|
47
46
|
end
|
@@ -54,7 +53,7 @@ Decidim.register_component(:dummy) do |component|
|
|
54
53
|
component.register_resource(:coauthorable_dummy_resource) do |resource|
|
55
54
|
resource.name = :coauthorable_dummy
|
56
55
|
resource.model_class_name = "Decidim::Dev::CoauthorableDummyResource"
|
57
|
-
resource.template = "decidim/coauthorabledummy_resource/
|
56
|
+
resource.template = "decidim/coauthorabledummy_resource/linked_dummies"
|
58
57
|
resource.actions = %w(foo-coauthorable)
|
59
58
|
resource.searchable = false
|
60
59
|
end
|
data/lib/decidim/dev/engine.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "decidim/dev/needs_development_tools"
|
4
|
+
|
3
5
|
module Decidim
|
4
6
|
module Dev
|
5
7
|
# Decidim's development Rails Engine.
|
@@ -27,6 +29,15 @@ module Decidim
|
|
27
29
|
Decidim.register_assets_path File.expand_path("app/packs", root)
|
28
30
|
end
|
29
31
|
|
32
|
+
initializer "decidim_dev.middleware.test_map_server" do |app|
|
33
|
+
next unless Rails.env.test?
|
34
|
+
|
35
|
+
require "decidim/dev/test/map_server"
|
36
|
+
|
37
|
+
# Add the test map server as the first middleware in the stack
|
38
|
+
app.config.middleware.insert_before 0, Decidim::Dev::Test::MapServer
|
39
|
+
end
|
40
|
+
|
30
41
|
initializer "decidim_dev.moderation_content" do
|
31
42
|
config.to_prepare do
|
32
43
|
ActiveSupport::Notifications.subscribe("decidim.admin.block_user:after") do |_event_name, data|
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Dev
|
5
|
+
module Test
|
6
|
+
# The test map server serves all map related requests for the app.
|
7
|
+
#
|
8
|
+
# Works as a rack middleware that is mounted to the Rails app during
|
9
|
+
# tests (at the decidim-dev module's engine).
|
10
|
+
class MapServer
|
11
|
+
def self.host
|
12
|
+
"http://#{hostname}:#{Capybara.server_port}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.hostname
|
16
|
+
"maps.lvh.me"
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.url(endpoint)
|
20
|
+
case endpoint
|
21
|
+
when :tiles
|
22
|
+
"#{host}/maptiles/{z}/{x}/{y}.png"
|
23
|
+
when :static
|
24
|
+
"#{host}/static"
|
25
|
+
when :autocomplete
|
26
|
+
"#{host}/photon_api"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(app)
|
31
|
+
@app = app
|
32
|
+
end
|
33
|
+
|
34
|
+
def call(env)
|
35
|
+
request = Rack::Request.new(env)
|
36
|
+
return @app.call(env) unless request.host == self.class.hostname
|
37
|
+
|
38
|
+
if (match = request.path.match(%r{^/maptiles/([0-9]+)/([0-9]+)/([0-9]+).png$}))
|
39
|
+
return serve_maptiles(request, { z: match[1], x: match[2], y: match[3] })
|
40
|
+
elsif request.path == "/static"
|
41
|
+
return serve_static(request)
|
42
|
+
elsif request.path == "/photon_api"
|
43
|
+
return serve_autocomplete(request)
|
44
|
+
end
|
45
|
+
|
46
|
+
not_found
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def tile_image_content
|
52
|
+
@tile_image_content ||= File.read(Decidim::Dev.asset("icon.png"))
|
53
|
+
end
|
54
|
+
|
55
|
+
def serve_maptiles(_request, _properties)
|
56
|
+
[200, { "Content-Type" => "image/png" }, [tile_image_content]]
|
57
|
+
end
|
58
|
+
|
59
|
+
def serve_static(_request)
|
60
|
+
[200, { "Content-Type" => "image/png" }, [tile_image_content]]
|
61
|
+
end
|
62
|
+
|
63
|
+
def serve_autocomplete(_request)
|
64
|
+
photon_response = {
|
65
|
+
features: [
|
66
|
+
{
|
67
|
+
properties: {
|
68
|
+
name: "Park",
|
69
|
+
street: "Street1",
|
70
|
+
housenumber: "1",
|
71
|
+
postcode: "123456",
|
72
|
+
city: "City1",
|
73
|
+
state: "State1",
|
74
|
+
country: "Country1"
|
75
|
+
},
|
76
|
+
geometry: {
|
77
|
+
coordinates: [2.234, 1.123]
|
78
|
+
}
|
79
|
+
},
|
80
|
+
{
|
81
|
+
properties: {
|
82
|
+
street: "Street2",
|
83
|
+
postcode: "654321",
|
84
|
+
city: "City2",
|
85
|
+
country: "Country2"
|
86
|
+
},
|
87
|
+
geometry: {
|
88
|
+
coordinates: [4.456, 3.345]
|
89
|
+
}
|
90
|
+
},
|
91
|
+
{
|
92
|
+
properties: {
|
93
|
+
street: "Street3",
|
94
|
+
housenumber: "3",
|
95
|
+
postcode: "142536",
|
96
|
+
city: "City3",
|
97
|
+
country: "Country3"
|
98
|
+
},
|
99
|
+
geometry: {
|
100
|
+
coordinates: [6.678, 5.567]
|
101
|
+
}
|
102
|
+
}
|
103
|
+
]
|
104
|
+
}.tap do |response|
|
105
|
+
Decidim::Map::Provider::Autocomplete::Test.stubs.length.positive? &&
|
106
|
+
response[:features] = Decidim::Map::Provider::Autocomplete::Test.stubs
|
107
|
+
end
|
108
|
+
|
109
|
+
[
|
110
|
+
200,
|
111
|
+
{
|
112
|
+
"Content-Type" => "application/json",
|
113
|
+
"Access-Control-Allow-Origin" => "*"
|
114
|
+
},
|
115
|
+
[photon_response.to_json.to_s]
|
116
|
+
]
|
117
|
+
end
|
118
|
+
|
119
|
+
def not_found
|
120
|
+
[404, { "Content-Type" => "text/plain" }, ["Not found."]]
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -14,10 +14,12 @@ module AttachmentHelpers
|
|
14
14
|
# Used in non-system tests that need files.
|
15
15
|
def upload_test_file(file, options = {})
|
16
16
|
filename = options[:filename] || upload_test_file_filename(file)
|
17
|
+
content_type = options[:content_type] || upload_test_file_content_type(file)
|
17
18
|
|
18
19
|
blob = ActiveStorage::Blob.create_and_upload!(
|
19
20
|
io: File.open(file),
|
20
|
-
filename
|
21
|
+
filename:,
|
22
|
+
content_type:
|
21
23
|
)
|
22
24
|
return blob if options[:return_blob]
|
23
25
|
|
@@ -9,9 +9,9 @@ module Capybara
|
|
9
9
|
expect(page).to have_css("#autoComplete_list_1") # select should be open now
|
10
10
|
|
11
11
|
expect(page).to have_css("#autoComplete_result_0", text: value)
|
12
|
-
|
12
|
+
find_by_id("autoComplete_result_0", text: value).hover
|
13
13
|
expect(page).to have_css("#autoComplete_result_0", text: value)
|
14
|
-
|
14
|
+
find_by_id("autoComplete_result_0", text: value).click
|
15
15
|
expect(page).to have_css(".autocomplete__selected-item", text: value)
|
16
16
|
end
|
17
17
|
end
|
@@ -17,6 +17,10 @@ RSpec.configure do |config|
|
|
17
17
|
Bullet.unused_eager_loading_enable = Decidim::Env.new("DECIDIM_BULLET_UNUSED_EAGER", "false").present?
|
18
18
|
# Detect unnecessary COUNT queries which could be avoided with a counter_cache
|
19
19
|
Bullet.counter_cache_enable = Decidim::Env.new("DECIDIM_BULLET_COUNTER_CACHE", "true").present?
|
20
|
+
|
21
|
+
# Having a counter cache for this column is too difficult, as this should also work for the Decidim::DummyResource
|
22
|
+
# model, and counter_cache needs a real table in the database.
|
23
|
+
Bullet.add_safelist type: :counter_cache, class_name: "Decidim::Proposals::Proposal", association: :attachments
|
20
24
|
end
|
21
25
|
|
22
26
|
if Bullet.enable?
|
@@ -10,6 +10,7 @@ module Decidim
|
|
10
10
|
|
11
11
|
app_host = (host ? "#{protocol}://#{host}" : nil)
|
12
12
|
Capybara.app_host = app_host
|
13
|
+
Rails.application.config.action_controller.asset_host = host
|
13
14
|
end
|
14
15
|
|
15
16
|
def switch_to_default_host
|
@@ -31,20 +32,29 @@ end
|
|
31
32
|
1.step do
|
32
33
|
port = rand(5000..6999)
|
33
34
|
begin
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
redis = Redis.new
|
36
|
+
reserved_ports = (redis.get("decidim_test_capybara_reserved_ports") || "").split(",").map(&:to_i)
|
37
|
+
unless reserved_ports.include?(port)
|
38
|
+
reserved_ports << port
|
39
|
+
if ParallelTests.last_process?
|
40
|
+
redis.del("decidim_test_capybara_reserved_ports")
|
41
|
+
else
|
42
|
+
redis.set("decidim_test_capybara_reserved_ports", reserved_ports.sort.join(","))
|
43
|
+
end
|
44
|
+
break
|
45
|
+
end
|
46
|
+
rescue Redis::CannotConnectError
|
47
|
+
# Redis is not available
|
39
48
|
break
|
40
49
|
end
|
50
|
+
ensure
|
51
|
+
Capybara.server_port = port
|
41
52
|
end
|
42
53
|
|
43
54
|
Capybara.register_driver :headless_chrome do |app|
|
44
55
|
options = Selenium::WebDriver::Chrome::Options.new
|
45
56
|
options.args << "--explicitly-allowed-ports=#{Capybara.server_port}"
|
46
57
|
options.args << "--headless=new"
|
47
|
-
options.args << "--disable-search-engine-choice-screen" # Prevents closing the window normally
|
48
58
|
# Do not limit browser resources
|
49
59
|
options.args << "--disable-dev-shm-usage"
|
50
60
|
options.args << "--no-sandbox"
|
@@ -67,7 +77,7 @@ Capybara.register_driver :pwa_chrome do |app|
|
|
67
77
|
options = Selenium::WebDriver::Chrome::Options.new
|
68
78
|
options.args << "--explicitly-allowed-ports=#{Capybara.server_port}"
|
69
79
|
# If we have a headless browser things like the offline navigation feature stop working,
|
70
|
-
# so we need to have
|
80
|
+
# so we need to have a headful/recapitated (aka not headless) browser for these specs
|
71
81
|
# options.args << "--headless"
|
72
82
|
options.args << "--no-sandbox"
|
73
83
|
# Do not limit browser resources
|
@@ -157,7 +167,7 @@ RSpec.configure do |config|
|
|
157
167
|
switch_to_default_host
|
158
168
|
domain = (try(:organization) || try(:current_organization))&.host
|
159
169
|
if domain
|
160
|
-
#
|
170
|
+
# JavaScript sets the cookie also for all subdomains but localhost is a
|
161
171
|
# special case.
|
162
172
|
domain = ".#{domain}" unless domain == "localhost"
|
163
173
|
page.driver.browser.execute_cdp(
|
@@ -12,7 +12,7 @@ shared_examples "has mandatory config setting" do |mandatory_field|
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "does not allow updating the component" do
|
15
|
-
|
15
|
+
click_on "Update"
|
16
16
|
|
17
17
|
within ".#{mandatory_field}_container" do
|
18
18
|
expect(page).to have_content("There is an error in this field")
|
@@ -7,30 +7,30 @@ module Capybara
|
|
7
7
|
visit decidim.root_path if options[:visit_root]
|
8
8
|
|
9
9
|
dialog_present = begin
|
10
|
-
|
10
|
+
find_by_id("dc-dialog-wrapper")
|
11
11
|
rescue Capybara::ElementNotFound => _e
|
12
12
|
false
|
13
13
|
end
|
14
14
|
|
15
15
|
if dialog_present
|
16
|
-
|
16
|
+
click_on "Settings"
|
17
17
|
else
|
18
18
|
within "footer" do
|
19
|
-
|
19
|
+
click_on "Cookie settings"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
if [true, "all"].include?(categories)
|
24
|
-
|
24
|
+
click_on "Accept all"
|
25
25
|
elsif categories.is_a?(Array)
|
26
26
|
categories.each do |category|
|
27
27
|
within "[data-id='#{category}']" do
|
28
28
|
find(".cookies__category-toggle").click
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
31
|
+
click_on "Save settings"
|
32
32
|
elsif [false, "essential"].include?(categories)
|
33
|
-
|
33
|
+
click_on "Accept only essential"
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Capybara
|
4
|
+
module DatepickerDateFill
|
5
|
+
# fill datepicker field correctly
|
6
|
+
|
7
|
+
def fill_in_datepicker(locator = nil, with:, currently_with: nil, fill_options: {}, **find_options)
|
8
|
+
find_options[:with] = currently_with if currently_with
|
9
|
+
find_options[:allow_self] = true if locator.nil?
|
10
|
+
with.chars.each do |character|
|
11
|
+
if character == "/"
|
12
|
+
find(:fillable_field, locator, **find_options).send_keys(:divide, **fill_options)
|
13
|
+
elsif character == "."
|
14
|
+
find(:fillable_field, locator, **find_options).send_keys(:decimal, **fill_options)
|
15
|
+
else
|
16
|
+
find(:fillable_field, locator, **find_options).send_keys(character, **fill_options)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
RSpec.configure do |config|
|
24
|
+
config.include Capybara::DatepickerDateFill, type: :system
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Capybara
|
4
|
+
module DatepickerTimeFill
|
5
|
+
# fill datepicker field correctly
|
6
|
+
|
7
|
+
def fill_in_timepicker(locator = nil, with:, currently_with: nil, fill_options: {}, **find_options)
|
8
|
+
find_options[:with] = currently_with if currently_with
|
9
|
+
find_options[:allow_self] = true if locator.nil?
|
10
|
+
with.chars.each do |character|
|
11
|
+
if character == ":"
|
12
|
+
find(:fillable_field, locator, **find_options).send_keys([:alt, ":"], **fill_options)
|
13
|
+
else
|
14
|
+
find(:fillable_field, locator, **find_options).send_keys(character, **fill_options)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
RSpec.configure do |config|
|
22
|
+
config.include Capybara::DatepickerTimeFill, type: :system
|
23
|
+
end
|
@@ -23,7 +23,7 @@ module Capybara
|
|
23
23
|
expect(page).to have_content(filename.first(12)) if front_interface
|
24
24
|
end
|
25
25
|
all(title_input(front_interface)).last.set(options[:title]) if options.has_key?(:title)
|
26
|
-
|
26
|
+
click_on("Save") unless options[:keep_modal_open]
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -36,7 +36,7 @@ module Capybara
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def click_remove(front_interface)
|
39
|
-
front_interface ?
|
39
|
+
front_interface ? click_on("Remove") : find(".remove-upload-item").click
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -14,24 +14,11 @@ module GeocoderHelpers
|
|
14
14
|
)
|
15
15
|
end
|
16
16
|
|
17
|
-
def stub_geocoding_coordinates(coordinates)
|
18
|
-
geocoder_request_url = "https://nominatim.openstreetmap.org/reverse?accept-language=en&addressdetails=1&format=json&lat=#{coordinates[0]}&lon=#{coordinates[1]}"
|
19
|
-
geocoder_response = File.read(Decidim::Dev.asset("geocoder_result_here.json"))
|
20
|
-
|
21
|
-
stub_request(:get, geocoder_request_url).with(
|
22
|
-
headers: {
|
23
|
-
"Accept" => "*/*",
|
24
|
-
"Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
|
25
|
-
"User-Agent" => "Ruby"
|
26
|
-
}
|
27
|
-
).to_return(body: geocoder_response)
|
28
|
-
end
|
29
|
-
|
30
17
|
# Waits for the front-end geocoding request to finish in order to ensure there
|
31
18
|
# are no pending requests when proceeding.
|
32
19
|
def fill_in_geocoding(attribute, options = {})
|
33
20
|
fill_in attribute, **options
|
34
|
-
expect(page).to
|
21
|
+
expect(page).to have_css(".autoComplete_wrapper ul#autoComplete_list_1", count: 1)
|
35
22
|
find("li#autoComplete_result_0").click
|
36
23
|
end
|
37
24
|
|
@@ -42,8 +29,13 @@ module GeocoderHelpers
|
|
42
29
|
Decidim.maps = {
|
43
30
|
provider: :test,
|
44
31
|
api_key: "1234123412341234",
|
45
|
-
|
46
|
-
|
32
|
+
dynamic: {
|
33
|
+
tile_layer: {
|
34
|
+
url: Decidim::Dev::Test::MapServer.url(:tiles)
|
35
|
+
}
|
36
|
+
},
|
37
|
+
static: { url: Decidim::Dev::Test::MapServer.url(:static) },
|
38
|
+
autocomplete: { url: Decidim::Dev::Test::MapServer.url(:autocomplete) }
|
47
39
|
}
|
48
40
|
end
|
49
41
|
end
|
@@ -115,77 +107,8 @@ RSpec.configure do |config|
|
|
115
107
|
configure_maps
|
116
108
|
end
|
117
109
|
|
118
|
-
config.before(:each, :serves_map) do
|
119
|
-
stub_request(:get, %r{https://www\.example\.org/my_static_map})
|
120
|
-
.to_return(body: "map_data")
|
121
|
-
end
|
122
|
-
|
123
110
|
config.before(:each, :serves_geocoding_autocomplete) do
|
124
111
|
# Clear the autocomplete stubs
|
125
112
|
Decidim::Map::Provider::Autocomplete::Test.clear_stubs
|
126
|
-
|
127
|
-
photon_response = lambda do
|
128
|
-
{
|
129
|
-
features: [
|
130
|
-
{
|
131
|
-
properties: {
|
132
|
-
name: "Park",
|
133
|
-
street: "Street1",
|
134
|
-
housenumber: "1",
|
135
|
-
postcode: "123456",
|
136
|
-
city: "City1",
|
137
|
-
state: "State1",
|
138
|
-
country: "Country1"
|
139
|
-
},
|
140
|
-
geometry: {
|
141
|
-
coordinates: [2.234, 1.123]
|
142
|
-
}
|
143
|
-
},
|
144
|
-
{
|
145
|
-
properties: {
|
146
|
-
street: "Street2",
|
147
|
-
postcode: "654321",
|
148
|
-
city: "City2",
|
149
|
-
country: "Country2"
|
150
|
-
},
|
151
|
-
geometry: {
|
152
|
-
coordinates: [4.456, 3.345]
|
153
|
-
}
|
154
|
-
},
|
155
|
-
{
|
156
|
-
properties: {
|
157
|
-
street: "Street3",
|
158
|
-
housenumber: "3",
|
159
|
-
postcode: "142536",
|
160
|
-
city: "City3",
|
161
|
-
country: "Country3"
|
162
|
-
},
|
163
|
-
geometry: {
|
164
|
-
coordinates: [6.678, 5.567]
|
165
|
-
}
|
166
|
-
}
|
167
|
-
]
|
168
|
-
}.tap do |response|
|
169
|
-
Decidim::Map::Provider::Autocomplete::Test.stubs.length.positive? &&
|
170
|
-
response[:features] = Decidim::Map::Provider::Autocomplete::Test.stubs
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
# The Photon API path needs to be mounted in the application itself because
|
175
|
-
# otherwise we would have to run a separate server for the API itself.
|
176
|
-
# Mocking the request would not work here because the call to the Photon API
|
177
|
-
# is initialized by the front-end to the URL specified for the maps
|
178
|
-
# geocoding autocompletion configuration which is not proxied by the
|
179
|
-
# headless browser running the Capybara tests.
|
180
|
-
Rails.application.routes.disable_clear_and_finalize = true
|
181
|
-
Rails.application.routes.draw do
|
182
|
-
get "photon_api", to: ->(_) { [200, { "Content-Type" => "application/json" }, [photon_response.call.to_json.to_s]] }
|
183
|
-
end
|
184
|
-
Rails.application.routes.disable_clear_and_finalize = false
|
185
|
-
end
|
186
|
-
|
187
|
-
config.after(:each, :serves_geocoding_autocomplete) do
|
188
|
-
# Reset the routes back to original
|
189
|
-
Rails.application.reload_routes!
|
190
113
|
end
|
191
114
|
end
|
@@ -5,7 +5,7 @@ module Decidim
|
|
5
5
|
module ComponentTestHelpers
|
6
6
|
def click_submenu_link(text)
|
7
7
|
within ".secondary-nav--subnav" do
|
8
|
-
|
8
|
+
click_on text
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -13,7 +13,7 @@ module Decidim
|
|
13
13
|
main_bar_selector = ".main-bar"
|
14
14
|
|
15
15
|
within main_bar_selector do
|
16
|
-
|
16
|
+
find_by_id("trigger-dropdown-account").click
|
17
17
|
|
18
18
|
yield
|
19
19
|
end
|
@@ -26,14 +26,14 @@ module Decidim
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def within_admin_menu
|
29
|
-
|
29
|
+
click_on "Manage"
|
30
30
|
within("[id*='dropdown-menu-settings']") do
|
31
31
|
yield
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
def within_language_menu(options = {})
|
36
|
-
within(options[:admin] ? ".
|
36
|
+
within(options[:admin] ? ".language-choose" : "footer") do
|
37
37
|
find(options[:admin] ? "#admin-menu-trigger" : "#trigger-dropdown-language-chooser").click
|
38
38
|
yield
|
39
39
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# https://github.com/orchidjs/tom-select/discussions/71#discussioncomment-641757
|
4
4
|
module Capybara
|
5
5
|
module TomSelect
|
6
|
-
# A helper for
|
6
|
+
# A helper for Capybara tests that need to set values from a tom-select.js input.
|
7
7
|
#
|
8
8
|
# This is a really hacky approach using execute_javascript, but it works. Not sure if there is
|
9
9
|
# a better way, we could try actually interacting with the on-screen tom-select-provided UI,
|