mirror of
https://github.com/we-promise/sure.git
synced 2026-06-04 10:19:03 +00:00
* feat(transactions): add inline tag creation and search in transaction forms * fix(transactions): add tag-only update endpoint for edit drawer * feat(transactions): implement TagSelectComponent for improved tag selection and management * feat(tag-select): refactor tag selection component for improved functionality and accessibility * feat(tag-select): implement inline tag rendering and error handling in tag selection component * refactor(tag-select): remove unused list target from tag select controller * fix: return forbidden JSON for denied tag updates * fix: lock transaction tags when clearing them * refactor: move tag select into DS namespace * refactor: add multiselect trigger form field style * fix: auto-position tag select dropdowns * feat: add keyboard navigation to tag select * feat: add create tag and search placeholder to transaction forms in multiple languages * style: tighten tag select option spacing * fix: align tag select spacing and focus behavior * refactor: render tag badges with DS pill --------- Signed-off-by: Juan José Mata <juanjo.mata@gmail.com> Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
74 lines
2.9 KiB
Ruby
74 lines
2.9 KiB
Ruby
require "test_helper"
|
|
|
|
class DS::PillTest < ViewComponent::TestCase
|
|
test "marker mode (default) renders uppercase sub-12px chrome with rounded-md" do
|
|
render_inline(DS::Pill.new(label: "Beta", tone: :violet))
|
|
|
|
pill = page.find("span", text: "Beta")
|
|
assert_includes pill[:class], "uppercase"
|
|
# Marker keeps sub-12px text via arbitrary value (intentional — see component docs).
|
|
assert_match(/text-\[1[01]px\]/, pill[:class])
|
|
# Marker uses rounded-md (chip shape).
|
|
assert_includes pill[:class], "rounded-md"
|
|
refute_includes pill[:class], "rounded-full"
|
|
end
|
|
|
|
test "marker: false renders normal-case DS-scale chrome with rounded-full" do
|
|
render_inline(DS::Pill.new(label: "Active", tone: :success, marker: false))
|
|
|
|
pill = page.find("span", text: "Active")
|
|
refute_includes pill[:class], "uppercase"
|
|
# Badge mode snaps to text-xs / text-sm — no sub-12px arbitrary values.
|
|
assert_match(/text-(xs|sm)/, pill[:class])
|
|
refute_match(/text-\[1[01]px\]/, pill[:class])
|
|
# Badge uses rounded-full to match the existing _status_pill / _maturity_badge convention.
|
|
assert_includes pill[:class], "rounded-full"
|
|
refute_includes pill[:class], "rounded-md"
|
|
end
|
|
|
|
test "semantic tone aliases resolve to visual palette tones" do
|
|
{
|
|
success: :green,
|
|
warning: :amber,
|
|
error: :red,
|
|
destructive: :red,
|
|
info: :indigo,
|
|
neutral: :gray
|
|
}.each do |alias_name, expected_visual|
|
|
pill = DS::Pill.new(label: "x", tone: alias_name)
|
|
assert_equal expected_visual, pill.tone, "Expected #{alias_name} → #{expected_visual}, got #{pill.tone}"
|
|
end
|
|
end
|
|
|
|
test "unknown tone falls back to violet" do
|
|
pill = DS::Pill.new(label: "x", tone: :nonexistent)
|
|
assert_equal :violet, pill.tone
|
|
end
|
|
|
|
test "red tone palette resolves to red-* tokens" do
|
|
pill = DS::Pill.new(label: "Failed", tone: :error)
|
|
assert_includes pill.palette[:dot], "color-red-500"
|
|
assert_includes pill.palette[:bg], "color-red-50"
|
|
end
|
|
|
|
test "custom color renders dynamic badge styles" do
|
|
render_inline(DS::Pill.new(label: "Groceries", marker: false, custom_color: "#f97316"))
|
|
|
|
pill = page.find("span", text: "Groceries")
|
|
assert_includes pill[:style], "color-mix(in oklab, #f97316 10%, transparent)"
|
|
assert_includes pill[:style], "color: #f97316"
|
|
end
|
|
|
|
test "icon option renders glyph in place of dot" do
|
|
render_inline(DS::Pill.new(label: "Syncing", tone: :info, marker: false, icon: "loader"))
|
|
|
|
# Lucide icon helper renders the inline SVG; verifying we see at least one <svg>
|
|
# is enough — the icon helper is covered by its own tests.
|
|
assert_selector "svg"
|
|
# And the dot is suppressed when an icon takes its place. The dot is an
|
|
# `inline-block` span (parent pill is `inline-flex`), so target it by
|
|
# `inline-block.rounded-full` to avoid matching the parent pill.
|
|
assert_no_selector "span.inline-block.rounded-full"
|
|
end
|
|
end
|