mirror of
https://github.com/we-promise/sure.git
synced 2026-07-12 04:45:19 +00:00
Ships DS::EmptyState — a centered icon / title / optional description /
optional action-slot state — plus a preview, tests, and an exemplar migration
of the recurring-transactions empty screen.
Consolidates the repeated `text-center py-12 + icon + title + description + CTA`
markup across the empty / no-data screens (recurring, imports, statements,
exports, and several connector setups). The audit flagged the self-hosted
feature-disabled pages rendering bare unstyled top-left text ("reads as a 500,
not a state") — wiring those through this primitive is the follow-up.
- app/components/DS/empty_state.rb: render DS::EmptyState.new(icon:, title:,
description:) with an optional `with_action` slot for the CTA.
- Migrate recurring_transactions/index empty branch.
Tests + rubocop + erb_lint clean.
Deferred: the remaining ~10 empty screens + the bare-text feature-disabled
states — same primitive, one migration each.
33 lines
1.0 KiB
Ruby
33 lines
1.0 KiB
Ruby
require "test_helper"
|
|
|
|
class DS::EmptyStateTest < ViewComponent::TestCase
|
|
test "renders a centered wrapper with title and description" do
|
|
render_inline(DS::EmptyState.new(icon: "repeat", title: "No data yet", description: "Add something."))
|
|
|
|
assert_selector "div.text-center.items-center"
|
|
assert_selector "p.text-primary", text: "No data yet"
|
|
assert_selector "p.text-secondary", text: "Add something."
|
|
end
|
|
|
|
test "description is optional" do
|
|
render_inline(DS::EmptyState.new(icon: "repeat", title: "Empty"))
|
|
|
|
assert_selector "p.text-primary", text: "Empty"
|
|
assert_no_selector "p.text-secondary"
|
|
end
|
|
|
|
test "renders the action slot" do
|
|
render_inline(DS::EmptyState.new(icon: "repeat", title: "Empty")) do |es|
|
|
es.with_action { "<a href='/go'>Go</a>".html_safe }
|
|
end
|
|
|
|
assert_selector "a[href='/go']", text: "Go"
|
|
end
|
|
|
|
test "passthrough class merges onto the wrapper" do
|
|
render_inline(DS::EmptyState.new(icon: "repeat", title: "Empty", class: "custom-x"))
|
|
|
|
assert_selector "div.custom-x.text-center"
|
|
end
|
|
end
|