baldur 0.1.7 → 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/README.md +78 -376
- data/TODO.md +53 -5
- data/app/assets/javascripts/baldur/controllers/confirmation_controller.js +23 -0
- data/app/assets/stylesheets/baldur/application/components/auth-page.css +7 -0
- data/app/assets/stylesheets/baldur/application/components/confirmation.css +11 -0
- data/app/assets/stylesheets/baldur/application/components/sidebar.css +234 -0
- data/app/assets/stylesheets/baldur.css +1 -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 +159 -121
- 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/_confirmation_modal.html.erb +99 -0
- data/app/views/baldur/components/_modal_host.html.erb +10 -0
- data/app/views/baldur/components/_sidebar.html.erb +30 -30
- 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 +20 -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 +241 -0
- 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/app/javascript/controllers/confirmation_controller.js +1 -0
- data/test/tmp/install_generator/config/initializers/baldur.rb +7 -7
- metadata +20 -8
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
require_relative 'test_helper'
|
|
2
|
+
require 'action_controller'
|
|
3
|
+
require_relative '../lib/generators/baldur/install/install_generator'
|
|
4
|
+
|
|
5
|
+
class BaldurConfirmationModalHelperTest < Minitest::Test
|
|
6
|
+
class TestController < ActionController::Base
|
|
7
|
+
append_view_path File.expand_path('../app/views', __dir__)
|
|
8
|
+
helper Baldur::UiHelper
|
|
9
|
+
helper Baldur::RenderHelper
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_ui_modal_host_renders_host_wrapper
|
|
13
|
+
html = TestController.render(
|
|
14
|
+
inline: <<~ERB,
|
|
15
|
+
<%= ui_modal_host(id: "test-modal") do %>
|
|
16
|
+
<p>Modal content</p>
|
|
17
|
+
<% end %>
|
|
18
|
+
ERB
|
|
19
|
+
formats: [:html]
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
assert_includes html, 'id="test-modal"'
|
|
23
|
+
assert_includes html, 'data-controller="modal"'
|
|
24
|
+
assert_includes html, 'data-modal-selector-value="#test-modal"'
|
|
25
|
+
assert_includes html, 'data-modal="true"'
|
|
26
|
+
assert_includes html, 'aria-hidden="true"'
|
|
27
|
+
assert_includes html, 'Modal content'
|
|
28
|
+
assert_includes html, 'class="fixed inset-0 z-50'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_ui_modal_host_with_custom_classes
|
|
32
|
+
html = TestController.render(
|
|
33
|
+
inline: <<~ERB,
|
|
34
|
+
<%= ui_modal_host(id: "custom-modal", classes: "my-extra-class") do %>
|
|
35
|
+
<p>Custom</p>
|
|
36
|
+
<% end %>
|
|
37
|
+
ERB
|
|
38
|
+
formats: [:html]
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
assert_includes html, 'my-extra-class'
|
|
42
|
+
assert_includes html, 'Custom'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_ui_confirmation_modal_renders_basic_structure
|
|
46
|
+
html = TestController.render(
|
|
47
|
+
inline: '<%=
|
|
48
|
+
ui_confirmation_modal(
|
|
49
|
+
host_id: "delete-modal",
|
|
50
|
+
dialog_id: "delete-dialog",
|
|
51
|
+
title: "Delete item?"
|
|
52
|
+
)
|
|
53
|
+
%>',
|
|
54
|
+
formats: [:html]
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
assert_includes html, 'id="delete-modal"'
|
|
58
|
+
assert_includes html, 'id="delete-dialog"'
|
|
59
|
+
assert_includes html, 'data-controller="modal"'
|
|
60
|
+
assert_includes html, 'Delete item?'
|
|
61
|
+
assert_includes html, 'Confirm'
|
|
62
|
+
assert_includes html, 'Cancel'
|
|
63
|
+
assert_includes html, 'data-modal-close="true"'
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_ui_confirmation_modal_with_danger_tone_shows_icon
|
|
67
|
+
html = TestController.render(
|
|
68
|
+
inline: '<%=
|
|
69
|
+
ui_confirmation_modal(
|
|
70
|
+
host_id: "danger-modal",
|
|
71
|
+
dialog_id: "danger-dialog",
|
|
72
|
+
title: "Discard collection?",
|
|
73
|
+
tone: :danger
|
|
74
|
+
)
|
|
75
|
+
%>',
|
|
76
|
+
formats: [:html]
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
assert_includes html, 'color-error'
|
|
80
|
+
assert_includes html, 'Discard collection?'
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def test_ui_confirmation_modal_default_tone_no_icon
|
|
84
|
+
html = TestController.render(
|
|
85
|
+
inline: '<%=
|
|
86
|
+
ui_confirmation_modal(
|
|
87
|
+
host_id: "default-modal",
|
|
88
|
+
dialog_id: "default-dialog",
|
|
89
|
+
title: "Proceed?"
|
|
90
|
+
)
|
|
91
|
+
%>',
|
|
92
|
+
formats: [:html]
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
refute_includes html, 'color-error'
|
|
96
|
+
assert_includes html, 'Proceed?'
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def test_ui_confirmation_modal_danger_tone_sets_danger_button_variant
|
|
100
|
+
html = TestController.render(
|
|
101
|
+
inline: '<%=
|
|
102
|
+
ui_confirmation_modal(
|
|
103
|
+
host_id: "danger-btn-modal",
|
|
104
|
+
dialog_id: "danger-btn-dialog",
|
|
105
|
+
title: "Discard?",
|
|
106
|
+
tone: :danger
|
|
107
|
+
)
|
|
108
|
+
%>',
|
|
109
|
+
formats: [:html]
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
assert_includes html, 'button--error'
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def test_ui_confirmation_modal_default_tone_sets_primary_button_variant
|
|
116
|
+
html = TestController.render(
|
|
117
|
+
inline: '<%=
|
|
118
|
+
ui_confirmation_modal(
|
|
119
|
+
host_id: "primary-btn-modal",
|
|
120
|
+
dialog_id: "primary-btn-dialog",
|
|
121
|
+
title: "Proceed?"
|
|
122
|
+
)
|
|
123
|
+
%>',
|
|
124
|
+
formats: [:html]
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
assert_includes html, 'button--filled'
|
|
128
|
+
refute_includes html, 'button--error'
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def test_ui_confirmation_modal_with_type_to_confirm
|
|
132
|
+
html = TestController.render(
|
|
133
|
+
inline: '<%=
|
|
134
|
+
ui_confirmation_modal(
|
|
135
|
+
host_id: "flush-modal",
|
|
136
|
+
dialog_id: "flush-dialog",
|
|
137
|
+
title: "Flush All Data",
|
|
138
|
+
description: "This cannot be undone.",
|
|
139
|
+
tone: :danger,
|
|
140
|
+
confirm_label: "Confirm",
|
|
141
|
+
type_to_confirm: {
|
|
142
|
+
expected_text: "confirm",
|
|
143
|
+
label: "Type confirm to continue",
|
|
144
|
+
placeholder: "confirm",
|
|
145
|
+
hint: "This permanently removes all data."
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
%>',
|
|
149
|
+
formats: [:html]
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
assert_includes html, 'modal confirmation'
|
|
153
|
+
assert_includes html, 'confirmation-case-sensitive-value'
|
|
154
|
+
assert_includes html, 'data-confirmation-target="input"'
|
|
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'
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def test_ui_confirmation_modal_type_to_confirm_disables_submit
|
|
164
|
+
html = TestController.render(
|
|
165
|
+
inline: '<%=
|
|
166
|
+
ui_confirmation_modal(
|
|
167
|
+
host_id: "disabled-modal",
|
|
168
|
+
dialog_id: "disabled-dialog",
|
|
169
|
+
title: "Delete?",
|
|
170
|
+
type_to_confirm: {
|
|
171
|
+
expected_text: "DELETE",
|
|
172
|
+
label: "Type DELETE"
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
%>',
|
|
176
|
+
formats: [:html]
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
assert_includes html, 'disabled'
|
|
180
|
+
assert_includes html, 'Type DELETE'
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def test_ui_confirmation_modal_type_to_confirm_case_insensitive
|
|
184
|
+
html = TestController.render(
|
|
185
|
+
inline: '<%=
|
|
186
|
+
ui_confirmation_modal(
|
|
187
|
+
host_id: "ci-modal",
|
|
188
|
+
dialog_id: "ci-dialog",
|
|
189
|
+
title: "Delete?",
|
|
190
|
+
type_to_confirm: {
|
|
191
|
+
expected_text: "delete",
|
|
192
|
+
case_sensitive: false
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
%>',
|
|
196
|
+
formats: [:html]
|
|
197
|
+
)
|
|
198
|
+
|
|
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
|
+
end
|
|
203
|
+
|
|
204
|
+
def test_ui_confirmation_modal_without_type_to_confirm_has_no_confirmation_controller
|
|
205
|
+
html = TestController.render(
|
|
206
|
+
inline: '<%=
|
|
207
|
+
ui_confirmation_modal(
|
|
208
|
+
host_id: "simple-modal",
|
|
209
|
+
dialog_id: "simple-dialog",
|
|
210
|
+
title: "Are you sure?"
|
|
211
|
+
)
|
|
212
|
+
%>',
|
|
213
|
+
formats: [:html]
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
assert_includes html, 'data-controller="modal"'
|
|
217
|
+
refute_includes html, 'confirmation'
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def test_ui_confirmation_modal_custom_labels
|
|
221
|
+
html = TestController.render(
|
|
222
|
+
inline: '<%=
|
|
223
|
+
ui_confirmation_modal(
|
|
224
|
+
host_id: "custom-modal",
|
|
225
|
+
dialog_id: "custom-dialog",
|
|
226
|
+
title: "Discard?",
|
|
227
|
+
confirm_label: "Discard",
|
|
228
|
+
cancel_label: "Go back"
|
|
229
|
+
)
|
|
230
|
+
%>',
|
|
231
|
+
formats: [:html]
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
assert_includes html, 'Discard'
|
|
235
|
+
assert_includes html, 'Go back'
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def test_install_generator_includes_confirmation_controller
|
|
239
|
+
assert_includes Baldur::Generators::InstallGenerator::CORE_CONTROLLERS, 'confirmation'
|
|
240
|
+
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
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
require_relative
|
|
2
|
-
require_relative
|
|
1
|
+
require_relative 'test_helper'
|
|
2
|
+
require_relative '../lib/generators/baldur/install_panel_secondary/install_panel_secondary_generator'
|
|
3
3
|
|
|
4
4
|
class BaldurInstallPanelSecondaryGeneratorTest < Rails::Generators::TestCase
|
|
5
5
|
tests Baldur::Generators::InstallPanelSecondaryGenerator
|
|
6
|
-
destination File.expand_path(
|
|
6
|
+
destination File.expand_path('tmp/install_panel_secondary_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'),
|
|
12
|
+
"@import \"tailwindcss\";\n@import \"../builds/tailwind/baldur.css\";\n")
|
|
12
13
|
end
|
|
13
14
|
|
|
14
|
-
test
|
|
15
|
+
test 'adds helper and controller without touching the tailwind contract' do
|
|
15
16
|
run_generator
|
|
16
17
|
|
|
17
|
-
assert_file
|
|
18
|
-
assert_file
|
|
19
|
-
|
|
18
|
+
assert_file 'app/helpers/panel_secondary_helper.rb', /include Baldur::Optional::PanelSecondaryHelper/
|
|
19
|
+
assert_file 'app/javascript/controllers/panel_secondary_controller.js',
|
|
20
|
+
%r{export \{ default \} from "baldur/controllers/panel_secondary_controller"}
|
|
21
|
+
assert_equal "@import \"tailwindcss\";\n@import \"../builds/tailwind/baldur.css\";\n",
|
|
22
|
+
File.read(File.join(destination_root, 'app/assets/tailwind/application.css'))
|
|
20
23
|
end
|
|
21
24
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require_relative
|
|
1
|
+
require_relative 'test_helper'
|
|
2
2
|
|
|
3
3
|
class BaldurMarketingHelperTest < Minitest::Test
|
|
4
4
|
HelperHost = Struct.new(:config) do
|
|
@@ -15,17 +15,17 @@ class BaldurMarketingHelperTest < Minitest::Test
|
|
|
15
15
|
|
|
16
16
|
def test_uses_configured_brand_without_host_helper_fallback
|
|
17
17
|
Baldur.config.marketing_brand = {
|
|
18
|
-
name:
|
|
19
|
-
wordmark:
|
|
20
|
-
logo_src:
|
|
18
|
+
name: 'Standalone',
|
|
19
|
+
wordmark: 'Standalone UI',
|
|
20
|
+
logo_src: '/standalone-logo.svg'
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
helper = HelperHost.new(Baldur.config)
|
|
24
24
|
resolved = helper.send(:ui_marketing_configured_brand)
|
|
25
25
|
|
|
26
|
-
assert_equal
|
|
27
|
-
assert_equal
|
|
28
|
-
assert_equal
|
|
26
|
+
assert_equal 'Standalone', resolved[:name]
|
|
27
|
+
assert_equal 'Standalone UI', resolved[:wordmark]
|
|
28
|
+
assert_equal '/standalone-logo.svg', resolved[:logo_src]
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def test_returns_empty_brand_hash_when_no_brand_is_configured
|
data/test/run_all.rb
CHANGED
data/test/sidebar_helper_test.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
require_relative
|
|
1
|
+
require_relative 'test_helper'
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require 'action_controller'
|
|
4
4
|
|
|
5
5
|
class BaldurSidebarHelperTest < 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::UiHelperSidebar
|
|
10
10
|
end
|
|
@@ -12,10 +12,10 @@ class BaldurSidebarHelperTest < Minitest::Test
|
|
|
12
12
|
def setup
|
|
13
13
|
@original_brand = Baldur.config.marketing_brand
|
|
14
14
|
Baldur.config.marketing_brand = {
|
|
15
|
-
name:
|
|
16
|
-
wordmark:
|
|
17
|
-
logo_src:
|
|
18
|
-
logo_alt:
|
|
15
|
+
name: 'Acme',
|
|
16
|
+
wordmark: 'Acme Ops',
|
|
17
|
+
logo_src: '/acme.svg',
|
|
18
|
+
logo_alt: 'Acme logo'
|
|
19
19
|
}
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -33,16 +33,16 @@ class BaldurSidebarHelperTest < Minitest::Test
|
|
|
33
33
|
secondary_label: "Admin"
|
|
34
34
|
) %>
|
|
35
35
|
ERB
|
|
36
|
-
formats: [
|
|
36
|
+
formats: [:html]
|
|
37
37
|
)
|
|
38
38
|
|
|
39
39
|
assert_includes html, 'data-controller="sidebar"'
|
|
40
40
|
assert_includes html, 'data-controller="mobile-sidebar"'
|
|
41
|
-
assert_includes html,
|
|
41
|
+
assert_includes html, 'Acme Ops'
|
|
42
42
|
assert_includes html, 'href="/dashboard"'
|
|
43
43
|
assert_includes html, 'href="/settings"'
|
|
44
44
|
assert_includes html, 'aria-current="page"'
|
|
45
|
-
assert_includes html,
|
|
45
|
+
assert_includes html, 'Admin'
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def test_sidebar_renders_slot_content_and_mobile_fallbacks
|
|
@@ -57,13 +57,13 @@ class BaldurSidebarHelperTest < Minitest::Test
|
|
|
57
57
|
<% end %>
|
|
58
58
|
<% end %>
|
|
59
59
|
ERB
|
|
60
|
-
formats: [
|
|
60
|
+
formats: [:html]
|
|
61
61
|
)
|
|
62
62
|
|
|
63
|
-
assert_includes html,
|
|
64
|
-
assert_includes html,
|
|
65
|
-
assert_includes html,
|
|
66
|
-
assert_operator html.scan(
|
|
67
|
-
assert_operator html.scan(
|
|
63
|
+
assert_includes html, 'Tenant Switcher'
|
|
64
|
+
assert_includes html, 'user-menu'
|
|
65
|
+
assert_includes html, 'Sign out'
|
|
66
|
+
assert_operator html.scan('Tenant Switcher').size, :>=, 2
|
|
67
|
+
assert_operator html.scan('Sign out').size, :>=, 2
|
|
68
68
|
end
|
|
69
69
|
end
|
data/test/test_helper.rb
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
ENV[
|
|
1
|
+
ENV['MT_NO_PLUGINS'] = '1'
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require
|
|
7
|
-
require
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'minitest/autorun'
|
|
5
|
+
require 'rails/generators/test_case'
|
|
6
|
+
require 'rails'
|
|
7
|
+
require 'lucide-rails'
|
|
8
8
|
|
|
9
|
-
require_relative
|
|
10
|
-
require_relative
|
|
11
|
-
require_relative
|
|
12
|
-
require_relative
|
|
13
|
-
require_relative
|
|
14
|
-
require_relative
|
|
15
|
-
require_relative
|
|
16
|
-
require_relative
|
|
9
|
+
require_relative '../lib/baldur'
|
|
10
|
+
require_relative '../app/helpers/baldur/render_helper'
|
|
11
|
+
require_relative '../app/helpers/baldur/ui_helper_feedback'
|
|
12
|
+
require_relative '../app/helpers/baldur/ui_helper_unavailable'
|
|
13
|
+
require_relative '../app/helpers/baldur/ui_helper_forms'
|
|
14
|
+
require_relative '../app/helpers/baldur/marketing_helper'
|
|
15
|
+
require_relative '../app/helpers/baldur/ui_helper_sidebar'
|
|
16
|
+
require_relative '../app/helpers/baldur/ui_helper'
|