From 1f0b54aaa8997128949ace7b96d75dbf793fd024 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 15 Aug 2014 10:59:40 +0200 Subject: [PATCH] Improved browser test. --- test/browser/text_module_test.rb | 44 +++++++++++++++++--------------- test/browser_test_helper.rb | 40 ++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 21 deletions(-) diff --git a/test/browser/text_module_test.rb b/test/browser/text_module_test.rb index 2bee460d8..70989c072 100644 --- a/test/browser/text_module_test.rb +++ b/test/browser/text_module_test.rb @@ -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, }, diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 24419cc67..b946a036e 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -253,9 +253,47 @@ class TestCase < Test::Unit::TestCase return end sleep 0.33 - } + } 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