baldur 0.2.0 → 0.2.4

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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/TODO.md +7 -1
  4. data/app/assets/stylesheets/baldur/application/components/auth-page.css +7 -0
  5. data/app/assets/stylesheets/baldur/application/components/confirmation.css +0 -6
  6. data/app/assets/tailwind/baldur/engine.css +2 -2
  7. data/app/helpers/baldur/marketing_helper.rb +71 -69
  8. data/app/helpers/baldur/optional/auth_page_helper.rb +4 -2
  9. data/app/helpers/baldur/optional/google_auth_helper.rb +2 -2
  10. data/app/helpers/baldur/optional/panel_secondary_helper.rb +3 -2
  11. data/app/helpers/baldur/ui_helper.rb +151 -138
  12. data/app/helpers/baldur/ui_helper_feedback.rb +38 -36
  13. data/app/helpers/baldur/ui_helper_forms.rb +81 -76
  14. data/app/helpers/baldur/ui_helper_sidebar.rb +6 -5
  15. data/app/helpers/baldur/ui_helper_unavailable.rb +17 -15
  16. data/app/views/baldur/components/_confirmation_modal.html.erb +13 -13
  17. data/app/views/baldur/components/_theme_toggle.html.erb +23 -0
  18. data/app/views/baldur/optional/_auth_page.html.erb +6 -0
  19. data/baldur.gemspec +23 -23
  20. data/config/importmap.rb +2 -2
  21. data/lib/baldur/configuration.rb +6 -6
  22. data/lib/baldur/engine.rb +3 -3
  23. data/lib/baldur/version.rb +1 -1
  24. data/lib/baldur.rb +5 -5
  25. data/lib/generators/baldur/install/install_generator.rb +19 -19
  26. data/lib/generators/baldur/install/templates/baldur_initializer.rb +7 -7
  27. data/lib/generators/baldur/install/templates/theme.css +32 -6
  28. data/lib/generators/baldur/install_google_auth/install_google_auth_generator.rb +2 -2
  29. data/lib/generators/baldur/install_panel_right/install_panel_right_generator.rb +2 -2
  30. data/lib/generators/baldur/install_panel_secondary/install_panel_secondary_generator.rb +3 -3
  31. data/script/verify_host_install +59 -31
  32. data/test/confirmation_modal_helper_test.rb +37 -34
  33. data/test/csp_rendering_test.rb +21 -21
  34. data/test/engine_css_test.rb +36 -0
  35. data/test/fixtures/shared/_brand_lockup.html.erb +1 -0
  36. data/test/gemspec_test.rb +7 -5
  37. data/test/install_generator_test.rb +25 -21
  38. data/test/install_panel_secondary_generator_test.rb +12 -9
  39. data/test/marketing_helper_test.rb +7 -7
  40. data/test/run_all.rb +1 -1
  41. data/test/sidebar_helper_test.rb +16 -16
  42. data/test/test_helper.rb +14 -14
  43. data/test/theme_toggle_helper_test.rb +119 -0
  44. data/test/tmp/install_generator/app/assets/stylesheets/theme.css +32 -6
  45. data/test/tmp/install_generator/config/initializers/baldur.rb +7 -7
  46. metadata +5 -1
@@ -1,9 +1,9 @@
1
- require "rails/generators"
1
+ require 'rails/generators'
2
2
 
3
3
  module Baldur
4
4
  module Generators
5
5
  class InstallGenerator < Rails::Generators::Base
6
- source_root File.expand_path("templates", __dir__)
6
+ source_root File.expand_path('templates', __dir__)
7
7
 
8
8
  CORE_CONTROLLERS = %w[
9
9
  accordion
@@ -35,19 +35,19 @@ module Baldur
35
35
  ].freeze
36
36
 
37
37
  def create_ui_helper
38
- template "ui_helper.rb", "app/helpers/ui_helper.rb"
38
+ template 'ui_helper.rb', 'app/helpers/ui_helper.rb'
39
39
  end
40
40
 
41
41
  def create_initializer
