Files
sure/test/components/DS/selectable_card_test.rb
Guillem Arias ec023cfe71 feat(retirement): PR4c DS::SelectableCard + bucket restyle
DS::SelectableCard — a checkbox rendered as a selectable card (whole card
toggles; brand-accent border + bg-surface when selected via peer-checked
on the sibling). Submits like a normal checkbox, so the bucket's
replace-all form is unchanged. Lookbook preview + component test.

Retirement bucket now renders each account as a DS::SelectableCard
(name · type · balance) instead of a bare checkbox row. Money stays
privacy-sensitive.
2026-05-29 12:36:53 +02:00

26 lines
925 B
Ruby

require "test_helper"
class DS::SelectableCardTest < ViewComponent::TestCase
test "renders a checkbox with title, subtitle, amount" do
render_inline(DS::SelectableCard.new(
name: "bucket[account_ids][]", value: "a1",
title: "Brokerage", subtitle: "ETF", amount: "$100,000"
))
assert_selector "input[type=checkbox][name='bucket[account_ids][]'][value='a1']", visible: false
assert_text "Brokerage"
assert_text "ETF"
assert_text "$100,000"
end
test "checked renders the checkbox checked" do
render_inline(DS::SelectableCard.new(name: "n", value: "v", title: "T", checked: true))
assert_selector "input[type=checkbox][checked]", visible: false
end
test "unchecked omits the checked attribute" do
render_inline(DS::SelectableCard.new(name: "n", value: "v", title: "T", checked: false))
assert_no_selector "input[type=checkbox][checked]", visible: false
end
end