From dc92a333be3029d9f7bee301788cd85e5ebc45d9 Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Tue, 10 Dec 2024 01:18:27 +0100 Subject: [PATCH] Fix UnitsTest#test_add_unit --- test/system/units_test.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/system/units_test.rb b/test/system/units_test.rb index a67a629..745a20e 100644 --- a/test/system/units_test.rb +++ b/test/system/units_test.rb @@ -21,13 +21,14 @@ class UnitsTest < ApplicationSystemTestCase end end + # TODO: check if Add buton is properly disabled/enabled # TODO: extend with add subunit test "add unit" do click_on t('units.index.add_unit') within 'tbody > tr:has(input[type=text], textarea)' do assert_selector ':focus' - maxlength = all(:fillable_field).to_h { |f| [f[:description], f[:maxlength].to_i || 1000] } + maxlength = all(:fillable_field).to_h { |f| [f[:name], f[:maxlength].to_i || 1000] } fill_in 'unit[symbol]', with: SecureRandom.random_symbol(rand([1..15, 15..maxlength['unit[symbol]']].sample)) fill_in 'unit[description]', @@ -41,7 +42,11 @@ class UnitsTest < ApplicationSystemTestCase assert_no_selector :fillable_field assert_selector 'tr', count: @user.units.count end - assert_selector '.flash.notice', text: /^#{t('units.create.success')}/ + assert_selector '.flash.notice', text: /^#{t('units.create.success', unit: @user.units.last)}/ + end + + # TODO: check proper form/button redisplay and flash messages + test "add unit on validation error" do end test "add and edit disallow opening multiple forms" do