Browse Source

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

Martin Edenhofer 11 years ago
parent
commit
acaab690ef

+ 18 - 0
app/assets/javascripts/app/lib/base/jquery.caretposition.js

@@ -4,6 +4,24 @@
  * @license under GNU license
  * @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() {
 
 	var calculator = {

+ 2 - 2
lib/auth/test.rb

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

+ 171 - 0
test/browser/text_module_test.rb

@@ -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

+ 1 - 1
test/browser_test_helper.rb

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