Update tests to new schema

This commit is contained in:
cryptogopher 2024-12-08 15:29:01 +01:00
parent a18f257378
commit 40808639cc
3 changed files with 15 additions and 12 deletions

View File

@ -4,7 +4,9 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
include ActionView::Helpers::UrlHelper
# NOTE: geckodriver installed with Firefox, ignore incompatibility warning
Selenium::WebDriver.logger.ignore(:selenium_manager)
Selenium::WebDriver.logger
.ignore(:selenium_manager, :clear_session_storage, :clear_local_storage)
Capybara.configure do |config|
config.save_path = "#{Rails.root}/tmp/screenshots/"
end

View File

@ -1,40 +1,40 @@
g:
user: admin
symbol: g
name: gram
description: gram
kg:
user: admin
symbol: kg
name: kilogram
description: kilogram
multiplier: 1000
base: g
1:
user: admin
symbol: 1
name: one
description: one
s:
user: admin
symbol: s
name: second
description: second
percent:
user: admin
symbol: '%'
name: percent
description: percent
multiplier: 0.01
base: 1
µg:
user: admin
symbol: µg
name: microgram
description: microgram
multiplier: 0.000001
base: g
mg:
user: admin
symbol: mg
name: milligram
description: milligram
multiplier: 0.001
base: g
g_alice:
user: alice
symbol: g
name: gram
description: gram

View File

@ -20,16 +20,17 @@ class UnitsTest < ApplicationSystemTestCase
end
end
# 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[:name], f[:maxlength].to_i || 1000] }
maxlength = all(:fillable_field).to_h { |f| [f[:description], f[:maxlength].to_i || 1000] }
fill_in 'unit[symbol]',
with: SecureRandom.random_symbol(rand([1..15, 15..maxlength['unit[symbol]']].sample))
fill_in 'unit[name]',
with: [nil, SecureRandom.alphanumeric(rand(1..maxlength['unit[name]']))].sample
fill_in 'unit[description]',
with: [nil, SecureRandom.alphanumeric(rand(1..maxlength['unit[description]']))].sample
assert_difference ->{ Unit.count }, 1 do
click_on t('helpers.submit.create')
end