42
- template "baldur_initializer.rb", "config/initializers/baldur.rb"
42
+ template 'baldur_initializer.rb', 'config/initializers/baldur.rb'
43
43
  end
44
44
 
45
45
  def create_theme_override
46
- template "theme.css", "app/assets/stylesheets/theme.css"
46
+ template 'theme.css', 'app/assets/stylesheets/theme.css'
47
47
  end
48
48
 
49
49
  def create_fonts_override
50
- template "fonts.css", "app/assets/stylesheets/fonts.css"
50
+ template 'fonts.css', 'app/assets/stylesheets/fonts.css'
51
51
  end
52
52
 
53
53
  def create_controller_shims
@@ -69,9 +69,9 @@ module Baldur
69
69
  def add_stylesheet_import
70
70
  return unless File.exist?(tailwind_entrypoint_path)
71
71
 
72
- append_unique_line tailwind_entrypoint_path, "@import \"../stylesheets/fonts.css\";"
73
- append_unique_line tailwind_entrypoint_path, "@import \"../builds/tailwind/baldur.css\";"
74
- append_unique_line tailwind_entrypoint_path, "@import \"../stylesheets/theme.css\";"
72
+ append_unique_line tailwind_entrypoint_path, '@import "../stylesheets/fonts.css";'
73
+ append_unique_line tailwind_entrypoint_path, '@import "../builds/tailwind/baldur.css";'
74
+ append_unique_line tailwind_entrypoint_path, '@import "../stylesheets/theme.css";'
75
75
  ensure_stylesheet_import_order
76
76
  end
77
77
 
@@ -83,19 +83,19 @@ module Baldur
83
83
 
84
84
  def ensure_stylesheet_import_order
85
85
  source = File.read(tailwind_entrypoint_path)
86
- fonts_import = "@import \"../stylesheets/fonts.css\";"
87
- tailwind_import = "@import \"tailwindcss\";"
88
- baldur_import = "@import \"../builds/tailwind/baldur.css\";"
89
- theme_import = "@import \"../stylesheets/theme.css\";"
86
+ fonts_import = '@import "../stylesheets/fonts.css";'
87
+ tailwind_import = '@import "tailwindcss";'
88
+ baldur_import = '@import "../builds/tailwind/baldur.css";'
89
+ theme_import = '@import "../stylesheets/theme.css";'
90
90
  normalized = source.lines.reject { |line| line.strip == fonts_import }.join
91
91
  normalized = if normalized.include?(tailwind_import)
92
- normalized.sub("#{tailwind_import}\n", "#{fonts_import}\n#{tailwind_import}\n")
93
- else
94
- "#{fonts_import}\n#{normalized}"
95
- end
92
+ normalized.sub("#{tailwind_import}\n", "#{fonts_import}\n#{tailwind_import}\n")
93
+ else
94
+ "#{fonts_import}\n#{normalized}"
95
+ end
96
96
 
97
97
  if normalized.include?(baldur_import) && normalized.include?(theme_import) &&
98
- normalized.index(baldur_import) > normalized.index(theme_import)
98
+ normalized.index(baldur_import) > normalized.index(theme_import)
99
99
  normalized = normalized.lines.reject { |line| line.strip == theme_import }.join
100
100
  normalized = normalized.sub("#{baldur_import}\n", "#{baldur_import}\n#{theme_import}\n")
101
101
  end
@@ -108,7 +108,7 @@ module Baldur
108
108
  end
109
109
 
110
110
  def tailwind_entrypoint
111
- "app/assets/tailwind/application.css"
111
+ 'app/assets/tailwind/application.css'
112
112
  end
113
113
  end
114
114
  end
@@ -1,13 +1,13 @@
1
- require "baldur"
1
+ require 'baldur'
2
2
 
3
3
  Baldur.configure do |config|
