panda-core 0.6.0 → 0.7.1
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/builders/panda/core/form_builder.rb +163 -11
- data/app/components/panda/core/admin/button_component.rb +27 -12
- data/app/components/panda/core/admin/container_component.rb +13 -1
- data/app/components/panda/core/admin/heading_component.rb +22 -14
- data/app/components/panda/core/admin/slideover_component.rb +52 -22
- data/app/controllers/panda/core/admin/my_profile_controller.rb +8 -1
- data/app/helpers/panda/core/asset_helper.rb +2 -0
- data/app/javascript/panda/core/controllers/image_cropper_controller.js +158 -0
- data/app/javascript/panda/core/controllers/index.js +6 -0
- data/app/javascript/panda/core/controllers/navigation_toggle_controller.js +66 -0
- data/app/models/panda/core/user.rb +13 -2
- data/app/services/panda/core/attach_avatar_service.rb +4 -0
- data/app/views/layouts/panda/core/admin.html.erb +39 -14
- data/app/views/panda/core/admin/dashboard/_default_content.html.erb +1 -1
- data/app/views/panda/core/admin/dashboard/show.html.erb +3 -3
- data/app/views/panda/core/admin/sessions/new.html.erb +1 -1
- data/app/views/panda/core/admin/shared/_breadcrumbs.html.erb +14 -24
- data/app/views/panda/core/admin/shared/_sidebar.html.erb +62 -11
- data/app/views/panda/core/admin/shared/_slideover.html.erb +1 -1
- data/config/importmap.rb +5 -0
- data/config/routes.rb +1 -1
- data/lib/panda/core/asset_loader.rb +5 -2
- data/lib/panda/core/engine.rb +26 -25
- data/lib/panda/core/oauth_providers.rb +3 -3
- data/lib/panda/core/testing/rails_helper.rb +175 -0
- data/lib/panda/core/version.rb +1 -1
- metadata +4 -69
- data/lib/generators/panda/core/authentication/templates/reek_spec.rb +0 -43
- data/lib/generators/panda/core/dev_tools/USAGE +0 -24
- data/lib/generators/panda/core/dev_tools/templates/lefthook.yml +0 -13
- data/lib/generators/panda/core/dev_tools/templates/spec_support_panda_core_helpers.rb +0 -18
- data/lib/generators/panda/core/dev_tools_generator.rb +0 -143
- data/lib/generators/panda/core/install_generator.rb +0 -41
- data/lib/generators/panda/core/templates/README +0 -25
- data/lib/generators/panda/core/templates/initializer.rb +0 -44
- data/lib/generators/panda/core/templates_generator.rb +0 -27
- data/lib/panda/core/testing/capybara_config.rb +0 -70
- data/lib/panda/core/testing/omniauth_helpers.rb +0 -52
- data/lib/panda/core/testing/rspec_config.rb +0 -72
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require "rails/generators"
|
|
2
|
-
require "fileutils"
|
|
3
|
-
require "pathname"
|
|
4
|
-
|
|
5
|
-
module Panda
|
|
6
|
-
module Core
|
|
7
|
-
module Generators
|
|
8
|
-
class TemplatesGenerator < Rails::Generators::Base
|
|
9
|
-
include Thor::Actions
|
|
10
|
-
|
|
11
|
-
desc "Copies shared configuration templates from panda_core"
|
|
12
|
-
|
|
13
|
-
source_root File.expand_path("templates", __dir__)
|
|
14
|
-
|
|
15
|
-
def copy_templates
|
|
16
|
-
Dir.glob(File.join(self.class.source_root, "**/{.*,*}"), File::FNM_DOTMATCH).each do |file|
|
|
17
|
-
next if File.directory?(file)
|
|
18
|
-
next if File.basename(file) == "." || File.basename(file) == ".."
|
|
19
|
-
|
|
20
|
-
relative_path = Pathname.new(file).relative_path_from(Pathname.new(self.class.source_root)).to_s
|
|
21
|
-
copy_file relative_path
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "capybara/rspec"
|
|
4
|
-
|
|
5
|
-
module Panda
|
|
6
|
-
module Core
|
|
7
|
-
module Testing
|
|
8
|
-
module CapybaraConfig
|
|
9
|
-
def self.configure
|
|
10
|
-
Capybara.server = :puma, {Silent: true}
|
|
11
|
-
Capybara.default_max_wait_time = 5
|
|
12
|
-
Capybara.disable_animation = true
|
|
13
|
-
|
|
14
|
-
# Register Chrome driver with sensible defaults
|
|
15
|
-
if defined?(Cuprite)
|
|
16
|
-
Capybara.register_driver :panda_chrome do |app|
|
|
17
|
-
Cuprite::Driver.new(
|
|
18
|
-
app,
|
|
19
|
-
window_size: [1400, 1400],
|
|
20
|
-
browser_options: {
|
|
21
|
-
"no-sandbox": nil,
|
|
22
|
-
"disable-gpu": nil,
|
|
23
|
-
"disable-dev-shm-usage": nil
|
|
24
|
-
},
|
|
25
|
-
inspector: ENV["INSPECTOR"] == "true",
|
|
26
|
-
headless: ENV["HEADLESS"] != "false"
|
|
27
|
-
)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
Capybara.javascript_driver = :panda_chrome
|
|
31
|
-
Capybara.default_driver = :rack_test
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# Helper methods for system tests
|
|
36
|
-
module Helpers
|
|
37
|
-
def wait_for_ajax
|
|
38
|
-
Timeout.timeout(Capybara.default_max_wait_time) do
|
|
39
|
-
loop until page.evaluate_script("jQuery.active").zero?
|
|
40
|
-
end
|
|
41
|
-
rescue Timeout::Error
|
|
42
|
-
# Ajax didn't finish, but continue anyway
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def wait_for_turbo
|
|
46
|
-
has_css?("html", wait: 0.1)
|
|
47
|
-
return unless page.evaluate_script("typeof Turbo !== 'undefined'")
|
|
48
|
-
|
|
49
|
-
page.evaluate_script("Turbo.session.drive = false")
|
|
50
|
-
yield if block_given?
|
|
51
|
-
page.evaluate_script("Turbo.session.drive = true")
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def take_screenshot_on_failure
|
|
55
|
-
return unless page.driver.respond_to?(:save_screenshot)
|
|
56
|
-
|
|
57
|
-
timestamp = Time.now.strftime("%Y%m%d_%H%M%S")
|
|
58
|
-
filename = "screenshot_#{timestamp}_#{example.description.parameterize}.png"
|
|
59
|
-
path = Rails.root.join("tmp", "screenshots", filename)
|
|
60
|
-
|
|
61
|
-
FileUtils.mkdir_p(File.dirname(path))
|
|
62
|
-
page.driver.save_screenshot(path)
|
|
63
|
-
|
|
64
|
-
puts "\nScreenshot saved: #{path}"
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Panda
|
|
4
|
-
module Core
|
|
5
|
-
module Testing
|
|
6
|
-
module OmniAuthHelpers
|
|
7
|
-
def mock_omniauth_login(email: "admin@example.com", name: "Test User", provider: :google_oauth2, uid: "123456789", is_admin: true)
|
|
8
|
-
OmniAuth.config.test_mode = true
|
|
9
|
-
OmniAuth.config.mock_auth[provider] = OmniAuth::AuthHash.new(
|
|
10
|
-
provider: provider.to_s,
|
|
11
|
-
uid: uid,
|
|
12
|
-
info: {
|
|
13
|
-
email: email,
|
|
14
|
-
name: name,
|
|
15
|
-
image: "https://example.com/avatar.jpg"
|
|
16
|
-
}
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
# Create or update the user in the test database
|
|
20
|
-
Panda::Core::User.find_or_create_by(email: email) do |u|
|
|
21
|
-
# Split name into firstname and lastname
|
|
22
|
-
parts = name.split(" ", 2)
|
|
23
|
-
u.firstname = parts[0] || name
|
|
24
|
-
u.lastname = parts[1] || ""
|
|
25
|
-
u.admin = is_admin
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def login_as_admin(email: "admin@example.com", name: "Admin User")
|
|
30
|
-
user = mock_omniauth_login(email: email, name: name, is_admin: true)
|
|
31
|
-
visit "/admin/auth/google_oauth2"
|
|
32
|
-
user
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def login_as_user(email: "user@example.com", name: "Regular User")
|
|
36
|
-
user = mock_omniauth_login(email: email, name: name, is_admin: false)
|
|
37
|
-
visit "/admin/auth/google_oauth2"
|
|
38
|
-
user
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def logout
|
|
42
|
-
visit "/admin/logout"
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def mock_omniauth_failure(message = "Authentication failed")
|
|
46
|
-
OmniAuth.config.test_mode = true
|
|
47
|
-
OmniAuth.config.mock_auth[:google_oauth2] = :invalid_credentials
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Panda
|
|
4
|
-
module Core
|
|
5
|
-
module Testing
|
|
6
|
-
module RSpecConfig
|
|
7
|
-
def self.configure(config)
|
|
8
|
-
# Add common RSpec configurations
|
|
9
|
-
config.expect_with :rspec do |expectations|
|
|
10
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
config.mock_with :rspec do |mocks|
|
|
14
|
-
mocks.verify_partial_doubles = true
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
config.shared_context_metadata_behavior = :apply_to_host_groups
|
|
18
|
-
config.filter_run_when_matching :focus
|
|
19
|
-
config.example_status_persistence_file_path = "spec/examples.txt"
|
|
20
|
-
config.disable_monkey_patching!
|
|
21
|
-
|
|
22
|
-
if config.files_to_run.one?
|
|
23
|
-
config.default_formatter = "doc"
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
config.order = :random
|
|
27
|
-
Kernel.srand config.seed
|
|
28
|
-
|
|
29
|
-
# Database cleaner setup
|
|
30
|
-
if defined?(DatabaseCleaner)
|
|
31
|
-
config.before(:suite) do
|
|
32
|
-
DatabaseCleaner.strategy = :transaction
|
|
33
|
-
DatabaseCleaner.clean_with(:truncation)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
config.around(:each) do |example|
|
|
37
|
-
DatabaseCleaner.cleaning do
|
|
38
|
-
example.run
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# OmniAuth test mode
|
|
44
|
-
if defined?(OmniAuth)
|
|
45
|
-
config.before(:each) do
|
|
46
|
-
OmniAuth.config.test_mode = true
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
config.after(:each) do
|
|
50
|
-
OmniAuth.config.mock_auth.clear
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
# Common matchers for Panda gems
|
|
56
|
-
def self.setup_matchers
|
|
57
|
-
RSpec::Matchers.define :have_breadcrumb do |expected|
|
|
58
|
-
match do |page|
|
|
59
|
-
page.has_css?(".breadcrumb", text: expected)
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
RSpec::Matchers.define :have_flash_message do |type, message|
|
|
64
|
-
match do |page|
|
|
65
|
-
page.has_css?(".flash-message.flash-#{type}", text: message)
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|