From dd42805d33ce386044dda0c244790fd080ba17bd Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sat, 31 May 2014 18:06:08 +0200 Subject: [PATCH] Improved core js tests. --- .../_application_controller_form.js.coffee | 4 +++ .../app/controllers/default_route.js.coffee | 7 ++++- .../app/controllers/widget/chat.js.coffee | 4 ++- public/assets/tests/core.js | 26 +++++++++---------- test/browser/{core.rb => core_test.rb} | 0 5 files changed, 26 insertions(+), 15 deletions(-) rename test/browser/{core.rb => core_test.rb} (100%) diff --git a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee index b1abfec81..cc8ddc75c 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee @@ -1238,6 +1238,10 @@ class App.ControllerForm extends App.Controller if form.children()[0] form = form.children().parents('form') + # find form based on parents next
+ else if form.is('form') + form = form + # find form based on parents next else if form.parents('form')[0] form = form.parents('form') diff --git a/app/assets/javascripts/app/controllers/default_route.js.coffee b/app/assets/javascripts/app/controllers/default_route.js.coffee index 9a38da8bc..682a6929f 100644 --- a/app/assets/javascripts/app/controllers/default_route.js.coffee +++ b/app/assets/javascripts/app/controllers/default_route.js.coffee @@ -2,7 +2,12 @@ class Index extends App.Controller constructor: -> super - + + # no default routing on test pages + if window.location.pathname.substr(0,5) is '/test' + return + + # route to getting started screen if !@Config.get('system_init_done') @navigate '#getting_started' return diff --git a/app/assets/javascripts/app/controllers/widget/chat.js.coffee b/app/assets/javascripts/app/controllers/widget/chat.js.coffee index 802337153..25bcd6908 100644 --- a/app/assets/javascripts/app/controllers/widget/chat.js.coffee +++ b/app/assets/javascripts/app/controllers/widget/chat.js.coffee @@ -177,7 +177,9 @@ class Widget extends App.Controller messages: @messageLog isShown: shown ) - document.getElementById('chat_log_container').scrollTop = 10000 + + if document.getElementById('chat_log_container') + document.getElementById('chat_log_container').scrollTop = 10000 # focus in input box if @focus diff --git a/public/assets/tests/core.js b/public/assets/tests/core.js index db2e584ff..6dda4c769 100644 --- a/public/assets/tests/core.js +++ b/public/assets/tests/core.js @@ -203,20 +203,20 @@ App.Interval.set( function() { 'interval-test1' ); App.Delay.set( function() { - test( "interval - test 1 - 1/1", function() { + test( "interval - test 1 - 1/2", function() { // check - equal( window.testInterval1, 6, 'interval - test 1' ); + equal( window.testInterval1, 4, 'interval - test 1' ); App.Interval.clear('interval-test1') }); }, 2400 ); App.Delay.set( function() { - test( "interval - test 1 - 1/1", function() { + test( "interval - test 1 - 2/2", function() { // check - equal( window.testInterval1, 6, 'interval - test after clear' ); + equal( window.testInterval1, 4, 'interval - test after clear' ); }); }, 3500 @@ -228,28 +228,28 @@ window.testInterval2 = 1 App.Interval.set( function() { window.testInterval2 += 1; }, - 500, + 1000, undefined, - 'page' + 'someLevel' ); App.Delay.set( function() { - test( "interval - test 2 - 1/1", function() { + test( "interval - test 2 - 1/2", function() { // check - equal( window.testInterval2, 6, 'interval - test 2' ); - App.Interval.clearLevel('page') + equal( window.testInterval2, 4, 'interval - test 2' ); + App.Interval.clearLevel('someLevel') }); }, - 2400 + 4900 ); App.Delay.set( function() { - test( "interval - test 2 - 1/1", function() { + test( "interval - test 2 - 2/2", function() { // check - equal( window.testInterval2, 6, 'interval - test 2 - after clear' ); + equal( window.testInterval2, 4, 'interval - test 2 - after clear' ); }); }, - 3500 + 6000 ); diff --git a/test/browser/core.rb b/test/browser/core_test.rb similarity index 100% rename from test/browser/core.rb rename to test/browser/core_test.rb