mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 22:54:47 +02:00
add new tests for admin users
This commit is contained in:
parent
54a8c65c27
commit
571755ffc3
2 changed files with 68 additions and 2 deletions
|
@ -13,6 +13,7 @@ class ApplicationSystemTestCase < ActionDispatch::IntegrationTest
|
||||||
WebMock.reset!
|
WebMock.reset!
|
||||||
Capybara.reset_sessions!
|
Capybara.reset_sessions!
|
||||||
Capybara.use_default_driver
|
Capybara.use_default_driver
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -28,17 +29,21 @@ class JavaScriptApplicationSystemTestCase < ApplicationSystemTestCase
|
||||||
options.add_argument('--disable-dev-shm-usage')
|
options.add_argument('--disable-dev-shm-usage')
|
||||||
options.add_argument('--window-size=1400,1400')
|
options.add_argument('--window-size=1400,1400')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
|
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
|
||||||
|
Capybara.exact = true
|
||||||
end
|
end
|
||||||
|
|
||||||
Capybara.server = :puma, { Silent: true }
|
Capybara.server = :puma, { Silent: true }
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
DatabaseCleaner.start
|
DatabaseCleaner.start
|
||||||
|
|
||||||
super
|
super
|
||||||
|
|
||||||
Capybara.current_driver = :chrome
|
Capybara.current_driver = :chrome
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
|
|
|
@ -6,10 +6,13 @@ class AdminAreaAdminUsersIntegrationTest < ApplicationSystemTestCase
|
||||||
include ActionView::Helpers::NumberHelper
|
include ActionView::Helpers::NumberHelper
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
|
|
||||||
@original_default_language = Setting.default_language
|
@original_default_language = Setting.default_language
|
||||||
sign_in users(:admin)
|
sign_in users(:admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# option_select = '//div[@class="selectize-input items has-options full has-items"]'
|
||||||
|
|
||||||
# "/admin/admin_users"
|
# "/admin/admin_users"
|
||||||
def test_create_new_admin_user
|
def test_create_new_admin_user
|
||||||
visit admin_admin_users_path
|
visit admin_admin_users_path
|
||||||
|
@ -73,6 +76,64 @@ class AdminAreaAdminUsersIntegrationTest < ApplicationSystemTestCase
|
||||||
|
|
||||||
click_on 'Save'
|
click_on 'Save'
|
||||||
assert_text 'Record updated'
|
assert_text 'Record updated'
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_edit_exist_record_with_invalid_data
|
||||||
|
visit admin_admin_users_path
|
||||||
|
click_on 'New admin user'
|
||||||
|
|
||||||
|
fill_in 'Username', with: 'test_user_name'
|
||||||
|
fill_in 'Password', with: 'test_password'
|
||||||
|
fill_in 'Password confirmation', with: 'test_password'
|
||||||
|
fill_in 'Identity code', with: '38903110313'
|
||||||
|
fill_in 'Email', with: 'oleg@tester.ee'
|
||||||
|
|
||||||
|
select 'Estonia', from: 'admin_user_country_code', match: :first
|
||||||
|
select 'User', from: 'admin_user_roles_', match: :first
|
||||||
|
|
||||||
|
click_on 'Save'
|
||||||
|
assert_text 'Record created'
|
||||||
|
|
||||||
|
visit admin_admin_users_path
|
||||||
|
click_on 'test_user_name'
|
||||||
|
|
||||||
|
assert_text 'General'
|
||||||
|
click_on 'Edit'
|
||||||
|
|
||||||
|
fill_in 'Password', with: 'test_password'
|
||||||
|
fill_in 'Password confirmation', with: 'test_password2'
|
||||||
|
|
||||||
|
click_on 'Save'
|
||||||
|
assert_text 'Failed to update record'
|
||||||
|
end
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
# def test_delete_exist_record
|
||||||
|
# visit admin_admin_users_path
|
||||||
|
# click_on 'New admin user'
|
||||||
|
|
||||||
|
# fill_in 'Username', with: 'test_user_name'
|
||||||
|
# fill_in 'Password', with: 'test_password'
|
||||||
|
# fill_in 'Password confirmation', with: 'test_password'
|
||||||
|
# fill_in 'Identity code', with: '38903110313'
|
||||||
|
# fill_in 'Email', with: 'oleg@tester.ee'
|
||||||
|
|
||||||
|
# select 'Estonia', from: 'admin_user_country_code', match: :first
|
||||||
|
# select 'User', from: 'admin_user_roles_', match: :first
|
||||||
|
|
||||||
|
# click_on 'Save'
|
||||||
|
# assert_text 'Record created'
|
||||||
|
|
||||||
|
# visit admin_admin_users_path
|
||||||
|
# click_on 'test_user_name'
|
||||||
|
|
||||||
|
# assert_text 'General'
|
||||||
|
# click_on 'Delete'
|
||||||
|
|
||||||
|
# accept_prompt(with: 'Are you sure?') do
|
||||||
|
# click_link('Ok')
|
||||||
|
# end
|
||||||
|
|
||||||
|
# assert_text ' Record deleted'
|
||||||
|
# end
|
||||||
end
|
end
|
Loading…
Add table
Add a link
Reference in a new issue