4
- config.unavailable_fallback_message = "Missing metric or raw data required to compute this value."
5
- config.theme_storage_key = "baldur.theme"
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: "Your Brand",
8
- wordmark: "Your Brand",
9
- logo_src: "/icon.png",
10
- logo_alt: "Your Brand logo"
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
- * Override only the base palette inputs below. Baldur remains the source of
5
- * truth for semantic tokens, light/dark role mapping, and component styling.
6
- * Use `fonts.css` to load font files, then map those loaded families to the
7
- * font tokens below.
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
- * Example:
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 "rails/generators"
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 "app/helpers/google_auth_helper.rb", <<~RUBY
7
+ create_file 'app/helpers/google_auth_helper.rb', <<~RUBY
8
8
  module GoogleAuthHelper
9
9
  include Baldur::Optional::GoogleAuthHelper
10
10
  end
@@ -1,5 +1,5 @@
1
- require "rails/generators"
2
- require_relative "../install_panel_secondary/install_panel_secondary_generator"
1
+ require 'rails/generators'
2
+ require_relative '../install_panel_secondary/install_panel_secondary_generator'
3
3
 
4
4
  module Baldur
5
5
  module Generators
@@ -1,10 +1,10 @@
1
- require "rails/generators"
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 "app/helpers/panel_secondary_helper.rb", <<~RUBY
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 "app/javascript/controllers/panel_secondary_controller.js", <<~JS
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
@@ -1,24 +1,26 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- ENV["RAILS_ENV"] ||= "development"
4
+ ENV['RAILS_ENV'] ||= 'development'
5
5
 
6
- require File.expand_path("../../../config/environment", __dir__)
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("app/assets/tailwind/application.css")
13
+ Rails.root.join('app/assets/tailwind/application.css')
14
14
  end
15
15
 
16
- puts "Baldur host install smoke check"
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!("Expected Baldur importmap path to be registered") do
21
- Rails.application.config.importmap.paths.any? { |path| path.to_s.end_with?("/config/importmap.rb") && path.to_s.include?("/baldur/") }
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!("Expected ui_button helper to be available") do
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: "Verify", href: "/")
41
- assert!("ui_button did not render expected markup") do
42
- button_html.include?("button") || button_html.include?("<a")
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: "verify-modal", title: "Verify") { "Body".html_safe }
46
- assert!("ui_modal did not render expected markup") do
47
- modal_html.include?("dialog") || modal_html.include?("modal")
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!("ui_modal did not render body content") do
50
- modal_html.include?("Body")
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: "Verify", body: "Card body")
54
- assert!("ui_card did not render body content") do
55
- card_html.include?("Card body")
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: [ { label: "Pricing", href: "/pricing", class: "nav-link" } ],
60
- primary_action: { label: "Verify", href: "/", variant: :primary }
61
+ links: [{ label: 'Pricing', href: '/pricing', class: 'nav-link' }],
62
+ primary_action: { label: 'Verify', href: '/', variant: :primary }
61
63
  )
62
- assert!("ui_marketing_top_nav did not render expected markup") do
63
- top_nav_html.include?("marketing-top-nav") && top_nav_html.include?("Pricing")
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("app/assets/stylesheets/fonts.css")
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("app/assets/stylesheets/theme.css")
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!("Expected host fonts import before Tailwind in the entrypoint") do
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!("Expected host theme override import after the Baldur import") do
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!("Expected Tailwind entrypoint to stop hard-coding Geist font imports") do
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: "verify-panel", title: "Panel", trigger_label: "Open") { "Body".html_safe }
106
- assert!("ui_panel_secondary did not render expected markup") do
107
- panel_html.include?("panel-secondary")
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 "Smoke check passed"
139
+ puts 'Smoke check passed'
@@ -1,10 +1,10 @@
1
- require_relative "test_helper"
2
- require "action_controller"
3
- require_relative "../lib/generators/baldur/install/install_generator"
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("../app/views", __dir__)
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, "Modal content"
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, "my-extra-class"
42
- assert_includes html, "Custom"
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, "Delete item?"
61
- assert_includes html, "Confirm"
62
- assert_includes html, "Cancel"
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, "color-error"
80
- assert_includes html, "Discard collection?"
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, "color-error"
96
- assert_includes html, "Proceed?"
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, "button--error"
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, "button--filled"
128
- refute_includes html, "button--error"
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,17 @@ class BaldurConfirmationModalHelperTest < Minitest::Test
149
149
  formats: [:html]
