mirror of
https://github.com/internetee/registry.git
synced 2025-06-12 07:34:45 +02:00
covered ui test for admin users page
This commit is contained in:
parent
571755ffc3
commit
8fe9e46fc9
2 changed files with 46 additions and 78 deletions
|
@ -32,7 +32,7 @@ class JavaScriptApplicationSystemTestCase < ApplicationSystemTestCase
|
||||||
|
|
||||||
|
|
||||||
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 }
|
||||||
|
|
|
@ -1,69 +1,65 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
require 'application_system_test_case'
|
require 'application_system_test_case'
|
||||||
|
|
||||||
class AdminAreaAdminUsersIntegrationTest < ApplicationSystemTestCase
|
class AdminAreaAdminUsersIntegrationTest < JavaScriptApplicationSystemTestCase
|
||||||
include Devise::Test::IntegrationHelpers
|
include Devise::Test::IntegrationHelpers
|
||||||
include ActionView::Helpers::NumberHelper
|
include ActionView::Helpers::NumberHelper
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
|
WebMock.allow_net_connect!
|
||||||
@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"]'
|
# Helpers funcs
|
||||||
|
def createNewAdminUser(valid)
|
||||||
# "/admin/admin_users"
|
|
||||||
def test_create_new_admin_user
|
|
||||||
visit admin_admin_users_path
|
visit admin_admin_users_path
|
||||||
click_on 'New admin user'
|
click_on 'New admin user'
|
||||||
|
|
||||||
fill_in 'Username', with: 'test_user_name'
|
fill_in 'Username', with: 'test_user_name'
|
||||||
fill_in 'Password', with: 'test_password'
|
# If valid=true creating valid user, if else, then with invalid data
|
||||||
fill_in 'Password confirmation', with: 'test_password'
|
if valid
|
||||||
|
fill_in 'Password', with: 'test_password'
|
||||||
|
fill_in 'Password confirmation', with: 'test_password'
|
||||||
|
else
|
||||||
|
fill_in 'Password', with: 'test_password'
|
||||||
|
fill_in 'Password confirmation', with: 'test_password2'
|
||||||
|
end
|
||||||
fill_in 'Identity code', with: '38903110313'
|
fill_in 'Identity code', with: '38903110313'
|
||||||
fill_in 'Email', with: 'oleg@tester.ee'
|
fill_in 'Email', with: 'oleg@tester.ee'
|
||||||
|
|
||||||
select 'Estonia', from: 'admin_user_country_code', match: :first
|
select 'Estonia', from: 'admin_user_country_code', match: :first
|
||||||
select 'User', from: 'admin_user_roles_', match: :first
|
|
||||||
|
# option_select = '//div[@class="selectize-input items has-options full has-items"]'
|
||||||
|
# find(:xpath, ".//table/tr").click
|
||||||
|
# select 'User', from: 'admin_user_roles_', match: :first
|
||||||
|
select_element = find(:xpath, "/html/body/div[2]/form/div[2]/div/div[7]/div[2]/div/div[1]")
|
||||||
|
select_element.click
|
||||||
|
|
||||||
|
# /html/body/div[2]/form/div[2]/div/div[7]/div[2]/div/div[2]/div/div[1]
|
||||||
|
option_element = find(:xpath, "/html/body/div[2]/form/div[2]/div/div[7]/div[2]/div/div[2]/div/div[1]")
|
||||||
|
option_element.click
|
||||||
|
|
||||||
click_on 'Save'
|
click_on 'Save'
|
||||||
assert_text 'Record created'
|
if valid
|
||||||
|
assert_text 'Record created'
|
||||||
|
else
|
||||||
|
assert_text 'Failed to create record'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Tests
|
||||||
# "/admin/admin_users"
|
# "/admin/admin_users"
|
||||||
|
def test_create_new_admin_user
|
||||||
|
createNewAdminUser(true)
|
||||||
|
end
|
||||||
|
|
||||||
def test_create_with_invalid_data_new_admin_user
|
def test_create_with_invalid_data_new_admin_user
|
||||||
visit admin_admin_users_path
|
createNewAdminUser(false)
|
||||||
click_on 'New admin user'
|
|
||||||
|
|
||||||
fill_in 'Username', with: 'test_user_name'
|
|
||||||
fill_in 'Password', with: 'test_password'
|
|
||||||
fill_in 'Password confirmation', with: 'test_password2'
|
|
||||||
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 'Failed to create record'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_edit_successfully_exist_record
|
def test_edit_successfully_exist_record
|
||||||
visit admin_admin_users_path
|
createNewAdminUser(true)
|
||||||
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
|
visit admin_admin_users_path
|
||||||
click_on 'test_user_name'
|
click_on 'test_user_name'
|
||||||
|
@ -79,20 +75,7 @@ class AdminAreaAdminUsersIntegrationTest < ApplicationSystemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_edit_exist_record_with_invalid_data
|
def test_edit_exist_record_with_invalid_data
|
||||||
visit admin_admin_users_path
|
createNewAdminUser(true)
|
||||||
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
|
visit admin_admin_users_path
|
||||||
click_on 'test_user_name'
|
click_on 'test_user_name'
|
||||||
|
@ -107,33 +90,18 @@ class AdminAreaAdminUsersIntegrationTest < ApplicationSystemTestCase
|
||||||
assert_text 'Failed to update record'
|
assert_text 'Failed to update record'
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO
|
def test_delete_exist_record
|
||||||
# def test_delete_exist_record
|
createNewAdminUser(true)
|
||||||
# visit admin_admin_users_path
|
|
||||||
# click_on 'New admin user'
|
|
||||||
|
|
||||||
# fill_in 'Username', with: 'test_user_name'
|
visit admin_admin_users_path
|
||||||
# fill_in 'Password', with: 'test_password'
|
click_on 'test_user_name'
|
||||||
# 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
|
assert_text 'General'
|
||||||
# select 'User', from: 'admin_user_roles_', match: :first
|
click_on 'Delete'
|
||||||
|
|
||||||
# click_on 'Save'
|
# Accept to delete in modal window
|
||||||
# assert_text 'Record created'
|
page.driver.browser.switch_to.alert.accept
|
||||||
|
|
||||||
# visit admin_admin_users_path
|
assert_text 'Record deleted'
|
||||||
# click_on 'test_user_name'
|
end
|
||||||
|
|
||||||
# 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