pageflow-support 17.0.5 → 17.2.0
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/pageflow/dom/admin/page.rb +3 -3
- data/pageflow/dom/editor/edit_configuration_view.rb +8 -2
- data/pageflow/dummy/app.rb +14 -3
- data/pageflow/dummy/rails_template.rb +34 -18
- data/pageflow/dummy/templates/create_test_generated_file.rb +18 -0
- data/pageflow/dummy/templates/favicon.ico +0 -0
- data/pageflow/edit_lock_test_helper.rb +1 -1
- data/pageflow/editor_controller_test_helper.rb +1 -1
- data/pageflow/entries_controller_test_helper.rb +17 -2
- data/pageflow/global_config_api_test_helper.rb +1 -0
- data/pageflow/lint/file_import.rb +5 -6
- data/pageflow/lint/file_type.rb +4 -4
- data/pageflow/lint.rb +8 -8
- data/pageflow/matchers/have_meta_tag.rb +1 -1
- data/pageflow/render_page_test_helper.rb +2 -2
- data/pageflow/shared_contexts/fake_translations.rb +2 -1
- data/pageflow/support/config/capybara/selenium_error_patch.rb +36 -0
- data/pageflow/support/config/capybara.rb +5 -1
- data/pageflow/test_generated_file.rb +28 -0
- metadata +34 -44
- data/pageflow/json_test_helper.rb +0 -46
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f1991e99e5e1c0667011d233f05503e5b772428bd431d908e1a9a949a4e12486
|
|
4
|
+
data.tar.gz: 4ed91c8684d1f5282a0699e0add758cf2559cc9d8b914cdce16863bf05383760
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: da5e455cac7b986e6d382d1a4dd64ff3e7451b29f856733a53ba66ccf0b4fc036bd9b1f0e8bcbc296dec605a70d2973d9c25e1fa2b9769bf96f31a7aa55e66b3
|
|
7
|
+
data.tar.gz: 835d7bcef5a870f4c252fc3b4efff5da7363ec2431f3de3677602a76e5994874e144218e8b9596986126a7905a81e9b5a2413a8d75b866148eb14284c91a632a
|
data/pageflow/dom/admin/page.rb
CHANGED
|
@@ -23,17 +23,17 @@ module Pageflow
|
|
|
23
23
|
def self.sign_in_as(role, options = {})
|
|
24
24
|
email = "#{role}@example.com"
|
|
25
25
|
password = '!Pass123'
|
|
26
|
-
user = FactoryBot.create(:user, options.reverse_merge(email
|
|
26
|
+
user = FactoryBot.create(:user, options.reverse_merge(email:, password:))
|
|
27
27
|
|
|
28
28
|
if role.to_sym == :admin
|
|
29
29
|
user.admin = true
|
|
30
30
|
user.save
|
|
31
31
|
else
|
|
32
|
-
FactoryBot.create(:membership, user
|
|
32
|
+
FactoryBot.create(:membership, user:, role:, entity: options[:on])
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
visit '/admin/login'
|
|
36
|
-
SignInForm.find!.submit_with(email
|
|
36
|
+
SignInForm.find!.submit_with(email:, password:)
|
|
37
37
|
|
|
38
38
|
unless page.has_content?(I18n.t('devise.sessions.signed_in'))
|
|
39
39
|
raise 'Expected to find sign in flash message.'
|
|
@@ -4,8 +4,14 @@ module Pageflow
|
|
|
4
4
|
class EditConfigurationView < Domino
|
|
5
5
|
selector 'sidebar .edit_configuration_view'
|
|
6
6
|
|
|
7
|
-
def
|
|
8
|
-
node.find('.
|
|
7
|
+
def actions_button
|
|
8
|
+
node.find('.drop_down_button')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def select_action(label)
|
|
12
|
+
actions_button.click
|
|
13
|
+
Capybara.current_session.find('#editor_menu_container .drop_down_button_item',
|
|
14
|
+
text: label).click
|
|
9
15
|
end
|
|
10
16
|
|
|
11
17
|
def back_button
|
data/pageflow/dummy/app.rb
CHANGED
|
@@ -8,7 +8,7 @@ module Pageflow
|
|
|
8
8
|
def generate
|
|
9
9
|
ENV['RAILS_ROOT'] = File.expand_path(directory)
|
|
10
10
|
|
|
11
|
-
if File.exist?(directory)
|
|
11
|
+
if File.exist?(directory) # rubocop:disable Style/GuardClause
|
|
12
12
|
puts("Dummy directory #{directory} exists.")
|
|
13
13
|
else
|
|
14
14
|
system('SKIP_EAGER_LOAD=true ' \
|
|
@@ -17,7 +17,18 @@ module Pageflow
|
|
|
17
17
|
raise('Error generating dummy app.')
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
require(File.join(ENV
|
|
20
|
+
require(File.join(ENV.fetch('RAILS_ROOT', nil), 'config', 'environment'))
|
|
21
|
+
|
|
22
|
+
load_routes
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Routes are only loaded on demand unless eager loading is
|
|
26
|
+
# enabled. Active Admin defines its controllers while routes are
|
|
27
|
+
# drawn, and specs reference those constants as they are loaded.
|
|
28
|
+
def load_routes
|
|
29
|
+
return unless Rails.application.respond_to?(:reload_routes_unless_loaded)
|
|
30
|
+
|
|
31
|
+
Rails.application.reload_routes_unless_loaded
|
|
21
32
|
end
|
|
22
33
|
|
|
23
34
|
def directory
|
|
@@ -30,7 +41,7 @@ module Pageflow
|
|
|
30
41
|
end
|
|
31
42
|
|
|
32
43
|
def rails_new_options
|
|
33
|
-
result = '--skip-test-unit --skip-bundle --database=mysql'
|
|
44
|
+
result = '--skip-test-unit --skip-bundle --database=mysql --skip-active-storage'
|
|
34
45
|
result << ' --skip-javascript'
|
|
35
46
|
result
|
|
36
47
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'pageflow/rails_version'
|
|
2
2
|
|
|
3
3
|
def source_paths
|
|
4
|
-
[File.join(
|
|
4
|
+
[File.join(__dir__, 'templates')]
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
# The Gemfile is not required. We'll use the one from the project root instead.
|
|
@@ -25,11 +25,11 @@ gsub_file('config/environments/test.rb',
|
|
|
25
25
|
'config.eager_load = ENV["CI"].present?',
|
|
26
26
|
'config.eager_load = ENV["CI"].present? && !ENV["SKIP_EAGER_LOAD"]')
|
|
27
27
|
|
|
28
|
-
append_to_file('config/application.rb', <<-
|
|
28
|
+
append_to_file('config/application.rb', <<-RUBY)
|
|
29
29
|
if ENV['PAGEFLOW_DB_HOST'].present?
|
|
30
30
|
ActiveRecord::Tasks::DatabaseTasks::LOCAL_HOSTS << ENV['PAGEFLOW_DB_HOST']
|
|
31
31
|
end
|
|
32
|
-
|
|
32
|
+
RUBY
|
|
33
33
|
|
|
34
34
|
# Ensure pageflow is required even if it is not listed in plugin Gemfile does
|
|
35
35
|
inject_into_file('config/application.rb',
|
|
@@ -38,7 +38,7 @@ inject_into_file('config/application.rb',
|
|
|
38
38
|
|
|
39
39
|
if in_root { File.exist?('app/assets/javascripts/application.js') }
|
|
40
40
|
# Remove requires to missing gems (i.e. turbolinks)
|
|
41
|
-
gsub_file('app/assets/javascripts/application.js', %r
|
|
41
|
+
gsub_file('app/assets/javascripts/application.js', %r{//=.*}, '')
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
# Recreate db. Ignore if it does not exist.
|
|
@@ -55,8 +55,12 @@ rake 'shakapacker:install' if ENV['PAGEFLOW_INSTALL_SHAKAPACKER'] == 'true'
|
|
|
55
55
|
|
|
56
56
|
generate 'pageflow:install', '--force'
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
# Invoking a generator that does not exist aborts the template, and not
|
|
59
|
+
# every plugin engine comes with an install generator.
|
|
60
|
+
plugin_engine = ENV['PAGEFLOW_PLUGIN_ENGINE'].presence
|
|
61
|
+
|
|
62
|
+
if plugin_engine && Rails::Generators.find_by_namespace('install', plugin_engine)
|
|
63
|
+
generate "#{plugin_engine}:install", '--force'
|
|
60
64
|
end
|
|
61
65
|
|
|
62
66
|
# Devise needs default_url_options for generating mails.
|
|
@@ -67,9 +71,9 @@ inject_into_file('config/environments/test.rb',
|
|
|
67
71
|
|
|
68
72
|
# ActiveAdmin does not look for admin definitions inside dummy apps by default.
|
|
69
73
|
|
|
70
|
-
prepend_to_file('config/initializers/pageflow.rb', <<-
|
|
74
|
+
prepend_to_file('config/initializers/pageflow.rb', <<-RUBY)
|
|
71
75
|
ActiveAdmin.application.load_paths.unshift(Dir[Rails.root.join('app/admin')].first)\n
|
|
72
|
-
|
|
76
|
+
RUBY
|
|
73
77
|
|
|
74
78
|
# Adapt default configuration
|
|
75
79
|
|
|
@@ -86,23 +90,35 @@ copy_file('test_theme_preview.png',
|
|
|
86
90
|
copy_file('test_theme_preview.png',
|
|
87
91
|
'app/assets/images/pageflow/themes/test_theme/preview_thumbnail.png')
|
|
88
92
|
|
|
93
|
+
# Add fallback favicon used by browsers to prevent console log warnings
|
|
94
|
+
|
|
95
|
+
copy_file('favicon.ico', 'public/favicon.ico', force: true)
|
|
96
|
+
|
|
89
97
|
# Normally theme stylesheets are added to the precompile list
|
|
90
98
|
# automatically. Since the test_theme is not yet registered when the
|
|
91
99
|
# environment is loaded, we need to add its stylesheet manually.
|
|
92
100
|
|
|
93
|
-
append_to_file('config/initializers/assets.rb', <<-
|
|
101
|
+
append_to_file('config/initializers/assets.rb', <<-RUBY)
|
|
94
102
|
Rails.application.config.assets.precompile += %w( pageflow/themes/test_theme.css )
|
|
95
|
-
|
|
103
|
+
RUBY
|
|
96
104
|
|
|
97
105
|
# Create database tables for fake hosted files and revision components.
|
|
98
106
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
migration_paths = Dir[File.join('db', 'migrate', '*.rb')]
|
|
108
|
+
latest_migration = migration_paths.map { |path| File.basename(path).split('_').first.to_i }.max
|
|
109
|
+
|
|
110
|
+
timestamp = (latest_migration || Time.now.utc.strftime('%Y%m%d%H%M%S').to_i) + 1
|
|
111
|
+
[
|
|
112
|
+
'create_test_uploadable_file.rb',
|
|
113
|
+
'create_test_multi_attachment_file.rb',
|
|
114
|
+
'create_test_generated_file.rb',
|
|
115
|
+
'create_test_revision_components.rb',
|
|
116
|
+
'add_custom_fields.rb'
|
|
117
|
+
].each_with_index do |migration, index|
|
|
118
|
+
copy_file(
|
|
119
|
+
migration,
|
|
120
|
+
format('db/migrate/%<timestamp>014d_%<name>s', timestamp: timestamp + index, name: migration)
|
|
121
|
+
)
|
|
122
|
+
end
|
|
107
123
|
|
|
108
124
|
rake 'db:migrate'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class CreateTestGeneratedFile < ActiveRecord::Migration[4.2]
|
|
2
|
+
def change
|
|
3
|
+
create_table :test_generated_files do |t|
|
|
4
|
+
t.belongs_to(:entry, index: true)
|
|
5
|
+
t.belongs_to(:uploader, index: true)
|
|
6
|
+
|
|
7
|
+
t.integer(:parent_file_id)
|
|
8
|
+
t.string(:parent_file_model_type)
|
|
9
|
+
|
|
10
|
+
t.string(:state)
|
|
11
|
+
t.string(:rights)
|
|
12
|
+
|
|
13
|
+
t.string(:url)
|
|
14
|
+
|
|
15
|
+
t.timestamps
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Pageflow
|
|
2
2
|
module EditLockTestHelpers
|
|
3
3
|
def acquire_edit_lock(user, entry)
|
|
4
|
-
edit_lock = FactoryBot.create(:edit_lock, user
|
|
4
|
+
edit_lock = FactoryBot.create(:edit_lock, user:, entry:)
|
|
5
5
|
request.headers['X-Edit-Lock'] = edit_lock.id
|
|
6
6
|
end
|
|
7
7
|
end
|
|
@@ -15,7 +15,7 @@ module Pageflow
|
|
|
15
15
|
# acquire an edit lock.
|
|
16
16
|
def authorize_for_editor_controller(entry)
|
|
17
17
|
user = FactoryBot.create(:user)
|
|
18
|
-
FactoryBot.create(:membership, user
|
|
18
|
+
FactoryBot.create(:membership, user:, entity: entry, role: :editor)
|
|
19
19
|
|
|
20
20
|
sign_in(user, scope: :user)
|
|
21
21
|
acquire_edit_lock(user, entry)
|
|
@@ -32,7 +32,20 @@ module Pageflow
|
|
|
32
32
|
#
|
|
33
33
|
# @param mode [:published|:preview] Whether to render the
|
|
34
34
|
# published revision or the draft.
|
|
35
|
-
|
|
35
|
+
#
|
|
36
|
+
# @param embed [Boolean] Whether the entry is being rendered as an
|
|
37
|
+
# embed.
|
|
38
|
+
#
|
|
39
|
+
# @param ui_locale [Symbol] Locale of the signed in user, i.e. the
|
|
40
|
+
# locale to render user interface displayed on top of the entry
|
|
41
|
+
# in. Not read from `I18n.locale` since entry type controllers
|
|
42
|
+
# are free to change it while rendering.
|
|
43
|
+
def get_with_entry_env(action,
|
|
44
|
+
entry:,
|
|
45
|
+
mode: :published,
|
|
46
|
+
embed: false,
|
|
47
|
+
ui_locale: I18n.default_locale,
|
|
48
|
+
params: {})
|
|
36
49
|
revision =
|
|
37
50
|
if mode == :published
|
|
38
51
|
entry.published_revision
|
|
@@ -43,7 +56,9 @@ module Pageflow
|
|
|
43
56
|
published_entry = PublishedEntry.new(entry, revision)
|
|
44
57
|
EntriesControllerEnvHelper.add_entry_info_to_env(request.env,
|
|
45
58
|
entry: published_entry,
|
|
46
|
-
mode
|
|
59
|
+
mode:,
|
|
60
|
+
embed:,
|
|
61
|
+
ui_locale:)
|
|
47
62
|
get(action, params: {**params})
|
|
48
63
|
end
|
|
49
64
|
end
|
|
@@ -15,12 +15,10 @@ module Pageflow
|
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
file_importer_credentials = lambda do |authentication_provider|
|
|
19
19
|
token = AuthenticationToken.where(provider: authentication_provider) if
|
|
20
20
|
authentication_provider.present?
|
|
21
|
-
|
|
22
|
-
token = nil if token.empty?
|
|
23
|
-
end
|
|
21
|
+
token = nil if !token.nil? && token.empty?
|
|
24
22
|
token
|
|
25
23
|
end
|
|
26
24
|
|
|
@@ -54,7 +52,7 @@ module Pageflow
|
|
|
54
52
|
expect(file_importer.class.method_defined?(:search)).to be(true)
|
|
55
53
|
expect {
|
|
56
54
|
provider = file_importer.authentication_provider
|
|
57
|
-
search_result = file_importer.search(file_importer_credentials(provider),
|
|
55
|
+
search_result = file_importer.search(file_importer_credentials.call(provider),
|
|
58
56
|
'test*$*page=1&per_page=15*$*')
|
|
59
57
|
expect(search_result).not_to be_nil
|
|
60
58
|
}.not_to raise_error
|
|
@@ -64,7 +62,8 @@ module Pageflow
|
|
|
64
62
|
expect(file_importer.class.method_defined?(:files_meta_data)).to be(true)
|
|
65
63
|
expect {
|
|
66
64
|
provider = file_importer.authentication_provider
|
|
67
|
-
meta_data = file_importer.files_meta_data(file_importer_credentials(provider),
|
|
65
|
+
meta_data = file_importer.files_meta_data(file_importer_credentials.call(provider),
|
|
66
|
+
{})
|
|
68
67
|
expect(meta_data).not_to be_nil
|
|
69
68
|
expect(meta_data).to include(:collection)
|
|
70
69
|
expect(meta_data).to include(:files)
|
data/pageflow/lint/file_type.rb
CHANGED
|
@@ -39,7 +39,7 @@ module Pageflow
|
|
|
39
39
|
formats: [:json],
|
|
40
40
|
locals: {
|
|
41
41
|
file: UsedFile.new(file, FileUsage.new),
|
|
42
|
-
file_type:
|
|
42
|
+
file_type:
|
|
43
43
|
})
|
|
44
44
|
}.not_to raise_error
|
|
45
45
|
end
|
|
@@ -51,14 +51,14 @@ module Pageflow
|
|
|
51
51
|
formats: [:json],
|
|
52
52
|
locals: {
|
|
53
53
|
file: UsedFile.new(file, FileUsage.new),
|
|
54
|
-
file_type:
|
|
54
|
+
file_type:
|
|
55
55
|
})
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
it 'provides css_background_image_urls that returns hash if present' do
|
|
59
59
|
if file_type.css_background_image_urls
|
|
60
60
|
entry = create(:entry)
|
|
61
|
-
result = file_type.css_background_image_urls_for(file, entry:
|
|
61
|
+
result = file_type.css_background_image_urls_for(file, entry:)
|
|
62
62
|
|
|
63
63
|
expect(result).to be_a(Hash)
|
|
64
64
|
end
|
|
@@ -66,7 +66,7 @@ module Pageflow
|
|
|
66
66
|
|
|
67
67
|
it 'can be exported and imported without error' do
|
|
68
68
|
exported_entry = create(:entry)
|
|
69
|
-
create(:file_usage, file
|
|
69
|
+
create(:file_usage, file:, revision: exported_entry.draft)
|
|
70
70
|
user = create(:user, :manager, on: create(:account))
|
|
71
71
|
|
|
72
72
|
get_prerequisite_files.call(file).each do |prerequisite_file|
|
data/pageflow/lint.rb
CHANGED
|
@@ -25,8 +25,8 @@ module Pageflow
|
|
|
25
25
|
# require 'pageflow/lint'
|
|
26
26
|
#
|
|
27
27
|
# Pageflow::Lint.entry_type(SomePlugin.entry_type)
|
|
28
|
-
def self.entry_type(
|
|
29
|
-
Lint::EntryType.lint(
|
|
28
|
+
def self.entry_type(*, **kws)
|
|
29
|
+
Lint::EntryType.lint(*, **kws)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
# Ensure file type json partials render correctly.
|
|
@@ -52,8 +52,8 @@ module Pageflow
|
|
|
52
52
|
# create_file_type: -> { SomePlugin.file_type },
|
|
53
53
|
# create_file: -> { create(:some_file) })
|
|
54
54
|
# end
|
|
55
|
-
def self.file_type(
|
|
56
|
-
Lint::FileType.lint(
|
|
55
|
+
def self.file_type(*, **kws)
|
|
56
|
+
Lint::FileType.lint(*, **kws)
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
# Contract specs for page types
|
|
@@ -70,8 +70,8 @@ module Pageflow
|
|
|
70
70
|
# module SomePlugin
|
|
71
71
|
# Pageflow::Lint.page_type(SomePLugin.page_type)
|
|
72
72
|
# end
|
|
73
|
-
def self.page_type(
|
|
74
|
-
Lint::PageType.lint(
|
|
73
|
+
def self.page_type(*, **kws)
|
|
74
|
+
Lint::PageType.lint(*, **kws)
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
# Contracts specs for file import plugin
|
|
@@ -83,8 +83,8 @@ module Pageflow
|
|
|
83
83
|
# module SomePlugin
|
|
84
84
|
# Pageflow::Lint.file_import(SomePLugin.file_import)
|
|
85
85
|
# end
|
|
86
|
-
def self.file_import(
|
|
87
|
-
Lint::FileImport.lint(
|
|
86
|
+
def self.file_import(*, **kws)
|
|
87
|
+
Lint::FileImport.lint(*, **kws)
|
|
88
88
|
end
|
|
89
89
|
end
|
|
90
90
|
end
|
|
@@ -8,7 +8,7 @@ module Pageflow
|
|
|
8
8
|
if page_type_or_page.is_a?(Page)
|
|
9
9
|
[page_type_or_page, page_type_or_page.page_type]
|
|
10
10
|
else
|
|
11
|
-
[FactoryBot.create(:page, template: page_type_or_page.name, configuration:
|
|
11
|
+
[FactoryBot.create(:page, template: page_type_or_page.name, configuration:),
|
|
12
12
|
page_type_or_page]
|
|
13
13
|
end
|
|
14
14
|
|
|
@@ -29,7 +29,7 @@ module Pageflow
|
|
|
29
29
|
|
|
30
30
|
assign(:entry, entry)
|
|
31
31
|
|
|
32
|
-
helper.render_page_template(page, entry:
|
|
32
|
+
helper.render_page_template(page, entry:)
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
end
|
|
@@ -4,6 +4,7 @@ RSpec.shared_context 'fake translations' do
|
|
|
4
4
|
@fake_i18n_backend = I18n::Backend::Simple.new
|
|
5
5
|
|
|
6
6
|
I18n.backend = @fake_i18n_backend
|
|
7
|
+
@fake_i18n_backend.send(:init_translations)
|
|
7
8
|
example.run
|
|
8
9
|
I18n.backend = i18n_backend_backup
|
|
9
10
|
end
|
|
@@ -14,7 +15,7 @@ RSpec.shared_context 'fake translations' do
|
|
|
14
15
|
data = {}
|
|
15
16
|
|
|
16
17
|
inner = keys.inject(data) do |result, key|
|
|
17
|
-
result[key] = {}
|
|
18
|
+
result[key] = {} # rubocop:disable Lint/UnmodifiedReduceAccumulator
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
inner[last_key] = value
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Taken from https://github.com/alphagov/forms-admin/commit/5ea98767d765a396ed06cf2cba8f9afb1b10fc0e#diff-c36c07a0c7f499b1b95634f9dce1a10ebf4d10a9dee872f39f746a9efa555ddbR1-R34
|
|
2
|
+
# Monkey patch for a specific intermittent Selenium error.
|
|
3
|
+
#
|
|
4
|
+
# Intermittently, Selenium/Chromedriver raises `Selenium::WebDriver::Error::UnknownError`
|
|
5
|
+
# with the message "Node with given id does not belong to the document".
|
|
6
|
+
|
|
7
|
+
# Capybara's automatic waiting/retrying mechanism doesn't catch it,
|
|
8
|
+
# leading to failure.
|
|
9
|
+
#
|
|
10
|
+
# We intercept the initialization of `UnknownError`. If the message matches this specific
|
|
11
|
+
# case, we raise a `StaleElementReferenceError` instead. This uses Capybara's
|
|
12
|
+
# retry logic which makes doesn't fail the test
|
|
13
|
+
#
|
|
14
|
+
# This can be removed once the following issue is resolved:
|
|
15
|
+
# https://github.com/teamcapybara/capybara/issues/2800
|
|
16
|
+
#
|
|
17
|
+
# taken from the following issue:
|
|
18
|
+
# https://github.com/teamcapybara/capybara/issues/2800#issuecomment-3049956982
|
|
19
|
+
|
|
20
|
+
module Selenium
|
|
21
|
+
module WebDriver
|
|
22
|
+
module Error
|
|
23
|
+
class UnknownError
|
|
24
|
+
alias old_initialize initialize
|
|
25
|
+
|
|
26
|
+
def initialize(msg = nil)
|
|
27
|
+
if msg&.include?('Node with given id does not belong to the document')
|
|
28
|
+
raise StaleElementReferenceError, msg
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
old_initialize(msg)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -2,6 +2,8 @@ require 'capybara/rspec'
|
|
|
2
2
|
require 'selenium-webdriver'
|
|
3
3
|
require 'capybara/chromedriver/logger'
|
|
4
4
|
|
|
5
|
+
require 'pageflow/support/config/capybara/selenium_error_patch'
|
|
6
|
+
|
|
5
7
|
Capybara.register_driver :selenium_chrome_headless_no_sandbox do |app|
|
|
6
8
|
options = Selenium::WebDriver::Options.chrome(
|
|
7
9
|
logging_prefs: {browser: 'ALL'}
|
|
@@ -9,14 +11,16 @@ Capybara.register_driver :selenium_chrome_headless_no_sandbox do |app|
|
|
|
9
11
|
|
|
10
12
|
options.add_argument('--headless=new')
|
|
11
13
|
options.add_argument('--no-sandbox')
|
|
14
|
+
options.add_argument('--disable-dev-shm-usage')
|
|
12
15
|
options.add_argument('--disable-gpu') if Gem.win_platform?
|
|
13
16
|
|
|
14
17
|
Capybara::Selenium::Driver.new(app,
|
|
15
18
|
browser: :chrome,
|
|
16
|
-
options:
|
|
19
|
+
options:)
|
|
17
20
|
end
|
|
18
21
|
|
|
19
22
|
Capybara.javascript_driver = :selenium_chrome_headless_no_sandbox
|
|
23
|
+
Capybara.server = :puma, {Silent: true}
|
|
20
24
|
|
|
21
25
|
Capybara::Chromedriver::Logger.raise_js_errors = true
|
|
22
26
|
Capybara::Chromedriver::Logger.filters = [
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Pageflow
|
|
2
|
+
class TestGeneratedFile < ActiveRecord::Base
|
|
3
|
+
self.table_name = :test_generated_files
|
|
4
|
+
include ReusableFile
|
|
5
|
+
|
|
6
|
+
def retryable?
|
|
7
|
+
false
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def ready?
|
|
11
|
+
true
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def failed?
|
|
15
|
+
false
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def publish!; end
|
|
19
|
+
|
|
20
|
+
def url
|
|
21
|
+
read_attribute(:url)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def original_url
|
|
25
|
+
url
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
metadata
CHANGED
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pageflow-support
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 17.0
|
|
4
|
+
version: 17.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Codevise Solutions Ltd
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-09-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: pageflow
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - '='
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: 17.0.5
|
|
20
|
-
type: :runtime
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - '='
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: 17.0.5
|
|
27
13
|
- !ruby/object:Gem::Dependency
|
|
28
14
|
name: mysql2
|
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -39,47 +25,47 @@ dependencies:
|
|
|
39
25
|
- !ruby/object:Gem::Version
|
|
40
26
|
version: 0.5.2
|
|
41
27
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
28
|
+
name: pageflow
|
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
|
44
30
|
requirements:
|
|
45
|
-
- -
|
|
31
|
+
- - '='
|
|
46
32
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
33
|
+
version: 17.2.0
|
|
48
34
|
type: :runtime
|
|
49
35
|
prerelease: false
|
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
37
|
requirements:
|
|
52
|
-
- -
|
|
38
|
+
- - '='
|
|
53
39
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
40
|
+
version: 17.2.0
|
|
55
41
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
42
|
+
name: domino
|
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
|
58
44
|
requirements:
|
|
59
45
|
- - "~>"
|
|
60
46
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
47
|
+
version: 0.7.0
|
|
62
48
|
type: :runtime
|
|
63
49
|
prerelease: false
|
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
51
|
requirements:
|
|
66
52
|
- - "~>"
|
|
67
53
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
54
|
+
version: 0.7.0
|
|
69
55
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
56
|
+
name: factory_bot_rails
|
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
|
72
58
|
requirements:
|
|
73
59
|
- - "~>"
|
|
74
60
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
61
|
+
version: '6.5'
|
|
76
62
|
type: :runtime
|
|
77
63
|
prerelease: false
|
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
65
|
requirements:
|
|
80
66
|
- - "~>"
|
|
81
67
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
68
|
+
version: '6.5'
|
|
83
69
|
- !ruby/object:Gem::Dependency
|
|
84
70
|
name: bootsnap
|
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -95,47 +81,47 @@ dependencies:
|
|
|
95
81
|
- !ruby/object:Gem::Version
|
|
96
82
|
version: '1.0'
|
|
97
83
|
- !ruby/object:Gem::Dependency
|
|
98
|
-
name:
|
|
84
|
+
name: listen
|
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
|
100
86
|
requirements:
|
|
101
87
|
- - "~>"
|
|
102
88
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: '
|
|
89
|
+
version: '3.0'
|
|
104
90
|
type: :runtime
|
|
105
91
|
prerelease: false
|
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
93
|
requirements:
|
|
108
94
|
- - "~>"
|
|
109
95
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: '
|
|
96
|
+
version: '3.0'
|
|
111
97
|
- !ruby/object:Gem::Dependency
|
|
112
|
-
name: resque
|
|
98
|
+
name: resque
|
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
|
114
100
|
requirements:
|
|
115
101
|
- - "~>"
|
|
116
102
|
- !ruby/object:Gem::Version
|
|
117
|
-
version: '
|
|
103
|
+
version: '2.6'
|
|
118
104
|
type: :runtime
|
|
119
105
|
prerelease: false
|
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
107
|
requirements:
|
|
122
108
|
- - "~>"
|
|
123
109
|
- !ruby/object:Gem::Version
|
|
124
|
-
version: '
|
|
110
|
+
version: '2.6'
|
|
125
111
|
- !ruby/object:Gem::Dependency
|
|
126
|
-
name:
|
|
112
|
+
name: resque-scheduler
|
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
|
128
114
|
requirements:
|
|
129
115
|
- - "~>"
|
|
130
116
|
- !ruby/object:Gem::Version
|
|
131
|
-
version:
|
|
117
|
+
version: '4.10'
|
|
132
118
|
type: :runtime
|
|
133
119
|
prerelease: false
|
|
134
120
|
version_requirements: !ruby/object:Gem::Requirement
|
|
135
121
|
requirements:
|
|
136
122
|
- - "~>"
|
|
137
123
|
- !ruby/object:Gem::Version
|
|
138
|
-
version:
|
|
124
|
+
version: '4.10'
|
|
139
125
|
- !ruby/object:Gem::Dependency
|
|
140
126
|
name: redis
|
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -178,7 +164,7 @@ dependencies:
|
|
|
178
164
|
- - "~>"
|
|
179
165
|
- !ruby/object:Gem::Version
|
|
180
166
|
version: '2.1'
|
|
181
|
-
description:
|
|
167
|
+
description:
|
|
182
168
|
email:
|
|
183
169
|
- info@codevise.de
|
|
184
170
|
executables: []
|
|
@@ -205,17 +191,18 @@ files:
|
|
|
205
191
|
- pageflow/dummy/exit_on_failure_patch.rb
|
|
206
192
|
- pageflow/dummy/rails_template.rb
|
|
207
193
|
- pageflow/dummy/templates/add_custom_fields.rb
|
|
194
|
+
- pageflow/dummy/templates/create_test_generated_file.rb
|
|
208
195
|
- pageflow/dummy/templates/create_test_multi_attachment_file.rb
|
|
209
196
|
- pageflow/dummy/templates/create_test_revision_components.rb
|
|
210
197
|
- pageflow/dummy/templates/create_test_uploadable_file.rb
|
|
211
198
|
- pageflow/dummy/templates/database.yml
|
|
199
|
+
- pageflow/dummy/templates/favicon.ico
|
|
212
200
|
- pageflow/dummy/templates/test_theme.scss
|
|
213
201
|
- pageflow/dummy/templates/test_theme_preview.png
|
|
214
202
|
- pageflow/edit_lock_test_helper.rb
|
|
215
203
|
- pageflow/editor_controller_test_helper.rb
|
|
216
204
|
- pageflow/entries_controller_test_helper.rb
|
|
217
205
|
- pageflow/global_config_api_test_helper.rb
|
|
218
|
-
- pageflow/json_test_helper.rb
|
|
219
206
|
- pageflow/lint.rb
|
|
220
207
|
- pageflow/lint/entry_type.rb
|
|
221
208
|
- pageflow/lint/file_import.rb
|
|
@@ -227,17 +214,20 @@ files:
|
|
|
227
214
|
- pageflow/shared_contexts/fake_translations.rb
|
|
228
215
|
- pageflow/support.rb
|
|
229
216
|
- pageflow/support/config/capybara.rb
|
|
217
|
+
- pageflow/support/config/capybara/selenium_error_patch.rb
|
|
230
218
|
- pageflow/support/config/paperclip.rb
|
|
231
219
|
- pageflow/support/config/webmock.rb
|
|
232
220
|
- pageflow/test_entry_type.rb
|
|
221
|
+
- pageflow/test_generated_file.rb
|
|
233
222
|
- pageflow/test_page_type.rb
|
|
234
223
|
- pageflow/test_uploadable_file.rb
|
|
235
224
|
- pageflow/test_widget_type.rb
|
|
236
225
|
- pageflow/used_file_test_helper.rb
|
|
237
226
|
homepage: https://pageflow.io
|
|
238
227
|
licenses: []
|
|
239
|
-
metadata:
|
|
240
|
-
|
|
228
|
+
metadata:
|
|
229
|
+
rubygems_mfa_required: 'true'
|
|
230
|
+
post_install_message:
|
|
241
231
|
rdoc_options: []
|
|
242
232
|
require_paths:
|
|
243
233
|
- "."
|
|
@@ -245,15 +235,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
245
235
|
requirements:
|
|
246
236
|
- - ">="
|
|
247
237
|
- !ruby/object:Gem::Version
|
|
248
|
-
version: '
|
|
238
|
+
version: '3.2'
|
|
249
239
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
250
240
|
requirements:
|
|
251
241
|
- - ">="
|
|
252
242
|
- !ruby/object:Gem::Version
|
|
253
243
|
version: '0'
|
|
254
244
|
requirements: []
|
|
255
|
-
rubygems_version: 3.4.
|
|
256
|
-
signing_key:
|
|
245
|
+
rubygems_version: 3.4.19
|
|
246
|
+
signing_key:
|
|
257
247
|
specification_version: 4
|
|
258
248
|
summary: Spec support for Pageflow extensions.
|
|
259
249
|
test_files: []
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
module Pageflow
|
|
2
|
-
module JsonTestHelper
|
|
3
|
-
def json_response(options = {})
|
|
4
|
-
json_get(response.body, options)
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def json_get(text, options = {})
|
|
8
|
-
object = JSON.parse(text)
|
|
9
|
-
path = options[:path] || []
|
|
10
|
-
pretty_path = nil
|
|
11
|
-
|
|
12
|
-
Array.wrap(path).inject(object) do |component, key|
|
|
13
|
-
case key
|
|
14
|
-
when Integer, '*'
|
|
15
|
-
expect(component).to be_a(Array),
|
|
16
|
-
"Expected json response to have array at '#{pretty_path || 'root'}'"
|
|
17
|
-
pretty_path = [pretty_path, "[#{key}]"].compact.join
|
|
18
|
-
|
|
19
|
-
if key == '*'
|
|
20
|
-
component
|
|
21
|
-
else
|
|
22
|
-
expect(component[key]).to be_present,
|
|
23
|
-
"Expected json response to have item at '#{pretty_path}'"
|
|
24
|
-
component[key]
|
|
25
|
-
end
|
|
26
|
-
when String, Symbol
|
|
27
|
-
key = key.to_s
|
|
28
|
-
pretty_path = [pretty_path, key].compact * '.'
|
|
29
|
-
|
|
30
|
-
case component
|
|
31
|
-
when Array
|
|
32
|
-
component.map do |c|
|
|
33
|
-
expect(c).to have_key(key),
|
|
34
|
-
"Expected json response to have key '#{pretty_path}'"
|
|
35
|
-
c[key]
|
|
36
|
-
end
|
|
37
|
-
else
|
|
38
|
-
expect(component).to have_key(key),
|
|
39
|
-
"Expected json response to have key '#{pretty_path}'"
|
|
40
|
-
component[key]
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|