150
150
  )
151
151
 
152
- assert_includes html, "modal confirmation"
153
- assert_includes html, "confirmation-case-sensitive-value"
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, "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"
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
+ assert_includes html, 'field text-field'
162
+ assert_includes html, 'field__label'
161
163
  end
162
164
 
163
165
  def test_ui_confirmation_modal_type_to_confirm_disables_submit
@@ -176,8 +178,8 @@ class BaldurConfirmationModalHelperTest < Minitest::Test
176
178
  formats: [:html]
177
179
  )
178
180
 
179
- assert_includes html, "disabled"
180
- assert_includes html, "Type DELETE"
181
+ assert_includes html, 'disabled'
182
+ assert_includes html, 'Type DELETE'
181
183
  end
182
184
 
183
185
  def test_ui_confirmation_modal_type_to_confirm_case_insensitive
@@ -196,9 +198,9 @@ class BaldurConfirmationModalHelperTest < Minitest::Test
196
198
  formats: [:html]
197
199
  )
198
200
 
199
- assert_includes html, "confirmation-case-sensitive-value"
200
- refute_includes html, "case-sensitive-value=\"true\""
201
- assert_includes html, "case-sensitive-value=&quot;false&quot;"
201
+ assert_includes html, 'confirmation-case-sensitive-value'
202
+ refute_includes html, 'case-sensitive-value="true"'
203
+ assert_includes html, 'case-sensitive-value=&quot;false&quot;'
202
204
  end
203
205
 
204
206
  def test_ui_confirmation_modal_without_type_to_confirm_has_no_confirmation_controller
@@ -214,7 +216,8 @@ class BaldurConfirmationModalHelperTest < Minitest::Test
214
216
  )
215
217
 
216
218
  assert_includes html, 'data-controller="modal"'
217
- refute_includes html, "confirmation"
219
+ refute_includes html, 'confirmation'
220
+ refute_includes html, 'field text-field'
218
221
  end
219
222
 
220
223
  def test_ui_confirmation_modal_custom_labels
@@ -231,11 +234,11 @@ class BaldurConfirmationModalHelperTest < Minitest::Test
231
234
  formats: [:html]
232
235
  )
233
236
 
234
- assert_includes html, "Discard"
235
- assert_includes html, "Go back"
237
+ assert_includes html, 'Discard'
238
+ assert_includes html, 'Go back'
236
239
  end
237
240
 
238
241
  def test_install_generator_includes_confirmation_controller
239
- assert_includes Baldur::Generators::InstallGenerator::CORE_CONTROLLERS, "confirmation"
242
+ assert_includes Baldur::Generators::InstallGenerator::CORE_CONTROLLERS, 'confirmation'
240
243
  end
241
- end
244
+ end
@@ -1,22 +1,22 @@
1
- require_relative "test_helper"
1
+ require_relative 'test_helper'
2
2
 
3
- require "action_controller"
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("../app/views", __dir__)
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: "baldur/components/tooltip",
14
+ partial: 'baldur/components/tooltip',
15
15
  locals: {
16
- text: "Info",
17
- content: "Tooltip body",
16
+ text: 'Info',
17
+ content: 'Tooltip body',
18
18
  show_icon: true,
19
- icon: "circle-help",
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: "baldur/components/date_field",
34
+ partial: 'baldur/components/date_field',
35
35
  locals: {
36
- wrapper_classes: "field date-field",
37
- label: "Due date",
36
+ wrapper_classes: 'field date-field',
37
+ label: 'Due date',
38
38
  supporting_text: nil,
39
39
  display_input_options: {
40
- id: "due-date-display",
41
- class: "text-field__control date-field__display",
42
- type: "text",
43
- name: "due_date"
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: "due-date-native",
47
- class: "date-field__native date-field__native--hidden",
48
- type: "date",
49
- tabindex: "-1"
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: "Open date picker",
52
- icon_name: "calendar",
53
- support_id: "due-date-support"
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>