Check for out of range float values

Remove unsupported attribute `[maxlength]` from `input[number]`.
This commit is contained in:
2026-07-20 16:39:35 +02:00
parent ef8214cfa7
commit 5d051de666
10 changed files with 88 additions and 38 deletions

View File

@@ -93,6 +93,10 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
XPath.descendant(:td).where(header_xp.boolean & position_xp)
end
expression_filter(:fillable) do |xpath, value|
value ? xpath.where(XPath.descendant(:input, :select, :textarea)) : xpath
end
node_filter(:with) do |node, expected|
value =
case expected

View File

@@ -101,8 +101,29 @@ class UnitsTest < ApplicationSystemTestCase
end
test "create fails with out of range multiplier" do
# TODO: multiplier with exponent > max, < min, precision > DIG, value <= 0
assert true
sign_in(user: users.select { |u| u.confirmed? && !u.units.empty? }.sample)
all(:link, exact_text: link_labels[:new_subunit]).sample.click
multipliers = [
"a", # * not a number (NaN)
"1e#{Float::MAX_10_EXP + 1}", # * value too big (Infinity)
# * value too big (> max), N/A
"-1e#{Float::MAX_10_EXP + 1}", # * value too small (-Infinity)
"-1", # * value too small (< min)
"0", # * -"-
"1." + "0" * (Float::DIG - 1) + "1", # * precision too big
"1" + "0" * (Float::DIG - 1) + "1", # * -"-
"0.1" + "0" * (Float::DIG - 1) + "1", # * -"-
"1e#{Float::MIN_10_EXP - Float::DIG - 1}", # * precision too big (MIN > value > 0)
]
field = find(:table_cell, column(:multiplier), fillable: true).find_field
assert_not_matches_selector field, ':invalid'
multipliers.shuffle.each do |multiplier|
field.fill_in with: multiplier
assert_matches_selector field, ':invalid'
end
end
test "create updates view in order" do