Improved browser test.
This commit is contained in:
parent
611161c76c
commit
1f0b54aaa8
2 changed files with 63 additions and 21 deletions
|
@ -2,25 +2,6 @@
|
|||
require 'browser_test_helper'
|
||||
|
||||
class TextModuleTest < TestCase
|
||||
|
||||
# create users
|
||||
roles = Role.where( :name => [ 'Agent' ] )
|
||||
groups = Group.all
|
||||
|
||||
agent1 = User.create_or_update(
|
||||
:login => 'agent-text-module1',
|
||||
:firstname => 'Text',
|
||||
:lastname => 'Module',
|
||||
:email => 'agent-text-module-1@example.com',
|
||||
:password => 'agentpw',
|
||||
:active => true,
|
||||
:roles => roles,
|
||||
:groups => groups,
|
||||
:updated_by_id => 1,
|
||||
:created_by_id => 1,
|
||||
)
|
||||
agent1.save
|
||||
|
||||
def test_I
|
||||
random = 'text_module_test_' + rand(999999).to_s
|
||||
random2 = 'text_module_test_' + rand(999999).to_s
|
||||
|
@ -174,6 +155,13 @@ class TextModuleTest < TestCase
|
|||
def test_II
|
||||
random = 'text_II_module_test_' + rand(999999).to_s
|
||||
|
||||
user_rand = rand(999999).to_s
|
||||
login = 'agent-text-module-' + user_rand
|
||||
firstname = 'Text' + user_rand
|
||||
lastname = 'Module' + user_rand
|
||||
email = 'agent-text-module-' + user_rand + '@example.com'
|
||||
password = 'agentpw'
|
||||
|
||||
# user
|
||||
tests = [
|
||||
{
|
||||
|
@ -277,6 +265,22 @@ class TextModuleTest < TestCase
|
|||
|
||||
],
|
||||
},
|
||||
|
||||
# create user
|
||||
{
|
||||
:name => 'create user',
|
||||
:action => [
|
||||
{
|
||||
:where => :instance1,
|
||||
:execute => 'create_user',
|
||||
:login => login,
|
||||
:firstname => firstname,
|
||||
:lastname => lastname,
|
||||
:email => email,
|
||||
:password => password,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
:name => 'check if text module exists in instance2, for ready to use',
|
||||
:action => [
|
||||
|
@ -542,7 +546,7 @@ class TextModuleTest < TestCase
|
|||
:where => :instance2,
|
||||
:execute => 'match',
|
||||
:css => '.active textarea[name=body]',
|
||||
:value => 'some content Module' + random,
|
||||
:value => 'some content ' + lastname,
|
||||
:no_quote => true,
|
||||
:match_result => true,
|
||||
},
|
||||
|
|
|
@ -256,6 +256,44 @@ class TestCase < Test::Unit::TestCase
|
|||
}
|
||||
assert( false, "(#{test[:name]}) '#{action[:value]}' found in '#{text}'" )
|
||||
return
|
||||
elsif action[:execute] == 'create_user'
|
||||
|
||||
instance.find_element( { :css => 'a[href="#manage"]' } ).click
|
||||
instance.find_element( { :css => 'a[href="#manage/users"]' } ).click
|
||||
sleep 2
|
||||
instance.find_element( { :css => 'a[data-type="new"]' } ).click
|
||||
sleep 2
|
||||
element = instance.find_element( { :css => '.modal input[name=login]' } )
|
||||
element.clear
|
||||
element.send_keys( action[:login] )
|
||||
element = instance.find_element( { :css => '.modal input[name=firstname]' } )
|
||||
element.clear
|
||||
element.send_keys( action[:firstname] )
|
||||
element = instance.find_element( { :css => '.modal input[name=lastname]' } )
|
||||
element.clear
|
||||
element.send_keys( action[:lastname] )
|
||||
element = instance.find_element( { :css => '.modal input[name=email]' } )
|
||||
element.clear
|
||||
element.send_keys( action[:email] )
|
||||
element = instance.find_element( { :css => '.modal input[name=password]' } )
|
||||
element.clear
|
||||
element.send_keys( action[:password] )
|
||||
element = instance.find_element( { :css => '.modal input[name=password_confirm]' } )
|
||||
element.clear
|
||||
element.send_keys( action[:password] )
|
||||
instance.find_element( { :css => '.modal input[name="role_ids"][value="3"]' } ).click
|
||||
instance.find_element( { :css => '.modal button.submit' } ).click
|
||||
(1..14).each {|loop|
|
||||
element = instance.find_element( { :css => 'body' } )
|
||||
text = element.text
|
||||
if text =~ /#{Regexp.quote(action[:lastname])}/
|
||||
assert( true, "(#{test[:name]}) user created" )
|
||||
return
|
||||
end
|
||||
sleep 0.5
|
||||
}
|
||||
assert( true, "(#{test[:name]}) user creation failed" )
|
||||
return
|
||||
elsif action[:execute] == 'create_ticket'
|
||||
instance.find_element( { :css => 'a[href="#new"]' } ).click
|
||||
instance.find_element( { :css => 'a[href="#ticket/create/call_inbound"]' } ).click
|
||||
|
|
Loading…
Reference in a new issue