mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 22:54:47 +02:00
changed tabs
This commit is contained in:
parent
02b5c8c4b6
commit
486fceca9c
3 changed files with 129 additions and 141 deletions
|
@ -2,38 +2,38 @@ require 'test_helper'
|
||||||
require 'application_system_test_case'
|
require 'application_system_test_case'
|
||||||
|
|
||||||
class AdminAreaAccountActivitiesIntegrationTest < ApplicationSystemTestCase
|
class AdminAreaAccountActivitiesIntegrationTest < ApplicationSystemTestCase
|
||||||
# /admin/account_activities
|
# /admin/account_activities
|
||||||
setup do
|
setup do
|
||||||
sign_in users(:admin)
|
sign_in users(:admin)
|
||||||
@original_default_language = Setting.default_language
|
@original_default_language = Setting.default_language
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_account_activities_page
|
def test_show_account_activities_page
|
||||||
account_activities(:one).update(sum: "123.00")
|
account_activities(:one).update(sum: "123.00")
|
||||||
visit admin_account_activities_path
|
visit admin_account_activities_path
|
||||||
assert_text 'Account activities'
|
assert_text 'Account activities'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_default_url_params
|
def test_default_url_params
|
||||||
account_activities(:one).update(sum: "123.00")
|
account_activities(:one).update(sum: "123.00")
|
||||||
visit admin_root_path
|
visit admin_root_path
|
||||||
click_link_or_button 'Settings', match: :first
|
click_link_or_button 'Settings', match: :first
|
||||||
find(:xpath, "//ul/li/a[text()='Account activities']").click
|
find(:xpath, "//ul/li/a[text()='Account activities']").click
|
||||||
|
|
||||||
assert has_current_path?(admin_account_activities_path(created_after: 'today'))
|
assert has_current_path?(admin_account_activities_path(created_after: 'today'))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_download_account_activity
|
def test_download_account_activity
|
||||||
now = Time.zone.parse('2010-07-05 08:00')
|
now = Time.zone.parse('2010-07-05 08:00')
|
||||||
travel_to now
|
travel_to now
|
||||||
account_activities(:one).update(sum: "123.00")
|
account_activities(:one).update(sum: "123.00")
|
||||||
|
|
||||||
get admin_account_activities_path(format: :csv)
|
get admin_account_activities_path(format: :csv)
|
||||||
|
|
||||||
assert_response :ok
|
assert_response :ok
|
||||||
assert_equal "text/csv", response.headers['Content-Type']
|
assert_equal "text/csv", response.headers['Content-Type']
|
||||||
assert_equal %(attachment; filename="account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv),
|
assert_equal %(attachment; filename="account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv),
|
||||||
response.headers['Content-Disposition']
|
response.headers['Content-Disposition']
|
||||||
assert_not_empty response.body
|
assert_not_empty response.body
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,103 +2,100 @@ require 'test_helper'
|
||||||
require 'application_system_test_case'
|
require 'application_system_test_case'
|
||||||
|
|
||||||
class AdminAreaAdminUsersIntegrationTest < JavaScriptApplicationSystemTestCase
|
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!
|
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
|
||||||
|
|
||||||
# Helpers funcs
|
def test_create_new_admin_user
|
||||||
def createNewAdminUser(valid)
|
createNewAdminUser(true)
|
||||||
visit admin_admin_users_path
|
end
|
||||||
click_on 'New admin user'
|
|
||||||
|
|
||||||
fill_in 'Username', with: 'test_user_name'
|
def test_create_with_invalid_data_new_admin_user
|
||||||
# If valid=true creating valid user, if else, then with invalid data
|
createNewAdminUser(false)
|
||||||
if valid
|
end
|
||||||
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 'Email', with: 'oleg@tester.ee'
|
|
||||||
|
|
||||||
select 'Estonia', from: 'admin_user_country_code', match: :first
|
def test_edit_successfully_exist_record
|
||||||
|
createNewAdminUser(true)
|
||||||
|
|
||||||
select_element = find(:xpath, "/html/body/div[2]/form/div[2]/div/div[7]/div[2]/div/div[1]")
|
visit admin_admin_users_path
|
||||||
select_element.click
|
click_on 'test_user_name'
|
||||||
|
|
||||||
option_element = find(:xpath, "/html/body/div[2]/form/div[2]/div/div[7]/div[2]/div/div[2]/div/div[1]")
|
assert_text 'General'
|
||||||
option_element.click
|
click_on 'Edit'
|
||||||
|
|
||||||
click_on 'Save'
|
fill_in 'Password', with: 'test_password'
|
||||||
|
fill_in 'Password confirmation', with: 'test_password'
|
||||||
|
|
||||||
if valid
|
click_on 'Save'
|
||||||
assert_text 'Record created'
|
assert_text 'Record updated'
|
||||||
else
|
end
|
||||||
assert_text 'Failed to create record'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Tests
|
def test_edit_exist_record_with_invalid_data
|
||||||
# "/admin/admin_users"
|
createNewAdminUser(true)
|
||||||
def test_create_new_admin_user
|
|
||||||
createNewAdminUser(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_create_with_invalid_data_new_admin_user
|
visit admin_admin_users_path
|
||||||
createNewAdminUser(false)
|
click_on 'test_user_name'
|
||||||
end
|
|
||||||
|
|
||||||
def test_edit_successfully_exist_record
|
assert_text 'General'
|
||||||
createNewAdminUser(true)
|
click_on 'Edit'
|
||||||
|
|
||||||
visit admin_admin_users_path
|
fill_in 'Password', with: 'test_password'
|
||||||
click_on 'test_user_name'
|
fill_in 'Password confirmation', with: 'test_password2'
|
||||||
|
|
||||||
assert_text 'General'
|
click_on 'Save'
|
||||||
click_on 'Edit'
|
assert_text 'Failed to update record'
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_delete_exist_record
|
||||||
|
createNewAdminUser(true)
|
||||||
|
|
||||||
|
visit admin_admin_users_path
|
||||||
|
click_on 'test_user_name'
|
||||||
|
assert_text 'General'
|
||||||
|
click_on 'Delete'
|
||||||
|
|
||||||
|
page.driver.browser.switch_to.alert.accept
|
||||||
|
|
||||||
|
assert_text 'Record deleted'
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def createNewAdminUser(valid)
|
||||||
|
visit admin_admin_users_path
|
||||||
|
click_on 'New admin user'
|
||||||
|
|
||||||
|
fill_in 'Username', with: 'test_user_name'
|
||||||
|
# If valid=true creating valid user, if else, then with invalid data
|
||||||
|
if valid
|
||||||
fill_in 'Password', with: 'test_password'
|
fill_in 'Password', with: 'test_password'
|
||||||
fill_in 'Password confirmation', with: 'test_password'
|
fill_in 'Password confirmation', with: 'test_password'
|
||||||
|
else
|
||||||
click_on 'Save'
|
|
||||||
assert_text 'Record updated'
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_edit_exist_record_with_invalid_data
|
|
||||||
createNewAdminUser(true)
|
|
||||||
|
|
||||||
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', with: 'test_password'
|
||||||
fill_in 'Password confirmation', with: 'test_password2'
|
fill_in 'Password confirmation', with: 'test_password2'
|
||||||
|
|
||||||
click_on 'Save'
|
|
||||||
assert_text 'Failed to update record'
|
|
||||||
end
|
end
|
||||||
|
fill_in 'Identity code', with: '38903110313'
|
||||||
|
fill_in 'Email', with: 'oleg@tester.ee'
|
||||||
|
|
||||||
def test_delete_exist_record
|
select 'Estonia', from: 'admin_user_country_code', match: :first
|
||||||
createNewAdminUser(true)
|
|
||||||
|
|
||||||
visit admin_admin_users_path
|
select_element = find(:xpath, "/html/body/div[2]/form/div[2]/div/div[7]/div[2]/div/div[1]")
|
||||||
click_on 'test_user_name'
|
select_element.click
|
||||||
|
|
||||||
assert_text 'General'
|
option_element = find(:xpath, "/html/body/div[2]/form/div[2]/div/div[7]/div[2]/div/div[2]/div/div[1]")
|
||||||
click_on 'Delete'
|
option_element.click
|
||||||
|
|
||||||
# Accept to delete in modal window
|
click_on 'Save'
|
||||||
page.driver.browser.switch_to.alert.accept
|
|
||||||
|
|
||||||
assert_text 'Record deleted'
|
if valid
|
||||||
|
assert_text 'Record created'
|
||||||
|
else
|
||||||
|
assert_text 'Failed to create record'
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,46 +3,37 @@ require 'application_system_test_case'
|
||||||
|
|
||||||
class AdminAreaReservedDomainsIntegrationTest < JavaScriptApplicationSystemTestCase
|
class AdminAreaReservedDomainsIntegrationTest < JavaScriptApplicationSystemTestCase
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
WebMock.allow_net_connect!
|
WebMock.allow_net_connect!
|
||||||
@original_default_language = Setting.default_language
|
@original_default_language = Setting.default_language
|
||||||
sign_in users(:admin)
|
sign_in users(:admin)
|
||||||
|
|
||||||
@reserved_domain = reserved_domains(:one)
|
@reserved_domain = reserved_domains(:one)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_remove_reserved_domain
|
def test_remove_reserved_domain
|
||||||
visit admin_reserved_domains_path
|
visit admin_reserved_domains_path
|
||||||
|
click_link_or_button 'Delete', match: :first
|
||||||
click_link_or_button 'Delete', match: :first
|
page.driver.browser.switch_to.alert.accept
|
||||||
|
|
||||||
# Accept to delete in modal window
|
assert_text 'Domain deleted!'
|
||||||
page.driver.browser.switch_to.alert.accept
|
end
|
||||||
|
|
||||||
assert_text 'Domain deleted!'
|
def test_add_invalid_domain
|
||||||
end
|
visit admin_reserved_domains_path
|
||||||
|
click_on 'New reserved domain'
|
||||||
|
fill_in "Name", with: "@##@$"
|
||||||
|
click_on 'Save'
|
||||||
|
|
||||||
def test_add_invalid_domain
|
assert_text 'Failed to add domain!'
|
||||||
visit admin_reserved_domains_path
|
end
|
||||||
|
|
||||||
click_on 'New reserved domain'
|
def test_update_reserved_domain
|
||||||
|
visit admin_reserved_domains_path
|
||||||
|
click_link_or_button 'Edit Pw', match: :first
|
||||||
|
fill_in 'Password', with: '12345678'
|
||||||
|
click_on 'Save'
|
||||||
|
|
||||||
fill_in "Name", with: "@##@$"
|
assert_text 'Domain updated!'
|
||||||
|
end
|
||||||
click_on 'Save'
|
|
||||||
|
|
||||||
assert_text 'Failed to add domain!'
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_update_reserved_domain
|
|
||||||
visit admin_reserved_domains_path
|
|
||||||
|
|
||||||
click_link_or_button 'Edit Pw', match: :first
|
|
||||||
|
|
||||||
fill_in 'Password', with: '12345678'
|
|
||||||
|
|
||||||
click_on 'Save'
|
|
||||||
|
|
||||||
assert_text 'Domain updated!'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue