baldur 0.2.0 → 0.2.3
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/Gemfile +1 -1
- data/TODO.md +7 -1
- data/app/assets/stylesheets/baldur/application/components/auth-page.css +7 -0
- data/app/assets/tailwind/baldur/engine.css +2 -2
- data/app/helpers/baldur/marketing_helper.rb +71 -69
- data/app/helpers/baldur/optional/auth_page_helper.rb +4 -2
- data/app/helpers/baldur/optional/google_auth_helper.rb +2 -2
- data/app/helpers/baldur/optional/panel_secondary_helper.rb +3 -2
- data/app/helpers/baldur/ui_helper.rb +151 -138
- data/app/helpers/baldur/ui_helper_feedback.rb +38 -36
- data/app/helpers/baldur/ui_helper_forms.rb +81 -76
- data/app/helpers/baldur/ui_helper_sidebar.rb +6 -5
- data/app/helpers/baldur/ui_helper_unavailable.rb +17 -15
- data/app/views/baldur/components/_theme_toggle.html.erb +23 -0
- data/app/views/baldur/optional/_auth_page.html.erb +6 -0
- data/baldur.gemspec +23 -23
- data/config/importmap.rb +2 -2
- data/lib/baldur/configuration.rb +6 -6
- data/lib/baldur/engine.rb +3 -3
- data/lib/baldur/version.rb +1 -1
- data/lib/baldur.rb +5 -5
- data/lib/generators/baldur/install/install_generator.rb +19 -19
- data/lib/generators/baldur/install/templates/baldur_initializer.rb +7 -7
- data/lib/generators/baldur/install/templates/theme.css +32 -6
- data/lib/generators/baldur/install_google_auth/install_google_auth_generator.rb +2 -2
- data/lib/generators/baldur/install_panel_right/install_panel_right_generator.rb +2 -2
- data/lib/generators/baldur/install_panel_secondary/install_panel_secondary_generator.rb +3 -3
- data/script/verify_host_install +59 -31
- data/test/confirmation_modal_helper_test.rb +34 -34
- data/test/csp_rendering_test.rb +21 -21
- data/test/engine_css_test.rb +36 -0
- data/test/fixtures/shared/_brand_lockup.html.erb +1 -0
- data/test/gemspec_test.rb +7 -5
- data/test/install_generator_test.rb +25 -21
- data/test/install_panel_secondary_generator_test.rb +12 -9
- data/test/marketing_helper_test.rb +7 -7
- data/test/run_all.rb +1 -1
- data/test/sidebar_helper_test.rb +16 -16
- data/test/test_helper.rb +14 -14
- data/test/theme_toggle_helper_test.rb +119 -0
- data/test/tmp/install_generator/app/assets/stylesheets/theme.css +32 -6
- data/test/tmp/install_generator/config/initializers/baldur.rb +7 -7
- metadata +5 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'baldur'
|
|
2
2
|
|
|
3
3
|
Baldur.configure do |config|
|
|
4
|
-
config.unavailable_fallback_message =
|
|
5
|
-
config.theme_storage_key =
|
|
4
|
+
config.unavailable_fallback_message = 'Missing metric or raw data required to compute this value.'
|
|
5
|
+
config.theme_storage_key = 'baldur.theme'
|
|
6
6
|
config.marketing_brand = {
|
|
7
|
-
name:
|
|
8
|
-
wordmark:
|
|
9
|
-
logo_src:
|
|
10
|
-
logo_alt:
|
|
7
|
+
name: 'Your Brand',
|
|
8
|
+
wordmark: 'Your Brand',
|
|
9
|
+
logo_src: '/icon.png',
|
|
10
|
+
logo_alt: 'Your Brand logo'
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
# Supply host-specific lookups when using unavailable dependency helpers.
|
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Host theme overrides.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* ── Brand inputs ─────────────────────────────────────────
|
|
5
|
+
* Override the four base palette tokens to rebrand. Baldur
|
|
6
|
+
* derives all semantic and role tokens from these inputs;
|
|
7
|
+
* do NOT override the semantic outputs directly.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* --_primary-base primary actions / CTA
|
|
10
|
+
* --_secondary-base sidebar, nav, subdued surfaces
|
|
11
|
+
* --_accent-base highlights, badges, tags
|
|
12
|
+
* --_neutral-base surfaces, text, borders
|
|
13
|
+
*
|
|
14
|
+
* Values are oklch(). To pick a color, convert to oklch and
|
|
15
|
+
* paste the three channels (L C H) — no parens needed:
|
|
16
|
+
*
|
|
17
|
+
* --_primary-base: oklch(0.68 0.16 27);
|
|
18
|
+
*
|
|
19
|
+
* ── Semantic tokens ──────────────────────────────────────
|
|
20
|
+
* Baldur owns all --color-* semantic tokens (e.g. --color-primary,
|
|
21
|
+
* --color-surface, --color-on-surface). They adapt between
|
|
22
|
+
* light/dark automatically. Do not override them here.
|
|
23
|
+
*
|
|
24
|
+
* ── Font mapping ─────────────────────────────────────────
|
|
25
|
+
* Load web fonts in fonts.css, then map the loaded families
|
|
26
|
+
* to the tokens below. Baldur uses --font-body as the default
|
|
27
|
+
* family for body, heading, and UI text unless overridden.
|
|
28
|
+
*
|
|
29
|
+
* --font-body body copy
|
|
30
|
+
* --font-heading headings (falls back to --font-body)
|
|
31
|
+
* --font-ui buttons, labels, form text (falls back to --font-body)
|
|
32
|
+
*
|
|
33
|
+
* ── Example ──────────────────────────────────────────────
|
|
10
34
|
* :root {
|
|
11
35
|
* --_primary-base: oklch(0.68 0.16 27);
|
|
12
36
|
* --_secondary-base: oklch(0.30 0.04 195);
|
|
@@ -15,6 +39,8 @@
|
|
|
15
39
|
* --font-body: "Geist", "Inter", "Segoe UI", "Helvetica Neue", Arial, system-ui, -apple-system, sans-serif;
|
|
16
40
|
* --font-heading: var(--font-body);
|
|
17
41
|
* --font-ui: var(--font-body);
|
|
42
|
+
* --font-family: var(--font-body);
|
|
43
|
+
* --font-sans: var(--font-body);
|
|
18
44
|
* }
|
|
19
45
|
*/
|
|
20
46
|
|
|
@@ -24,4 +50,4 @@
|
|
|
24
50
|
--font-ui: var(--font-body);
|
|
25
51
|
--font-family: var(--font-body);
|
|
26
52
|
--font-sans: var(--font-body);
|
|
27
|
-
}
|
|
53
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'rails/generators'
|
|
2
2
|
|
|
3
3
|
module Baldur
|
|
4
4
|
module Generators
|
|
5
5
|
class InstallGoogleAuthGenerator < Rails::Generators::Base
|
|
6
6
|
def create_helper
|
|
7
|
-
create_file
|
|
7
|
+
create_file 'app/helpers/google_auth_helper.rb', <<~RUBY
|
|
8
8
|
module GoogleAuthHelper
|
|
9
9
|
include Baldur::Optional::GoogleAuthHelper
|
|
10
10
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'rails/generators'
|
|
2
2
|
|
|
3
3
|
module Baldur
|
|
4
4
|
module Generators
|
|
5
5
|
class InstallPanelSecondaryGenerator < Rails::Generators::Base
|
|
6
6
|
def create_helper
|
|
7
|
-
create_file
|
|
7
|
+
create_file 'app/helpers/panel_secondary_helper.rb', <<~RUBY
|
|
8
8
|
module PanelSecondaryHelper
|
|
9
9
|
include Baldur::Optional::PanelSecondaryHelper
|
|
10
10
|
end
|
|
@@ -12,7 +12,7 @@ module Baldur
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def create_controller_shim
|
|
15
|
-
create_file
|
|
15
|
+
create_file 'app/javascript/controllers/panel_secondary_controller.js', <<~JS
|
|
16
16
|
export { default } from "baldur/controllers/panel_secondary_controller"
|
|
17
17
|
JS
|
|
18
18
|
end
|
data/script/verify_host_install
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
-
ENV[
|
|
4
|
+
ENV['RAILS_ENV'] ||= 'development'
|
|
5
5
|
|
|
6
|
-
require File.expand_path(
|
|
6
|
+
require File.expand_path('../../../config/environment', __dir__)
|
|
7
7
|
|
|
8
8
|
def assert!(message)
|
|
9
9
|
raise message unless yield
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def tailwind_entrypoint
|
|
13
|
-
Rails.root.join(
|
|
13
|
+
Rails.root.join('app/assets/tailwind/application.css')
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
puts
|
|
16
|
+
puts 'Baldur host install smoke check'
|
|
17
17
|
puts "Rails root: #{Rails.root}"
|
|
18
18
|
puts "Baldur root: #{Baldur::Engine.root}"
|
|
19
19
|
|
|
20
|
-
assert!(
|
|
21
|
-
Rails.application.config.importmap.paths.any?
|
|
20
|
+
assert!('Expected Baldur importmap path to be registered') do
|
|
21
|
+
Rails.application.config.importmap.paths.any? do |path|
|
|
22
|
+
path.to_s.end_with?('/config/importmap.rb') && path.to_s.include?('/baldur/')
|
|
23
|
+
end
|
|
22
24
|
end
|
|
23
25
|
|
|
24
26
|
%w[
|
|
@@ -33,34 +35,34 @@ end
|
|
|
33
35
|
assert!("Missing generated shim: #{relative_path}") { path.exist? }
|
|
34
36
|
end
|
|
35
37
|
|
|
36
|
-
assert!(
|
|
38
|
+
assert!('Expected ui_button helper to be available') do
|
|
37
39
|
ApplicationController.helpers.respond_to?(:ui_button)
|
|
38
40
|
end
|
|
39
41
|
|
|
40
|
-
button_html = ApplicationController.helpers.ui_button(label:
|
|
41
|
-
assert!(
|
|
42
|
-
button_html.include?(
|
|
42
|
+
button_html = ApplicationController.helpers.ui_button(label: 'Verify', href: '/')
|
|
43
|
+
assert!('ui_button did not render expected markup') do
|
|
44
|
+
button_html.include?('button') || button_html.include?('<a')
|
|
43
45
|
end
|
|
44
46
|
|
|
45
|
-
modal_html = ApplicationController.helpers.ui_modal(id:
|
|
46
|
-
assert!(
|
|
47
|
-
modal_html.include?(
|
|
47
|
+
modal_html = ApplicationController.helpers.ui_modal(id: 'verify-modal', title: 'Verify') { 'Body'.html_safe }
|
|
48
|
+
assert!('ui_modal did not render expected markup') do
|
|
49
|
+
modal_html.include?('dialog') || modal_html.include?('modal')
|
|
48
50
|
end
|
|
49
|
-
assert!(
|
|
50
|
-
modal_html.include?(
|
|
51
|
+
assert!('ui_modal did not render body content') do
|
|
52
|
+
modal_html.include?('Body')
|
|
51
53
|
end
|
|
52
54
|
|
|
53
|
-
card_html = ApplicationController.helpers.ui_card(title:
|
|
54
|
-
assert!(
|
|
55
|
-
card_html.include?(
|
|
55
|
+
card_html = ApplicationController.helpers.ui_card(title: 'Verify', body: 'Card body')
|
|
56
|
+
assert!('ui_card did not render body content') do
|
|
57
|
+
card_html.include?('Card body')
|
|
56
58
|
end
|
|
57
59
|
|
|
58
60
|
top_nav_html = ApplicationController.helpers.ui_marketing_top_nav(
|
|
59
|
-
links: [
|
|
60
|
-
primary_action: { label:
|
|
61
|
+
links: [{ label: 'Pricing', href: '/pricing', class: 'nav-link' }],
|
|
62
|
+
primary_action: { label: 'Verify', href: '/', variant: :primary }
|
|
61
63
|
)
|
|
62
|
-
assert!(
|
|
63
|
-
top_nav_html.include?(
|
|
64
|
+
assert!('ui_marketing_top_nav did not render expected markup') do
|
|
65
|
+
top_nav_html.include?('marketing-top-nav') && top_nav_html.include?('Pricing')
|
|
64
66
|
end
|
|
65
67
|
|
|
66
68
|
assert!("Expected Tailwind entrypoint at #{tailwind_entrypoint}") do
|
|
@@ -77,35 +79,61 @@ tailwind_source = tailwind_entrypoint.read
|
|
|
77
79
|
assert!("Missing Tailwind integration line: #{line}") { tailwind_source.include?(line) }
|
|
78
80
|
end
|
|
79
81
|
|
|
80
|
-
host_fonts = Rails.root.join(
|
|
82
|
+
host_fonts = Rails.root.join('app/assets/stylesheets/fonts.css')
|
|
81
83
|
assert!("Expected host font override scaffold at #{host_fonts}") do
|
|
82
84
|
host_fonts.exist?
|
|
83
85
|
end
|
|
84
86
|
|
|
85
|
-
host_theme = Rails.root.join(
|
|
87
|
+
host_theme = Rails.root.join('app/assets/stylesheets/theme.css')
|
|
86
88
|
assert!("Expected host theme override scaffold at #{host_theme}") do
|
|
87
89
|
host_theme.exist?
|
|
88
90
|
end
|
|
89
91
|
|
|
90
|
-
assert!(
|
|
92
|
+
assert!('Expected host fonts import before Tailwind in the entrypoint') do
|
|
91
93
|
tailwind_source.index('@import "../stylesheets/fonts.css";') <
|
|
92
94
|
tailwind_source.index('@import "tailwindcss";')
|
|
93
95
|
end
|
|
94
96
|
|
|
95
|
-
assert!(
|
|
97
|
+
assert!('Expected host theme override import after the Baldur import') do
|
|
96
98
|
tailwind_source.index('@import "../builds/tailwind/baldur.css";') <
|
|
97
99
|
tailwind_source.index('@import "../stylesheets/theme.css";')
|
|
98
100
|
end
|
|
99
101
|
|
|
100
|
-
assert!(
|
|
102
|
+
assert!('Expected Tailwind entrypoint to stop hard-coding Geist font imports') do
|
|
101
103
|
!tailwind_source.include?('family=Geist:wght@100..900')
|
|
102
104
|
end
|
|
103
105
|
|
|
106
|
+
engine_css = Baldur::Engine.root.join('app/assets/tailwind/baldur/engine.css')
|
|
107
|
+
if engine_css.exist?
|
|
108
|
+
engine_source = engine_css.read
|
|
109
|
+
%w[helpers views].each do |dir|
|
|
110
|
+
assert!("Expected @source for #{dir} with correct depth (../../../#{dir}) in engine.css") do
|
|
111
|
+
engine_source.include?("@source \"../../../#{dir}\"")
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
104
116
|
if ApplicationController.helpers.respond_to?(:ui_panel_secondary)
|
|
105
|
-
panel_html = ApplicationController.helpers.ui_panel_secondary(id:
|
|
106
|
-
|
|
107
|
-
|
|
117
|
+
panel_html = ApplicationController.helpers.ui_panel_secondary(id: 'verify-panel', title: 'Panel',
|
|
118
|
+
trigger_label: 'Open') do
|
|
119
|
+
'Body'.html_safe
|
|
120
|
+
end
|
|
121
|
+
assert!('ui_panel_secondary did not render expected markup') do
|
|
122
|
+
panel_html.include?('panel-secondary')
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
compiled_css_path = Rails.root.join('app/assets/builds/tailwind/application.css')
|
|
127
|
+
if compiled_css_path.exist?
|
|
128
|
+
compiled_css = compiled_css_path.read
|
|
129
|
+
%w[px-6 py-4 uppercase tracking-wide font-semibold].each do |utility|
|
|
130
|
+
assert!("Expected Baldur utility .#{utility} in compiled CSS — engine @source paths may be misconfigured") do
|
|
131
|
+
compiled_css.include?(".#{utility}")
|
|
132
|
+
end
|
|
108
133
|
end
|
|
134
|
+
else
|
|
135
|
+
warn "WARNING: Compiled Tailwind CSS not found at #{compiled_css_path}; skipping utility-class checks."
|
|
136
|
+
warn 'Run `bundle exec rails tailwindcss:build` then re-run this check.'
|
|
109
137
|
end
|
|
110
138
|
|
|
111
|
-
puts
|
|
139
|
+
puts 'Smoke check passed'
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
require_relative
|
|
2
|
-
require
|
|
3
|
-
require_relative
|
|
1
|
+
require_relative 'test_helper'
|
|
2
|
+
require 'action_controller'
|
|
3
|
+
require_relative '../lib/generators/baldur/install/install_generator'
|
|
4
4
|
|
|
5
5
|
class BaldurConfirmationModalHelperTest < Minitest::Test
|
|
6
6
|
class TestController < ActionController::Base
|
|
7
|
-
append_view_path File.expand_path(
|
|
7
|
+
append_view_path File.expand_path('../app/views', __dir__)
|
|
8
8
|
helper Baldur::UiHelper
|
|
9
9
|
helper Baldur::RenderHelper
|
|
10
10
|
end
|
|
@@ -24,7 +24,7 @@ class BaldurConfirmationModalHelperTest < Minitest::Test
|
|
|
24
24
|
assert_includes html, 'data-modal-selector-value="#test-modal"'
|
|
25
25
|
assert_includes html, 'data-modal="true"'
|
|
26
26
|
assert_includes html, 'aria-hidden="true"'
|
|
27
|
-
assert_includes html,
|
|
27
|
+
assert_includes html, 'Modal content'
|
|
28
28
|
assert_includes html, 'class="fixed inset-0 z-50'
|
|
29
29
|
end
|
|
30
30
|
|
|
@@ -38,8 +38,8 @@ class BaldurConfirmationModalHelperTest < Minitest::Test
|
|
|
38
38
|
formats: [:html]
|
|
39
39
|
)
|
|
40
40
|
|
|
41
|
-
assert_includes html,
|
|
42
|
-
assert_includes html,
|
|
41
|
+
assert_includes html, 'my-extra-class'
|
|
42
|
+
assert_includes html, 'Custom'
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def test_ui_confirmation_modal_renders_basic_structure
|
|
@@ -57,9 +57,9 @@ class BaldurConfirmationModalHelperTest < Minitest::Test
|
|
|
57
57
|
assert_includes html, 'id="delete-modal"'
|
|
58
58
|
assert_includes html, 'id="delete-dialog"'
|
|
59
59
|
assert_includes html, 'data-controller="modal"'
|
|
60
|
-
assert_includes html,
|
|
61
|
-
assert_includes html,
|
|
62
|
-
assert_includes html,
|
|
60
|
+
assert_includes html, 'Delete item?'
|
|
61
|
+
assert_includes html, 'Confirm'
|
|
62
|
+
assert_includes html, 'Cancel'
|
|
63
63
|
assert_includes html, 'data-modal-close="true"'
|
|
64
64
|
end
|
|
65
65
|
|
|
@@ -76,8 +76,8 @@ class BaldurConfirmationModalHelperTest < Minitest::Test
|
|
|
76
76
|
formats: [:html]
|
|
77
77
|
)
|
|
78
78
|
|
|
79
|
-
assert_includes html,
|
|
80
|
-
assert_includes html,
|
|
79
|
+
assert_includes html, 'color-error'
|
|
80
|
+
assert_includes html, 'Discard collection?'
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
def test_ui_confirmation_modal_default_tone_no_icon
|
|
@@ -92,8 +92,8 @@ class BaldurConfirmationModalHelperTest < Minitest::Test
|
|
|
92
92
|
formats: [:html]
|
|
93
93
|
)
|
|
94
94
|
|
|
95
|
-
refute_includes html,
|
|
96
|
-
assert_includes html,
|
|
95
|
+
refute_includes html, 'color-error'
|
|
96
|
+
assert_includes html, 'Proceed?'
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
def test_ui_confirmation_modal_danger_tone_sets_danger_button_variant
|
|
@@ -109,7 +109,7 @@ class BaldurConfirmationModalHelperTest < Minitest::Test
|
|
|
109
109
|
formats: [:html]
|
|
110
110
|
)
|
|
111
111
|
|
|
112
|
-
assert_includes html,
|
|
112
|
+
assert_includes html, 'button--error'
|
|
113
113
|
end
|
|
114
114
|
|
|
115
115
|
def test_ui_confirmation_modal_default_tone_sets_primary_button_variant
|
|
@@ -124,8 +124,8 @@ class BaldurConfirmationModalHelperTest < Minitest::Test
|
|
|
124
124
|
formats: [:html]
|
|
125
125
|
)
|
|
126
126
|
|
|
127
|
-
assert_includes html,
|
|
128
|
-
refute_includes html,
|
|
127
|
+
assert_includes html, 'button--filled'
|
|
128
|
+
refute_includes html, 'button--error'
|
|
129
129
|
end
|
|
130
130
|
|
|
131
131
|
def test_ui_confirmation_modal_with_type_to_confirm
|
|
@@ -149,15 +149,15 @@ class BaldurConfirmationModalHelperTest < Minitest::Test
|
|
|
149
149
|
formats: [:html]
|
|
150
150
|
)
|
|
151
151
|
|
|
152
|
-
assert_includes html,
|
|
153
|
-
assert_includes html,
|
|
152
|
+
assert_includes html, 'modal confirmation'
|
|
153
|
+
assert_includes html, 'confirmation-case-sensitive-value'
|
|
154
154
|
assert_includes html, 'data-confirmation-target="input"'
|
|
155
155
|
assert_includes html, 'data-confirmation-target="submit"'
|
|
156
|
-
assert_includes html,
|
|
157
|
-
assert_includes html,
|
|
158
|
-
assert_includes html,
|
|
159
|
-
assert_includes html,
|
|
160
|
-
assert_includes html,
|
|
156
|
+
assert_includes html, 'confirmation#validate'
|
|
157
|
+
assert_includes html, 'Type confirm to continue'
|
|
158
|
+
assert_includes html, 'This permanently removes all data.'
|
|
159
|
+
assert_includes html, 'Flush All Data'
|
|
160
|
+
assert_includes html, 'Confirm'
|
|
161
161
|
end
|
|
162
162
|
|
|
163
163
|
def test_ui_confirmation_modal_type_to_confirm_disables_submit
|
|
@@ -176,8 +176,8 @@ class BaldurConfirmationModalHelperTest < Minitest::Test
|
|
|
176
176
|
formats: [:html]
|
|
177
177
|
)
|
|
178
178
|
|
|
179
|
-
assert_includes html,
|
|
180
|
-
assert_includes html,
|
|
179
|
+
assert_includes html, 'disabled'
|
|
180
|
+
assert_includes html, 'Type DELETE'
|
|
181
181
|
end
|
|
182
182
|
|
|
183
183
|
def test_ui_confirmation_modal_type_to_confirm_case_insensitive
|
|
@@ -196,9 +196,9 @@ class BaldurConfirmationModalHelperTest < Minitest::Test
|
|
|
196
196
|
formats: [:html]
|
|
197
197
|
)
|
|
198
198
|
|
|
199
|
-
assert_includes html,
|
|
200
|
-
refute_includes html,
|
|
201
|
-
assert_includes html,
|
|
199
|
+
assert_includes html, 'confirmation-case-sensitive-value'
|
|
200
|
+
refute_includes html, 'case-sensitive-value="true"'
|
|
201
|
+
assert_includes html, 'case-sensitive-value="false"'
|
|
202
202
|
end
|
|
203
203
|
|
|
204
204
|
def test_ui_confirmation_modal_without_type_to_confirm_has_no_confirmation_controller
|
|
@@ -214,7 +214,7 @@ class BaldurConfirmationModalHelperTest < Minitest::Test
|
|
|
214
214
|
)
|
|
215
215
|
|
|
216
216
|
assert_includes html, 'data-controller="modal"'
|
|
217
|
-
refute_includes html,
|
|
217
|
+
refute_includes html, 'confirmation'
|
|
218
218
|
end
|
|
219
219
|
|
|
220
220
|
def test_ui_confirmation_modal_custom_labels
|
|
@@ -231,11 +231,11 @@ class BaldurConfirmationModalHelperTest < Minitest::Test
|
|
|
231
231
|
formats: [:html]
|
|
232
232
|
)
|
|
233
233
|
|
|
234
|
-
assert_includes html,
|
|
235
|
-
assert_includes html,
|
|
234
|
+
assert_includes html, 'Discard'
|
|
235
|
+
assert_includes html, 'Go back'
|
|
236
236
|
end
|
|
237
237
|
|
|
238
238
|
def test_install_generator_includes_confirmation_controller
|
|
239
|
-
assert_includes Baldur::Generators::InstallGenerator::CORE_CONTROLLERS,
|
|
239
|
+
assert_includes Baldur::Generators::InstallGenerator::CORE_CONTROLLERS, 'confirmation'
|
|
240
240
|
end
|
|
241
|
-
end
|
|
241
|
+
end
|
data/test/csp_rendering_test.rb
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
require_relative
|
|
1
|
+
require_relative 'test_helper'
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require 'action_controller'
|
|
4
4
|
|
|
5
5
|
class BaldurCspRenderingTest < Minitest::Test
|
|
6
6
|
class TestController < ActionController::Base
|
|
7
|
-
append_view_path File.expand_path(
|
|
7
|
+
append_view_path File.expand_path('../app/views', __dir__)
|
|
8
8
|
helper Baldur::UiHelper
|
|
9
9
|
helper Baldur::UiHelperForms
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def test_tooltip_renders_without_inline_style_attribute
|
|
13
13
|
html = TestController.render(
|
|
14
|
-
partial:
|
|
14
|
+
partial: 'baldur/components/tooltip',
|
|
15
15
|
locals: {
|
|
16
|
-
text:
|
|
17
|
-
content:
|
|
16
|
+
text: 'Info',
|
|
17
|
+
content: 'Tooltip body',
|
|
18
18
|
show_icon: true,
|
|
19
|
-
icon:
|
|
19
|
+
icon: 'circle-help',
|
|
20
20
|
variant: :link,
|
|
21
21
|
wrapper_class: nil,
|
|
22
22
|
trigger_class: nil,
|
|
@@ -31,26 +31,26 @@ class BaldurCspRenderingTest < Minitest::Test
|
|
|
31
31
|
|
|
32
32
|
def test_date_field_renders_hidden_native_input_class_without_inline_style
|
|
33
33
|
html = TestController.render(
|
|
34
|
-
partial:
|
|
34
|
+
partial: 'baldur/components/date_field',
|
|
35
35
|
locals: {
|
|
36
|
-
wrapper_classes:
|
|
37
|
-
label:
|
|
36
|
+
wrapper_classes: 'field date-field',
|
|
37
|
+
label: 'Due date',
|
|
38
38
|
supporting_text: nil,
|
|
39
39
|
display_input_options: {
|
|
40
|
-
id:
|
|
41
|
-
class:
|
|
42
|
-
type:
|
|
43
|
-
name:
|
|
40
|
+
id: 'due-date-display',
|
|
41
|
+
class: 'text-field__control date-field__display',
|
|
42
|
+
type: 'text',
|
|
43
|
+
name: 'due_date'
|
|
44
44
|
},
|
|
45
45
|
native_input_options: {
|
|
46
|
-
id:
|
|
47
|
-
class:
|
|
48
|
-
type:
|
|
49
|
-
tabindex:
|
|
46
|
+
id: 'due-date-native',
|
|
47
|
+
class: 'date-field__native date-field__native--hidden',
|
|
48
|
+
type: 'date',
|
|
49
|
+
tabindex: '-1'
|
|
50
50
|
},
|
|
51
|
-
toggle_label:
|
|
52
|
-
icon_name:
|
|
53
|
-
support_id:
|
|
51
|
+
toggle_label: 'Open date picker',
|
|
52
|
+
icon_name: 'calendar',
|
|
53
|
+
support_id: 'due-date-support'
|
|
54
54
|
}
|
|
55
55
|
)
|
|
56
56
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require_relative 'test_helper'
|
|
2
|
+
|
|
3
|
+
class EngineCssTest < Minitest::Test
|
|
4
|
+
def engine_css_path
|
|
5
|
+
Baldur::Engine.root.join('app/assets/tailwind/baldur/engine.css')
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def test_engine_css_exists
|
|
9
|
+
assert engine_css_path.exist?, "engine.css missing at #{engine_css_path}"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_source_paths_resolve_to_app_helpers_and_views
|
|
13
|
+
skip('engine.css not found') unless engine_css_path.exist?
|
|
14
|
+
|
|
15
|
+
source = engine_css_path.read
|
|
16
|
+
|
|
17
|
+
%w[helpers views].each do |dir|
|
|
18
|
+
assert_includes source, "@source \"../../../#{dir}\"",
|
|
19
|
+
"engine.css @source for #{dir} must resolve from app/assets/tailwind/baldur/ → app/#{dir}\n" \
|
|
20
|
+
"Expected: @source \"../../../#{dir}\"\n" \
|
|
21
|
+
"Got: check #{engine_css_path}"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_source_paths_do_not_use_shallow_relative
|
|
26
|
+
skip('engine.css not found') unless engine_css_path.exist?
|
|
27
|
+
|
|
28
|
+
source = engine_css_path.read
|
|
29
|
+
|
|
30
|
+
%w[helpers views].each do |dir|
|
|
31
|
+
refute_includes source, "@source \"../../#{dir}\"",
|
|
32
|
+
"engine.css uses shallow @source \"../../#{dir}\" which resolves to app/assets/tailwind/#{dir} (nonexistent)\n" \
|
|
33
|
+
"Must use \"../../../#{dir}\" to reach app/#{dir}"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div class="brand-lockup"><span>Brand</span></div>
|
data/test/gemspec_test.rb
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
require_relative
|
|
1
|
+
require_relative 'test_helper'
|
|
2
2
|
|
|
3
3
|
class BaldurGemspecTest < Minitest::Test
|
|
4
4
|
def test_gemspec_lists_only_files
|
|
5
|
-
spec = Gem::Specification.load(File.expand_path(
|
|
5
|
+
spec = Gem::Specification.load(File.expand_path('../baldur.gemspec', __dir__))
|
|
6
6
|
|
|
7
|
-
assert spec.files.any?,
|
|
8
|
-
assert spec.files.all? { |path|
|
|
9
|
-
|
|
7
|
+
assert spec.files.any?, 'expected gemspec to include files'
|
|
8
|
+
assert spec.files.all? { |path|
|
|
9
|
+
File.file?(File.expand_path("../#{path}", __dir__))
|
|
10
|
+
}, 'expected spec.files to contain only files'
|
|
11
|
+
assert_includes spec.files, 'app/assets/tailwind/baldur/engine.css'
|
|
10
12
|
end
|
|
11
13
|
end
|
|
@@ -1,37 +1,41 @@
|
|
|
1
|
-
require_relative
|
|
2
|
-
require_relative
|
|
1
|
+
require_relative 'test_helper'
|
|
2
|
+
require_relative '../lib/generators/baldur/install/install_generator'
|
|
3
3
|
|
|
4
4
|
class BaldurInstallGeneratorTest < Rails::Generators::TestCase
|
|
5
5
|
tests Baldur::Generators::InstallGenerator
|
|
6
|
-
destination File.expand_path(
|
|
6
|
+
destination File.expand_path('tmp/install_generator', __dir__)
|
|
7
7
|
setup :prepare_destination
|
|
8
8
|
|
|
9
9
|
setup do
|
|
10
|
-
FileUtils.mkdir_p File.join(destination_root,
|
|
11
|
-
File.write(File.join(destination_root,
|
|
10
|
+
FileUtils.mkdir_p File.join(destination_root, 'app/assets/tailwind')
|
|
11
|
+
File.write(File.join(destination_root, 'app/assets/tailwind/application.css'), "@import \"tailwindcss\";\n")
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
test
|
|
14
|
+
test 'installs path agnostic tailwind integration and helper shims' do
|
|
15
15
|
run_generator
|
|
16
16
|
|
|
17
|
-
tailwind_entrypoint = File.join(destination_root,
|
|
17
|
+
tailwind_entrypoint = File.join(destination_root, 'app/assets/tailwind/application.css')
|
|
18
18
|
tailwind_source = File.read(tailwind_entrypoint)
|
|
19
19
|
|
|
20
|
-
assert_includes tailwind_source,
|
|
21
|
-
assert_includes tailwind_source,
|
|
22
|
-
assert_includes tailwind_source,
|
|
23
|
-
refute_includes tailwind_source,
|
|
20
|
+
assert_includes tailwind_source, '@import "../stylesheets/fonts.css";'
|
|
21
|
+
assert_includes tailwind_source, '@import "../builds/tailwind/baldur.css";'
|
|
22
|
+
assert_includes tailwind_source, '@import "../stylesheets/theme.css";'
|
|
23
|
+
refute_includes tailwind_source, 'gems/baldur'
|
|
24
24
|
|
|
25
|
-
assert_operator tailwind_source.index(
|
|
26
|
-
|
|
25
|
+
assert_operator tailwind_source.index('@import "../stylesheets/fonts.css";'), :<,
|
|
26
|
+
tailwind_source.index('@import "tailwindcss";')
|
|
27
|
+
assert_operator tailwind_source.index('@import "../builds/tailwind/baldur.css";'), :<,
|
|
28
|
+
tailwind_source.index('@import "../stylesheets/theme.css";')
|
|
27
29
|
|
|
28
|
-
assert_file
|
|
29
|
-
assert_file
|
|
30
|
-
assert_file
|
|
31
|
-
assert_file
|
|
32
|
-
assert_file
|
|
33
|
-
assert_file
|
|
34
|
-
|
|
35
|
-
assert_file
|
|
30
|
+
assert_file 'app/helpers/ui_helper.rb'
|
|
31
|
+
assert_file 'app/helpers/ui_helper.rb', /include Baldur::Optional::AuthPageHelper/
|
|
32
|
+
assert_file 'config/initializers/baldur.rb'
|
|
33
|
+
assert_file 'app/assets/stylesheets/fonts.css'
|
|
34
|
+
assert_file 'app/assets/stylesheets/theme.css'
|
|
35
|
+
assert_file 'app/javascript/controllers/mobile_sidebar_controller.js',
|
|
36
|
+
%r{export \{ default \} from "baldur/controllers/mobile_sidebar_controller"}
|
|
37
|
+
assert_file 'app/javascript/controllers/sidebar_controller.js',
|
|
38
|
+
%r{export \{ default \} from "baldur/controllers/sidebar_controller"}
|
|
39
|
+
assert_file 'app/javascript/lib/snackbar.js', %r{export \* from "baldur/lib/snackbar"}
|
|
36
40
|
end
|
|
37
41
|
end
|