Added browser tests for text module. Fixed jquery 1.9 compatibility.

This commit is contained in:
Martin Edenhofer 2013-05-28 14:24:48 +02:00
parent be1b38b91b
commit acaab690ef
4 changed files with 192 additions and 3 deletions

View file

@ -4,6 +4,24 @@
* @license under GNU license * @license under GNU license
* @author Bevis Zhao (i@bevis.me, http://bevis.me) * @author Bevis Zhao (i@bevis.me, http://bevis.me)
*/ */
// workaround to work with jquery 1.9
// http://api.jquery.com/jQuery.browser/
(function(){
if (!jQuery.browser) {
jQuery.browser={};
jQuery.browser.msie = false;
jQuery.browser.version = 0;
if( navigator.userAgent.match(/MSIE ([0-9]+)\./) ){
jQuery.browser.msie = true;
jQuery.browser.version = RegExp.$1;
}
else if ( !navigator.userAgent.match(/mozilla/i) && !navigator.userAgent.match(/webkit/i) ){
jQuery.browser.mozilla = true;
}
}
})();
$(function() { $(function() {
var calculator = { var calculator = {

View file

@ -7,7 +7,7 @@ module Auth::TEST
if !ENV['RAILS_ENV'] || ENV['RAILS_ENV'] == 'development' if !ENV['RAILS_ENV'] || ENV['RAILS_ENV'] == 'development'
return user if password == 'test' return user if password == 'test'
end end
return false return false
end end
end end

View file

@ -0,0 +1,171 @@
# encoding: utf-8
require 'browser_test_helper'
class TextModuleTest < TestCase
def test_user
random = 'text_module_test_' + rand(999999).to_s
random2 = 'text_module_test_' + rand(999999).to_s
user_email = random + '@example.com'
# user
tests = [
{
:name => 'add #1',
:action => [
{
:execute => 'click',
:css => 'a[href="#admin"]',
},
{
:execute => 'click',
:css => 'a[href="#text_modules"]',
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'click',
:css => 'a[data-type="new"]',
},
{
:execute => 'wait',
:value => 2,
},
{
:execute => 'set',
:css => 'input[name=name]',
:value => 'some name' + random,
},
{
:execute => 'set',
:css => 'input[name="keywords"]',
:value => random,
},
{
:execute => 'set',
:css => 'textarea[name="content"]',
:value => 'some content' + random,
},
{
:execute => 'click',
:css => 'button.submit',
},
{
:execute => 'wait',
:value => 3,
},
{
:execute => 'match',
:css => 'body',
:value => random,
:match_result => true,
},
],
},
{
:name => 'add #2',
:action => [
{
:execute => 'click',
:css => 'a[href="#admin"]',
},
{
:execute => 'click',
:css => 'a[href="#text_modules"]',
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'click',
:css => 'a[data-type="new"]',
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'set',
:css => 'input[name=name]',
:value => 'some name' + random2,
},
{
:execute => 'set',
:css => 'input[name="keywords"]',
:value => random2,
},
{
:execute => 'set',
:css => 'textarea[name="content"]',
:value => 'some content' + random2,
},
{
:execute => 'click',
:css => 'button.submit',
},
{
:execute => 'wait',
:value => 3,
},
{
:execute => 'match',
:css => 'body',
:value => random2,
:match_result => true,
},
],
},
{
:name => 'verify usage',
:action => [
{
:execute => 'click',
:css => 'a[href="#new"]',
},
{
:execute => 'click',
:css => 'a[href="#ticket_create/call_outbound"]',
},
{
:execute => 'wait',
:value => 2,
},
{
:execute => 'set',
:css => 'textarea[name=body]',
:value => '::' + random,
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'match',
:css => 'body',
:value => random,
:match_result => true,
},
{
:execute => 'sendkey',
:css => 'textarea[name=body]',
:value => :enter,
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'match',
:css => 'textarea[name=body]',
:value => random,
:match_result => true,
},
],
},
]
browser_signle_test_with_login(tests, { :username => 'master@example.com' })
end
end

View file

@ -227,7 +227,7 @@ class TestCase < Test::Unit::TestCase
end end
end end
else else
if action[:css] =~ /input/i if action[:css] =~ /(input|textarea)/i
text = element.attribute('value') text = element.attribute('value')
else else
text = element.text text = element.text